• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 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 #ifndef PANDA_INTERPRETER_ACC_VREGISTER_H_
16 #define PANDA_INTERPRETER_ACC_VREGISTER_H_
17 
18 #include <cstddef>
19 #include <cstdint>
20 
21 #include "runtime/interpreter/vregister.h"
22 
23 namespace panda::interpreter {
24 
25 class AccVRegister : public VRegisterIface<AccVRegister> {
26 public:
27     ALWAYS_INLINE inline AccVRegister() = default;
28 
AccVRegister(int64_t payload,int64_t mirror)29     ALWAYS_INLINE inline AccVRegister(int64_t payload, int64_t mirror) : payload_(payload), mirror_(mirror) {}
30 
GetValue()31     ALWAYS_INLINE inline int64_t GetValue() const
32     {
33         return payload_.GetValue();
34     }
35 
SetValue(int64_t value)36     ALWAYS_INLINE inline void SetValue(int64_t value)
37     {
38         payload_.SetValue(value);
39     }
40 
GetTag()41     ALWAYS_INLINE inline int64_t GetTag() const
42     {
43         return mirror_.GetValue();
44     }
45 
SetTag(int64_t value)46     ALWAYS_INLINE inline void SetTag(int64_t value)
47     {
48         mirror_.SetValue(value);
49     }
50 
51     template <bool is_dynamic = false>
AsVRegRef()52     ALWAYS_INLINE inline typename std::enable_if<is_dynamic, DynamicVRegisterRef>::type AsVRegRef()
53     {
54         return DynamicVRegisterRef(&payload_);
55     }
56 
57     template <bool is_dynamic = false>
AsVRegRef()58     ALWAYS_INLINE inline typename std::enable_if<!is_dynamic, StaticVRegisterRef>::type AsVRegRef()
59     {
60         return StaticVRegisterRef(&payload_, &mirror_);
61     }
62 
GetMirrorOffset()63     ALWAYS_INLINE static inline constexpr uint32_t GetMirrorOffset()
64     {
65         return MEMBER_OFFSET(AccVRegister, mirror_);
66     }
67 
68     ~AccVRegister() = default;
69 
70     DEFAULT_COPY_SEMANTIC(AccVRegister);
71     DEFAULT_MOVE_SEMANTIC(AccVRegister);
72 
73 private:
74     VRegister payload_;
75     VRegister mirror_;
76 };
77 
78 }  // namespace panda::interpreter
79 
80 #endif  // PANDA_INTERPRETER_ACC_VREGISTER_H_
81