[Hexagon] Adding loop0/1 sp0/1/2loop0 instructions.
[oota-llvm.git] / 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> {
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         RegisterWithSubRegs<n, subregs> {
25     field bits<5> Num;
26     let HWEncoding{4-0} = num;
27   }
28
29   // Registers are identified with 5-bit ID numbers.
30   // Ri - 32-bit integer registers.
31   class Ri<bits<5> num, string n, list<string> alt = []> : HexagonReg<num, n, alt> {
32     let Num = num;
33   }
34
35   // Rf - 32-bit floating-point registers.
36   class Rf<bits<5> num, string n> : HexagonReg<num, n> {
37     let Num = num;
38   }
39
40
41   // Rd - 64-bit registers.
42   class Rd<bits<5> num, string n, list<Register> subregs> :
43         HexagonDoubleReg<num, n, subregs> {
44     let Num = num;
45     let SubRegs = subregs;
46   }
47
48   // Rp - predicate registers
49   class Rp<bits<5> num, string n> : HexagonReg<num, n> {
50     let Num = num;
51   }
52
53   // Rc - control registers
54   class Rc<bits<5> num, string n> : HexagonReg<num, n> {
55     let Num = num;
56   }
57
58   def subreg_loreg  : SubRegIndex<32>;
59   def subreg_hireg  : SubRegIndex<32, 32>;
60   def subreg_overflow : SubRegIndex<1, 0>;
61
62   // Integer registers.
63   foreach i = 0-28 in {
64     def R#i  : Ri<i, "r"#i>,  DwarfRegNum<[i]>;
65   }
66
67   def R29 : Ri<29, "r29", ["sp"]>, DwarfRegNum<[29]>;
68   def R30 : Ri<30, "r30", ["fp"]>, DwarfRegNum<[30]>;
69   def R31 : Ri<31, "r31", ["lr"]>, DwarfRegNum<[31]>;
70
71   // Aliases of the R* registers used to hold 64-bit int values (doubles).
72   let SubRegIndices = [subreg_loreg, subreg_hireg], CoveredBySubRegs = 1 in {
73   def D0  : Rd< 0,  "r1:0",  [R0,  R1]>, DwarfRegNum<[32]>;
74   def D1  : Rd< 2,  "r3:2",  [R2,  R3]>, DwarfRegNum<[34]>;
75   def D2  : Rd< 4,  "r5:4",  [R4,  R5]>, DwarfRegNum<[36]>;
76   def D3  : Rd< 6,  "r7:6",  [R6,  R7]>, DwarfRegNum<[38]>;
77   def D4  : Rd< 8,  "r9:8",  [R8,  R9]>, DwarfRegNum<[40]>;
78   def D5  : Rd<10, "r11:10", [R10, R11]>, DwarfRegNum<[42]>;
79   def D6  : Rd<12, "r13:12", [R12, R13]>, DwarfRegNum<[44]>;
80   def D7  : Rd<14, "r15:14", [R14, R15]>, DwarfRegNum<[46]>;
81   def D8  : Rd<16, "r17:16", [R16, R17]>, DwarfRegNum<[48]>;
82   def D9  : Rd<18, "r19:18", [R18, R19]>, DwarfRegNum<[50]>;
83   def D10 : Rd<20, "r21:20", [R20, R21]>, DwarfRegNum<[52]>;
84   def D11 : Rd<22, "r23:22", [R22, R23]>, DwarfRegNum<[54]>;
85   def D12 : Rd<24, "r25:24", [R24, R25]>, DwarfRegNum<[56]>;
86   def D13 : Rd<26, "r27:26", [R26, R27]>, DwarfRegNum<[58]>;
87   def D14 : Rd<28, "r29:28", [R28, R29]>, DwarfRegNum<[60]>;
88   def D15 : Rd<30, "r31:30", [R30, R31]>, DwarfRegNum<[62]>;
89   }
90
91   // Predicate registers.
92   def P0 : Rp<0, "p0">, DwarfRegNum<[63]>;
93   def P1 : Rp<1, "p1">, DwarfRegNum<[64]>;
94   def P2 : Rp<2, "p2">, DwarfRegNum<[65]>;
95   def P3 : Rp<3, "p3">, DwarfRegNum<[66]>;
96
97   // Fake register to represent USR.OVF bit. Artihmetic/saturating instruc-
98   // tions modify this bit, and multiple such instructions are allowed in the
99   // same packet. We need to ignore output dependencies on this bit, but not
100   // on the entire USR.
101   def USR_OVF : Rc<?, "usr.ovf">;
102
103   // Control registers.
104   def SA0 : Rc<0, "sa0">, DwarfRegNum<[67]>;
105   def LC0 : Rc<1, "lc0">, DwarfRegNum<[68]>;
106
107   def SA1 : Rc<2, "sa1">, DwarfRegNum<[69]>;
108   def LC1 : Rc<3, "lc1">, DwarfRegNum<[70]>;
109
110   def M0 : Rc<6, "m0">, DwarfRegNum<[71]>;
111   def M1 : Rc<7, "m1">, DwarfRegNum<[72]>;
112
113   def USR  : Rc<8,  "usr">,   DwarfRegNum<[74]> {
114     let SubRegIndices = [subreg_overflow];
115     let SubRegs = [USR_OVF];
116   }
117   def PC : Rc<9,  "pc">, DwarfRegNum<[32]>; // is the Dwarf number correct?
118   def GP : Rc<11, "gp">, DwarfRegNum<[33]>; // is the Dwarf number correct?
119 }
120
121 // Register classes.
122 //
123 // FIXME: the register order should be defined in terms of the preferred
124 // allocation order...
125 //
126 def IntRegs : RegisterClass<"Hexagon", [i32,f32], 32,
127                             (add (sequence "R%u", 0, 9),
128                                  (sequence "R%u", 12, 28),
129                                  R10, R11, R29, R30, R31)> {
130 }
131
132 def DoubleRegs : RegisterClass<"Hexagon", [i64,f64], 64,
133                                (add (sequence "D%u", 0, 4),
134                                     (sequence "D%u", 6, 13), D5, D14, D15)>;
135
136
137 def PredRegs : RegisterClass<"Hexagon", [i1], 32, (add (sequence "P%u", 0, 3))>
138 {
139   let Size = 32;
140 }
141
142 def CRRegs : RegisterClass<"Hexagon", [i32], 32,
143                            (add LC0, SA0, LC1, SA1,
144                                 M0, M1,
145                                 USR, USR_OVF, PC, GP)> {
146   let Size = 32;
147 }
148
149 def VolatileV3 {
150   list<Register> Regs = [D0, D1, D2, D3, D4, D5, D6, D7,
151                          R28, R31,
152                          P0, P1, P2, P3,
153                          M0, M1,
154                          LC0, LC1, SA0, SA1, USR, USR_OVF];
155 }
156
157 def PositiveHalfWord : PatLeaf<(i32 IntRegs:$a),
158 [{
159   return isPositiveHalfWord(N);
160 }]>;