1 //===-- RegisterInfos_loongarch64.h -----------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifdef DECLARE_REGISTER_INFOS_LOONGARCH64_STRUCT
13 #include "lldb/lldb-defines.h"
14 #include "lldb/lldb-enumerations.h"
15 #include "lldb/lldb-private.h"
17 #include "Utility/LoongArch_DWARF_Registers.h"
18 #include "lldb-loongarch-register-enums.h"
21 #error GPR_OFFSET must be defined before including this header file
25 #error FPR_OFFSET must be defined before including this header file
29 #error LSX_OFFSET must be defined before including this header file
33 #error LASX_OFFSET must be defined before including this header file
36 using namespace loongarch_dwarf
;
40 // I suppose EHFrame and DWARF are the same.
41 #define KIND_HELPER(reg, generic_kind) \
43 loongarch_dwarf::dwarf_##reg, loongarch_dwarf::dwarf_##reg, generic_kind, \
44 LLDB_INVALID_REGNUM, reg##_loongarch \
47 // Generates register kinds array for generic purpose registers
48 #define GPR64_KIND(reg, generic_kind) KIND_HELPER(reg, generic_kind)
50 // Generates register kinds array for floating point registers
51 #define FPR64_KIND(reg, generic_kind) KIND_HELPER(reg, generic_kind)
53 // Defines a 64-bit general purpose register
54 #define DEFINE_GPR64(reg, generic_kind) DEFINE_GPR64_ALT(reg, reg, generic_kind)
55 #define DEFINE_GPR64_ALT(reg, alt, generic_kind) \
57 #reg, #alt, 8, GPR_OFFSET(gpr_##reg##_loongarch - gpr_first_loongarch), \
58 lldb::eEncodingUint, lldb::eFormatHex, \
59 GPR64_KIND(gpr_##reg, generic_kind), nullptr, nullptr, nullptr, \
62 // Defines a 64-bit floating point register
63 #define DEFINE_FPR64(reg, generic_kind) DEFINE_FPR64_ALT(reg, reg, generic_kind)
64 #define DEFINE_FPR64_ALT(reg, alt, generic_kind) \
66 #reg, #alt, 8, FPR_OFFSET(fpr_##reg##_loongarch - fpr_first_loongarch), \
67 lldb::eEncodingUint, lldb::eFormatHex, \
68 FPR64_KIND(fpr_##reg, generic_kind), nullptr, nullptr, nullptr, \
71 #define DEFINE_FCC(reg, generic_kind) \
73 #reg, nullptr, 1, FCC_OFFSET(fpr_##reg##_loongarch - fpr_fcc0_loongarch), \
74 lldb::eEncodingUint, lldb::eFormatHex, \
75 FPR64_KIND(fpr_##reg, generic_kind), nullptr, nullptr, nullptr, \
78 #define DEFINE_FCSR(reg, generic_kind) \
80 #reg, nullptr, 4, FCSR_OFFSET, \
81 lldb::eEncodingUint, lldb::eFormatHex, \
82 FPR64_KIND(fpr_##reg, generic_kind), nullptr, nullptr, nullptr, \
85 #define DEFINE_LSX(reg, generic_kind) \
87 #reg, nullptr, 16, LSX_OFFSET(lsx_##reg##_loongarch - lsx_first_loongarch),\
88 lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, \
89 KIND_HELPER(lsx_##reg, generic_kind), nullptr, nullptr, nullptr, \
92 #define DEFINE_LASX(reg, generic_kind) \
95 LASX_OFFSET(lasx_##reg##_loongarch - lasx_first_loongarch), \
96 lldb::eEncodingVector, lldb::eFormatVectorOfUInt8, \
97 KIND_HELPER(lasx_##reg, generic_kind), nullptr, nullptr, nullptr, \
102 static lldb_private::RegisterInfo g_register_infos_loongarch64
[] = {
103 DEFINE_GPR64_ALT(r0
, zero
, LLDB_INVALID_REGNUM
),
104 DEFINE_GPR64_ALT(r1
, ra
, LLDB_REGNUM_GENERIC_RA
),
105 DEFINE_GPR64_ALT(r2
, tp
, LLDB_INVALID_REGNUM
),
106 DEFINE_GPR64_ALT(r3
, sp
, LLDB_REGNUM_GENERIC_SP
),
107 DEFINE_GPR64_ALT(r4
, a0
, LLDB_REGNUM_GENERIC_ARG1
),
108 DEFINE_GPR64_ALT(r5
, a1
, LLDB_REGNUM_GENERIC_ARG2
),
109 DEFINE_GPR64_ALT(r6
, a2
, LLDB_REGNUM_GENERIC_ARG3
),
110 DEFINE_GPR64_ALT(r7
, a3
, LLDB_REGNUM_GENERIC_ARG4
),
111 DEFINE_GPR64_ALT(r8
, a4
, LLDB_REGNUM_GENERIC_ARG5
),
112 DEFINE_GPR64_ALT(r9
, a5
, LLDB_REGNUM_GENERIC_ARG6
),
113 DEFINE_GPR64_ALT(r10
, a6
, LLDB_REGNUM_GENERIC_ARG7
),
114 DEFINE_GPR64_ALT(r11
, a7
, LLDB_REGNUM_GENERIC_ARG8
),
115 DEFINE_GPR64_ALT(r12
, t0
, LLDB_INVALID_REGNUM
),
116 DEFINE_GPR64_ALT(r13
, t1
, LLDB_INVALID_REGNUM
),
117 DEFINE_GPR64_ALT(r14
, t2
, LLDB_INVALID_REGNUM
),
118 DEFINE_GPR64_ALT(r15
, t3
, LLDB_INVALID_REGNUM
),
119 DEFINE_GPR64_ALT(r16
, t4
, LLDB_INVALID_REGNUM
),
120 DEFINE_GPR64_ALT(r17
, t5
, LLDB_INVALID_REGNUM
),
121 DEFINE_GPR64_ALT(r18
, t6
, LLDB_INVALID_REGNUM
),
122 DEFINE_GPR64_ALT(r19
, t7
, LLDB_INVALID_REGNUM
),
123 DEFINE_GPR64_ALT(r20
, t8
, LLDB_INVALID_REGNUM
),
124 DEFINE_GPR64(r21
, LLDB_INVALID_REGNUM
),
125 DEFINE_GPR64_ALT(r22
, fp
, LLDB_REGNUM_GENERIC_FP
),
126 DEFINE_GPR64_ALT(r23
, s0
, LLDB_INVALID_REGNUM
),
127 DEFINE_GPR64_ALT(r24
, s1
, LLDB_INVALID_REGNUM
),
128 DEFINE_GPR64_ALT(r25
, s2
, LLDB_INVALID_REGNUM
),
129 DEFINE_GPR64_ALT(r26
, s3
, LLDB_INVALID_REGNUM
),
130 DEFINE_GPR64_ALT(r27
, s4
, LLDB_INVALID_REGNUM
),
131 DEFINE_GPR64_ALT(r28
, s5
, LLDB_INVALID_REGNUM
),
132 DEFINE_GPR64_ALT(r29
, s6
, LLDB_INVALID_REGNUM
),
133 DEFINE_GPR64_ALT(r30
, s7
, LLDB_INVALID_REGNUM
),
134 DEFINE_GPR64_ALT(r31
, s8
, LLDB_INVALID_REGNUM
),
136 DEFINE_GPR64(orig_a0
, LLDB_INVALID_REGNUM
),
137 DEFINE_GPR64(pc
, LLDB_REGNUM_GENERIC_PC
),
138 DEFINE_GPR64(badv
, LLDB_INVALID_REGNUM
),
139 DEFINE_GPR64(reserved0
, LLDB_INVALID_REGNUM
),
140 DEFINE_GPR64(reserved1
, LLDB_INVALID_REGNUM
),
141 DEFINE_GPR64(reserved2
, LLDB_INVALID_REGNUM
),
142 DEFINE_GPR64(reserved3
, LLDB_INVALID_REGNUM
),
143 DEFINE_GPR64(reserved4
, LLDB_INVALID_REGNUM
),
144 DEFINE_GPR64(reserved5
, LLDB_INVALID_REGNUM
),
145 DEFINE_GPR64(reserved6
, LLDB_INVALID_REGNUM
),
146 DEFINE_GPR64(reserved7
, LLDB_INVALID_REGNUM
),
147 DEFINE_GPR64(reserved8
, LLDB_INVALID_REGNUM
),
148 DEFINE_GPR64(reserved9
, LLDB_INVALID_REGNUM
),
150 DEFINE_FPR64_ALT(f0
, fa0
, LLDB_INVALID_REGNUM
),
151 DEFINE_FPR64_ALT(f1
, fa1
, LLDB_INVALID_REGNUM
),
152 DEFINE_FPR64_ALT(f2
, fa2
, LLDB_INVALID_REGNUM
),
153 DEFINE_FPR64_ALT(f3
, fa3
, LLDB_INVALID_REGNUM
),
154 DEFINE_FPR64_ALT(f4
, fa4
, LLDB_INVALID_REGNUM
),
155 DEFINE_FPR64_ALT(f5
, fa5
, LLDB_INVALID_REGNUM
),
156 DEFINE_FPR64_ALT(f6
, fa6
, LLDB_INVALID_REGNUM
),
157 DEFINE_FPR64_ALT(f7
, fa7
, LLDB_INVALID_REGNUM
),
158 DEFINE_FPR64_ALT(f8
, ft0
, LLDB_INVALID_REGNUM
),
159 DEFINE_FPR64_ALT(f9
, ft1
, LLDB_INVALID_REGNUM
),
160 DEFINE_FPR64_ALT(f10
, ft2
, LLDB_INVALID_REGNUM
),
161 DEFINE_FPR64_ALT(f11
, ft3
, LLDB_INVALID_REGNUM
),
162 DEFINE_FPR64_ALT(f12
, ft4
, LLDB_INVALID_REGNUM
),
163 DEFINE_FPR64_ALT(f13
, ft5
, LLDB_INVALID_REGNUM
),
164 DEFINE_FPR64_ALT(f14
, ft6
, LLDB_INVALID_REGNUM
),
165 DEFINE_FPR64_ALT(f15
, ft7
, LLDB_INVALID_REGNUM
),
166 DEFINE_FPR64_ALT(f16
, ft8
, LLDB_INVALID_REGNUM
),
167 DEFINE_FPR64_ALT(f17
, ft9
, LLDB_INVALID_REGNUM
),
168 DEFINE_FPR64_ALT(f18
, ft10
, LLDB_INVALID_REGNUM
),
169 DEFINE_FPR64_ALT(f19
, ft11
, LLDB_INVALID_REGNUM
),
170 DEFINE_FPR64_ALT(f20
, ft12
, LLDB_INVALID_REGNUM
),
171 DEFINE_FPR64_ALT(f21
, ft13
, LLDB_INVALID_REGNUM
),
172 DEFINE_FPR64_ALT(f22
, ft14
, LLDB_INVALID_REGNUM
),
173 DEFINE_FPR64_ALT(f23
, ft15
, LLDB_INVALID_REGNUM
),
174 DEFINE_FPR64_ALT(f24
, fs0
, LLDB_INVALID_REGNUM
),
175 DEFINE_FPR64_ALT(f25
, fs1
, LLDB_INVALID_REGNUM
),
176 DEFINE_FPR64_ALT(f26
, fs2
, LLDB_INVALID_REGNUM
),
177 DEFINE_FPR64_ALT(f27
, fs3
, LLDB_INVALID_REGNUM
),
178 DEFINE_FPR64_ALT(f28
, fs4
, LLDB_INVALID_REGNUM
),
179 DEFINE_FPR64_ALT(f29
, fs5
, LLDB_INVALID_REGNUM
),
180 DEFINE_FPR64_ALT(f30
, fs6
, LLDB_INVALID_REGNUM
),
181 DEFINE_FPR64_ALT(f31
, fs7
, LLDB_INVALID_REGNUM
),
183 DEFINE_FCC(fcc0
, LLDB_INVALID_REGNUM
),
184 DEFINE_FCC(fcc1
, LLDB_INVALID_REGNUM
),
185 DEFINE_FCC(fcc2
, LLDB_INVALID_REGNUM
),
186 DEFINE_FCC(fcc3
, LLDB_INVALID_REGNUM
),
187 DEFINE_FCC(fcc4
, LLDB_INVALID_REGNUM
),
188 DEFINE_FCC(fcc5
, LLDB_INVALID_REGNUM
),
189 DEFINE_FCC(fcc6
, LLDB_INVALID_REGNUM
),
190 DEFINE_FCC(fcc7
, LLDB_INVALID_REGNUM
),
191 DEFINE_FCSR(fcsr
, LLDB_INVALID_REGNUM
),
193 DEFINE_LSX(vr0
, LLDB_INVALID_REGNUM
),
194 DEFINE_LSX(vr1
, LLDB_INVALID_REGNUM
),
195 DEFINE_LSX(vr2
, LLDB_INVALID_REGNUM
),
196 DEFINE_LSX(vr3
, LLDB_INVALID_REGNUM
),
197 DEFINE_LSX(vr4
, LLDB_INVALID_REGNUM
),
198 DEFINE_LSX(vr5
, LLDB_INVALID_REGNUM
),
199 DEFINE_LSX(vr6
, LLDB_INVALID_REGNUM
),
200 DEFINE_LSX(vr7
, LLDB_INVALID_REGNUM
),
201 DEFINE_LSX(vr8
, LLDB_INVALID_REGNUM
),
202 DEFINE_LSX(vr9
, LLDB_INVALID_REGNUM
),
203 DEFINE_LSX(vr10
, LLDB_INVALID_REGNUM
),
204 DEFINE_LSX(vr11
, LLDB_INVALID_REGNUM
),
205 DEFINE_LSX(vr12
, LLDB_INVALID_REGNUM
),
206 DEFINE_LSX(vr13
, LLDB_INVALID_REGNUM
),
207 DEFINE_LSX(vr14
, LLDB_INVALID_REGNUM
),
208 DEFINE_LSX(vr15
, LLDB_INVALID_REGNUM
),
209 DEFINE_LSX(vr16
, LLDB_INVALID_REGNUM
),
210 DEFINE_LSX(vr17
, LLDB_INVALID_REGNUM
),
211 DEFINE_LSX(vr18
, LLDB_INVALID_REGNUM
),
212 DEFINE_LSX(vr19
, LLDB_INVALID_REGNUM
),
213 DEFINE_LSX(vr20
, LLDB_INVALID_REGNUM
),
214 DEFINE_LSX(vr21
, LLDB_INVALID_REGNUM
),
215 DEFINE_LSX(vr22
, LLDB_INVALID_REGNUM
),
216 DEFINE_LSX(vr23
, LLDB_INVALID_REGNUM
),
217 DEFINE_LSX(vr24
, LLDB_INVALID_REGNUM
),
218 DEFINE_LSX(vr25
, LLDB_INVALID_REGNUM
),
219 DEFINE_LSX(vr26
, LLDB_INVALID_REGNUM
),
220 DEFINE_LSX(vr27
, LLDB_INVALID_REGNUM
),
221 DEFINE_LSX(vr28
, LLDB_INVALID_REGNUM
),
222 DEFINE_LSX(vr29
, LLDB_INVALID_REGNUM
),
223 DEFINE_LSX(vr30
, LLDB_INVALID_REGNUM
),
224 DEFINE_LSX(vr31
, LLDB_INVALID_REGNUM
),
226 DEFINE_LASX(xr0
, LLDB_INVALID_REGNUM
),
227 DEFINE_LASX(xr1
, LLDB_INVALID_REGNUM
),
228 DEFINE_LASX(xr2
, LLDB_INVALID_REGNUM
),
229 DEFINE_LASX(xr3
, LLDB_INVALID_REGNUM
),
230 DEFINE_LASX(xr4
, LLDB_INVALID_REGNUM
),
231 DEFINE_LASX(xr5
, LLDB_INVALID_REGNUM
),
232 DEFINE_LASX(xr6
, LLDB_INVALID_REGNUM
),
233 DEFINE_LASX(xr7
, LLDB_INVALID_REGNUM
),
234 DEFINE_LASX(xr8
, LLDB_INVALID_REGNUM
),
235 DEFINE_LASX(xr9
, LLDB_INVALID_REGNUM
),
236 DEFINE_LASX(xr10
, LLDB_INVALID_REGNUM
),
237 DEFINE_LASX(xr11
, LLDB_INVALID_REGNUM
),
238 DEFINE_LASX(xr12
, LLDB_INVALID_REGNUM
),
239 DEFINE_LASX(xr13
, LLDB_INVALID_REGNUM
),
240 DEFINE_LASX(xr14
, LLDB_INVALID_REGNUM
),
241 DEFINE_LASX(xr15
, LLDB_INVALID_REGNUM
),
242 DEFINE_LASX(xr16
, LLDB_INVALID_REGNUM
),
243 DEFINE_LASX(xr17
, LLDB_INVALID_REGNUM
),
244 DEFINE_LASX(xr18
, LLDB_INVALID_REGNUM
),
245 DEFINE_LASX(xr19
, LLDB_INVALID_REGNUM
),
246 DEFINE_LASX(xr20
, LLDB_INVALID_REGNUM
),
247 DEFINE_LASX(xr21
, LLDB_INVALID_REGNUM
),
248 DEFINE_LASX(xr22
, LLDB_INVALID_REGNUM
),
249 DEFINE_LASX(xr23
, LLDB_INVALID_REGNUM
),
250 DEFINE_LASX(xr24
, LLDB_INVALID_REGNUM
),
251 DEFINE_LASX(xr25
, LLDB_INVALID_REGNUM
),
252 DEFINE_LASX(xr26
, LLDB_INVALID_REGNUM
),
253 DEFINE_LASX(xr27
, LLDB_INVALID_REGNUM
),
254 DEFINE_LASX(xr28
, LLDB_INVALID_REGNUM
),
255 DEFINE_LASX(xr29
, LLDB_INVALID_REGNUM
),
256 DEFINE_LASX(xr30
, LLDB_INVALID_REGNUM
),
257 DEFINE_LASX(xr31
, LLDB_INVALID_REGNUM
),
260 #endif // DECLARE_REGISTER_INFOS_LOONGARCH64_STRUCT