1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PANDA_RUNTIME_INTERPRETER_ACC_VREGISTER_H_ 17 #define PANDA_RUNTIME_INTERPRETER_ACC_VREGISTER_H_ 18 19 #include <cstddef> 20 #include <cstdint> 21 22 #include "runtime/interpreter/frame.h" 23 24 #ifdef PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES 25 #include "arch/global_regs.h" 26 #endif 27 28 namespace panda::interpreter { 29 30 #ifdef PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES 31 32 class AccVRegister : public VRegisterIface<AccVRegister> { 33 public: AccVRegister(const Frame::VRegister & other)34 ALWAYS_INLINE inline AccVRegister(const Frame::VRegister &other) 35 { 36 SetValue(other.GetValue()); 37 SetTag(other.GetTag()); 38 } 39 ~AccVRegister() = default; 40 DEFAULT_COPY_SEMANTIC(AccVRegister); 41 DEFAULT_MOVE_SEMANTIC(AccVRegister); 42 VRegister()43 ALWAYS_INLINE inline operator panda::Frame::VRegister() const 44 { 45 return Frame::VRegister(GetValue(), GetTag()); 46 } 47 GetValue()48 ALWAYS_INLINE inline int64_t GetValue() const 49 { 50 return arch::regs::GetAccValue(); 51 } 52 SetValue(int64_t value)53 ALWAYS_INLINE inline void SetValue(int64_t value) 54 { 55 arch::regs::SetAccValue(value); 56 } 57 GetTag()58 ALWAYS_INLINE inline uint64_t GetTag() const 59 { 60 return arch::regs::GetAccTag(); 61 } 62 SetTag(uint64_t value)63 ALWAYS_INLINE inline void SetTag(uint64_t value) 64 { 65 arch::regs::SetAccTag(value); 66 } 67 }; 68 69 #else 70 71 using AccVRegister = Frame::VRegister; 72 73 #endif // PANDA_ENABLE_GLOBAL_REGISTER_VARIABLES 74 75 } // namespace panda::interpreter 76 77 #endif // PANDA_RUNTIME_INTERPRETER_ACC_VREGISTER_H_ 78