OSDN Git Service

Add even-odd register pairs
[android-x86/external-llvm.git] / lib / Target / SystemZ / SystemZRegisterInfo.td
1 //===- SystemZRegisterInfo.td - The PowerPC Register File ------*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 class SystemZReg<string n> : Register<n> {
14   let Namespace = "SystemZ";
15 }
16
17 class SystemZRegWithSubregs<string n, list<Register> subregs>
18   : RegisterWithSubRegs<n, subregs> {
19   let Namespace = "SystemZ";
20 }
21
22 // We identify all our registers with a 4-bit ID, for consistency's sake.
23
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;
27 }
28
29 // GPR64 - One of the 16 64-bit general-purpose registers
30 class GPR64<bits<4> num, string n, list<Register> subregs>
31  : SystemZRegWithSubregs<n, subregs> {
32   field bits<4> Num = num;
33 }
34
35 // GPR128 - 8 even-odd register pairs
36 class GPR128<bits<4> num, string n, list<Register> subregs>
37  : SystemZRegWithSubregs<n, subregs> {
38   field bits<4> Num = num;
39 }
40
41 // FPR - One of the 16 64-bit floating-point registers
42 class FPR<bits<4> num, string n> : SystemZReg<n> {
43   field bits<4> Num = num;
44 }
45
46 // General-purpose registers
47 def R0W  : GPR32< 0,  "r0">, DwarfRegNum<[0]>;
48 def R1W  : GPR32< 1,  "r1">, DwarfRegNum<[1]>;
49 def R2W  : GPR32< 2,  "r2">, DwarfRegNum<[2]>;
50 def R3W  : GPR32< 3,  "r3">, DwarfRegNum<[3]>;
51 def R4W  : GPR32< 4,  "r4">, DwarfRegNum<[4]>;
52 def R5W  : GPR32< 5,  "r5">, DwarfRegNum<[5]>;
53 def R6W  : GPR32< 6,  "r6">, DwarfRegNum<[6]>;
54 def R7W  : GPR32< 7,  "r7">, DwarfRegNum<[7]>;
55 def R8W  : GPR32< 8,  "r8">, DwarfRegNum<[8]>;
56 def R9W  : GPR32< 9,  "r9">, DwarfRegNum<[9]>;
57 def R10W : GPR32<10, "r10">, DwarfRegNum<[10]>;
58 def R11W : GPR32<11, "r11">, DwarfRegNum<[11]>;
59 def R12W : GPR32<12, "r12">, DwarfRegNum<[12]>;
60 def R13W : GPR32<13, "r13">, DwarfRegNum<[13]>;
61 def R14W : GPR32<14, "r14">, DwarfRegNum<[14]>;
62 def R15W : GPR32<15, "r15">, DwarfRegNum<[15]>;
63
64 def R0D  : GPR64< 0,  "r0", [R0W]>,  DwarfRegNum<[0]>;
65 def R1D  : GPR64< 1,  "r1", [R1W]>,  DwarfRegNum<[1]>;
66 def R2D  : GPR64< 2,  "r2", [R2W]>,  DwarfRegNum<[2]>;
67 def R3D  : GPR64< 3,  "r3", [R3W]>,  DwarfRegNum<[3]>;
68 def R4D  : GPR64< 4,  "r4", [R4W]>,  DwarfRegNum<[4]>;
69 def R5D  : GPR64< 5,  "r5", [R5W]>,  DwarfRegNum<[5]>;
70 def R6D  : GPR64< 6,  "r6", [R6W]>,  DwarfRegNum<[6]>;
71 def R7D  : GPR64< 7,  "r7", [R7W]>,  DwarfRegNum<[7]>;
72 def R8D  : GPR64< 8,  "r8", [R8W]>,  DwarfRegNum<[8]>;
73 def R9D  : GPR64< 9,  "r9", [R9W]>,  DwarfRegNum<[9]>;
74 def R10D : GPR64<10, "r10", [R10W]>, DwarfRegNum<[10]>;
75 def R11D : GPR64<11, "r11", [R11W]>, DwarfRegNum<[11]>;
76 def R12D : GPR64<12, "r12", [R12W]>, DwarfRegNum<[12]>;
77 def R13D : GPR64<13, "r13", [R13W]>, DwarfRegNum<[13]>;
78 def R14D : GPR64<14, "r14", [R14W]>, DwarfRegNum<[14]>;
79 def R15D : GPR64<15, "r15", [R15W]>, DwarfRegNum<[15]>;
80
81 // Register pairs
82 def R0Q  : GPR128< 0,  "r0", [R0D,  R1D]>,  DwarfRegNum<[0]>;
83 def R2Q  : GPR128< 2,  "r2", [R2D,  R3D]>,  DwarfRegNum<[2]>;
84 def R4Q  : GPR128< 4,  "r4", [R4D,  R5D]>,  DwarfRegNum<[4]>;
85 def R6Q  : GPR128< 6,  "r6", [R6D,  R7D]>,  DwarfRegNum<[6]>;
86 def R8Q  : GPR128< 8,  "r8", [R8D,  R9D]>,  DwarfRegNum<[8]>;
87 def R10Q : GPR128<10, "r10", [R10D, R11D]>, DwarfRegNum<[10]>;
88 def R12Q : GPR128<12, "r12", [R12D, R13D]>, DwarfRegNum<[12]>;
89 def R14Q : GPR128<14, "r14", [R14D, R15D]>, DwarfRegNum<[14]>;
90
91 // Floating-point registers
92 def F0  : FPR< 0,  "f0">, DwarfRegNum<[16]>;
93 def F1  : FPR< 1,  "f1">, DwarfRegNum<[17]>;
94 def F2  : FPR< 2,  "f2">, DwarfRegNum<[18]>;
95 def F3  : FPR< 3,  "f3">, DwarfRegNum<[19]>;
96 def F4  : FPR< 4,  "f4">, DwarfRegNum<[20]>;
97 def F5  : FPR< 5,  "f5">, DwarfRegNum<[21]>;
98 def F6  : FPR< 6,  "f6">, DwarfRegNum<[22]>;
99 def F7  : FPR< 7,  "f7">, DwarfRegNum<[23]>;
100 def F8  : FPR< 8,  "f8">, DwarfRegNum<[24]>;
101 def F9  : FPR< 9,  "f9">, DwarfRegNum<[25]>;
102 def F10 : FPR<10, "f10">, DwarfRegNum<[26]>;
103 def F11 : FPR<11, "f11">, DwarfRegNum<[27]>;
104 def F12 : FPR<12, "f12">, DwarfRegNum<[28]>;
105 def F13 : FPR<13, "f13">, DwarfRegNum<[29]>;
106 def F14 : FPR<14, "f14">, DwarfRegNum<[30]>;
107 def F15 : FPR<15, "f15">, DwarfRegNum<[31]>;
108
109 // Status register
110 def PSW : SystemZReg<"psw">;
111
112 def subreg_32bit  : PatLeaf<(i32 1)>;
113 def subreg_64even : PatLeaf<(i32 2)>;
114 def subreg_64odd  : PatLeaf<(i32 3)>;
115
116 def : SubRegSet<1, [R0D, R1D,  R2D,  R3D,  R4D,  R5D,  R6D,  R7D,
117                     R8D, R9D, R10D, R11D, R12D, R13D, R14D, R15D],
118                    [R0W, R1W,  R2W,  R3W,  R4W,  R5W,  R6W,  R7W,
119                     R8W, R9W, R10W, R11W, R12W, R13W, R14W, R15W]>;
120
121 def : SubRegSet<2, [R0Q, R2Q, R4Q, R6Q, R8Q, R10Q, R12Q, R14Q],
122                    [R0D, R2D, R4D, R6D, R8D, R10D, R12D, R14D]>;
123
124 def : SubRegSet<3, [R0Q, R2Q, R4Q, R6Q, R8Q, R10Q, R12Q, R14Q],
125                    [R1D, R3D, R5D, R7D, R9D, R11D, R13D, R15D]>;
126
127 /// Register classes
128 def GR32 : RegisterClass<"SystemZ", [i32], 32,
129    // Volatile registers
130   [R0D, R1W, R2W, R3W, R4W, R5W, R6W, R7W, R8W, R9W, R10W, R12W, R13W,
131    // Frame pointer, sometimes allocable
132    R11W,
133    // Volatile, but not allocable
134    R14W, R15W]>
135 {
136   let MethodProtos = [{
137     iterator allocation_order_begin(const MachineFunction &MF) const;
138     iterator allocation_order_end(const MachineFunction &MF) const;
139   }];
140   let MethodBodies = [{
141     static const unsigned SystemZ_REG32[] = {
142       SystemZ::R1W,  SystemZ::R2W,  SystemZ::R3W,  SystemZ::R4W,
143       SystemZ::R5W,  SystemZ::R0W,  SystemZ::R12W, SystemZ::R11W,
144       SystemZ::R10W, SystemZ::R9W,  SystemZ::R8W,  SystemZ::R7W,
145       SystemZ::R6W,  SystemZ::R14W, SystemZ::R13W
146     };
147     static const unsigned SystemZ_REG32_nofp[] = {
148       SystemZ::R1W,  SystemZ::R2W,  SystemZ::R3W,  SystemZ::R4W,
149       SystemZ::R5W,  SystemZ::R0W,  SystemZ::R12W, /* No R11W */
150       SystemZ::R10W, SystemZ::R9W,  SystemZ::R8W,  SystemZ::R7W,
151       SystemZ::R6W,  SystemZ::R14W, SystemZ::R13W
152     };
153     GR32Class::iterator
154     GR32Class::allocation_order_begin(const MachineFunction &MF) const {
155       const TargetMachine &TM = MF.getTarget();
156       const TargetRegisterInfo *RI = TM.getRegisterInfo();
157       if (RI->hasFP(MF))
158         return SystemZ_REG32_nofp;
159       else
160         return SystemZ_REG32;
161     }
162     GR32Class::iterator
163     GR32Class::allocation_order_end(const MachineFunction &MF) const {
164       const TargetMachine &TM = MF.getTarget();
165       const TargetRegisterInfo *RI = TM.getRegisterInfo();
166       if (RI->hasFP(MF))
167         return SystemZ_REG32_nofp + (sizeof(SystemZ_REG32_nofp) / sizeof(unsigned));
168       else
169         return SystemZ_REG32 + (sizeof(SystemZ_REG32) / sizeof(unsigned));
170     }
171   }];
172 }
173
174 /// Registers used to generate address. Everything except R0.
175 def ADDR32 : RegisterClass<"SystemZ", [i32], 32,
176    // Volatile registers
177   [R1W, R2W, R3W, R4W, R5W, R6W, R7W, R8W, R9W, R10W, R12W, R13W,
178    // Frame pointer, sometimes allocable
179    R11W,
180    // Volatile, but not allocable
181    R14W, R15W]>
182 {
183   let MethodProtos = [{
184     iterator allocation_order_begin(const MachineFunction &MF) const;
185     iterator allocation_order_end(const MachineFunction &MF) const;
186   }];
187   let MethodBodies = [{
188     static const unsigned SystemZ_ADDR32[] = {
189       SystemZ::R1W,  SystemZ::R2W,  SystemZ::R3W,  SystemZ::R4W,
190       SystemZ::R5W,  /* No R0W */   SystemZ::R12W, SystemZ::R11W,
191       SystemZ::R10W, SystemZ::R9W,  SystemZ::R8W,  SystemZ::R7W,
192       SystemZ::R6W,  SystemZ::R14W, SystemZ::R13W
193     };
194     static const unsigned SystemZ_ADDR32_nofp[] = {
195       SystemZ::R1W,  SystemZ::R2W,  SystemZ::R3W,  SystemZ::R4W,
196       SystemZ::R5W,  /* No R0W */   SystemZ::R12W, /* No R11W */
197       SystemZ::R10W, SystemZ::R9W,  SystemZ::R8W,  SystemZ::R7W,
198       SystemZ::R6W,  SystemZ::R14W, SystemZ::R13W
199     };
200     ADDR32Class::iterator
201     ADDR32Class::allocation_order_begin(const MachineFunction &MF) const {
202       const TargetMachine &TM = MF.getTarget();
203       const TargetRegisterInfo *RI = TM.getRegisterInfo();
204       if (RI->hasFP(MF))
205         return SystemZ_ADDR32_nofp;
206       else
207         return SystemZ_ADDR32;
208     }
209     ADDR32Class::iterator
210     ADDR32Class::allocation_order_end(const MachineFunction &MF) const {
211       const TargetMachine &TM = MF.getTarget();
212       const TargetRegisterInfo *RI = TM.getRegisterInfo();
213       if (RI->hasFP(MF))
214         return SystemZ_ADDR32_nofp + (sizeof(SystemZ_ADDR32_nofp) / sizeof(unsigned));
215       else
216         return SystemZ_ADDR32 + (sizeof(SystemZ_ADDR32) / sizeof(unsigned));
217     }
218   }];
219 }
220
221 def GR64 : RegisterClass<"SystemZ", [i64], 64,
222    // Volatile registers
223   [R0D, R1D, R2D, R3D, R4D, R5D, R6D, R7D, R8D, R9D, R10D, R12D, R13D,
224    // Frame pointer, sometimes allocable
225    R11D,
226    // Volatile, but not allocable
227    R14D, R15D]>
228 {
229   let SubRegClassList = [GR32];
230   let MethodProtos = [{
231     iterator allocation_order_begin(const MachineFunction &MF) const;
232     iterator allocation_order_end(const MachineFunction &MF) const;
233   }];
234   let MethodBodies = [{
235     static const unsigned SystemZ_REG64[] = {
236       SystemZ::R1D,  SystemZ::R2D,  SystemZ::R3D,  SystemZ::R4D,
237       SystemZ::R5D,  SystemZ::R0D,  SystemZ::R12D, SystemZ::R11D,
238       SystemZ::R10D, SystemZ::R9D,  SystemZ::R8D,  SystemZ::R7D,
239       SystemZ::R6D,  SystemZ::R14D, SystemZ::R13D
240     };
241     static const unsigned SystemZ_REG64_nofp[] = {
242       SystemZ::R1D,  SystemZ::R2D,  SystemZ::R3D,  SystemZ::R4D,
243       SystemZ::R5D,  SystemZ::R0D,  SystemZ::R12D, /* No R11D */
244       SystemZ::R10D, SystemZ::R9D,  SystemZ::R8D,  SystemZ::R7D,
245       SystemZ::R6D,  SystemZ::R14D, SystemZ::R13D
246     };
247     GR64Class::iterator
248     GR64Class::allocation_order_begin(const MachineFunction &MF) const {
249       const TargetMachine &TM = MF.getTarget();
250       const TargetRegisterInfo *RI = TM.getRegisterInfo();
251       if (RI->hasFP(MF))
252         return SystemZ_REG64_nofp;
253       else
254         return SystemZ_REG64;
255     }
256     GR64Class::iterator
257     GR64Class::allocation_order_end(const MachineFunction &MF) const {
258       const TargetMachine &TM = MF.getTarget();
259       const TargetRegisterInfo *RI = TM.getRegisterInfo();
260       if (RI->hasFP(MF))
261         return SystemZ_REG64_nofp + (sizeof(SystemZ_REG64_nofp) / sizeof(unsigned));
262       else
263         return SystemZ_REG64 + (sizeof(SystemZ_REG64) / sizeof(unsigned));
264     }
265   }];
266 }
267
268 def ADDR64 : RegisterClass<"SystemZ", [i64], 64,
269    // Volatile registers
270   [R1D, R2D, R3D, R4D, R5D, R6D, R7D, R8D, R9D, R10D, R12D, R13D,
271    // Frame pointer, sometimes allocable
272    R11D,
273    // Volatile, but not allocable
274    R14D, R15D]>
275 {
276   let SubRegClassList = [ADDR32];
277   let MethodProtos = [{
278     iterator allocation_order_begin(const MachineFunction &MF) const;
279     iterator allocation_order_end(const MachineFunction &MF) const;
280   }];
281   let MethodBodies = [{
282     static const unsigned SystemZ_ADDR64[] = {
283       SystemZ::R1D,  SystemZ::R2D,  SystemZ::R3D,  SystemZ::R4D,
284       SystemZ::R5D,  /* No R0D */   SystemZ::R12D, SystemZ::R11D,
285       SystemZ::R10D, SystemZ::R9D,  SystemZ::R8D,  SystemZ::R7D,
286       SystemZ::R6D,  SystemZ::R14D, SystemZ::R13D
287     };
288     static const unsigned SystemZ_ADDR64_nofp[] = {
289       SystemZ::R1D,  SystemZ::R2D,  SystemZ::R3D,  SystemZ::R4D,
290       SystemZ::R5D,  /* No R0D */   SystemZ::R12D, /* No R11D */
291       SystemZ::R10D, SystemZ::R9D,  SystemZ::R8D,  SystemZ::R7D,
292       SystemZ::R6D,  SystemZ::R14D, SystemZ::R13D
293     };
294     ADDR64Class::iterator
295     ADDR64Class::allocation_order_begin(const MachineFunction &MF) const {
296       const TargetMachine &TM = MF.getTarget();
297       const TargetRegisterInfo *RI = TM.getRegisterInfo();
298       if (RI->hasFP(MF))
299         return SystemZ_ADDR64_nofp;
300       else
301         return SystemZ_ADDR64;
302     }
303     ADDR64Class::iterator
304     ADDR64Class::allocation_order_end(const MachineFunction &MF) const {
305       const TargetMachine &TM = MF.getTarget();
306       const TargetRegisterInfo *RI = TM.getRegisterInfo();
307       if (RI->hasFP(MF))
308         return SystemZ_ADDR64_nofp + (sizeof(SystemZ_ADDR64_nofp) / sizeof(unsigned));
309       else
310         return SystemZ_ADDR64 + (sizeof(SystemZ_ADDR64) / sizeof(unsigned));
311     }
312   }];
313 }
314
315 // Even-odd register pairs
316 def GR128 : RegisterClass<"SystemZ", [i128], 128,
317   [R0Q, R2Q, R4Q, R6Q, R8Q, R10Q, R12Q, R14Q]>
318 {
319   let SubRegClassList = [GR64, GR64];
320   let MethodProtos = [{
321     iterator allocation_order_begin(const MachineFunction &MF) const;
322     iterator allocation_order_end(const MachineFunction &MF) const;
323   }];
324   let MethodBodies = [{
325     static const unsigned SystemZ_REG128[] = {
326       SystemZ::R0Q,  SystemZ::R2Q,  SystemZ::R4Q,  SystemZ::R10Q,
327       SystemZ::R8Q,  SystemZ::R6Q };
328     static const unsigned SystemZ_REG128_nofp[] = {
329       SystemZ::R0Q,  SystemZ::R2Q,  SystemZ::R4Q, /* NO R10Q */
330       SystemZ::R8Q,  SystemZ::R6Q };
331     GR128Class::iterator
332     GR128Class::allocation_order_begin(const MachineFunction &MF) const {
333       const TargetMachine &TM = MF.getTarget();
334       const TargetRegisterInfo *RI = TM.getRegisterInfo();
335       if (RI->hasFP(MF))
336         return SystemZ_REG128_nofp;
337       else
338         return SystemZ_REG128;
339     }
340     GR128Class::iterator
341     GR128Class::allocation_order_end(const MachineFunction &MF) const {
342       const TargetMachine &TM = MF.getTarget();
343       const TargetRegisterInfo *RI = TM.getRegisterInfo();
344       if (RI->hasFP(MF))
345         return SystemZ_REG128_nofp + (sizeof(SystemZ_REG128_nofp) / sizeof(unsigned));
346       else
347         return SystemZ_REG128 + (sizeof(SystemZ_REG128) / sizeof(unsigned));
348     }
349   }];
350 }
351
352 def FP64 : RegisterClass<"SystemZ", [f64], 64,
353  [F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15]>;
354
355 // Status flags registers.
356 def CCR : RegisterClass<"SystemZ", [i64], 64, [PSW]> {
357   let CopyCost = -1;  // Don't allow copying of status registers.
358 }