3fe8f918c56f7b6dc6bae6798281cfdb9d74745b
[oota-llvm.git] / lib / Target / Mips / Mips32r6InstrFormats.td
1 //=- Mips32r6InstrFormats.td - Mips32r6 Instruction Formats -*- 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 // This file describes Mips32r6 instruction formats.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class MipsR6Inst : MipsInst<(outs), (ins), "", [], NoItinerary, FrmOther>,
15                    PredicateControl {
16   let DecoderNamespace = "Mips32r6_64r6";
17   let EncodingPredicates = [HasStdEnc];
18 }
19
20 //===----------------------------------------------------------------------===//
21 //
22 // Field Values
23 //
24 //===----------------------------------------------------------------------===//
25
26 def OPGROUP_COP1    { bits<6> Value = 0b010001; }
27 def OPGROUP_AUI     { bits<6> Value = 0b001111; }
28 def OPGROUP_DAUI    { bits<6> Value = 0b011101; }
29 def OPGROUP_PCREL   { bits<6> Value = 0b111011; }
30 def OPGROUP_REGIMM  { bits<6> Value = 0b000001; }
31 def OPGROUP_SPECIAL { bits<6> Value = 0b000000; }
32 def OPGROUP_SPECIAL3 { bits<6> Value = 0b011111; }
33
34 class OPCODE2<bits<2> Val> {
35   bits<2> Value = Val;
36 }
37 def OPCODE2_ADDIUPC : OPCODE2<0b00>;
38
39 class OPCODE5<bits<5> Val> {
40   bits<5> Value = Val;
41 }
42 def OPCODE5_ALUIPC : OPCODE5<0b11111>;
43 def OPCODE5_AUIPC  : OPCODE5<0b11110>;
44 def OPCODE5_DAHI : OPCODE5<0b00110>;
45 def OPCODE5_DATI : OPCODE5<0b11110>;
46
47 class OPCODE6<bits<6> Val> {
48   bits<6> Value = Val;
49 }
50 def OPCODE6_ALIGN    : OPCODE6<0b100000>;
51 def OPCODE6_DALIGN   : OPCODE6<0b100100>;
52 def OPCODE6_BITSWAP  : OPCODE6<0b100000>;
53 def OPCODE6_DBITSWAP : OPCODE6<0b100100>;
54
55 class FIELD_FMT<bits<5> Val> {
56   bits<5> Value = Val;
57 }
58 def FIELD_FMT_S : FIELD_FMT<0b10000>;
59 def FIELD_FMT_D : FIELD_FMT<0b10001>;
60
61 class FIELD_CMP_COND<bits<5> Val> {
62   bits<5> Value = Val;
63 }
64 def FIELD_CMP_COND_F    : FIELD_CMP_COND<0b00000>;
65 def FIELD_CMP_COND_UN   : FIELD_CMP_COND<0b00001>;
66 def FIELD_CMP_COND_EQ   : FIELD_CMP_COND<0b00010>;
67 def FIELD_CMP_COND_UEQ  : FIELD_CMP_COND<0b00011>;
68 def FIELD_CMP_COND_OLT  : FIELD_CMP_COND<0b00100>;
69 def FIELD_CMP_COND_ULT  : FIELD_CMP_COND<0b00101>;
70 def FIELD_CMP_COND_OLE  : FIELD_CMP_COND<0b00110>;
71 def FIELD_CMP_COND_ULE  : FIELD_CMP_COND<0b00111>;
72 def FIELD_CMP_COND_SF   : FIELD_CMP_COND<0b01000>;
73 def FIELD_CMP_COND_NGLE : FIELD_CMP_COND<0b01001>;
74 def FIELD_CMP_COND_SEQ  : FIELD_CMP_COND<0b01010>;
75 def FIELD_CMP_COND_NGL  : FIELD_CMP_COND<0b01011>;
76 def FIELD_CMP_COND_LT   : FIELD_CMP_COND<0b01100>;
77 def FIELD_CMP_COND_NGE  : FIELD_CMP_COND<0b01101>;
78 def FIELD_CMP_COND_LE   : FIELD_CMP_COND<0b01110>;
79 def FIELD_CMP_COND_NGT  : FIELD_CMP_COND<0b01111>;
80
81 class FIELD_CMP_FORMAT<bits<5> Val> {
82   bits<5> Value = Val;
83 }
84 def FIELD_CMP_FORMAT_S : FIELD_CMP_FORMAT<0b10100>;
85 def FIELD_CMP_FORMAT_D : FIELD_CMP_FORMAT<0b10101>;
86
87 //===----------------------------------------------------------------------===//
88 //
89 // Encoding Formats
90 //
91 //===----------------------------------------------------------------------===//
92
93 class AUI_FM : MipsR6Inst {
94   bits<5> rs;
95   bits<5> rt;
96   bits<16> imm;
97
98   bits<32> Inst;
99
100   let Inst{31-26} = OPGROUP_AUI.Value;
101   let Inst{25-21} = rs;
102   let Inst{20-16} = rt;
103   let Inst{15-0} = imm;
104 }
105
106 class DAUI_FM : AUI_FM {
107   let Inst{31-26} = OPGROUP_DAUI.Value;
108 }
109
110 class COP1_2R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
111   bits<5> fs;
112   bits<5> fd;
113
114   bits<32> Inst;
115
116   let Inst{31-26} = OPGROUP_COP1.Value;
117   let Inst{25-21} = Format.Value;
118   let Inst{20-16} = 0b00000;
119   let Inst{15-11} = fs;
120   let Inst{10-6}  = fd;
121   let Inst{5-0}   = funct;
122 }
123
124 class COP1_3R_FM<bits<6> funct, FIELD_FMT Format> : MipsR6Inst {
125   bits<5> ft;
126   bits<5> fs;
127   bits<5> fd;
128
129   bits<32> Inst;
130
131   let Inst{31-26} = OPGROUP_COP1.Value;
132   let Inst{25-21} = Format.Value;
133   let Inst{20-16} = ft;
134   let Inst{15-11} = fs;
135   let Inst{10-6} = fd;
136   let Inst{5-0} = funct;
137 }
138
139 class PCREL16_FM<OPCODE5 Operation> : MipsR6Inst {
140   bits<5> rs;
141   bits<16> imm;
142
143   bits<32> Inst;
144
145   let Inst{31-26} = OPGROUP_PCREL.Value;
146   let Inst{25-21} = rs;
147   let Inst{20-16} = Operation.Value;
148   let Inst{15-0} = imm;
149 }
150
151 class PCREL19_FM<OPCODE2 Operation> : MipsR6Inst {
152   bits<5> rs;
153   bits<19> imm;
154
155   bits<32> Inst;
156
157   let Inst{31-26} = OPGROUP_PCREL.Value;
158   let Inst{25-21} = rs;
159   let Inst{20-19} = Operation.Value;
160   let Inst{18-0} = imm;
161 }
162
163 class SPECIAL3_2R_FM<OPCODE6 Operation> : MipsR6Inst {
164   bits<5> rd;
165   bits<5> rt;
166
167   bits<32> Inst;
168
169   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
170   let Inst{25-21} = 0b00000;
171   let Inst{20-16} = rt;
172   let Inst{15-11} = rd;
173   let Inst{10-6}  = 0b00000;
174   let Inst{5-0}   = Operation.Value;
175 }
176
177 class SPECIAL_3R_FM<bits<5> mulop, bits<6> funct> : MipsR6Inst {
178   bits<5> rd;
179   bits<5> rs;
180   bits<5> rt;
181
182   bits<32> Inst;
183
184   let Inst{31-26} = OPGROUP_SPECIAL.Value;
185   let Inst{25-21} = rs;
186   let Inst{20-16} = rt;
187   let Inst{15-11} = rd;
188   let Inst{10-6}  = mulop;
189   let Inst{5-0}   = funct;
190 }
191
192 class SPECIAL3_ALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
193   bits<5> rd;
194   bits<5> rs;
195   bits<5> rt;
196   bits<2> bp;
197
198   bits<32> Inst;
199
200   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
201   let Inst{25-21} = rs;
202   let Inst{20-16} = rt;
203   let Inst{15-11} = rd;
204   let Inst{10-8}  = 0b010;
205   let Inst{7-6}   = bp;
206   let Inst{5-0}   = Operation.Value;
207 }
208
209 class SPECIAL3_DALIGN_FM<OPCODE6 Operation> : MipsR6Inst {
210   bits<5> rd;
211   bits<5> rs;
212   bits<5> rt;
213   bits<3> bp;
214
215   bits<32> Inst;
216
217   let Inst{31-26} = OPGROUP_SPECIAL3.Value;
218   let Inst{25-21} = rs;
219   let Inst{20-16} = rt;
220   let Inst{15-11} = rd;
221   let Inst{10-9}  = 0b01;
222   let Inst{8-6}   = bp;
223   let Inst{5-0}   = Operation.Value;
224 }
225
226 class REGIMM_FM<OPCODE5 Operation> : MipsR6Inst {
227   bits<5> rs;
228   bits<16> imm;
229
230   bits<32> Inst;
231
232   let Inst{31-26} = OPGROUP_REGIMM.Value;
233   let Inst{25-21} = rs;
234   let Inst{20-16} = Operation.Value;
235   let Inst{15-0} = imm;
236 }
237
238 class COP1_CMP_CONDN_FM<FIELD_CMP_FORMAT Format,
239                         FIELD_CMP_COND Cond> : MipsR6Inst {
240   bits<5> fd;
241   bits<5> fs;
242   bits<5> ft;
243
244   bits<32> Inst;
245
246   let Inst{31-26} = OPGROUP_COP1.Value;
247   let Inst{25-21} = Format.Value;
248   let Inst{20-16} = ft;
249   let Inst{15-11} = fs;
250   let Inst{10-6}  = fd;
251   let Inst{5}     = 0;
252   let Inst{4-0}   = Cond.Value;
253 }
254