1 //===- SystemZRegisterInfo.td - The PowerPC Register File ------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class SystemZReg<string n> : Register<n> {
14 let Namespace = "SystemZ";
17 class SystemZRegWithSubregs<string n, list<Register> subregs>
18 : RegisterWithSubRegs<n, subregs> {
19 let Namespace = "SystemZ";
22 // We identify all our registers with a 4-bit ID, for consistency's sake.
24 // GPR32 - Lower 32 bits of one of the 16 64-bit general-purpose registers
25 class GPR32<bits<4> num, string n> : SystemZReg<n> {
26 field bits<4> Num = num;
29 // GPR64 - One of the 16 64-bit general-purpose registers
30 class GPR64<bits<4> num, string n, list<Register> subregs,
31 list<Register> aliases = []>
32 : SystemZRegWithSubregs<n, subregs> {
33 field bits<4> Num = num;
34 let Aliases = aliases;
37 // GPR128 - 8 even-odd register pairs
38 class GPR128<bits<4> num, string n, list<Register> subregs,
39 list<Register> aliases = []>
40 : SystemZRegWithSubregs<n, subregs> {
41 field bits<4> Num = num;
42 let Aliases = aliases;
45 // FPR - One of the 16 64-bit floating-point registers
46 class FPR<bits<4> num, string n> : SystemZReg<n> {
47 field bits<4> Num = num;
50 // General-purpose registers
51 def R0W : GPR32< 0, "r0">, DwarfRegNum<[0]>;
52 def R1W : GPR32< 1, "r1">, DwarfRegNum<[1]>;
53 def R2W : GPR32< 2, "r2">, DwarfRegNum<[2]>;
54 def R3W : GPR32< 3, "r3">, DwarfRegNum<[3]>;
55 def R4W : GPR32< 4, "r4">, DwarfRegNum<[4]>;
56 def R5W : GPR32< 5, "r5">, DwarfRegNum<[5]>;
57 def R6W : GPR32< 6, "r6">, DwarfRegNum<[6]>;
58 def R7W : GPR32< 7, "r7">, DwarfRegNum<[7]>;
59 def R8W : GPR32< 8, "r8">, DwarfRegNum<[8]>;
60 def R9W : GPR32< 9, "r9">, DwarfRegNum<[9]>;
61 def R10W : GPR32<10, "r10">, DwarfRegNum<[10]>;
62 def R11W : GPR32<11, "r11">, DwarfRegNum<[11]>;
63 def R12W : GPR32<12, "r12">, DwarfRegNum<[12]>;
64 def R13W : GPR32<13, "r13">, DwarfRegNum<[13]>;
65 def R14W : GPR32<14, "r14">, DwarfRegNum<[14]>;
66 def R15W : GPR32<15, "r15">, DwarfRegNum<[15]>;
68 def R0D : GPR64< 0, "r0", [R0W]>, DwarfRegNum<[0]>;
69 def R1D : GPR64< 1, "r1", [R1W]>, DwarfRegNum<[1]>;
70 def R2D : GPR64< 2, "r2", [R2W]>, DwarfRegNum<[2]>;
71 def R3D : GPR64< 3, "r3", [R3W]>, DwarfRegNum<[3]>;
72 def R4D : GPR64< 4, "r4", [R4W]>, DwarfRegNum<[4]>;
73 def R5D : GPR64< 5, "r5", [R5W]>, DwarfRegNum<[5]>;
74 def R6D : GPR64< 6, "r6", [R6W]>, DwarfRegNum<[6]>;
75 def R7D : GPR64< 7, "r7", [R7W]>, DwarfRegNum<[7]>;
76 def R8D : GPR64< 8, "r8", [R8W]>, DwarfRegNum<[8]>;
77 def R9D : GPR64< 9, "r9", [R9W]>, DwarfRegNum<[9]>;
78 def R10D : GPR64<10, "r10", [R10W]>, DwarfRegNum<[10]>;
79 def R11D : GPR64<11, "r11", [R11W]>, DwarfRegNum<[11]>;
80 def R12D : GPR64<12, "r12", [R12W]>, DwarfRegNum<[12]>;
81 def R13D : GPR64<13, "r13", [R13W]>, DwarfRegNum<[13]>;
82 def R14D : GPR64<14, "r14", [R14W]>, DwarfRegNum<[14]>;
83 def R15D : GPR64<15, "r15", [R15W]>, DwarfRegNum<[15]>;
86 def R0P : GPR64< 0, "r0", [R0W, R1W], [R0D, R1D]>, DwarfRegNum<[0]>;
87 def R2P : GPR64< 2, "r2", [R2W, R3W], [R2D, R3D]>, DwarfRegNum<[2]>;
88 def R4P : GPR64< 4, "r4", [R4W, R5W], [R4D, R5D]>, DwarfRegNum<[4]>;
89 def R6P : GPR64< 6, "r6", [R6W, R7W], [R6D, R7D]>, DwarfRegNum<[6]>;
90 def R8P : GPR64< 8, "r8", [R8W, R9W], [R8D, R9D]>, DwarfRegNum<[8]>;
91 def R10P : GPR64<10, "r10", [R10W, R11W], [R10D, R11D]>, DwarfRegNum<[10]>;
92 def R12P : GPR64<12, "r12", [R12W, R13W], [R12D, R13D]>, DwarfRegNum<[12]>;
93 def R14P : GPR64<14, "r14", [R14W, R15W], [R14D, R15D]>, DwarfRegNum<[14]>;
95 def R0Q : GPR128< 0, "r0", [R0D, R1D], [R0P]>, DwarfRegNum<[0]>;
96 def R2Q : GPR128< 2, "r2", [R2D, R3D], [R2P]>, DwarfRegNum<[2]>;
97 def R4Q : GPR128< 4, "r4", [R4D, R5D], [R4P]>, DwarfRegNum<[4]>;
98 def R6Q : GPR128< 6, "r6", [R6D, R7D], [R6P]>, DwarfRegNum<[6]>;
99 def R8Q : GPR128< 8, "r8", [R8D, R9D], [R8P]>, DwarfRegNum<[8]>;
100 def R10Q : GPR128<10, "r10", [R10D, R11D], [R10P]>, DwarfRegNum<[10]>;
101 def R12Q : GPR128<12, "r12", [R12D, R13D], [R12P]>, DwarfRegNum<[12]>;
102 def R14Q : GPR128<14, "r14", [R14D, R15D], [R14P]>, DwarfRegNum<[14]>;
104 // Floating-point registers
105 def F0 : FPR< 0, "f0">, DwarfRegNum<[16]>;
106 def F1 : FPR< 1, "f1">, DwarfRegNum<[17]>;
107 def F2 : FPR< 2, "f2">, DwarfRegNum<[18]>;
108 def F3 : FPR< 3, "f3">, DwarfRegNum<[19]>;
109 def F4 : FPR< 4, "f4">, DwarfRegNum<[20]>;
110 def F5 : FPR< 5, "f5">, DwarfRegNum<[21]>;
111 def F6 : FPR< 6, "f6">, DwarfRegNum<[22]>;
112 def F7 : FPR< 7, "f7">, DwarfRegNum<[23]>;
113 def F8 : FPR< 8, "f8">, DwarfRegNum<[24]>;
114 def F9 : FPR< 9, "f9">, DwarfRegNum<[25]>;
115 def F10 : FPR<10, "f10">, DwarfRegNum<[26]>;
116 def F11 : FPR<11, "f11">, DwarfRegNum<[27]>;
117 def F12 : FPR<12, "f12">, DwarfRegNum<[28]>;
118 def F13 : FPR<13, "f13">, DwarfRegNum<[29]>;
119 def F14 : FPR<14, "f14">, DwarfRegNum<[30]>;
120 def F15 : FPR<15, "f15">, DwarfRegNum<[31]>;
123 def PSW : SystemZReg<"psw">;
125 def subreg_32bit : PatLeaf<(i32 1)>;
126 def subreg_even : PatLeaf<(i32 1)>;
127 def subreg_odd : PatLeaf<(i32 2)>;
129 def : SubRegSet<1, [R0D, R1D, R2D, R3D, R4D, R5D, R6D, R7D,
130 R8D, R9D, R10D, R11D, R12D, R13D, R14D, R15D],
131 [R0W, R1W, R2W, R3W, R4W, R5W, R6W, R7W,
132 R8W, R9W, R10W, R11W, R12W, R13W, R14W, R15W]>;
134 def : SubRegSet<1, [R0Q, R2Q, R4Q, R6Q, R8Q, R10Q, R12Q, R14Q],
135 [R0D, R2D, R4D, R6D, R8D, R10D, R12D, R14D]>;
137 def : SubRegSet<2, [R0Q, R2Q, R4Q, R6Q, R8Q, R10Q, R12Q, R14Q],
138 [R1D, R3D, R5D, R7D, R9D, R11D, R13D, R15D]>;
140 def : SubRegSet<1, [R0P, R2P, R4P, R6P, R8P, R10P, R12P, R14P],
141 [R0W, R2W, R4W, R6W, R8W, R10W, R12W, R14W]>;
143 def : SubRegSet<2, [R0P, R2P, R4P, R6P, R8P, R10P, R12P, R14P],
144 [R1W, R3W, R5W, R7W, R9W, R11W, R13W, R15W]>;
147 def GR32 : RegisterClass<"SystemZ", [i32], 32,
148 // Volatile registers
149 [R0W, R1W, R2W, R3W, R4W, R5W, R6W, R7W, R8W, R9W, R10W, R12W, R13W,
150 // Frame pointer, sometimes allocable
152 // Volatile, but not allocable
155 let MethodProtos = [{
156 iterator allocation_order_begin(const MachineFunction &MF) const;
157 iterator allocation_order_end(const MachineFunction &MF) const;
159 let MethodBodies = [{
160 static const unsigned SystemZ_REG32[] = {
161 SystemZ::R1W, SystemZ::R2W, SystemZ::R3W, SystemZ::R4W,
162 SystemZ::R5W, SystemZ::R0W, SystemZ::R12W, SystemZ::R11W,
163 SystemZ::R10W, SystemZ::R9W, SystemZ::R8W, SystemZ::R7W,
164 SystemZ::R6W, SystemZ::R14W, SystemZ::R13W
166 static const unsigned SystemZ_REG32_nofp[] = {
167 SystemZ::R1W, SystemZ::R2W, SystemZ::R3W, SystemZ::R4W,
168 SystemZ::R5W, SystemZ::R0W, SystemZ::R12W, /* No R11W */
169 SystemZ::R10W, SystemZ::R9W, SystemZ::R8W, SystemZ::R7W,
170 SystemZ::R6W, SystemZ::R14W, SystemZ::R13W
173 GR32Class::allocation_order_begin(const MachineFunction &MF) const {
174 const TargetMachine &TM = MF.getTarget();
175 const TargetRegisterInfo *RI = TM.getRegisterInfo();
177 return SystemZ_REG32_nofp;
179 return SystemZ_REG32;
182 GR32Class::allocation_order_end(const MachineFunction &MF) const {
183 const TargetMachine &TM = MF.getTarget();
184 const TargetRegisterInfo *RI = TM.getRegisterInfo();
186 return SystemZ_REG32_nofp + (sizeof(SystemZ_REG32_nofp) / sizeof(unsigned));
188 return SystemZ_REG32 + (sizeof(SystemZ_REG32) / sizeof(unsigned));
193 /// Registers used to generate address. Everything except R0.
194 def ADDR32 : RegisterClass<"SystemZ", [i32], 32,
195 // Volatile registers
196 [R1W, R2W, R3W, R4W, R5W, R6W, R7W, R8W, R9W, R10W, R12W, R13W,
197 // Frame pointer, sometimes allocable
199 // Volatile, but not allocable
202 let MethodProtos = [{
203 iterator allocation_order_begin(const MachineFunction &MF) const;
204 iterator allocation_order_end(const MachineFunction &MF) const;
206 let MethodBodies = [{
207 static const unsigned SystemZ_ADDR32[] = {
208 SystemZ::R1W, SystemZ::R2W, SystemZ::R3W, SystemZ::R4W,
209 SystemZ::R5W, /* No R0W */ SystemZ::R12W, SystemZ::R11W,
210 SystemZ::R10W, SystemZ::R9W, SystemZ::R8W, SystemZ::R7W,
211 SystemZ::R6W, SystemZ::R14W, SystemZ::R13W
213 static const unsigned SystemZ_ADDR32_nofp[] = {
214 SystemZ::R1W, SystemZ::R2W, SystemZ::R3W, SystemZ::R4W,
215 SystemZ::R5W, /* No R0W */ SystemZ::R12W, /* No R11W */
216 SystemZ::R10W, SystemZ::R9W, SystemZ::R8W, SystemZ::R7W,
217 SystemZ::R6W, SystemZ::R14W, SystemZ::R13W
219 ADDR32Class::iterator
220 ADDR32Class::allocation_order_begin(const MachineFunction &MF) const {
221 const TargetMachine &TM = MF.getTarget();
222 const TargetRegisterInfo *RI = TM.getRegisterInfo();
224 return SystemZ_ADDR32_nofp;
226 return SystemZ_ADDR32;
228 ADDR32Class::iterator
229 ADDR32Class::allocation_order_end(const MachineFunction &MF) const {
230 const TargetMachine &TM = MF.getTarget();
231 const TargetRegisterInfo *RI = TM.getRegisterInfo();
233 return SystemZ_ADDR32_nofp + (sizeof(SystemZ_ADDR32_nofp) / sizeof(unsigned));
235 return SystemZ_ADDR32 + (sizeof(SystemZ_ADDR32) / sizeof(unsigned));
240 def GR64 : RegisterClass<"SystemZ", [i64], 64,
241 // Volatile registers
242 [R0D, R1D, R2D, R3D, R4D, R5D, R6D, R7D, R8D, R9D, R10D, R12D, R13D,
243 // Frame pointer, sometimes allocable
245 // Volatile, but not allocable
248 let SubRegClassList = [GR32];
249 let MethodProtos = [{
250 iterator allocation_order_begin(const MachineFunction &MF) const;
251 iterator allocation_order_end(const MachineFunction &MF) const;
253 let MethodBodies = [{
254 static const unsigned SystemZ_REG64[] = {
255 SystemZ::R1D, SystemZ::R2D, SystemZ::R3D, SystemZ::R4D,
256 SystemZ::R5D, SystemZ::R0D, SystemZ::R12D, SystemZ::R11D,
257 SystemZ::R10D, SystemZ::R9D, SystemZ::R8D, SystemZ::R7D,
258 SystemZ::R6D, SystemZ::R14D, SystemZ::R13D
260 static const unsigned SystemZ_REG64_nofp[] = {
261 SystemZ::R1D, SystemZ::R2D, SystemZ::R3D, SystemZ::R4D,
262 SystemZ::R5D, SystemZ::R0D, SystemZ::R12D, /* No R11D */
263 SystemZ::R10D, SystemZ::R9D, SystemZ::R8D, SystemZ::R7D,
264 SystemZ::R6D, SystemZ::R14D, SystemZ::R13D
267 GR64Class::allocation_order_begin(const MachineFunction &MF) const {
268 const TargetMachine &TM = MF.getTarget();
269 const TargetRegisterInfo *RI = TM.getRegisterInfo();
271 return SystemZ_REG64_nofp;
273 return SystemZ_REG64;
276 GR64Class::allocation_order_end(const MachineFunction &MF) const {
277 const TargetMachine &TM = MF.getTarget();
278 const TargetRegisterInfo *RI = TM.getRegisterInfo();
280 return SystemZ_REG64_nofp + (sizeof(SystemZ_REG64_nofp) / sizeof(unsigned));
282 return SystemZ_REG64 + (sizeof(SystemZ_REG64) / sizeof(unsigned));
287 def ADDR64 : RegisterClass<"SystemZ", [i64], 64,
288 // Volatile registers
289 [R1D, R2D, R3D, R4D, R5D, R6D, R7D, R8D, R9D, R10D, R12D, R13D,
290 // Frame pointer, sometimes allocable
292 // Volatile, but not allocable
295 let SubRegClassList = [ADDR32];
296 let MethodProtos = [{
297 iterator allocation_order_begin(const MachineFunction &MF) const;
298 iterator allocation_order_end(const MachineFunction &MF) const;
300 let MethodBodies = [{
301 static const unsigned SystemZ_ADDR64[] = {
302 SystemZ::R1D, SystemZ::R2D, SystemZ::R3D, SystemZ::R4D,
303 SystemZ::R5D, /* No R0D */ SystemZ::R12D, SystemZ::R11D,
304 SystemZ::R10D, SystemZ::R9D, SystemZ::R8D, SystemZ::R7D,
305 SystemZ::R6D, SystemZ::R14D, SystemZ::R13D
307 static const unsigned SystemZ_ADDR64_nofp[] = {
308 SystemZ::R1D, SystemZ::R2D, SystemZ::R3D, SystemZ::R4D,
309 SystemZ::R5D, /* No R0D */ SystemZ::R12D, /* No R11D */
310 SystemZ::R10D, SystemZ::R9D, SystemZ::R8D, SystemZ::R7D,
311 SystemZ::R6D, SystemZ::R14D, SystemZ::R13D
313 ADDR64Class::iterator
314 ADDR64Class::allocation_order_begin(const MachineFunction &MF) const {
315 const TargetMachine &TM = MF.getTarget();
316 const TargetRegisterInfo *RI = TM.getRegisterInfo();
318 return SystemZ_ADDR64_nofp;
320 return SystemZ_ADDR64;
322 ADDR64Class::iterator
323 ADDR64Class::allocation_order_end(const MachineFunction &MF) const {
324 const TargetMachine &TM = MF.getTarget();
325 const TargetRegisterInfo *RI = TM.getRegisterInfo();
327 return SystemZ_ADDR64_nofp + (sizeof(SystemZ_ADDR64_nofp) / sizeof(unsigned));
329 return SystemZ_ADDR64 + (sizeof(SystemZ_ADDR64) / sizeof(unsigned));
334 // Even-odd register pairs
335 def GR64P : RegisterClass<"SystemZ", [v2i32], 64,
336 [R0P, R2P, R4P, R6P, R8P, R10P, R12P, R14P]>
338 let SubRegClassList = [GR32, GR32];
339 let MethodProtos = [{
340 iterator allocation_order_begin(const MachineFunction &MF) const;
341 iterator allocation_order_end(const MachineFunction &MF) const;
343 let MethodBodies = [{
344 static const unsigned SystemZ_REG64P[] = {
345 SystemZ::R0P, SystemZ::R2P, SystemZ::R4P, SystemZ::R10P,
346 SystemZ::R8P, SystemZ::R6P };
347 static const unsigned SystemZ_REG64P_nofp[] = {
348 SystemZ::R0P, SystemZ::R2P, SystemZ::R4P, /* NO R10P */
349 SystemZ::R8P, SystemZ::R6P };
351 GR64PClass::allocation_order_begin(const MachineFunction &MF) const {
352 const TargetMachine &TM = MF.getTarget();
353 const TargetRegisterInfo *RI = TM.getRegisterInfo();
355 return SystemZ_REG64P_nofp;
357 return SystemZ_REG64P;
360 GR64PClass::allocation_order_end(const MachineFunction &MF) const {
361 const TargetMachine &TM = MF.getTarget();
362 const TargetRegisterInfo *RI = TM.getRegisterInfo();
364 return SystemZ_REG64P_nofp + (sizeof(SystemZ_REG64P_nofp) / sizeof(unsigned));
366 return SystemZ_REG64P + (sizeof(SystemZ_REG64P) / sizeof(unsigned));
371 def GR128 : RegisterClass<"SystemZ", [i128, v2i64], 128,
372 [R0Q, R2Q, R4Q, R6Q, R8Q, R10Q, R12Q, R14Q]>
374 let SubRegClassList = [GR64, GR64];
375 let MethodProtos = [{
376 iterator allocation_order_begin(const MachineFunction &MF) const;
377 iterator allocation_order_end(const MachineFunction &MF) const;
379 let MethodBodies = [{
380 static const unsigned SystemZ_REG128[] = {
381 SystemZ::R0Q, SystemZ::R2Q, SystemZ::R4Q, SystemZ::R10Q,
382 SystemZ::R8Q, SystemZ::R6Q };
383 static const unsigned SystemZ_REG128_nofp[] = {
384 SystemZ::R0Q, SystemZ::R2Q, SystemZ::R4Q, /* NO R10Q */
385 SystemZ::R8Q, SystemZ::R6Q };
387 GR128Class::allocation_order_begin(const MachineFunction &MF) const {
388 const TargetMachine &TM = MF.getTarget();
389 const TargetRegisterInfo *RI = TM.getRegisterInfo();
391 return SystemZ_REG128_nofp;
393 return SystemZ_REG128;
396 GR128Class::allocation_order_end(const MachineFunction &MF) const {
397 const TargetMachine &TM = MF.getTarget();
398 const TargetRegisterInfo *RI = TM.getRegisterInfo();
400 return SystemZ_REG128_nofp + (sizeof(SystemZ_REG128_nofp) / sizeof(unsigned));
402 return SystemZ_REG128 + (sizeof(SystemZ_REG128) / sizeof(unsigned));
407 def FP64 : RegisterClass<"SystemZ", [f64], 64,
408 [F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15]>;
410 // Status flags registers.
411 def CCR : RegisterClass<"SystemZ", [i64], 64, [PSW]> {
412 let CopyCost = -1; // Don't allow copying of status registers.