• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_ARCH_AARCH64_GLOBAL_REGS_H_
17 #define PANDA_RUNTIME_INTERPRETER_ARCH_AARCH64_GLOBAL_REGS_H_
18 
19 #include <cstdint>
20 
21 namespace panda {
22 class Frame;
23 class ManagedThread;
24 }  //  namespace panda
25 
26 namespace panda::interpreter::arch::regs {
27 
28 #ifndef FFIXED_REGISTERS
29 #error "Need to compile source with -ffixed-x20 -ffixed-x21 -ffixed-x22 -ffixed-x23 -ffixed-x24 -ffixed-x28"
30 #endif
31 
32 register const uint8_t *g_pc asm("x20");
33 register int64_t g_acc_value asm("x21");
34 register uint64_t g_acc_tag asm("x22");
35 register Frame *g_frame asm("x23");
36 register const void *const *g_dispatch_table asm("x24");
37 register ManagedThread *g_thread asm("x28");
38 
GetPc()39 ALWAYS_INLINE inline const uint8_t *GetPc()
40 {
41     return g_pc;
42 }
43 
SetPc(const uint8_t * pc)44 ALWAYS_INLINE inline void SetPc(const uint8_t *pc)
45 {
46     g_pc = pc;
47 }
48 
GetAccValue()49 ALWAYS_INLINE inline int64_t GetAccValue()
50 {
51     return g_acc_value;
52 }
53 
SetAccValue(int64_t value)54 ALWAYS_INLINE inline void SetAccValue(int64_t value)
55 {
56     g_acc_value = value;
57 }
58 
GetAccTag()59 ALWAYS_INLINE inline uint64_t GetAccTag()
60 {
61     return g_acc_tag;
62 }
63 
SetAccTag(uint64_t tag)64 ALWAYS_INLINE inline void SetAccTag(uint64_t tag)
65 {
66     g_acc_tag = tag;
67 }
68 
GetFrame()69 ALWAYS_INLINE inline Frame *GetFrame()
70 {
71     return g_frame;
72 }
73 
SetFrame(Frame * frame)74 ALWAYS_INLINE inline void SetFrame(Frame *frame)
75 {
76     g_frame = frame;
77 }
78 
GetDispatchTable()79 ALWAYS_INLINE inline const void *const *GetDispatchTable()
80 {
81     return g_dispatch_table;
82 }
83 
SetDispatchTable(const void * const * dispatch_table)84 ALWAYS_INLINE inline void SetDispatchTable(const void *const *dispatch_table)
85 {
86     g_dispatch_table = dispatch_table;
87 }
88 
GetThread()89 ALWAYS_INLINE inline ManagedThread *GetThread()
90 {
91     return g_thread;
92 }
93 
SetThread(ManagedThread * thread)94 ALWAYS_INLINE inline void SetThread(ManagedThread *thread)
95 {
96     g_thread = thread;
97 }
98 
99 }  // namespace panda::interpreter::arch::regs
100 
101 #endif  // PANDA_RUNTIME_INTERPRETER_ARCH_AARCH64_GLOBAL_REGS_H_
102