1 //===- BlackfinRegisterInfo.td - Blackfin Register defs ----*- 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 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // Declarations that describe the Blackfin register file
12 //===----------------------------------------------------------------------===//
17 // 3: .W (32 low bits of 40-bit accu)
18 let Namespace = "BF" in {
19 def lo16 : SubRegIndex;
20 def hi16 : SubRegIndex;
21 def lo32 : SubRegIndex;
22 def hi32 : SubRegIndex;
25 // Registers are identified with 3-bit group and 3-bit ID numbers.
26 class BlackfinReg<string n> : Register<n> {
32 // Rc - 1-bit registers
33 class Rc<bits<5> bitno, string n> : BlackfinReg<n> {
34 field bits<5> BitNum = bitno;
37 // Rs - 16-bit integer registers
38 class Rs<bits<3> group, bits<3> num, bits<1> hi, string n> : BlackfinReg<n> {
41 field bits<1> High = hi;
44 // Ri - 32-bit integer registers with subregs
45 class Ri<bits<3> group, bits<3> num, string n> : BlackfinReg<n> {
50 // Ra 40-bit accumulator registers
51 class Ra<bits<3> num, string n, list<Register> subs> : BlackfinReg<n> {
53 let SubRegIndices = [hi32, lo32];
58 // Two halves of 32-bit register
59 multiclass Rss<bits<3> group, bits<3> num, string n> {
60 def H : Rs<group, num, 1, !strconcat(n, ".h")>;
61 def L : Rs<group, num, 0, !strconcat(n, ".l")>;
64 // Rii - 32-bit integer registers with subregs
65 class Rii<bits<3> group, bits<3> num, string n, list<Register> subs>
68 let SubRegIndices = [hi16, lo16];
73 // Status bits are all part of ASTAT
76 def CC : Rc<5, "cc">, DwarfRegNum<[34]>;
77 def NCC : Rc<5, "!cc"> { let Aliases = [CC]; }
79 def AC0 : Rc<12, "ac0">;
80 def AC1 : Rc<13, "ac1">;
81 def AV0 : Rc<16, "av0">;
82 def AV0S : Rc<17, "av0s">;
83 def AV1 : Rc<18, "av1">;
84 def AV1S : Rc<19, "av1s">;
86 def VS : Rc<25, "vs">;
87 // Skipped non-status bits: AC0_COPY, V_COPY, RND_MOD
89 // Group 0: Integer registers
90 defm R0 : Rss<0, 0, "r0">;
91 def R0 : Rii<0, 0, "r0", [R0H, R0L]>, DwarfRegNum<[0]>;
92 defm R1 : Rss<0, 1, "r1">;
93 def R1 : Rii<0, 1, "r1", [R1H, R1L]>, DwarfRegNum<[1]>;
94 defm R2 : Rss<0, 2, "r2">;
95 def R2 : Rii<0, 2, "r2", [R2H, R2L]>, DwarfRegNum<[2]>;
96 defm R3 : Rss<0, 3, "r3">;
97 def R3 : Rii<0, 3, "r3", [R3H, R3L]>, DwarfRegNum<[3]>;
98 defm R4 : Rss<0, 4, "r4">;
99 def R4 : Rii<0, 4, "r4", [R4H, R4L]>, DwarfRegNum<[4]>;
100 defm R5 : Rss<0, 5, "r5">;
101 def R5 : Rii<0, 5, "r5", [R5H, R5L]>, DwarfRegNum<[5]>;
102 defm R6 : Rss<0, 6, "r6">;
103 def R6 : Rii<0, 6, "r6", [R6H, R6L]>, DwarfRegNum<[6]>;
104 defm R7 : Rss<0, 7, "r7">;
105 def R7 : Rii<0, 7, "r7", [R7H, R7L]>, DwarfRegNum<[7]>;
107 // Group 1: Pointer registers
108 defm P0 : Rss<1, 0, "p0">;
109 def P0 : Rii<1, 0, "p0", [P0H, P0L]>, DwarfRegNum<[8]>;
110 defm P1 : Rss<1, 1, "p1">;
111 def P1 : Rii<1, 1, "p1", [P1H, P1L]>, DwarfRegNum<[9]>;
112 defm P2 : Rss<1, 2, "p2">;
113 def P2 : Rii<1, 2, "p2", [P2H, P2L]>, DwarfRegNum<[10]>;
114 defm P3 : Rss<1, 3, "p3">;
115 def P3 : Rii<1, 3, "p3", [P3H, P3L]>, DwarfRegNum<[11]>;
116 defm P4 : Rss<1, 4, "p4">;
117 def P4 : Rii<1, 4, "p4", [P4H, P4L]>, DwarfRegNum<[12]>;
118 defm P5 : Rss<1, 5, "p5">;
119 def P5 : Rii<1, 5, "p5", [P5H, P5L]>, DwarfRegNum<[13]>;
120 defm SP : Rss<1, 6, "sp">;
121 def SP : Rii<1, 6, "sp", [SPH, SPL]>, DwarfRegNum<[14]>;
122 defm FP : Rss<1, 7, "fp">;
123 def FP : Rii<1, 7, "fp", [FPH, FPL]>, DwarfRegNum<[15]>;
125 // Group 2: Index registers
126 defm I0 : Rss<2, 0, "i0">;
127 def I0 : Rii<2, 0, "i0", [I0H, I0L]>, DwarfRegNum<[16]>;
128 defm I1 : Rss<2, 1, "i1">;
129 def I1 : Rii<2, 1, "i1", [I1H, I1L]>, DwarfRegNum<[17]>;
130 defm I2 : Rss<2, 2, "i2">;
131 def I2 : Rii<2, 2, "i2", [I2H, I2L]>, DwarfRegNum<[18]>;
132 defm I3 : Rss<2, 3, "i3">;
133 def I3 : Rii<2, 3, "i3", [I3H, I3L]>, DwarfRegNum<[19]>;
134 defm M0 : Rss<2, 4, "m0">;
135 def M0 : Rii<2, 4, "m0", [M0H, M0L]>, DwarfRegNum<[20]>;
136 defm M1 : Rss<2, 5, "m1">;
137 def M1 : Rii<2, 5, "m1", [M1H, M1L]>, DwarfRegNum<[21]>;
138 defm M2 : Rss<2, 6, "m2">;
139 def M2 : Rii<2, 6, "m2", [M2H, M2L]>, DwarfRegNum<[22]>;
140 defm M3 : Rss<2, 7, "m3">;
141 def M3 : Rii<2, 7, "m3", [M3H, M3L]>, DwarfRegNum<[23]>;
143 // Group 3: Cyclic indexing registers
144 defm B0 : Rss<3, 0, "b0">;
145 def B0 : Rii<3, 0, "b0", [B0H, B0L]>, DwarfRegNum<[24]>;
146 defm B1 : Rss<3, 1, "b1">;
147 def B1 : Rii<3, 1, "b1", [B1H, B1L]>, DwarfRegNum<[25]>;
148 defm B2 : Rss<3, 2, "b2">;
149 def B2 : Rii<3, 2, "b2", [B2H, B2L]>, DwarfRegNum<[26]>;
150 defm B3 : Rss<3, 3, "b3">;
151 def B3 : Rii<3, 3, "b3", [B3H, B3L]>, DwarfRegNum<[27]>;
152 defm L0 : Rss<3, 4, "l0">;
153 def L0 : Rii<3, 4, "l0", [L0H, L0L]>, DwarfRegNum<[28]>;
154 defm L1 : Rss<3, 5, "l1">;
155 def L1 : Rii<3, 5, "l1", [L1H, L1L]>, DwarfRegNum<[29]>;
156 defm L2 : Rss<3, 6, "l2">;
157 def L2 : Rii<3, 6, "l2", [L2H, L2L]>, DwarfRegNum<[30]>;
158 defm L3 : Rss<3, 7, "l3">;
159 def L3 : Rii<3, 7, "l3", [L3H, L3L]>, DwarfRegNum<[31]>;
162 def A0X : Ri <4, 0, "a0.x">;
163 defm A0 : Rss<4, 1, "a0">;
164 def A0W : Rii<4, 1, "a0.w", [A0H, A0L]>, DwarfRegNum<[32]>;
165 def A0 : Ra <0, "a0", [A0X, A0W]>;
167 def A1X : Ri <4, 2, "a1.x">;
168 defm A1 : Rss<4, 3, "a1">;
169 def A1W : Rii<4, 3, "a1.w", [A1H, A1L]>, DwarfRegNum<[33]>;
170 def A1 : Ra <2, "a1", [A1X, A1W]>;
172 def RETS : Ri<4, 7, "rets">, DwarfRegNum<[35]>;
173 def RETI : Ri<7, 3, "reti">, DwarfRegNum<[36]>;
174 def RETX : Ri<7, 4, "retx">, DwarfRegNum<[37]>;
175 def RETN : Ri<7, 5, "retn">, DwarfRegNum<[38]>;
176 def RETE : Ri<7, 6, "rete">, DwarfRegNum<[39]>;
178 def ASTAT : Ri<4, 6, "astat">, DwarfRegNum<[40]> {
179 let Aliases = [AZ, AN, CC, NCC, AQ, AC0, AC1, AV0, AV0S, AV1, AV1S, V, VS];
182 def SEQSTAT : Ri<7, 1, "seqstat">, DwarfRegNum<[41]>;
183 def USP : Ri<7, 0, "usp">, DwarfRegNum<[42]>;
184 def EMUDAT : Ri<7, 7, "emudat">, DwarfRegNum<[43]>;
185 def SYSCFG : Ri<7, 2, "syscfg">;
186 def CYCLES : Ri<6, 6, "cycles">;
187 def CYCLES2 : Ri<6, 7, "cycles2">;
190 def LT0 : Ri<6, 1, "lt0">, DwarfRegNum<[44]>;
191 def LT1 : Ri<6, 4, "lt1">, DwarfRegNum<[45]>;
192 def LC0 : Ri<6, 0, "lc0">, DwarfRegNum<[46]>;
193 def LC1 : Ri<6, 3, "lc1">, DwarfRegNum<[47]>;
194 def LB0 : Ri<6, 2, "lb0">, DwarfRegNum<[48]>;
195 def LB1 : Ri<6, 5, "lb1">, DwarfRegNum<[49]>;
198 def D16 : RegisterClass<"BF", [i16], 16,
199 [R0H, R0L, R1H, R1L, R2H, R2L, R3H, R3L,
200 R4H, R4L, R5H, R5L, R6H, R6L, R7H, R7L]>;
202 def D16L : RegisterClass<"BF", [i16], 16,
203 [R0L, R1L, R2L, R3L, R4L, R5L, R6L, R7L]>;
205 def D16H : RegisterClass<"BF", [i16], 16,
206 [R0H, R1H, R2H, R3H, R4H, R5H, R6H, R7H]>;
208 def P16 : RegisterClass<"BF", [i16], 16,
209 [P0H, P0L, P1H, P1L, P2H, P2L, P3H, P3L,
210 P4H, P4L, P5H, P5L, SPH, SPL, FPH, FPL]>;
212 def P16L : RegisterClass<"BF", [i16], 16,
213 [P0L, P1L, P2L, P3L, P4L, P5L, SPL, FPL]>;
215 def P16H : RegisterClass<"BF", [i16], 16,
216 [P0H, P1H, P2H, P3H, P4H, P5H, SPH, FPH]>;
218 def DP16 : RegisterClass<"BF", [i16], 16,
219 [R0H, R0L, R1H, R1L, R2H, R2L, R3H, R3L,
220 R4H, R4L, R5H, R5L, R6H, R6L, R7H, R7L,
221 P0H, P0L, P1H, P1L, P2H, P2L, P3H, P3L,
222 P4H, P4L, P5H, P5L, SPH, SPL, FPH, FPL]>;
224 def DP16L : RegisterClass<"BF", [i16], 16,
225 [R0L, R1L, R2L, R3L, R4L, R5L, R6L, R7L,
226 P0L, P1L, P2L, P3L, P4L, P5L, SPL, FPL]>;
228 def DP16H : RegisterClass<"BF", [i16], 16,
229 [R0H, R1H, R2H, R3H, R4H, R5H, R6H, R7H,
230 P0H, P1H, P2H, P3H, P4H, P5H, SPH, FPH]>;
232 def GR16 : RegisterClass<"BF", [i16], 16,
233 [R0H, R0L, R1H, R1L, R2H, R2L, R3H, R3L,
234 R4H, R4L, R5H, R5L, R6H, R6L, R7H, R7L,
235 P0H, P0L, P1H, P1L, P2H, P2L, P3H, P3L,
236 P4H, P4L, P5H, P5L, SPH, SPL, FPH, FPL,
237 I0H, I0L, I1H, I1L, I2H, I2L, I3H, I3L,
238 M0H, M0L, M1H, M1L, M2H, M2L, M3H, M3L,
239 B0H, B0L, B1H, B1L, B2H, B2L, B3H, B3L,
240 L0H, L0L, L1H, L1L, L2H, L2L, L3H, L3L]>;
242 def D : RegisterClass<"BF", [i32], 32, [R0, R1, R2, R3, R4, R5, R6, R7]> {
243 let SubRegClasses = [(D16L lo16), (D16H hi16)];
246 def P : RegisterClass<"BF", [i32], 32, [P0, P1, P2, P3, P4, P5, FP, SP]> {
247 let SubRegClasses = [(P16L lo16), (P16H hi16)];
248 let MethodProtos = [{
249 iterator allocation_order_end(const MachineFunction &MF) const;
251 let MethodBodies = [{
253 PClass::allocation_order_end(const MachineFunction &MF) const {
254 const TargetMachine &TM = MF.getTarget();
255 const TargetRegisterInfo *RI = TM.getRegisterInfo();
256 return allocation_order_begin(MF)
257 + (RI->hasFP(MF) ? 7 : 6);
262 def I : RegisterClass<"BF", [i32], 32, [I0, I1, I2, I3]>;
263 def M : RegisterClass<"BF", [i32], 32, [M0, M1, M2, M3]>;
264 def B : RegisterClass<"BF", [i32], 32, [B0, B1, B2, B3]>;
265 def L : RegisterClass<"BF", [i32], 32, [L0, L1, L2, L3]>;
267 def DP : RegisterClass<"BF", [i32], 32,
268 [R0, R1, R2, R3, R4, R5, R6, R7,
269 P0, P1, P2, P3, P4, P5, FP, SP]> {
270 let SubRegClasses = [(DP16L lo16), (DP16H hi16)];
271 let MethodProtos = [{
272 iterator allocation_order_end(const MachineFunction &MF) const;
274 let MethodBodies = [{
276 DPClass::allocation_order_end(const MachineFunction &MF) const {
277 const TargetMachine &TM = MF.getTarget();
278 const TargetRegisterInfo *RI = TM.getRegisterInfo();
279 return allocation_order_begin(MF)
280 + (RI->hasFP(MF) ? 15 : 14);
285 def GR : RegisterClass<"BF", [i32], 32,
286 [R0, R1, R2, R3, R4, R5, R6, R7,
287 P0, P1, P2, P3, P4, P5,
288 I0, I1, I2, I3, M0, M1, M2, M3,
289 B0, B1, B2, B3, L0, L1, L2, L3,
291 let MethodProtos = [{
292 iterator allocation_order_end(const MachineFunction &MF) const;
294 let MethodBodies = [{
296 GRClass::allocation_order_end(const MachineFunction &MF) const {
297 const TargetMachine &TM = MF.getTarget();
298 const TargetRegisterInfo *RI = TM.getRegisterInfo();
299 return allocation_order_begin(MF)
300 + (RI->hasFP(MF) ? 31 : 30);
305 def ALL : RegisterClass<"BF", [i32], 32,
306 [R0, R1, R2, R3, R4, R5, R6, R7,
307 P0, P1, P2, P3, P4, P5,
308 I0, I1, I2, I3, M0, M1, M2, M3,
309 B0, B1, B2, B3, L0, L1, L2, L3,
311 A0X, A0W, A1X, A1W, ASTAT, RETS,
312 LC0, LT0, LB0, LC1, LT1, LB1, CYCLES, CYCLES2,
313 USP, SEQSTAT, SYSCFG, RETI, RETX, RETN, RETE, EMUDAT]> {
314 let MethodProtos = [{
315 iterator allocation_order_end(const MachineFunction &MF) const;
317 let MethodBodies = [{
319 ALLClass::allocation_order_end(const MachineFunction &MF) const {
320 const TargetMachine &TM = MF.getTarget();
321 const TargetRegisterInfo *RI = TM.getRegisterInfo();
322 return allocation_order_begin(MF)
323 + (RI->hasFP(MF) ? 31 : 30);
328 def PI : RegisterClass<"BF", [i32], 32,
329 [P0, P1, P2, P3, P4, P5, I0, I1, I2, I3, FP, SP]> {
330 let MethodProtos = [{
331 iterator allocation_order_end(const MachineFunction &MF) const;
333 let MethodBodies = [{
335 PIClass::allocation_order_end(const MachineFunction &MF) const {
336 const TargetMachine &TM = MF.getTarget();
337 const TargetRegisterInfo *RI = TM.getRegisterInfo();
338 return allocation_order_begin(MF)
339 + (RI->hasFP(MF) ? 11 : 10);
344 // We are going to pretend that CC and !CC are 32-bit registers, even though
345 // they only can hold 1 bit.
346 let CopyCost = -1, Size = 8 in {
347 def JustCC : RegisterClass<"BF", [i32], 8, [CC]>;
348 def NotCC : RegisterClass<"BF", [i32], 8, [NCC]>;
349 def AnyCC : RegisterClass<"BF", [i32], 8, [CC, NCC]> {
350 let MethodProtos = [{
351 iterator allocation_order_end(const MachineFunction &MF) const;
353 let MethodBodies = [{
355 AnyCCClass::allocation_order_end(const MachineFunction &MF) const {
356 return allocation_order_begin(MF)+1;
360 def StatBit : RegisterClass<"BF", [i1], 8,
361 [AZ, AN, CC, AQ, AC0, AC1, AV0, AV0S, AV1, AV1S, V, VS]>;
364 // Should be i40, but that isn't defined. It is not a legal type yet anyway.
365 def Accu : RegisterClass<"BF", [i64], 64, [A0, A1]>;