1 //===-- SparcInstrFormats.td - Sparc Instruction Formats ---*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 class InstSP<dag outs, dag ins, string asmstr, list<dag> pattern,
10 InstrItinClass itin = NoItinerary>
18 let Inst{31-30} = op; // Top two bits are the 'op' field
20 dag OutOperandList = outs;
21 dag InOperandList = ins;
22 let AsmString = asmstr;
23 let Pattern = pattern;
25 let DecoderNamespace = "Sparc";
26 field bits<32> SoftFail = 0;
31 //===----------------------------------------------------------------------===//
32 // Format #2 instruction classes in the Sparc
33 //===----------------------------------------------------------------------===//
35 // Format 2 instructions
36 class F2<dag outs, dag ins, string asmstr, list<dag> pattern,
37 InstrItinClass itin = NoItinerary>
38 : InstSP<outs, ins, asmstr, pattern, itin> {
42 let Inst{24-22} = op2;
43 let Inst{21-0} = imm22;
46 // Specific F2 classes: SparcV8 manual, page 44
48 class F2_1<bits<3> op2Val, dag outs, dag ins, string asmstr, list<dag> pattern,
49 InstrItinClass itin = NoItinerary>
50 : F2<outs, ins, asmstr, pattern, itin> {
58 class F2_2<bits<3> op2Val, bit annul, dag outs, dag ins, string asmstr,
59 list<dag> pattern, InstrItinClass itin = NoItinerary>
60 : F2<outs, ins, asmstr, pattern, itin> {
65 let Inst{28-25} = cond;
68 class F2_3<bits<3> op2Val, bit annul, bit pred,
69 dag outs, dag ins, string asmstr, list<dag> pattern,
70 InstrItinClass itin = NoItinerary>
71 : InstSP<outs, ins, asmstr, pattern, itin> {
79 let Inst{28-25} = cond;
80 let Inst{24-22} = op2Val;
83 let Inst{18-0} = imm19;
86 class F2_4<bits<3> cond, bit annul, bit pred, dag outs, dag ins,
87 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
88 : InstSP<outs, ins, asmstr, pattern, itin> {
96 let Inst{27-25} = cond;
97 let Inst{24-22} = 0b011;
98 let Inst{21-20} = imm16{15-14};
100 let Inst{18-14} = rs1;
101 let Inst{13-0} = imm16{13-0};
105 //===----------------------------------------------------------------------===//
106 // Format #3 instruction classes in the Sparc
107 //===----------------------------------------------------------------------===//
109 class F3<dag outs, dag ins, string asmstr, list<dag> pattern,
110 InstrItinClass itin = NoItinerary>
111 : InstSP<outs, ins, asmstr, pattern, itin> {
115 let op{1} = 1; // Op = 2 or 3
116 let Inst{29-25} = rd;
117 let Inst{24-19} = op3;
118 let Inst{18-14} = rs1;
121 // Specific F3 classes: SparcV8 manual, page 44
123 class F3_1_asi<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
124 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
125 : F3<outs, ins, asmstr, pattern, itin> {
132 let Inst{13} = 0; // i field = 0
133 let Inst{12-5} = asi; // address space identifier
137 class F3_1<bits<2> opVal, bits<6> op3val, dag outs, dag ins, string asmstr,
138 list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
139 : F3_1_asi<opVal, op3val, outs, ins, asmstr, pattern, itin> {
143 class F3_2<bits<2> opVal, bits<6> op3val, dag outs, dag ins,
144 string asmstr, list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
145 : F3<outs, ins, asmstr, pattern, itin> {
151 let Inst{13} = 1; // i field = 1
152 let Inst{12-0} = simm13;
156 class F3_3<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
157 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
158 : F3<outs, ins, asmstr, pattern, itin> {
164 let Inst{13-5} = opfval; // fp opcode
168 // floating-point unary operations.
169 class F3_3u<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
170 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
171 : F3<outs, ins, asmstr, pattern, itin> {
178 let Inst{13-5} = opfval; // fp opcode
182 // floating-point compares.
183 class F3_3c<bits<2> opVal, bits<6> op3val, bits<9> opfval, dag outs, dag ins,
184 string asmstr, list<dag> pattern, InstrItinClass itin = NoItinerary>
185 : F3<outs, ins, asmstr, pattern, itin> {
191 let Inst{13-5} = opfval; // fp opcode
195 // Shift by register rs2.
196 class F3_Sr<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
197 string asmstr, list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
198 : F3<outs, ins, asmstr, pattern, itin> {
199 bit x = xVal; // 1 for 64-bit shifts.
205 let Inst{13} = 0; // i field = 0
206 let Inst{12} = x; // extended registers.
210 // Shift by immediate.
211 class F3_Si<bits<2> opVal, bits<6> op3val, bit xVal, dag outs, dag ins,
212 string asmstr, list<dag> pattern, InstrItinClass itin = IIC_iu_instr>
213 : F3<outs, ins, asmstr, pattern, itin> {
214 bit x = xVal; // 1 for 64-bit shifts.
215 bits<6> shcnt; // shcnt32 / shcnt64.
220 let Inst{13} = 1; // i field = 1
221 let Inst{12} = x; // extended registers.
222 let Inst{5-0} = shcnt;
225 // Define rr and ri shift instructions with patterns.
226 multiclass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode,
227 ValueType VT, RegisterClass RC,
228 InstrItinClass itin = IIC_iu_instr> {
229 def rr : F3_Sr<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, IntRegs:$rs2),
230 !strconcat(OpcStr, " $rs1, $rs2, $rd"),
231 [(set VT:$rd, (OpNode VT:$rs1, i32:$rs2))],
233 def ri : F3_Si<2, Op3Val, XVal, (outs RC:$rd), (ins RC:$rs1, i32imm:$shcnt),
234 !strconcat(OpcStr, " $rs1, $shcnt, $rd"),
235 [(set VT:$rd, (OpNode VT:$rs1, (i32 imm:$shcnt)))],
239 class F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern,
240 InstrItinClass itin = NoItinerary>
241 : InstSP<outs, ins, asmstr, pattern, itin> {
245 let Inst{29-25} = rd;
246 let Inst{24-19} = op3;
250 class F4_1<bits<6> op3, dag outs, dag ins,
251 string asmstr, list<dag> pattern,
252 InstrItinClass itin = NoItinerary>
253 : F4<op3, outs, ins, asmstr, pattern, itin> {
260 let Inst{12-11} = cc;
262 let Inst{17-14} = cond;
263 let Inst{18} = intcc;
266 class F4_2<bits<6> op3, dag outs, dag ins,
267 string asmstr, list<dag> pattern,
268 InstrItinClass itin = NoItinerary>
269 : F4<op3, outs, ins, asmstr, pattern, itin> {
275 let Inst{10-0} = simm11;
276 let Inst{12-11} = cc;
278 let Inst{17-14} = cond;
279 let Inst{18} = intcc;
282 class F4_3<bits<6> op3, bits<6> opf_low, dag outs, dag ins,
283 string asmstr, list<dag> pattern,
284 InstrItinClass itin = NoItinerary>
285 : F4<op3, outs, ins, asmstr, pattern, itin> {
292 let Inst{17-14} = cond;
293 let Inst{13} = intcc;
294 let Inst{12-11} = opf_cc;
295 let Inst{10-5} = opf_low;
299 class F4_4r<bits<6> op3, bits<5> opf_low, bits<3> rcond, dag outs, dag ins,
300 string asmstr, list<dag> pattern,
301 InstrItinClass itin = NoItinerary>
302 : F4<op3, outs, ins, asmstr, pattern, itin> {
305 let Inst{18-14} = rs1;
306 let Inst{13} = 0; // IsImm
307 let Inst{12-10} = rcond;
308 let Inst{9-5} = opf_low;
313 class F4_4i<bits<6> op3, bits<3> rcond, dag outs, dag ins,
314 string asmstr, list<dag> pattern,
315 InstrItinClass itin = NoItinerary>
316 : F4<op3, outs, ins, asmstr, pattern, itin> {
319 let Inst{18-14} = rs1;
320 let Inst{13} = 1; // IsImm
321 let Inst{12-10} = rcond;
322 let Inst{9-0} = simm10;
326 class TRAPSP<bits<6> op3Val, bit isimm, dag outs, dag ins,
327 string asmstr, list<dag> pattern,
328 InstrItinClass itin = NoItinerary>
329 : F3<outs, ins, asmstr, pattern, itin> {
337 let Inst{13} = isimm;
338 let Inst{12-11} = cc;
342 class TRAPSPrr<bits<6> op3Val, dag outs, dag ins,
343 string asmstr, list<dag> pattern,
344 InstrItinClass itin = NoItinerary>
345 : TRAPSP<op3Val, 0, outs, ins, asmstr, pattern, itin> {
352 class TRAPSPri<bits<6> op3Val, dag outs, dag ins,
353 string asmstr, list<dag> pattern,
354 InstrItinClass itin = NoItinerary>
355 : TRAPSP<op3Val, 1, outs, ins, asmstr, pattern, itin> {
362 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
363 // These are aliases that require C++ handling to convert to the target
364 // instruction, while InstAliases can be handled directly by tblgen.
365 class AsmPseudoInst<dag outs, dag ins, string asm>
366 : InstSP<outs, ins, asm, []> {