1 //===-- SparcInstrFormats.td - Sparc Instruction Formats ---*- 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 class InstSP<dag outs, dag ins, string asmstr, list<dag> pattern,
11 InstrItinClass itin = NoItinerary>
19 let Inst{31-30} = op; // Top two bits are the 'op' field
21 dag OutOperandList = outs;
22 dag InOperandList = ins;
23 let AsmString = asmstr;
24 let Pattern = pattern;
26 let DecoderNamespace = "Sparc";
27 field bits<32> SoftFail = 0;
32 //===----------------------------------------------------------------------===//
33 // Format #2 instruction classes in the Sparc
34 //===----------------------------------------------------------------------===//
36 // Format 2 instructions
37 class F2<dag outs, dag ins, string asmstr, list<dag> pattern,
38 InstrItinClass itin = NoItinerary>
39 : InstSP<outs, ins, asmstr, pattern, itin> {
43 let Inst{24-22} = op2;
44 let Inst{21-0} = imm22;
47 // Specific F2 classes: SparcV8 manual, page 44
49 class F2_1<bits<3> op2Val, dag outs, dag ins, string asmstr, list<dag> pattern,
50 InstrItinClass itin = NoItinerary>
51 : F2<outs, ins, asmstr, pattern, itin> {
59 class F2_2<bits<3> op2Val, bit annul, dag outs, dag ins, string asmstr,
60 list<dag> pattern, InstrItinClass itin = NoItinerary>
61 : F2<outs, ins, asmstr, pattern, itin> {
66 let Inst{28-25} = cond;
69 class F2_3<bits<3> op2Val, bit annul, bit pred,
70 dag outs, dag ins, string asmstr, list<dag> pattern,
71 InstrItinClass itin = NoItinerary>
72 : InstSP<outs, ins, asmstr, pattern, itin> {
80 let Inst{28-25} = cond;
81 let Inst{24-22} = op2Val;
84 let Inst{18-0} = imm19;
87 class F2_4<bits<3> cond, bit annul, bit pred, dag outs, dag ins,
88 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
89 : InstSP<outs, ins, asmstr, pattern, itin> {
97 let Inst{27-25} = cond;
98 let Inst{24-22} = 0b011;
99 let Inst{21-20} = imm16{15-14};
101 let Inst{18-14} = rs1;
102 let Inst{13-0} = imm16{13-0};
106 //===----------------------------------------------------------------------===//
107 // Format #3 instruction classes in the Sparc
108 //===----------------------------------------------------------------------===//
110 class F3<dag outs, dag ins, string asmstr, list<dag> pattern,
111 InstrItinClass itin = NoItinerary>
112 : InstSP<outs, ins, asmstr, pattern, itin> {
116 let op{1} = 1; // Op = 2 or 3
117 let Inst{29-25} = rd;
118 let Inst{24-19} = op3;
119 let Inst{18-14} = rs1;
122 // Specific F3 classes: SparcV8 manual, page 44
124 class F3_1_asi<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
125 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
126 : F3<outs, ins, asmstr, pattern, itin> {
133 let Inst{13} = 0; // i field = 0
134 let Inst{12-5} = asi; // address space identifier
138 class F3_1<bits<2> opVal, bits<6> op3val, dag outs, dag ins, string asmstr,
139 list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
140 : F3_1_asi<opVal, op3val, outs, ins, asmstr, pattern, itin> {
144 class F3_2<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
145 string asmstr, list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
146 : F3<outs, ins, asmstr, pattern, itin> {
152 let Inst{13} = 1; // i field = 1
153 let Inst{12-0} = simm13;
157 class F3_3<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
158 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
159 : F3<outs, ins, asmstr, pattern, itin> {
165 let Inst{13-5} = opfval; // fp opcode
169 // floating-point unary operations.
170 class F3_3u<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
171 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
172 : F3<outs, ins, asmstr, pattern, itin> {
179 let Inst{13-5} = opfval; // fp opcode
183 // floating-point compares.
184 class F3_3c<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
185 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
186 : F3<outs, ins, asmstr, pattern, itin> {
192 let Inst{13-5} = opfval; // fp opcode
196 // Shift by register rs2.
197 class F3_Sr<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
198 string asmstr, list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
199 : F3<outs, ins, asmstr, pattern, itin> {
200 bit x = xVal; // 1 for 64-bit shifts.
206 let Inst{13} = 0; // i field = 0
207 let Inst{12} = x; // extended registers.
211 // Shift by immediate.
212 class F3_Si<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
213 string asmstr, list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
214 : F3<outs, ins, asmstr, pattern, itin> {
215 bit x = xVal; // 1 for 64-bit shifts.
216 bits<6> shcnt; // shcnt32 / shcnt64.
221 let Inst{13} = 1; // i field = 1
222 let Inst{12} = x; // extended registers.
223 let Inst{5-0} = shcnt;
226 // Define rr and ri shift instructions with patterns.
227 multiclass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode,
228 ValueType VT, RegisterClass RC,
229 InstrItinClass itin = IIC_iu_instr> {
230 def rr : F3_Sr<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, IntRegs:$rs2),
231 !strconcat(OpcStr, " $rs1, $rs2, $rd"),
232 [(set VT:$rd, (OpNode VT:$rs1, i32:$rs2))],
234 def ri : F3_Si<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, i32imm:$shcnt),
235 !strconcat(OpcStr, " $rs1, $shcnt, $rd"),
236 [(set VT:$rd, (OpNode VT:$rs1, (i32 imm:$shcnt)))],
240 class F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern,
241 InstrItinClass itin = NoItinerary>
242 : InstSP<outs, ins, asmstr, pattern, itin> {
246 let Inst{29-25} = rd;
247 let Inst{24-19} = op3;
251 class F4_1<bits<6> op3, dag outs, dag ins,
252 string asmstr, list<dag> pattern,
253 InstrItinClass itin = NoItinerary>
254 : F4<op3, outs, ins, asmstr, pattern, itin> {
261 let Inst{12-11} = cc;
263 let Inst{17-14} = cond;
264 let Inst{18} = intcc;
267 class F4_2<bits<6> op3, dag outs, dag ins,
268 string asmstr, list<dag> pattern,
269 InstrItinClass itin = NoItinerary>
270 : F4<op3, outs, ins, asmstr, pattern, itin> {
276 let Inst{10-0} = simm11;
277 let Inst{12-11} = cc;
279 let Inst{17-14} = cond;
280 let Inst{18} = intcc;
283 class F4_3<bits<6> op3, bits<6> opf_low, dag outs, dag ins,
284 string asmstr, list<dag> pattern,
285 InstrItinClass itin = NoItinerary>
286 : F4<op3, outs, ins, asmstr, pattern, itin> {
293 let Inst{17-14} = cond;
294 let Inst{13} = intcc;
295 let Inst{12-11} = opf_cc;
296 let Inst{10-5} = opf_low;
300 class F4_4r<bits<6> op3, bits<5> opf_low, bits<3> rcond, dag outs, dag ins,
301 string asmstr, list<dag> pattern,
302 InstrItinClass itin = NoItinerary>
303 : F4<op3, outs, ins, asmstr, pattern, itin> {
306 let Inst{18-14} = rs1;
307 let Inst{13} = 0; // IsImm
308 let Inst{12-10} = rcond;
309 let Inst{9-5} = opf_low;
314 class F4_4i<bits<6> op3, bits<3> rcond, dag outs, dag ins,
315 string asmstr, list<dag> pattern,
316 InstrItinClass itin = NoItinerary>
317 : F4<op3, outs, ins, asmstr, pattern, itin> {
320 let Inst{18-14} = rs1;
321 let Inst{13} = 1; // IsImm
322 let Inst{12-10} = rcond;
323 let Inst{9-0} = simm10;
327 class TRAPSP<bits<6> op3Val, bit isimm, dag outs, dag ins,
328 string asmstr, list<dag> pattern,
329 InstrItinClass itin = NoItinerary>
330 : F3<outs, ins, asmstr, pattern, itin> {
338 let Inst{13} = isimm;
339 let Inst{12-11} = cc;
343 class TRAPSPrr<bits<6> op3Val, dag outs, dag ins,
344 string asmstr, list<dag> pattern,
345 InstrItinClass itin = NoItinerary>
346 : TRAPSP<op3Val, 0, outs, ins, asmstr, pattern, itin> {
353 class TRAPSPri<bits<6> op3Val, dag outs, dag ins,
354 string asmstr, list<dag> pattern,
355 InstrItinClass itin = NoItinerary>
356 : TRAPSP<op3Val, 1, outs, ins, asmstr, pattern, itin> {
363 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
364 // These are aliases that require C++ handling to convert to the target
365 // instruction, while InstAliases can be handled directly by tblgen.
366 class AsmPseudoInst<dag outs, dag ins, string asm>
367 : InstSP<outs, ins, asm, []> {