1 //===-- SIInstrInfo.td - SI Instruction Infos -------------*- 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 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
14 // SMRD takes a 64bit memory address and can only add an 32bit offset
15 def SIadd64bit32bit : SDNode<"ISD::ADD",
16 SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, SDTCisVT<0, i64>, SDTCisVT<2, i32>]>
19 // Transformation function, extract the lower 32bit of a 64bit immediate
20 def LO32 : SDNodeXForm<imm, [{
21 return CurDAG->getTargetConstant(N->getZExtValue() & 0xffffffff, MVT::i32);
24 // Transformation function, extract the upper 32bit of a 64bit immediate
25 def HI32 : SDNodeXForm<imm, [{
26 return CurDAG->getTargetConstant(N->getZExtValue() >> 32, MVT::i32);
29 def IMM8bitDWORD : ImmLeaf <
31 return (Imm & ~0x3FC) == 0;
32 }], SDNodeXForm<imm, [{
33 return CurDAG->getTargetConstant(
34 N->getZExtValue() >> 2, MVT::i32);
38 def IMM12bit : ImmLeaf <
40 [{return isUInt<12>(Imm);}]
43 class InlineImm <ValueType vt> : PatLeaf <(vt imm), [{
44 return ((const SITargetLowering &)TLI).analyzeImmediate(N) == 0;
47 //===----------------------------------------------------------------------===//
48 // SI assembler operands
49 //===----------------------------------------------------------------------===//
56 include "SIInstrFormats.td"
58 //===----------------------------------------------------------------------===//
60 // SI Instruction multiclass helpers.
62 // Instructions with _32 take 32-bit operands.
63 // Instructions with _64 take 64-bit operands.
65 // VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit
66 // encoding is the standard encoding, but instruction that make use of
67 // any of the instruction modifiers must use the 64-bit encoding.
69 // Instructions with _e32 use the 32-bit encoding.
70 // Instructions with _e64 use the 64-bit encoding.
72 //===----------------------------------------------------------------------===//
74 //===----------------------------------------------------------------------===//
76 //===----------------------------------------------------------------------===//
78 class SOP1_32 <bits<8> op, string opName, list<dag> pattern> : SOP1 <
79 op, (outs SReg_32:$dst), (ins SSrc_32:$src0),
80 opName#" $dst, $src0", pattern
83 class SOP1_64 <bits<8> op, string opName, list<dag> pattern> : SOP1 <
84 op, (outs SReg_64:$dst), (ins SSrc_64:$src0),
85 opName#" $dst, $src0", pattern
88 class SOP2_32 <bits<7> op, string opName, list<dag> pattern> : SOP2 <
89 op, (outs SReg_32:$dst), (ins SSrc_32:$src0, SSrc_32:$src1),
90 opName#" $dst, $src0, $src1", pattern
93 class SOP2_64 <bits<7> op, string opName, list<dag> pattern> : SOP2 <
94 op, (outs SReg_64:$dst), (ins SSrc_64:$src0, SSrc_64:$src1),
95 opName#" $dst, $src0, $src1", pattern
98 class SOPC_32 <bits<7> op, string opName, list<dag> pattern> : SOPC <
99 op, (outs SCCReg:$dst), (ins SSrc_32:$src0, SSrc_32:$src1),
100 opName#" $dst, $src0, $src1", pattern
103 class SOPC_64 <bits<7> op, string opName, list<dag> pattern> : SOPC <
104 op, (outs SCCReg:$dst), (ins SSrc_64:$src0, SSrc_64:$src1),
105 opName#" $dst, $src0, $src1", pattern
108 class SOPK_32 <bits<5> op, string opName, list<dag> pattern> : SOPK <
109 op, (outs SReg_32:$dst), (ins i16imm:$src0),
110 opName#" $dst, $src0", pattern
113 class SOPK_64 <bits<5> op, string opName, list<dag> pattern> : SOPK <
114 op, (outs SReg_64:$dst), (ins i16imm:$src0),
115 opName#" $dst, $src0", pattern
118 multiclass SMRD_Helper <bits<5> op, string asm, RegisterClass dstClass> {
120 op, 1, (outs dstClass:$dst),
121 (ins SReg_64:$sbase, i32imm:$offset),
122 asm#" $dst, $sbase, $offset", []
126 op, 0, (outs dstClass:$dst),
127 (ins SReg_64:$sbase, SReg_32:$soff),
128 asm#" $dst, $sbase, $soff", []
132 //===----------------------------------------------------------------------===//
133 // Vector ALU classes
134 //===----------------------------------------------------------------------===//
136 class VOP <string opName> {
137 string OpName = opName;
140 multiclass VOP1_Helper <bits<8> op, RegisterClass drc, RegisterClass src,
141 string opName, list<dag> pattern> {
144 op, (outs drc:$dst), (ins src:$src0),
145 opName#"_e32 $dst, $src0", pattern
149 {1, 1, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
152 i32imm:$abs, i32imm:$clamp,
153 i32imm:$omod, i32imm:$neg),
154 opName#"_e64 $dst, $src0, $abs, $clamp, $omod, $neg", []
156 let SRC1 = SIOperand.ZERO;
157 let SRC2 = SIOperand.ZERO;
161 multiclass VOP1_32 <bits<8> op, string opName, list<dag> pattern>
162 : VOP1_Helper <op, VReg_32, VSrc_32, opName, pattern>;
164 multiclass VOP1_64 <bits<8> op, string opName, list<dag> pattern>
165 : VOP1_Helper <op, VReg_64, VSrc_64, opName, pattern>;
167 multiclass VOP2_Helper <bits<6> op, RegisterClass vrc, RegisterClass arc,
168 string opName, list<dag> pattern> {
170 op, (outs vrc:$dst), (ins arc:$src0, vrc:$src1),
171 opName#"_e32 $dst, $src0, $src1", pattern
175 {1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
177 (ins arc:$src0, arc:$src1,
178 i32imm:$abs, i32imm:$clamp,
179 i32imm:$omod, i32imm:$neg),
180 opName#"_e64 $dst, $src0, $src1, $abs, $clamp, $omod, $neg", []
182 let SRC2 = SIOperand.ZERO;
186 multiclass VOP2_32 <bits<6> op, string opName, list<dag> pattern>
187 : VOP2_Helper <op, VReg_32, VSrc_32, opName, pattern>;
189 multiclass VOP2_64 <bits<6> op, string opName, list<dag> pattern>
190 : VOP2_Helper <op, VReg_64, VSrc_64, opName, pattern>;
192 multiclass VOP2b_32 <bits<6> op, string opName, list<dag> pattern> {
195 op, (outs VReg_32:$dst), (ins VSrc_32:$src0, VReg_32:$src1),
196 opName#"_e32 $dst, $src0, $src1", pattern
200 {1, 0, 0, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
202 (ins VSrc_32:$src0, VSrc_32:$src1,
203 i32imm:$abs, i32imm:$clamp,
204 i32imm:$omod, i32imm:$neg),
205 opName#"_e64 $dst, $src0, $src1, $abs, $clamp, $omod, $neg", []
207 let SRC2 = SIOperand.ZERO;
208 /* the VOP2 variant puts the carry out into VCC, the VOP3 variant
209 can write it into any SGPR. We currently don't use the carry out,
210 so for now hardcode it to VCC as well */
211 let SDST = SIOperand.VCC;
215 multiclass VOPC_Helper <bits<8> op, RegisterClass vrc, RegisterClass arc,
216 string opName, ValueType vt, PatLeaf cond> {
219 op, (ins arc:$src0, vrc:$src1),
220 opName#"_e32 $dst, $src0, $src1", []
224 {0, op{7}, op{6}, op{5}, op{4}, op{3}, op{2}, op{1}, op{0}},
226 (ins arc:$src0, arc:$src1,
227 InstFlag:$abs, InstFlag:$clamp,
228 InstFlag:$omod, InstFlag:$neg),
229 opName#"_e64 $dst, $src0, $src1, $abs, $clamp, $omod, $neg",
230 !if(!eq(!cast<string>(cond), "COND_NULL"), []<dag>,
231 [(set SReg_64:$dst, (i1 (setcc (vt arc:$src0), arc:$src1, cond)))]
234 let SRC2 = SIOperand.ZERO;
238 multiclass VOPC_32 <bits<8> op, string opName,
239 ValueType vt = untyped, PatLeaf cond = COND_NULL>
240 : VOPC_Helper <op, VReg_32, VSrc_32, opName, vt, cond>;
242 multiclass VOPC_64 <bits<8> op, string opName,
243 ValueType vt = untyped, PatLeaf cond = COND_NULL>
244 : VOPC_Helper <op, VReg_64, VSrc_64, opName, vt, cond>;
246 class VOP3_32 <bits<9> op, string opName, list<dag> pattern> : VOP3 <
247 op, (outs VReg_32:$dst),
248 (ins VSrc_32:$src0, VSrc_32:$src1, VSrc_32:$src2,
249 i32imm:$abs, i32imm:$clamp, i32imm:$omod, i32imm:$neg),
250 opName#" $dst, $src0, $src1, $src2, $abs, $clamp, $omod, $neg", pattern
253 class VOP3_64 <bits<9> op, string opName, list<dag> pattern> : VOP3 <
254 op, (outs VReg_64:$dst),
255 (ins VSrc_64:$src0, VSrc_64:$src1, VSrc_64:$src2,
256 i32imm:$abs, i32imm:$clamp, i32imm:$omod, i32imm:$neg),
257 opName#" $dst, $src0, $src1, $src2, $abs, $clamp, $omod, $neg", pattern
260 //===----------------------------------------------------------------------===//
261 // Vector I/O classes
262 //===----------------------------------------------------------------------===//
264 class MTBUF_Store_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
267 (ins regClass:$vdata, i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc,
268 i1imm:$addr64, i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr,
269 SReg_128:$srsrc, i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset),
270 asm#" $vdata, $offset, $offen, $idxen, $glc, $addr64, $dfmt,"
271 #" $nfmt, $vaddr, $srsrc, $slc, $tfe, $soffset",
277 class MUBUF_Load_Helper <bits<7> op, string asm, RegisterClass regClass> : MUBUF <
279 (outs regClass:$dst),
280 (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
281 i1imm:$lds, VReg_32:$vaddr, SReg_128:$srsrc, i1imm:$slc,
282 i1imm:$tfe, SSrc_32:$soffset),
283 asm#" $dst, $offset, $offen, $idxen, $glc, $addr64, "
284 #"$lds, $vaddr, $srsrc, $slc, $tfe, $soffset",
290 class MTBUF_Load_Helper <bits<3> op, string asm, RegisterClass regClass> : MTBUF <
292 (outs regClass:$dst),
293 (ins i16imm:$offset, i1imm:$offen, i1imm:$idxen, i1imm:$glc, i1imm:$addr64,
294 i8imm:$dfmt, i8imm:$nfmt, VReg_32:$vaddr, SReg_128:$srsrc,
295 i1imm:$slc, i1imm:$tfe, SSrc_32:$soffset),
296 asm#" $dst, $offset, $offen, $idxen, $glc, $addr64, $dfmt,"
297 #" $nfmt, $vaddr, $srsrc, $slc, $tfe, $soffset",
303 class MIMG_Load_Helper <bits<7> op, string asm> : MIMG <
305 (outs VReg_128:$vdata),
306 (ins i32imm:$dmask, i1imm:$unorm, i1imm:$glc, i1imm:$da, i1imm:$r128,
307 i1imm:$tfe, i1imm:$lwe, i1imm:$slc, VReg_32:$vaddr,
308 SReg_256:$srsrc, SReg_128:$ssamp),
309 asm#" $vdata, $dmask, $unorm, $glc, $da, $r128,"
310 #" $tfe, $lwe, $slc, $vaddr, $srsrc, $ssamp",
316 //===----------------------------------------------------------------------===//
317 // Vector instruction mappings
318 //===----------------------------------------------------------------------===//
320 // Maps an opcode in e32 form to its e64 equivalent
321 def getVOPe64 : InstrMapping {
322 let FilterClass = "VOP";
323 let RowFields = ["OpName"];
324 let ColFields = ["Size"];
326 let ValueCols = [["8"]];
329 include "SIInstructions.td"