1 //===-- RegisterContextFreeBSD_powerpc.cpp --------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===---------------------------------------------------------------------===// 8 9 #include "RegisterContextFreeBSD_powerpc.h" 10 #include "RegisterContextPOSIX_powerpc.h" 11 #include <vector> 12 13 using namespace lldb_private; 14 using namespace lldb; 15 16 // http://svnweb.freebsd.org/base/head/sys/powerpc/include/reg.h 17 typedef struct _GPR64 { 18 uint64_t r0; 19 uint64_t r1; 20 uint64_t r2; 21 uint64_t r3; 22 uint64_t r4; 23 uint64_t r5; 24 uint64_t r6; 25 uint64_t r7; 26 uint64_t r8; 27 uint64_t r9; 28 uint64_t r10; 29 uint64_t r11; 30 uint64_t r12; 31 uint64_t r13; 32 uint64_t r14; 33 uint64_t r15; 34 uint64_t r16; 35 uint64_t r17; 36 uint64_t r18; 37 uint64_t r19; 38 uint64_t r20; 39 uint64_t r21; 40 uint64_t r22; 41 uint64_t r23; 42 uint64_t r24; 43 uint64_t r25; 44 uint64_t r26; 45 uint64_t r27; 46 uint64_t r28; 47 uint64_t r29; 48 uint64_t r30; 49 uint64_t r31; 50 uint64_t lr; 51 uint64_t cr; 52 uint64_t xer; 53 uint64_t ctr; 54 uint64_t pc; 55 } GPR64; 56 57 typedef struct _GPR32 { 58 uint32_t r0; 59 uint32_t r1; 60 uint32_t r2; 61 uint32_t r3; 62 uint32_t r4; 63 uint32_t r5; 64 uint32_t r6; 65 uint32_t r7; 66 uint32_t r8; 67 uint32_t r9; 68 uint32_t r10; 69 uint32_t r11; 70 uint32_t r12; 71 uint32_t r13; 72 uint32_t r14; 73 uint32_t r15; 74 uint32_t r16; 75 uint32_t r17; 76 uint32_t r18; 77 uint32_t r19; 78 uint32_t r20; 79 uint32_t r21; 80 uint32_t r22; 81 uint32_t r23; 82 uint32_t r24; 83 uint32_t r25; 84 uint32_t r26; 85 uint32_t r27; 86 uint32_t r28; 87 uint32_t r29; 88 uint32_t r30; 89 uint32_t r31; 90 uint32_t lr; 91 uint32_t cr; 92 uint32_t xer; 93 uint32_t ctr; 94 uint32_t pc; 95 } GPR32; 96 97 typedef struct _FPR { 98 uint64_t f0; 99 uint64_t f1; 100 uint64_t f2; 101 uint64_t f3; 102 uint64_t f4; 103 uint64_t f5; 104 uint64_t f6; 105 uint64_t f7; 106 uint64_t f8; 107 uint64_t f9; 108 uint64_t f10; 109 uint64_t f11; 110 uint64_t f12; 111 uint64_t f13; 112 uint64_t f14; 113 uint64_t f15; 114 uint64_t f16; 115 uint64_t f17; 116 uint64_t f18; 117 uint64_t f19; 118 uint64_t f20; 119 uint64_t f21; 120 uint64_t f22; 121 uint64_t f23; 122 uint64_t f24; 123 uint64_t f25; 124 uint64_t f26; 125 uint64_t f27; 126 uint64_t f28; 127 uint64_t f29; 128 uint64_t f30; 129 uint64_t f31; 130 uint64_t fpscr; 131 } FPR; 132 133 typedef struct _VMX { 134 uint32_t v0[4]; 135 uint32_t v1[4]; 136 uint32_t v2[4]; 137 uint32_t v3[4]; 138 uint32_t v4[4]; 139 uint32_t v5[4]; 140 uint32_t v6[4]; 141 uint32_t v7[4]; 142 uint32_t v8[4]; 143 uint32_t v9[4]; 144 uint32_t v10[4]; 145 uint32_t v11[4]; 146 uint32_t v12[4]; 147 uint32_t v13[4]; 148 uint32_t v14[4]; 149 uint32_t v15[4]; 150 uint32_t v16[4]; 151 uint32_t v17[4]; 152 uint32_t v18[4]; 153 uint32_t v19[4]; 154 uint32_t v20[4]; 155 uint32_t v21[4]; 156 uint32_t v22[4]; 157 uint32_t v23[4]; 158 uint32_t v24[4]; 159 uint32_t v25[4]; 160 uint32_t v26[4]; 161 uint32_t v27[4]; 162 uint32_t v28[4]; 163 uint32_t v29[4]; 164 uint32_t v30[4]; 165 uint32_t v31[4]; 166 uint32_t pad[2]; 167 uint32_t vrsave; 168 uint32_t vscr; 169 } VMX; 170 171 // Include RegisterInfos_powerpc to declare our g_register_infos_powerpc 172 // structure. 173 #define DECLARE_REGISTER_INFOS_POWERPC_STRUCT 174 #include "RegisterInfos_powerpc.h" 175 #undef DECLARE_REGISTER_INFOS_POWERPC_STRUCT 176 RegisterContextFreeBSD_powerpc(const ArchSpec & target_arch)177RegisterContextFreeBSD_powerpc::RegisterContextFreeBSD_powerpc( 178 const ArchSpec &target_arch) 179 : RegisterInfoInterface(target_arch) {} 180 ~RegisterContextFreeBSD_powerpc()181RegisterContextFreeBSD_powerpc::~RegisterContextFreeBSD_powerpc() {} 182 GetGPRSize() const183size_t RegisterContextFreeBSD_powerpc::GetGPRSize() const { 184 // This is an 'abstract' base, so no GPR struct. 185 return 0; 186 } 187 GetRegisterInfo() const188const RegisterInfo *RegisterContextFreeBSD_powerpc::GetRegisterInfo() const { 189 // assert (m_target_arch.GetCore() == ArchSpec::eCore_powerpc); 190 llvm_unreachable("Abstract class!"); 191 return nullptr; 192 } 193 GetRegisterCount() const194uint32_t RegisterContextFreeBSD_powerpc::GetRegisterCount() const { return 0; } 195 RegisterContextFreeBSD_powerpc32(const ArchSpec & target_arch)196RegisterContextFreeBSD_powerpc32::RegisterContextFreeBSD_powerpc32( 197 const ArchSpec &target_arch) 198 : RegisterContextFreeBSD_powerpc(target_arch) {} 199 ~RegisterContextFreeBSD_powerpc32()200RegisterContextFreeBSD_powerpc32::~RegisterContextFreeBSD_powerpc32() {} 201 GetGPRSize() const202size_t RegisterContextFreeBSD_powerpc32::GetGPRSize() const { 203 return sizeof(GPR32); 204 } 205 GetRegisterInfo() const206const RegisterInfo *RegisterContextFreeBSD_powerpc32::GetRegisterInfo() const { 207 // assert (m_target_arch.GetCore() == ArchSpec::eCore_powerpc); 208 return g_register_infos_powerpc32; 209 } 210 GetRegisterCount() const211uint32_t RegisterContextFreeBSD_powerpc32::GetRegisterCount() const { 212 return static_cast<uint32_t>(sizeof(g_register_infos_powerpc32) / 213 sizeof(g_register_infos_powerpc32[0])); 214 } 215 RegisterContextFreeBSD_powerpc64(const ArchSpec & target_arch)216RegisterContextFreeBSD_powerpc64::RegisterContextFreeBSD_powerpc64( 217 const ArchSpec &target_arch) 218 : RegisterContextFreeBSD_powerpc(target_arch) {} 219 ~RegisterContextFreeBSD_powerpc64()220RegisterContextFreeBSD_powerpc64::~RegisterContextFreeBSD_powerpc64() {} 221 GetGPRSize() const222size_t RegisterContextFreeBSD_powerpc64::GetGPRSize() const { 223 return sizeof(GPR64); 224 } 225 GetRegisterInfo() const226const RegisterInfo *RegisterContextFreeBSD_powerpc64::GetRegisterInfo() const { 227 // assert (m_target_arch.GetCore() == ArchSpec::eCore_powerpc); 228 if (m_target_arch.GetMachine() == llvm::Triple::ppc) 229 return g_register_infos_powerpc64_32; 230 return g_register_infos_powerpc64; 231 } 232 GetRegisterCount() const233uint32_t RegisterContextFreeBSD_powerpc64::GetRegisterCount() const { 234 return static_cast<uint32_t>(sizeof(g_register_infos_powerpc64) / 235 sizeof(g_register_infos_powerpc64[0])); 236 } 237