• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2024 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_ARCH_AARCH64_GLOBAL_REGS_H_
16 #define PANDA_INTERPRETER_ARCH_AARCH64_GLOBAL_REGS_H_
17 
18 #include <cstdint>
19 
20 namespace ark {
21 class Frame;
22 class ManagedThread;
23 }  //  namespace ark
24 
25 namespace ark::interpreter::arch::regs {
26 
27 #ifndef FFIXED_REGISTERS
28 #error "Need to compile source with -ffixed-x20 -ffixed-x21 -ffixed-x22 -ffixed-x23 -ffixed-x24 -ffixed-x25 -ffixed-x28"
29 #endif
30 
31 // NOLINTBEGIN(hicpp-no-assembler, misc-definitions-in-headers)
32 register const uint8_t *g_pc asm("x20");
33 register int64_t g_accValue asm("x21");
34 register int64_t g_accTag asm("x22");
35 register void *g_fp asm("x23");
36 register const void *const *g_dispatchTable asm("x24");
37 register void *g_mFp asm("x25");
38 register ManagedThread *g_thread asm("x28");
39 // NOLINTEND(hicpp-no-assembler, misc-definitions-in-headers)
40 
GetPc()41 ALWAYS_INLINE inline const uint8_t *GetPc()
42 {
43     return g_pc;
44 }
45 
SetPc(const uint8_t * pc)46 ALWAYS_INLINE inline void SetPc(const uint8_t *pc)
47 {
48     g_pc = pc;
49 }
50 
GetAccValue()51 ALWAYS_INLINE inline int64_t GetAccValue()
52 {
53     return g_accValue;
54 }
55 
SetAccValue(int64_t value)56 ALWAYS_INLINE inline void SetAccValue(int64_t value)
57 {
58     g_accValue = value;
59 }
60 
GetAccTag()61 ALWAYS_INLINE inline int64_t GetAccTag()
62 {
63     return g_accTag;
64 }
65 
SetAccTag(int64_t tag)66 ALWAYS_INLINE inline void SetAccTag(int64_t tag)
67 {
68     g_accTag = tag;
69 }
70 
GetFrame()71 ALWAYS_INLINE inline Frame *GetFrame()
72 {
73     return reinterpret_cast<Frame *>(reinterpret_cast<uintptr_t>(g_fp) - Frame::GetVregsOffset());
74 }
75 
SetFrame(Frame * frame)76 ALWAYS_INLINE inline void SetFrame(Frame *frame)
77 {
78     g_fp = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(frame) + Frame::GetVregsOffset());
79 }
80 
GetFp()81 ALWAYS_INLINE inline void *GetFp()
82 {
83     return g_fp;
84 }
85 
SetFp(void * fp)86 ALWAYS_INLINE inline void SetFp(void *fp)
87 {
88     g_fp = fp;
89 }
90 
GetMirrorFp()91 ALWAYS_INLINE inline void *GetMirrorFp()
92 {
93     return g_mFp;
94 }
95 
SetMirrorFp(void * mFp)96 ALWAYS_INLINE inline void SetMirrorFp(void *mFp)
97 {
98     g_mFp = mFp;
99 }
100 
GetDispatchTable()101 ALWAYS_INLINE inline const void *const *GetDispatchTable()
102 {
103     return g_dispatchTable;
104 }
105 
SetDispatchTable(const void * const * dispatchTable)106 ALWAYS_INLINE inline void SetDispatchTable(const void *const *dispatchTable)
107 {
108     g_dispatchTable = dispatchTable;
109 }
110 
GetThread()111 ALWAYS_INLINE inline ManagedThread *GetThread()
112 {
113     return g_thread;
114 }
115 
SetThread(ManagedThread * thread)116 ALWAYS_INLINE inline void SetThread(ManagedThread *thread)
117 {
118     g_thread = thread;
119 }
120 
121 }  // namespace ark::interpreter::arch::regs
122 
123 #endif  // PANDA_INTERPRETER_ARCH_AARCH64_GLOBAL_REG_VARS_H_
124