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_ARCH_AARCH64_GLOBAL_REGS_H_ 16 #define PANDA_INTERPRETER_ARCH_AARCH64_GLOBAL_REGS_H_ 17 18 #include <cstdint> 19 20 namespace panda { 21 class Frame; 22 class ManagedThread; 23 } // namespace panda 24 25 namespace panda::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 register const uint8_t *g_pc asm("x20"); 32 register int64_t g_acc_value asm("x21"); 33 register int64_t g_acc_tag asm("x22"); 34 register void *g_fp asm("x23"); 35 register const void *const *g_dispatch_table asm("x24"); 36 register void *g_m_fp asm("x25"); 37 register ManagedThread *g_thread asm("x28"); 38 GetPc()39ALWAYS_INLINE inline const uint8_t *GetPc() 40 { 41 return g_pc; 42 } 43 SetPc(const uint8_t * pc)44ALWAYS_INLINE inline void SetPc(const uint8_t *pc) 45 { 46 g_pc = pc; 47 } 48 GetAccValue()49ALWAYS_INLINE inline int64_t GetAccValue() 50 { 51 return g_acc_value; 52 } 53 SetAccValue(int64_t value)54ALWAYS_INLINE inline void SetAccValue(int64_t value) 55 { 56 g_acc_value = value; 57 } 58 GetAccTag()59ALWAYS_INLINE inline int64_t GetAccTag() 60 { 61 return g_acc_tag; 62 } 63 SetAccTag(int64_t tag)64ALWAYS_INLINE inline void SetAccTag(int64_t tag) 65 { 66 g_acc_tag = tag; 67 } 68 GetFrame()69ALWAYS_INLINE inline Frame *GetFrame() 70 { 71 return reinterpret_cast<Frame *>(reinterpret_cast<uintptr_t>(g_fp) - Frame::GetVregsOffset()); 72 } 73 SetFrame(Frame * frame)74ALWAYS_INLINE inline void SetFrame(Frame *frame) 75 { 76 g_fp = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(frame) + Frame::GetVregsOffset()); 77 } 78 GetFp()79ALWAYS_INLINE inline void *GetFp() 80 { 81 return g_fp; 82 } 83 SetFp(void * fp)84ALWAYS_INLINE inline void SetFp(void *fp) 85 { 86 g_fp = fp; 87 } 88 GetMirrorFp()89ALWAYS_INLINE inline void *GetMirrorFp() 90 { 91 return g_m_fp; 92 } 93 SetMirrorFp(void * m_fp)94ALWAYS_INLINE inline void SetMirrorFp(void *m_fp) 95 { 96 g_m_fp = m_fp; 97 } 98 GetDispatchTable()99ALWAYS_INLINE inline const void *const *GetDispatchTable() 100 { 101 return g_dispatch_table; 102 } 103 SetDispatchTable(const void * const * dispatch_table)104ALWAYS_INLINE inline void SetDispatchTable(const void *const *dispatch_table) 105 { 106 g_dispatch_table = dispatch_table; 107 } 108 GetThread()109ALWAYS_INLINE inline ManagedThread *GetThread() 110 { 111 return g_thread; 112 } 113 SetThread(ManagedThread * thread)114ALWAYS_INLINE inline void SetThread(ManagedThread *thread) 115 { 116 g_thread = thread; 117 } 118 119 } // namespace panda::interpreter::arch::regs 120 121 #endif // PANDA_INTERPRETER_ARCH_AARCH64_GLOBAL_REG_VARS_H_ 122