]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Hexagon/HexagonRegisterInfo.td
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r302418, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Hexagon / HexagonRegisterInfo.td
1 //===-- HexagonRegisterInfo.td - Hexagon Register defs -----*- 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 //  Declarations that describe the Hexagon register file.
12 //===----------------------------------------------------------------------===//
13
14 let Namespace = "Hexagon" in {
15
16   class HexagonReg<bits<5> num, string n, list<string> alt = [],
17                    list<Register> alias = []> : Register<n, alt> {
18     field bits<5> Num;
19     let Aliases = alias;
20     let HWEncoding{4-0} = num;
21   }
22
23   class HexagonDoubleReg<bits<5> num, string n, list<Register> subregs,
24                          list<string> alt = []> :
25         RegisterWithSubRegs<n, subregs> {
26     field bits<5> Num;
27
28     let AltNames = alt;
29     let HWEncoding{4-0} = num;
30   }
31
32   // Registers are identified with 5-bit ID numbers.
33   // Ri - 32-bit integer registers.
34   class Ri<bits<5> num, string n, list<string> alt = []> :
35         HexagonReg<num, n, alt> {
36     let Num = num;
37   }
38
39   // Rf - 32-bit floating-point registers.
40   class Rf<bits<5> num, string n> : HexagonReg<num, n> {
41     let Num = num;
42   }
43
44
45   // Rd - 64-bit registers.
46   class Rd<bits<5> num, string n, list<Register> subregs,
47            list<string> alt = []> :
48         HexagonDoubleReg<num, n, subregs, alt> {
49     let Num = num;
50     let SubRegs = subregs;
51   }
52
53   // Rp - predicate registers
54   class Rp<bits<5> num, string n> : HexagonReg<num, n> {
55     let Num = num;
56   }
57
58
59   // Rq - vector predicate registers
60   class Rq<bits<3> num, string n> : Register<n, []> {
61     let HWEncoding{2-0} = num;
62   }
63
64   // Rc - control registers
65   class Rc<bits<5> num, string n,
66            list<string> alt = [], list<Register> alias = []> : 
67         HexagonReg<num, n, alt, alias> {
68     let Num = num;
69   }
70
71   // Rcc - 64-bit control registers.
72   class Rcc<bits<5> num, string n, list<Register> subregs,
73             list<string> alt = []> :
74         HexagonDoubleReg<num, n, subregs, alt> {
75     let Num = num;
76     let SubRegs = subregs;
77   }
78
79   // Mx - address modifier registers
80   class Mx<bits<1> num, string n> : HexagonReg<{0b0000, num}, n> {
81     let Num = !cast<bits<5>>(num);
82   }
83
84   def isub_lo  : SubRegIndex<32>;
85   def isub_hi  : SubRegIndex<32, 32>;
86   def vsub_lo  : SubRegIndex<512>;
87   def vsub_hi  : SubRegIndex<512, 512>;
88   def subreg_overflow : SubRegIndex<1, 0>;
89
90   // Integer registers.
91   foreach i = 0-28 in {
92     def R#i  : Ri<i, "r"#i>,  DwarfRegNum<[i]>;
93   }
94
95   def R29 : Ri<29, "r29", ["sp"]>, DwarfRegNum<[29]>;
96   def R30 : Ri<30, "r30", ["fp"]>, DwarfRegNum<[30]>;
97   def R31 : Ri<31, "r31", ["lr"]>, DwarfRegNum<[31]>;
98
99   // Aliases of the R* registers used to hold 64-bit int values (doubles).
100   let SubRegIndices = [isub_lo, isub_hi], CoveredBySubRegs = 1 in {
101   def D0  : Rd< 0,  "r1:0",  [R0,  R1]>,  DwarfRegNum<[32]>;
102   def D1  : Rd< 2,  "r3:2",  [R2,  R3]>,  DwarfRegNum<[34]>;
103   def D2  : Rd< 4,  "r5:4",  [R4,  R5]>,  DwarfRegNum<[36]>;
104   def D3  : Rd< 6,  "r7:6",  [R6,  R7]>,  DwarfRegNum<[38]>;
105   def D4  : Rd< 8,  "r9:8",  [R8,  R9]>,  DwarfRegNum<[40]>;
106   def D5  : Rd<10, "r11:10", [R10, R11]>, DwarfRegNum<[42]>;
107   def D6  : Rd<12, "r13:12", [R12, R13]>, DwarfRegNum<[44]>;
108   def D7  : Rd<14, "r15:14", [R14, R15]>, DwarfRegNum<[46]>;
109   def D8  : Rd<16, "r17:16", [R16, R17]>, DwarfRegNum<[48]>;
110   def D9  : Rd<18, "r19:18", [R18, R19]>, DwarfRegNum<[50]>;
111   def D10 : Rd<20, "r21:20", [R20, R21]>, DwarfRegNum<[52]>;
112   def D11 : Rd<22, "r23:22", [R22, R23]>, DwarfRegNum<[54]>;
113   def D12 : Rd<24, "r25:24", [R24, R25]>, DwarfRegNum<[56]>;
114   def D13 : Rd<26, "r27:26", [R26, R27]>, DwarfRegNum<[58]>;
115   def D14 : Rd<28, "r29:28", [R28, R29]>, DwarfRegNum<[60]>;
116   def D15 : Rd<30, "r31:30", [R30, R31], ["lr:fp"]>, DwarfRegNum<[62]>;
117   }
118
119   // Predicate registers.
120   def P0 : Rp<0, "p0">, DwarfRegNum<[63]>;
121   def P1 : Rp<1, "p1">, DwarfRegNum<[64]>;
122   def P2 : Rp<2, "p2">, DwarfRegNum<[65]>;
123   def P3 : Rp<3, "p3">, DwarfRegNum<[66]>;
124
125   // Fake register to represent USR.OVF bit. Artihmetic/saturating instruc-
126   // tions modify this bit, and multiple such instructions are allowed in the
127   // same packet. We need to ignore output dependencies on this bit, but not
128   // on the entire USR.
129   def USR_OVF : Rc<?, "usr.ovf">;
130
131   def USR  : Rc<8,  "usr",       ["c8"]>,   DwarfRegNum<[75]> {
132     let SubRegIndices = [subreg_overflow];
133     let SubRegs = [USR_OVF];
134   }
135
136   // Control registers.
137   def SA0:        Rc<0,  "sa0",        ["c0"]>,    DwarfRegNum<[67]>;
138   def LC0:        Rc<1,  "lc0",        ["c1"]>,    DwarfRegNum<[68]>;
139   def SA1:        Rc<2,  "sa1",        ["c2"]>,    DwarfRegNum<[69]>;
140   def LC1:        Rc<3,  "lc1",        ["c3"]>,    DwarfRegNum<[70]>;
141   def P3_0:       Rc<4,  "p3:0",       ["c4"], [P0, P1, P2, P3]>,
142                                                    DwarfRegNum<[71]>;
143   // When defining more Cn registers, make sure to explicitly mark them
144   // as reserved in HexagonRegisterInfo.cpp.
145   def C5:         Rc<5,  "c5",         ["c5"]>,    DwarfRegNum<[72]>;
146   def M0:         Rc<6,  "m0",         ["c6"]>,    DwarfRegNum<[73]>;
147   def M1:         Rc<7,  "m1",         ["c7"]>,    DwarfRegNum<[74]>;
148   // Define C8 separately and make it aliased with USR.
149   // The problem is that USR has subregisters (e.g. overflow). If USR was
150   // specified as a subregister of C9_8, it would imply that subreg_overflow
151   // and isub_lo can be composed, which leads to all kinds of issues
152   // with lane masks.
153   def C8:         Rc<8,  "c8",         [], [USR]>, DwarfRegNum<[75]>;
154   def PC:         Rc<9,  "pc",         ["c9"]>,    DwarfRegNum<[76]>;
155   def UGP:        Rc<10, "ugp",        ["c10"]>,   DwarfRegNum<[77]>;
156   def GP:         Rc<11, "gp",         ["c11"]>,   DwarfRegNum<[78]>;
157   def CS0:        Rc<12, "cs0",        ["c12"]>,   DwarfRegNum<[79]>;
158   def CS1:        Rc<13, "cs1",        ["c13"]>,   DwarfRegNum<[80]>;
159   def UPCYCLELO:  Rc<14, "upcyclelo",  ["c14"]>,   DwarfRegNum<[81]>;
160   def UPCYCLEHI:  Rc<15, "upcyclehi",  ["c15"]>,   DwarfRegNum<[82]>;
161   def FRAMELIMIT: Rc<16, "framelimit", ["c16"]>,   DwarfRegNum<[83]>;
162   def FRAMEKEY:   Rc<17, "framekey",   ["c17"]>,   DwarfRegNum<[84]>;
163   def PKTCOUNTLO: Rc<18, "pktcountlo", ["c18"]>,   DwarfRegNum<[85]>;
164   def PKTCOUNTHI: Rc<19, "pktcounthi", ["c19"]>,   DwarfRegNum<[86]>;
165   def UTIMERLO:   Rc<30, "utimerlo",   ["c30"]>,   DwarfRegNum<[97]>;
166   def UTIMERHI:   Rc<31, "utimerhi",   ["c31"]>,   DwarfRegNum<[98]>;
167 }
168
169   // Control registers pairs.
170   let SubRegIndices = [isub_lo, isub_hi], CoveredBySubRegs = 1 in {
171     def C1_0:     Rcc<0,  "c1:0",   [SA0, LC0], ["lc0:sa0"]>, DwarfRegNum<[67]>;
172     def C3_2:     Rcc<2,  "c3:2",   [SA1, LC1], ["lc1:sa1"]>, DwarfRegNum<[69]>;
173     def C5_4:     Rcc<4,  "c5:4",   [P3_0, C5]>,              DwarfRegNum<[71]>;
174     def C7_6:     Rcc<6,  "c7:6",   [M0, M1],   ["m1:0"]>,    DwarfRegNum<[72]>;
175     // Use C8 instead of USR as a subregister of C9_8.
176     def C9_8:     Rcc<8,  "c9:8",   [C8, PC]>,                DwarfRegNum<[74]>;
177     def C11_10:   Rcc<10, "c11:10", [UGP, GP]>,               DwarfRegNum<[76]>;
178     def CS:       Rcc<12, "c13:12", [CS0, CS1], ["cs1:0"]>,   DwarfRegNum<[78]>;
179     def UPCYCLE:  Rcc<14, "c15:14", [UPCYCLELO, UPCYCLEHI]>,  DwarfRegNum<[80]>;
180     def C17_16:   Rcc<16, "c17:16", [FRAMELIMIT, FRAMEKEY]>,  DwarfRegNum<[83]>;
181     def PKTCOUNT: Rcc<18, "c19:18", [PKTCOUNTLO, PKTCOUNTHI], ["pktcount"]>,
182                                                               DwarfRegNum<[85]>;
183     def UTIMER:   Rcc<30, "c31:30", [UTIMERLO, UTIMERHI], ["utimer"]>,
184                                                               DwarfRegNum<[97]>;
185   }
186
187   foreach i = 0-31 in {
188     def V#i  : Ri<i, "v"#i>,  DwarfRegNum<[!add(i, 99)]>;
189   }
190
191   // Aliases of the V* registers used to hold double vec values.
192   let SubRegIndices = [vsub_lo, vsub_hi], CoveredBySubRegs = 1 in {
193   def W0  : Rd< 0,  "v1:0",  [V0,  V1]>,  DwarfRegNum<[99]>;
194   def W1  : Rd< 2,  "v3:2",  [V2,  V3]>,  DwarfRegNum<[101]>;
195   def W2  : Rd< 4,  "v5:4",  [V4,  V5]>,  DwarfRegNum<[103]>;
196   def W3  : Rd< 6,  "v7:6",  [V6,  V7]>,  DwarfRegNum<[105]>;
197   def W4  : Rd< 8,  "v9:8",  [V8,  V9]>,  DwarfRegNum<[107]>;
198   def W5  : Rd<10, "v11:10", [V10, V11]>, DwarfRegNum<[109]>;
199   def W6  : Rd<12, "v13:12", [V12, V13]>, DwarfRegNum<[111]>;
200   def W7  : Rd<14, "v15:14", [V14, V15]>, DwarfRegNum<[113]>;
201   def W8  : Rd<16, "v17:16", [V16, V17]>, DwarfRegNum<[115]>;
202   def W9  : Rd<18, "v19:18", [V18, V19]>, DwarfRegNum<[117]>;
203   def W10 : Rd<20, "v21:20", [V20, V21]>, DwarfRegNum<[119]>;
204   def W11 : Rd<22, "v23:22", [V22, V23]>, DwarfRegNum<[121]>;
205   def W12 : Rd<24, "v25:24", [V24, V25]>, DwarfRegNum<[123]>;
206   def W13 : Rd<26, "v27:26", [V26, V27]>, DwarfRegNum<[125]>;
207   def W14 : Rd<28, "v29:28", [V28, V29]>, DwarfRegNum<[127]>;
208   def W15 : Rd<30, "v31:30", [V30, V31]>, DwarfRegNum<[129]>;
209   }
210
211   // Vector Predicate registers.
212   def Q0 : Rq<0, "q0">, DwarfRegNum<[131]>;
213   def Q1 : Rq<1, "q1">, DwarfRegNum<[132]>;
214   def Q2 : Rq<2, "q2">, DwarfRegNum<[133]>;
215   def Q3 : Rq<3, "q3">, DwarfRegNum<[134]>;
216
217 // Register classes.
218 //
219 // FIXME: the register order should be defined in terms of the preferred
220 // allocation order...
221 //
222 def IntRegs : RegisterClass<"Hexagon", [i32, f32, v4i8, v2i16], 32,
223                             (add (sequence "R%u", 0, 9),
224                                  (sequence "R%u", 12, 28),
225                                  R10, R11, R29, R30, R31)> {
226 }
227
228 // Registers are listed in reverse order for allocation preference reasons.
229 def GeneralSubRegs : RegisterClass<"Hexagon", [i32], 32,
230                                    (add R23, R22, R21, R20, R19, R18, R17,
231                                         R16, R7, R6, R5, R4, R3, R2, R1, R0)>;
232
233 def IntRegsLow8 : RegisterClass<"Hexagon", [i32], 32,
234                                 (add R7, R6, R5, R4, R3, R2, R1, R0)> ;
235
236 def DoubleRegs : RegisterClass<"Hexagon", [i64, f64, v8i8, v4i16, v2i32], 64,
237                                (add (sequence "D%u", 0, 4),
238                                     (sequence "D%u", 6, 13), D5, D14, D15)>;
239
240 def GeneralDoubleLow8Regs : RegisterClass<"Hexagon", [i64], 64,
241                                           (add D11, D10, D9, D8, D3, D2, D1,
242                                                D0)>;
243
244 def VectorRegs : RegisterClass<"Hexagon", [v64i8, v32i16, v16i32, v8i64], 512,
245                                (add (sequence "V%u", 0, 31))>;
246
247 def VecDblRegs : RegisterClass<"Hexagon",
248                          [v128i8, v64i16, v32i32, v16i64], 1024,
249                                (add (sequence "W%u", 0, 15))>;
250
251 def VectorRegs128B : RegisterClass<"Hexagon",
252                          [v128i8, v64i16, v32i32, v16i64], 1024,
253                                (add (sequence "V%u", 0, 31))>;
254
255 def VecDblRegs128B : RegisterClass<"Hexagon",
256                          [v256i8,v128i16,v64i32,v32i64], 2048,
257                                (add (sequence "W%u", 0, 15))>;
258
259 def VecPredRegs : RegisterClass<"Hexagon", [v512i1], 512,
260                                 (add (sequence "Q%u", 0, 3))>;
261
262 def VecPredRegs128B : RegisterClass<"Hexagon", [v1024i1], 1024,
263                                    (add (sequence "Q%u", 0, 3))>;
264
265 def PredRegs : RegisterClass<"Hexagon", 
266                              [i1, v2i1, v4i1, v8i1, v4i8, v2i16, i32], 32,
267                              (add (sequence "P%u", 0, 3))>
268 {
269   let Size = 32;
270 }
271
272 let Size = 32 in
273 def ModRegs : RegisterClass<"Hexagon", [i32], 32, (add M0, M1)>;
274
275 let Size = 32, isAllocatable = 0 in
276 def CtrRegs : RegisterClass<"Hexagon", [i32], 32,
277   (add LC0, SA0, LC1, SA1, P3_0, C5, C8, PC, UGP, GP, CS0, CS1,
278        UPCYCLELO, UPCYCLEHI,
279        FRAMELIMIT, FRAMEKEY, PKTCOUNTLO, PKTCOUNTHI, UTIMERLO, UTIMERHI,
280        M0, M1, USR)>;
281
282 let isAllocatable = 0 in
283 def UsrBits : RegisterClass<"Hexagon", [i1], 0, (add USR_OVF)>;
284
285 let Size = 64, isAllocatable = 0 in
286 def CtrRegs64 : RegisterClass<"Hexagon", [i64], 64,
287   (add C1_0, C3_2, C5_4, C7_6, C9_8, C11_10, CS, UPCYCLE, C17_16,
288        PKTCOUNT, UTIMER)>;
289
290 // These registers are new for v62 and onward.
291 // The function RegisterMatchesArch() uses this list for validation.
292 let isAllocatable = 0 in
293 def V62Regs : RegisterClass<"Hexagon", [i32], 32,
294                             (add FRAMELIMIT, FRAMEKEY,   C17_16,
295                                  PKTCOUNTLO, PKTCOUNTHI, PKTCOUNT,
296                                  UTIMERLO,   UTIMERHI,   UTIMER)>;
297
298
299 def HexagonCSR
300   : CalleeSavedRegs<(add R16, R17, R18, R19, R20, R21, R22, R23,
301                          R24, R25, R26, R27)>;