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 //===----------------------------------------------------------------------===//
9 def isCI : Predicate<"Subtarget->getGeneration() "
10 ">= AMDGPUSubtarget::SEA_ISLANDS">;
11 def isCIOnly : Predicate<"Subtarget->getGeneration() =="
12 "AMDGPUSubtarget::SEA_ISLANDS">,
13 AssemblerPredicate <"FeatureSeaIslands">;
14 def isVIOnly : Predicate<"Subtarget->getGeneration() =="
15 "AMDGPUSubtarget::VOLCANIC_ISLANDS">,
16 AssemblerPredicate <"FeatureVolcanicIslands">;
18 def DisableInst : Predicate <"false">, AssemblerPredicate<"FeatureDisable">;
20 class GCNPredicateControl : PredicateControl {
21 Predicate SIAssemblerPredicate = isSICI;
22 Predicate VIAssemblerPredicate = isVI;
25 // Execpt for the NONE field, this must be kept in sync with the
26 // SIEncodingFamily enum in AMDGPUInstrInfo.cpp
27 def SIEncodingFamily {
37 //===----------------------------------------------------------------------===//
39 //===----------------------------------------------------------------------===//
41 def AMDGPUclamp : SDNode<"AMDGPUISD::CLAMP", SDTFPUnaryOp>;
43 def SIload_constant : SDNode<"AMDGPUISD::LOAD_CONSTANT",
44 SDTypeProfile<1, 2, [SDTCisVT<0, f32>, SDTCisVT<1, v4i32>, SDTCisVT<2, i32>]>,
45 [SDNPMayLoad, SDNPMemOperand]
48 def SIatomic_inc : SDNode<"AMDGPUISD::ATOMIC_INC", SDTAtomic2,
49 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
52 def SIatomic_dec : SDNode<"AMDGPUISD::ATOMIC_DEC", SDTAtomic2,
53 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
56 def SDTAtomic2_f32 : SDTypeProfile<1, 2, [
57 SDTCisSameAs<0,2>, SDTCisFP<0>, SDTCisPtrTy<1>
60 def SIatomic_fadd : SDNode<"AMDGPUISD::ATOMIC_LOAD_FADD", SDTAtomic2_f32,
61 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
64 def SIatomic_fmin : SDNode<"AMDGPUISD::ATOMIC_LOAD_FMIN", SDTAtomic2_f32,
65 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
68 def SIatomic_fmax : SDNode<"AMDGPUISD::ATOMIC_LOAD_FMAX", SDTAtomic2_f32,
69 [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
72 def SDTbuffer_load : SDTypeProfile<1, 9,
74 SDTCisVT<1, v4i32>, // rsrc
75 SDTCisVT<2, i32>, // vindex(VGPR)
76 SDTCisVT<3, i32>, // voffset(VGPR)
77 SDTCisVT<4, i32>, // soffset(SGPR)
78 SDTCisVT<5, i32>, // offset(imm)
79 SDTCisVT<6, i32>, // dfmt(imm)
80 SDTCisVT<7, i32>, // nfmt(imm)
81 SDTCisVT<8, i32>, // glc(imm)
82 SDTCisVT<9, i32> // slc(imm)
85 def SItbuffer_load : SDNode<"AMDGPUISD::TBUFFER_LOAD_FORMAT", SDTbuffer_load,
86 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]>;
87 def SItbuffer_load_d16 : SDNode<"AMDGPUISD::TBUFFER_LOAD_FORMAT_D16",
89 [SDNPMayLoad, SDNPMemOperand, SDNPHasChain]>;
91 def SDTtbuffer_store : SDTypeProfile<0, 10,
93 SDTCisVT<1, v4i32>, // rsrc
94 SDTCisVT<2, i32>, // vindex(VGPR)
95 SDTCisVT<3, i32>, // voffset(VGPR)
96 SDTCisVT<4, i32>, // soffset(SGPR)
97 SDTCisVT<5, i32>, // offset(imm)
98 SDTCisVT<6, i32>, // dfmt(imm)
99 SDTCisVT<7, i32>, // nfmt(imm)
100 SDTCisVT<8, i32>, // glc(imm)
101 SDTCisVT<9, i32> // slc(imm)
104 def SItbuffer_store : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT", SDTtbuffer_store,
105 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
106 def SItbuffer_store_x3 : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT_X3",
108 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
109 def SItbuffer_store_d16 : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT_D16",
111 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
113 def SDTBufferLoad : SDTypeProfile<1, 5,
115 SDTCisVT<1, v4i32>, // rsrc
116 SDTCisVT<2, i32>, // vindex
117 SDTCisVT<3, i32>, // offset
118 SDTCisVT<4, i1>, // glc
119 SDTCisVT<5, i1>]>; // slc
121 def SIbuffer_load : SDNode <"AMDGPUISD::BUFFER_LOAD", SDTBufferLoad,
122 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
123 def SIbuffer_load_format : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT", SDTBufferLoad,
124 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
125 def SIbuffer_load_format_d16 : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT_D16",
127 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
129 def SDTBufferStore : SDTypeProfile<0, 6,
131 SDTCisVT<1, v4i32>, // rsrc
132 SDTCisVT<2, i32>, // vindex
133 SDTCisVT<3, i32>, // offset
134 SDTCisVT<4, i1>, // glc
135 SDTCisVT<5, i1>]>; // slc
137 def SIbuffer_store : SDNode <"AMDGPUISD::BUFFER_STORE", SDTBufferStore,
138 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
139 def SIbuffer_store_format : SDNode <"AMDGPUISD::BUFFER_STORE_FORMAT",
141 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
142 def SIbuffer_store_format_d16 : SDNode <"AMDGPUISD::BUFFER_STORE_FORMAT_D16",
144 [SDNPMayStore, SDNPMemOperand, SDNPHasChain]>;
146 class SDBufferAtomic<string opcode> : SDNode <opcode,
148 [SDTCisVT<0, i32>, // dst
149 SDTCisVT<1, i32>, // vdata
150 SDTCisVT<2, v4i32>, // rsrc
151 SDTCisVT<3, i32>, // vindex
152 SDTCisVT<4, i32>, // offset
153 SDTCisVT<5, i1>]>, // slc
154 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore]
157 def SIbuffer_atomic_swap : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SWAP">;
158 def SIbuffer_atomic_add : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_ADD">;
159 def SIbuffer_atomic_sub : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SUB">;
160 def SIbuffer_atomic_smin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SMIN">;
161 def SIbuffer_atomic_umin : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_UMIN">;
162 def SIbuffer_atomic_smax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_SMAX">;
163 def SIbuffer_atomic_umax : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_UMAX">;
164 def SIbuffer_atomic_and : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_AND">;
165 def SIbuffer_atomic_or : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_OR">;
166 def SIbuffer_atomic_xor : SDBufferAtomic <"AMDGPUISD::BUFFER_ATOMIC_XOR">;
168 def SIbuffer_atomic_cmpswap : SDNode <"AMDGPUISD::BUFFER_ATOMIC_CMPSWAP",
170 [SDTCisVT<0, i32>, // dst
171 SDTCisVT<1, i32>, // src
172 SDTCisVT<2, i32>, // cmp
173 SDTCisVT<3, v4i32>, // rsrc
174 SDTCisVT<4, i32>, // vindex
175 SDTCisVT<5, i32>, // offset
176 SDTCisVT<6, i1>]>, // slc
177 [SDNPMemOperand, SDNPHasChain, SDNPMayLoad, SDNPMayStore]
180 def SIpc_add_rel_offset : SDNode<"AMDGPUISD::PC_ADD_REL_OFFSET",
181 SDTypeProfile<1, 2, [SDTCisVT<0, iPTR>, SDTCisSameAs<0,1>, SDTCisSameAs<0,2>]>
184 //===----------------------------------------------------------------------===//
186 //===----------------------------------------------------------------------===//
188 // Returns 1 if the source arguments have modifiers, 0 if they do not.
189 // XXX - do f16 instructions?
190 class isFloatType<ValueType SrcVT> {
192 !if(!eq(SrcVT.Value, f16.Value), 1,
193 !if(!eq(SrcVT.Value, f32.Value), 1,
194 !if(!eq(SrcVT.Value, f64.Value), 1,
195 !if(!eq(SrcVT.Value, v2f16.Value), 1,
199 class isIntType<ValueType SrcVT> {
201 !if(!eq(SrcVT.Value, i16.Value), 1,
202 !if(!eq(SrcVT.Value, i32.Value), 1,
203 !if(!eq(SrcVT.Value, i64.Value), 1,
207 class isPackedType<ValueType SrcVT> {
209 !if(!eq(SrcVT.Value, v2i16.Value), 1,
210 !if(!eq(SrcVT.Value, v2f16.Value), 1, 0)
214 //===----------------------------------------------------------------------===//
215 // PatFrags for global memory operations
216 //===----------------------------------------------------------------------===//
218 defm atomic_inc_global : global_binary_atomic_op<SIatomic_inc>;
219 defm atomic_dec_global : global_binary_atomic_op<SIatomic_dec>;
221 def atomic_inc_local : local_binary_atomic_op<SIatomic_inc>;
222 def atomic_dec_local : local_binary_atomic_op<SIatomic_dec>;
223 def atomic_load_fadd_local : local_binary_atomic_op<SIatomic_fadd>;
224 def atomic_load_fmin_local : local_binary_atomic_op<SIatomic_fmin>;
225 def atomic_load_fmax_local : local_binary_atomic_op<SIatomic_fmax>;
227 //===----------------------------------------------------------------------===//
228 // SDNodes PatFrags for loads/stores with a glue input.
229 // This is for SDNodes and PatFrag for local loads and stores to
230 // enable s_mov_b32 m0, -1 to be glued to the memory instructions.
232 // These mirror the regular load/store PatFrags and rely on special
233 // processing during Select() to add the glued copy.
235 //===----------------------------------------------------------------------===//
237 def AMDGPUld_glue : SDNode <"ISD::LOAD", SDTLoad,
238 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
241 def AMDGPUatomic_ld_glue : SDNode <"ISD::ATOMIC_LOAD", SDTAtomicLoad,
242 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
245 def unindexedload_glue : PatFrag <(ops node:$ptr), (AMDGPUld_glue node:$ptr), [{
246 return cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
249 def load_glue : PatFrag <(ops node:$ptr), (unindexedload_glue node:$ptr), [{
250 return cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
253 def atomic_load_32_glue : PatFrag<(ops node:$ptr),
254 (AMDGPUatomic_ld_glue node:$ptr)> {
259 def atomic_load_64_glue : PatFrag<(ops node:$ptr),
260 (AMDGPUatomic_ld_glue node:$ptr)> {
265 def extload_glue : PatFrag<(ops node:$ptr), (load_glue node:$ptr), [{
266 return cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD;
269 def sextload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr), [{
270 return cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
273 def zextload_glue : PatFrag<(ops node:$ptr), (unindexedload_glue node:$ptr), [{
274 return cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
277 def az_extload_glue : AZExtLoadBase <unindexedload_glue>;
279 def az_extloadi8_glue : PatFrag<(ops node:$ptr), (az_extload_glue node:$ptr), [{
280 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
283 def az_extloadi16_glue : PatFrag<(ops node:$ptr), (az_extload_glue node:$ptr), [{
284 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
287 def sextloadi8_glue : PatFrag<(ops node:$ptr), (sextload_glue node:$ptr), [{
288 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;
291 def sextloadi16_glue : PatFrag<(ops node:$ptr), (sextload_glue node:$ptr), [{
292 return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;
295 def load_glue_align8 : Aligned8Bytes <
296 (ops node:$ptr), (load_glue node:$ptr)
298 def load_glue_align16 : Aligned16Bytes <
299 (ops node:$ptr), (load_glue node:$ptr)
303 def load_local_m0 : LoadFrag<load_glue>, LocalAddress;
304 def sextloadi8_local_m0 : LoadFrag<sextloadi8_glue>, LocalAddress;
305 def sextloadi16_local_m0 : LoadFrag<sextloadi16_glue>, LocalAddress;
306 def az_extloadi8_local_m0 : LoadFrag<az_extloadi8_glue>, LocalAddress;
307 def az_extloadi16_local_m0 : LoadFrag<az_extloadi16_glue>, LocalAddress;
308 def load_align8_local_m0 : LoadFrag <load_glue_align8>, LocalAddress;
309 def load_align16_local_m0 : LoadFrag <load_glue_align16>, LocalAddress;
310 def atomic_load_32_local_m0 : LoadFrag<atomic_load_32_glue>, LocalAddress;
311 def atomic_load_64_local_m0 : LoadFrag<atomic_load_64_glue>, LocalAddress;
314 def AMDGPUst_glue : SDNode <"ISD::STORE", SDTStore,
315 [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue]
318 def AMDGPUatomic_st_glue : SDNode <"ISD::ATOMIC_STORE", SDTAtomicStore,
319 [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue]
322 def atomic_store_glue : PatFrag<(ops node:$ptr, node:$val),
323 (AMDGPUatomic_st_glue node:$ptr, node:$val)> {
326 def unindexedstore_glue : PatFrag<(ops node:$val, node:$ptr),
327 (AMDGPUst_glue node:$val, node:$ptr), [{
328 return cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED;
331 def store_glue : PatFrag<(ops node:$val, node:$ptr),
332 (unindexedstore_glue node:$val, node:$ptr), [{
333 return !cast<StoreSDNode>(N)->isTruncatingStore();
336 def truncstore_glue : PatFrag<(ops node:$val, node:$ptr),
337 (unindexedstore_glue node:$val, node:$ptr), [{
338 return cast<StoreSDNode>(N)->isTruncatingStore();
341 def truncstorei8_glue : PatFrag<(ops node:$val, node:$ptr),
342 (truncstore_glue node:$val, node:$ptr), [{
343 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
346 def truncstorei16_glue : PatFrag<(ops node:$val, node:$ptr),
347 (truncstore_glue node:$val, node:$ptr), [{
348 return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
351 def store_glue_align8 : Aligned8Bytes <
352 (ops node:$value, node:$ptr), (store_glue node:$value, node:$ptr)
355 def store_glue_align16 : Aligned16Bytes <
356 (ops node:$value, node:$ptr), (store_glue node:$value, node:$ptr)
359 def store_local_m0 : StoreFrag<store_glue>, LocalAddress;
360 def truncstorei8_local_m0 : StoreFrag<truncstorei8_glue>, LocalAddress;
361 def truncstorei16_local_m0 : StoreFrag<truncstorei16_glue>, LocalAddress;
362 def atomic_store_local_m0 : StoreFrag<AMDGPUatomic_st_glue>, LocalAddress;
364 def store_align8_local_m0 : StoreFrag<store_glue_align8>, LocalAddress;
365 def store_align16_local_m0 : StoreFrag<store_glue_align16>, LocalAddress;
367 def si_setcc_uniform : PatFrag <
368 (ops node:$lhs, node:$rhs, node:$cond),
369 (setcc node:$lhs, node:$rhs, node:$cond), [{
370 for (SDNode *Use : N->uses()) {
371 if (Use->isMachineOpcode() || Use->getOpcode() != ISD::CopyToReg)
374 unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
375 if (Reg != AMDGPU::SCC)
381 def lshr_rev : PatFrag <
382 (ops node:$src1, node:$src0),
386 def ashr_rev : PatFrag <
387 (ops node:$src1, node:$src0),
391 def lshl_rev : PatFrag <
392 (ops node:$src1, node:$src0),
396 multiclass SIAtomicM0Glue2 <string op_name, bit is_amdgpu = 0,
397 SDTypeProfile tc = SDTAtomic2> {
400 !if(is_amdgpu, "AMDGPUISD", "ISD")#"::ATOMIC_"#op_name, tc,
401 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
404 def _local_m0 : local_binary_atomic_op <!cast<SDNode>(NAME#"_glue")>;
407 defm atomic_load_add : SIAtomicM0Glue2 <"LOAD_ADD">;
408 defm atomic_load_sub : SIAtomicM0Glue2 <"LOAD_SUB">;
409 defm atomic_inc : SIAtomicM0Glue2 <"INC", 1>;
410 defm atomic_dec : SIAtomicM0Glue2 <"DEC", 1>;
411 defm atomic_load_and : SIAtomicM0Glue2 <"LOAD_AND">;
412 defm atomic_load_min : SIAtomicM0Glue2 <"LOAD_MIN">;
413 defm atomic_load_max : SIAtomicM0Glue2 <"LOAD_MAX">;
414 defm atomic_load_or : SIAtomicM0Glue2 <"LOAD_OR">;
415 defm atomic_load_xor : SIAtomicM0Glue2 <"LOAD_XOR">;
416 defm atomic_load_umin : SIAtomicM0Glue2 <"LOAD_UMIN">;
417 defm atomic_load_umax : SIAtomicM0Glue2 <"LOAD_UMAX">;
418 defm atomic_swap : SIAtomicM0Glue2 <"SWAP">;
419 defm atomic_load_fadd : SIAtomicM0Glue2 <"LOAD_FADD", 1, SDTAtomic2_f32>;
420 defm atomic_load_fmin : SIAtomicM0Glue2 <"LOAD_FMIN", 1, SDTAtomic2_f32>;
421 defm atomic_load_fmax : SIAtomicM0Glue2 <"LOAD_FMAX", 1, SDTAtomic2_f32>;
423 def atomic_cmp_swap_glue : SDNode <"ISD::ATOMIC_CMP_SWAP", SDTAtomic3,
424 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
427 def atomic_cmp_swap_local_m0 : AtomicCmpSwapLocal<atomic_cmp_swap_glue>;
430 def as_i1imm : SDNodeXForm<imm, [{
431 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i1);
434 def as_i8imm : SDNodeXForm<imm, [{
435 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i8);
438 def as_i16imm : SDNodeXForm<imm, [{
439 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16);
442 def as_i32imm: SDNodeXForm<imm, [{
443 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32);
446 def as_i64imm: SDNodeXForm<imm, [{
447 return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i64);
450 def cond_as_i32imm: SDNodeXForm<cond, [{
451 return CurDAG->getTargetConstant(N->get(), SDLoc(N), MVT::i32);
454 // Copied from the AArch64 backend:
455 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
456 return CurDAG->getTargetConstant(
457 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
460 def frameindex_to_targetframeindex : SDNodeXForm<frameindex, [{
461 auto FI = cast<FrameIndexSDNode>(N);
462 return CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
465 // Copied from the AArch64 backend:
466 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
467 return CurDAG->getTargetConstant(
468 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
471 class bitextract_imm<int bitnum> : SDNodeXForm<imm, [{
472 uint64_t Imm = N->getZExtValue();
473 unsigned Bit = (Imm >> }] # bitnum # [{ ) & 1;
474 return CurDAG->getTargetConstant(Bit, SDLoc(N), MVT::i1);
477 def SIMM16bit : PatLeaf <(imm),
478 [{return isInt<16>(N->getSExtValue());}]
481 class InlineImm <ValueType vt> : PatLeaf <(vt imm), [{
482 return isInlineImmediate(N);
485 class InlineFPImm <ValueType vt> : PatLeaf <(vt fpimm), [{
486 return isInlineImmediate(N);
489 class VGPRImm <dag frag> : PatLeaf<frag, [{
490 if (Subtarget->getGeneration() < AMDGPUSubtarget::SOUTHERN_ISLANDS) {
493 const SIRegisterInfo *SIRI =
494 static_cast<const SIRegisterInfo *>(Subtarget->getRegisterInfo());
496 for (SDNode::use_iterator U = N->use_begin(), E = SDNode::use_end();
497 Limit < 10 && U != E; ++U, ++Limit) {
498 const TargetRegisterClass *RC = getOperandRegClass(*U, U.getOperandNo());
500 // If the register class is unknown, it could be an unknown
501 // register class that needs to be an SGPR, e.g. an inline asm
503 if (!RC || SIRI->isSGPRClass(RC))
510 def NegateImm : SDNodeXForm<imm, [{
511 return CurDAG->getConstant(-N->getSExtValue(), SDLoc(N), MVT::i32);
514 // TODO: When FP inline imm values work?
515 def NegSubInlineConst32 : ImmLeaf<i32, [{
516 return Imm < -16 && Imm >= -64;
519 def NegSubInlineConst16 : ImmLeaf<i16, [{
520 return Imm < -16 && Imm >= -64;
523 def ShiftAmt32Imm : PatLeaf <(imm), [{
524 return N->getZExtValue() < 32;
527 //===----------------------------------------------------------------------===//
529 //===----------------------------------------------------------------------===//
531 def SoppBrTarget : AsmOperandClass {
532 let Name = "SoppBrTarget";
533 let ParserMethod = "parseSOppBrTarget";
536 def sopp_brtarget : Operand<OtherVT> {
537 let EncoderMethod = "getSOPPBrEncoding";
538 let DecoderMethod = "decodeSoppBrTarget";
539 let OperandType = "OPERAND_PCREL";
540 let ParserMatchClass = SoppBrTarget;
543 def si_ga : Operand<iPTR>;
545 def InterpSlotMatchClass : AsmOperandClass {
546 let Name = "InterpSlot";
547 let PredicateMethod = "isInterpSlot";
548 let ParserMethod = "parseInterpSlot";
549 let RenderMethod = "addImmOperands";
552 def InterpSlot : Operand<i32> {
553 let PrintMethod = "printInterpSlot";
554 let ParserMatchClass = InterpSlotMatchClass;
555 let OperandType = "OPERAND_IMMEDIATE";
558 def AttrMatchClass : AsmOperandClass {
560 let PredicateMethod = "isInterpAttr";
561 let ParserMethod = "parseInterpAttr";
562 let RenderMethod = "addImmOperands";
565 // It appears to be necessary to create a separate operand for this to
566 // be able to parse attr<num> with no space.
567 def Attr : Operand<i32> {
568 let PrintMethod = "printInterpAttr";
569 let ParserMatchClass = AttrMatchClass;
570 let OperandType = "OPERAND_IMMEDIATE";
573 def AttrChanMatchClass : AsmOperandClass {
574 let Name = "AttrChan";
575 let PredicateMethod = "isAttrChan";
576 let RenderMethod = "addImmOperands";
579 def AttrChan : Operand<i32> {
580 let PrintMethod = "printInterpAttrChan";
581 let ParserMatchClass = AttrChanMatchClass;
582 let OperandType = "OPERAND_IMMEDIATE";
585 def SendMsgMatchClass : AsmOperandClass {
586 let Name = "SendMsg";
587 let PredicateMethod = "isSendMsg";
588 let ParserMethod = "parseSendMsgOp";
589 let RenderMethod = "addImmOperands";
592 def SwizzleMatchClass : AsmOperandClass {
593 let Name = "Swizzle";
594 let PredicateMethod = "isSwizzle";
595 let ParserMethod = "parseSwizzleOp";
596 let RenderMethod = "addImmOperands";
600 def ExpTgtMatchClass : AsmOperandClass {
602 let PredicateMethod = "isExpTgt";
603 let ParserMethod = "parseExpTgt";
604 let RenderMethod = "printExpTgt";
607 def SendMsgImm : Operand<i32> {
608 let PrintMethod = "printSendMsg";
609 let ParserMatchClass = SendMsgMatchClass;
612 def SwizzleImm : Operand<i16> {
613 let PrintMethod = "printSwizzle";
614 let ParserMatchClass = SwizzleMatchClass;
617 def SWaitMatchClass : AsmOperandClass {
618 let Name = "SWaitCnt";
619 let RenderMethod = "addImmOperands";
620 let ParserMethod = "parseSWaitCntOps";
623 def VReg32OrOffClass : AsmOperandClass {
624 let Name = "VReg32OrOff";
625 let ParserMethod = "parseVReg32OrOff";
628 def WAIT_FLAG : Operand <i32> {
629 let ParserMatchClass = SWaitMatchClass;
630 let PrintMethod = "printWaitFlag";
633 include "SIInstrFormats.td"
634 include "VIInstrFormats.td"
636 // ===----------------------------------------------------------------------===//
637 // ExpSrc* Special cases for exp src operands which are printed as
638 // "off" depending on en operand.
639 // ===----------------------------------------------------------------------===//
641 def ExpSrc0 : RegisterOperand<VGPR_32> {
642 let PrintMethod = "printExpSrc0";
643 let ParserMatchClass = VReg32OrOffClass;
646 def ExpSrc1 : RegisterOperand<VGPR_32> {
647 let PrintMethod = "printExpSrc1";
648 let ParserMatchClass = VReg32OrOffClass;
651 def ExpSrc2 : RegisterOperand<VGPR_32> {
652 let PrintMethod = "printExpSrc2";
653 let ParserMatchClass = VReg32OrOffClass;
656 def ExpSrc3 : RegisterOperand<VGPR_32> {
657 let PrintMethod = "printExpSrc3";
658 let ParserMatchClass = VReg32OrOffClass;
661 class SDWASrc<ValueType vt> : RegisterOperand<VS_32> {
662 let OperandNamespace = "AMDGPU";
663 string Type = !if(isFloatType<vt>.ret, "FP", "INT");
664 let OperandType = "OPERAND_REG_INLINE_C_"#Type#vt.Size;
665 let DecoderMethod = "decodeSDWASrc"#vt.Size;
666 let EncoderMethod = "getSDWASrcEncoding";
669 def SDWASrc_i32 : SDWASrc<i32>;
670 def SDWASrc_i16 : SDWASrc<i16>;
671 def SDWASrc_f32 : SDWASrc<f32>;
672 def SDWASrc_f16 : SDWASrc<f16>;
674 def SDWAVopcDst : VOPDstOperand<SReg_64> {
675 let OperandNamespace = "AMDGPU";
676 let OperandType = "OPERAND_SDWA_VOPC_DST";
677 let EncoderMethod = "getSDWAVopcDstEncoding";
678 let DecoderMethod = "decodeSDWAVopcDst";
681 class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass {
682 let Name = "Imm"#CName;
683 let PredicateMethod = "is"#CName;
684 let ParserMethod = !if(Optional, "parseOptionalOperand", "parse"#CName);
685 let RenderMethod = "addImmOperands";
686 let IsOptional = Optional;
687 let DefaultMethod = !if(Optional, "default"#CName, ?);
690 class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> {
691 let PrintMethod = "print"#Name;
692 let ParserMatchClass = MatchClass;
695 class NamedOperandU8<string Name, AsmOperandClass MatchClass> : Operand<i8> {
696 let PrintMethod = "print"#Name;
697 let ParserMatchClass = MatchClass;
700 class NamedOperandU12<string Name, AsmOperandClass MatchClass> : Operand<i16> {
701 let PrintMethod = "print"#Name;
702 let ParserMatchClass = MatchClass;
705 class NamedOperandU16<string Name, AsmOperandClass MatchClass> : Operand<i16> {
706 let PrintMethod = "print"#Name;
707 let ParserMatchClass = MatchClass;
710 class NamedOperandS13<string Name, AsmOperandClass MatchClass> : Operand<i16> {
711 let PrintMethod = "print"#Name;
712 let ParserMatchClass = MatchClass;
715 class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
716 let PrintMethod = "print"#Name;
717 let ParserMatchClass = MatchClass;
720 class NamedOperandU32Default0<string Name, AsmOperandClass MatchClass> :
721 OperandWithDefaultOps<i32, (ops (i32 0))> {
722 let PrintMethod = "print"#Name;
723 let ParserMatchClass = MatchClass;
726 let OperandType = "OPERAND_IMMEDIATE" in {
728 def offen : NamedOperandBit<"Offen", NamedMatchClass<"Offen">>;
729 def idxen : NamedOperandBit<"Idxen", NamedMatchClass<"Idxen">>;
730 def addr64 : NamedOperandBit<"Addr64", NamedMatchClass<"Addr64">>;
732 def offset_u12 : NamedOperandU12<"Offset", NamedMatchClass<"OffsetU12">>;
733 def offset_s13 : NamedOperandS13<"OffsetS13", NamedMatchClass<"OffsetS13">>;
734 def offset : NamedOperandU16<"Offset", NamedMatchClass<"Offset">>;
735 def offset0 : NamedOperandU8<"Offset0", NamedMatchClass<"Offset0">>;
736 def offset1 : NamedOperandU8<"Offset1", NamedMatchClass<"Offset1">>;
738 def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>;
740 def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>;
741 def clampmod : NamedOperandBit<"ClampSI", NamedMatchClass<"ClampSI">>;
742 def highmod : NamedOperandBit<"High", NamedMatchClass<"High">>;
744 def GLC : NamedOperandBit<"GLC", NamedMatchClass<"GLC">>;
745 def SLC : NamedOperandBit<"SLC", NamedMatchClass<"SLC">>;
746 def TFE : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>;
747 def UNorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>;
748 def DA : NamedOperandBit<"DA", NamedMatchClass<"DA">>;
749 def R128 : NamedOperandBit<"R128", NamedMatchClass<"R128">>;
750 def D16 : NamedOperandBit<"D16", NamedMatchClass<"D16">>;
751 def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>;
752 def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>;
753 def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>;
755 def DFMT : NamedOperandU8<"DFMT", NamedMatchClass<"DFMT">>;
756 def NFMT : NamedOperandU8<"NFMT", NamedMatchClass<"NFMT">>;
758 def DMask : NamedOperandU16<"DMask", NamedMatchClass<"DMask">>;
760 def dpp_ctrl : NamedOperandU32<"DPPCtrl", NamedMatchClass<"DPPCtrl", 0>>;
761 def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>;
762 def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>;
763 def bound_ctrl : NamedOperandBit<"BoundCtrl", NamedMatchClass<"BoundCtrl">>;
765 def dst_sel : NamedOperandU32<"SDWADstSel", NamedMatchClass<"SDWADstSel">>;
766 def src0_sel : NamedOperandU32<"SDWASrc0Sel", NamedMatchClass<"SDWASrc0Sel">>;
767 def src1_sel : NamedOperandU32<"SDWASrc1Sel", NamedMatchClass<"SDWASrc1Sel">>;
768 def dst_unused : NamedOperandU32<"SDWADstUnused", NamedMatchClass<"SDWADstUnused">>;
770 def op_sel : NamedOperandU32Default0<"OpSel", NamedMatchClass<"OpSel">>;
771 def op_sel_hi : NamedOperandU32Default0<"OpSelHi", NamedMatchClass<"OpSelHi">>;
772 def neg_lo : NamedOperandU32Default0<"NegLo", NamedMatchClass<"NegLo">>;
773 def neg_hi : NamedOperandU32Default0<"NegHi", NamedMatchClass<"NegHi">>;
775 def hwreg : NamedOperandU16<"Hwreg", NamedMatchClass<"Hwreg", 0>>;
777 def exp_tgt : NamedOperandU8<"ExpTgt", NamedMatchClass<"ExpTgt", 0>> {
781 } // End OperandType = "OPERAND_IMMEDIATE"
783 class KImmMatchClass<int size> : AsmOperandClass {
784 let Name = "KImmFP"#size;
785 let PredicateMethod = "isKImmFP"#size;
786 let ParserMethod = "parseImm";
787 let RenderMethod = "addKImmFP"#size#"Operands";
790 class kimmOperand<ValueType vt> : Operand<vt> {
791 let OperandNamespace = "AMDGPU";
792 let OperandType = "OPERAND_KIMM"#vt.Size;
793 let PrintMethod = "printU"#vt.Size#"ImmOperand";
794 let ParserMatchClass = !cast<AsmOperandClass>("KImmFP"#vt.Size#"MatchClass");
797 // 32-bit VALU immediate operand that uses the constant bus.
798 def KImmFP32MatchClass : KImmMatchClass<32>;
799 def f32kimm : kimmOperand<i32>;
801 // 32-bit VALU immediate operand with a 16-bit value that uses the
803 def KImmFP16MatchClass : KImmMatchClass<16>;
804 def f16kimm : kimmOperand<i16>;
807 def VOPDstS64 : VOPDstOperand <SReg_64>;
809 class FPInputModsMatchClass <int opSize> : AsmOperandClass {
810 let Name = "RegOrImmWithFP"#opSize#"InputMods";
811 let ParserMethod = "parseRegOrImmWithFPInputMods";
812 let PredicateMethod = "isRegOrImmWithFP"#opSize#"InputMods";
815 def FP16InputModsMatchClass : FPInputModsMatchClass<16>;
816 def FP32InputModsMatchClass : FPInputModsMatchClass<32>;
817 def FP64InputModsMatchClass : FPInputModsMatchClass<64>;
819 class InputMods <AsmOperandClass matchClass> : Operand <i32> {
820 let OperandNamespace = "AMDGPU";
821 let OperandType = "OPERAND_INPUT_MODS";
822 let ParserMatchClass = matchClass;
825 class FPInputMods <FPInputModsMatchClass matchClass> : InputMods <matchClass> {
826 let PrintMethod = "printOperandAndFPInputMods";
829 def FP16InputMods : FPInputMods<FP16InputModsMatchClass>;
830 def FP32InputMods : FPInputMods<FP32InputModsMatchClass>;
831 def FP64InputMods : FPInputMods<FP64InputModsMatchClass>;
833 class IntInputModsMatchClass <int opSize> : AsmOperandClass {
834 let Name = "RegOrImmWithInt"#opSize#"InputMods";
835 let ParserMethod = "parseRegOrImmWithIntInputMods";
836 let PredicateMethod = "isRegOrImmWithInt"#opSize#"InputMods";
838 def Int32InputModsMatchClass : IntInputModsMatchClass<32>;
839 def Int64InputModsMatchClass : IntInputModsMatchClass<64>;
841 class IntInputMods <IntInputModsMatchClass matchClass> : InputMods <matchClass> {
842 let PrintMethod = "printOperandAndIntInputMods";
844 def Int32InputMods : IntInputMods<Int32InputModsMatchClass>;
845 def Int64InputMods : IntInputMods<Int64InputModsMatchClass>;
847 class OpSelModsMatchClass : AsmOperandClass {
848 let Name = "OpSelMods";
849 let ParserMethod = "parseRegOrImm";
850 let PredicateMethod = "isRegOrImm";
853 def IntOpSelModsMatchClass : OpSelModsMatchClass;
854 def IntOpSelMods : InputMods<IntOpSelModsMatchClass>;
856 class FPSDWAInputModsMatchClass <int opSize> : AsmOperandClass {
857 let Name = "SDWAWithFP"#opSize#"InputMods";
858 let ParserMethod = "parseRegOrImmWithFPInputMods";
859 let PredicateMethod = "isSDWAFP"#opSize#"Operand";
862 def FP16SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<16>;
863 def FP32SDWAInputModsMatchClass : FPSDWAInputModsMatchClass<32>;
865 class FPSDWAInputMods <FPSDWAInputModsMatchClass matchClass> :
866 InputMods <matchClass> {
867 let PrintMethod = "printOperandAndFPInputMods";
870 def FP16SDWAInputMods : FPSDWAInputMods<FP16SDWAInputModsMatchClass>;
871 def FP32SDWAInputMods : FPSDWAInputMods<FP32SDWAInputModsMatchClass>;
873 def FPVRegInputModsMatchClass : AsmOperandClass {
874 let Name = "VRegWithFPInputMods";
875 let ParserMethod = "parseRegWithFPInputMods";
876 let PredicateMethod = "isVReg";
879 def FPVRegInputMods : InputMods <FPVRegInputModsMatchClass> {
880 let PrintMethod = "printOperandAndFPInputMods";
883 class IntSDWAInputModsMatchClass <int opSize> : AsmOperandClass {
884 let Name = "SDWAWithInt"#opSize#"InputMods";
885 let ParserMethod = "parseRegOrImmWithIntInputMods";
886 let PredicateMethod = "isSDWAInt"#opSize#"Operand";
889 def Int16SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<16>;
890 def Int32SDWAInputModsMatchClass : IntSDWAInputModsMatchClass<32>;
892 class IntSDWAInputMods <IntSDWAInputModsMatchClass matchClass> :
893 InputMods <matchClass> {
894 let PrintMethod = "printOperandAndIntInputMods";
897 def Int16SDWAInputMods : IntSDWAInputMods<Int16SDWAInputModsMatchClass>;
898 def Int32SDWAInputMods : IntSDWAInputMods<Int32SDWAInputModsMatchClass>;
900 def IntVRegInputModsMatchClass : AsmOperandClass {
901 let Name = "VRegWithIntInputMods";
902 let ParserMethod = "parseRegWithIntInputMods";
903 let PredicateMethod = "isVReg";
906 def IntVRegInputMods : InputMods <IntVRegInputModsMatchClass> {
907 let PrintMethod = "printOperandAndIntInputMods";
910 class PackedFPInputModsMatchClass <int opSize> : AsmOperandClass {
911 let Name = "PackedFP"#opSize#"InputMods";
912 let ParserMethod = "parseRegOrImm";
913 let PredicateMethod = "isRegOrImm";
914 // let PredicateMethod = "isPackedFP"#opSize#"InputMods";
917 class PackedIntInputModsMatchClass <int opSize> : AsmOperandClass {
918 let Name = "PackedInt"#opSize#"InputMods";
919 let ParserMethod = "parseRegOrImm";
920 let PredicateMethod = "isRegOrImm";
921 // let PredicateMethod = "isPackedInt"#opSize#"InputMods";
924 def PackedF16InputModsMatchClass : PackedFPInputModsMatchClass<16>;
925 def PackedI16InputModsMatchClass : PackedIntInputModsMatchClass<16>;
927 class PackedFPInputMods <PackedFPInputModsMatchClass matchClass> : InputMods <matchClass> {
928 // let PrintMethod = "printPackedFPInputMods";
931 class PackedIntInputMods <PackedIntInputModsMatchClass matchClass> : InputMods <matchClass> {
932 //let PrintMethod = "printPackedIntInputMods";
935 def PackedF16InputMods : PackedFPInputMods<PackedF16InputModsMatchClass>;
936 def PackedI16InputMods : PackedIntInputMods<PackedI16InputModsMatchClass>;
938 //===----------------------------------------------------------------------===//
940 //===----------------------------------------------------------------------===//
942 def DS1Addr1Offset : ComplexPattern<i32, 2, "SelectDS1Addr1Offset">;
943 def DS64Bit4ByteAligned : ComplexPattern<i32, 3, "SelectDS64Bit4ByteAligned">;
945 def MOVRELOffset : ComplexPattern<i32, 2, "SelectMOVRELOffset">;
947 def VOP3Mods0 : ComplexPattern<untyped, 4, "SelectVOP3Mods0">;
948 def VOP3Mods0Clamp : ComplexPattern<untyped, 3, "SelectVOP3Mods0Clamp">;
949 def VOP3Mods0Clamp0OMod : ComplexPattern<untyped, 4, "SelectVOP3Mods0Clamp0OMod">;
950 def VOP3Mods : ComplexPattern<untyped, 2, "SelectVOP3Mods">;
951 def VOP3NoMods : ComplexPattern<untyped, 1, "SelectVOP3NoMods">;
952 // VOP3Mods, but the input source is known to never be NaN.
953 def VOP3Mods_nnan : ComplexPattern<fAny, 2, "SelectVOP3Mods_NNaN">;
955 def VOP3OMods : ComplexPattern<untyped, 3, "SelectVOP3OMods">;
957 def VOP3PMods : ComplexPattern<untyped, 2, "SelectVOP3PMods">;
958 def VOP3PMods0 : ComplexPattern<untyped, 3, "SelectVOP3PMods0">;
960 def VOP3OpSel : ComplexPattern<untyped, 2, "SelectVOP3OpSel">;
961 def VOP3OpSel0 : ComplexPattern<untyped, 3, "SelectVOP3OpSel0">;
963 def VOP3OpSelMods : ComplexPattern<untyped, 2, "SelectVOP3OpSelMods">;
964 def VOP3OpSelMods0 : ComplexPattern<untyped, 3, "SelectVOP3OpSelMods0">;
966 def VOP3PMadMixMods : ComplexPattern<untyped, 2, "SelectVOP3PMadMixMods">;
969 def Hi16Elt : ComplexPattern<untyped, 1, "SelectHi16Elt">;
971 //===----------------------------------------------------------------------===//
972 // SI assembler operands
973 //===----------------------------------------------------------------------===//
981 // This should be kept in sync with SISrcMods enum
1005 int LLVM_DEBUG_TRAP = 3;
1008 //===----------------------------------------------------------------------===//
1010 // SI Instruction multiclass helpers.
1012 // Instructions with _32 take 32-bit operands.
1013 // Instructions with _64 take 64-bit operands.
1015 // VOP_* instructions can use either a 32-bit or 64-bit encoding. The 32-bit
1016 // encoding is the standard encoding, but instruction that make use of
1017 // any of the instruction modifiers must use the 64-bit encoding.
1019 // Instructions with _e32 use the 32-bit encoding.
1020 // Instructions with _e64 use the 64-bit encoding.
1022 //===----------------------------------------------------------------------===//
1024 class SIMCInstr <string pseudo, int subtarget> {
1025 string PseudoInstr = pseudo;
1026 int Subtarget = subtarget;
1029 //===----------------------------------------------------------------------===//
1031 //===----------------------------------------------------------------------===//
1033 class EXP_Helper<bit done, SDPatternOperator node = null_frag> : EXPCommon<
1036 ExpSrc0:$src0, ExpSrc1:$src1, ExpSrc2:$src2, ExpSrc3:$src3,
1037 exp_vm:$vm, exp_compr:$compr, i8imm:$en),
1038 "exp$tgt $src0, $src1, $src2, $src3"#!if(done, " done", "")#"$compr$vm",
1039 [(node (i8 timm:$tgt), (i8 timm:$en),
1040 f32:$src0, f32:$src1, f32:$src2, f32:$src3,
1041 (i1 timm:$compr), (i1 timm:$vm))]> {
1042 let AsmMatchConverter = "cvtExp";
1045 // Split EXP instruction into EXP and EXP_DONE so we can set
1046 // mayLoad for done=1.
1047 multiclass EXP_m<bit done, SDPatternOperator node> {
1048 let mayLoad = done, DisableWQM = 1 in {
1049 let isPseudo = 1, isCodeGenOnly = 1 in {
1050 def "" : EXP_Helper<done, node>,
1051 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.NONE>;
1054 let done = done in {
1055 def _si : EXP_Helper<done>,
1056 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.SI>,
1058 let AssemblerPredicates = [isSICI];
1059 let DecoderNamespace = "SICI";
1060 let DisableDecoder = DisableSIDecoder;
1063 def _vi : EXP_Helper<done>,
1064 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.VI>,
1066 let AssemblerPredicates = [isVI];
1067 let DecoderNamespace = "VI";
1068 let DisableDecoder = DisableVIDecoder;
1074 //===----------------------------------------------------------------------===//
1075 // Vector ALU classes
1076 //===----------------------------------------------------------------------===//
1078 class getNumSrcArgs<ValueType Src0, ValueType Src1, ValueType Src2> {
1080 !if (!eq(Src0.Value, untyped.Value), 0,
1081 !if (!eq(Src1.Value, untyped.Value), 1, // VOP1
1082 !if (!eq(Src2.Value, untyped.Value), 2, // VOP2
1086 // Returns the register class to use for the destination of VOP[123C]
1087 // instructions for the given VT.
1088 class getVALUDstForVT<ValueType VT> {
1089 RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand<VGPR_32>,
1090 !if(!eq(VT.Size, 128), VOPDstOperand<VReg_128>,
1091 !if(!eq(VT.Size, 64), VOPDstOperand<VReg_64>,
1092 !if(!eq(VT.Size, 16), VOPDstOperand<VGPR_32>,
1093 VOPDstOperand<SReg_64>)))); // else VT == i1
1096 // Returns the register class to use for the destination of VOP[12C]
1097 // instructions with SDWA extension
1098 class getSDWADstForVT<ValueType VT> {
1099 RegisterOperand ret = !if(!eq(VT.Size, 1),
1100 SDWAVopcDst, // VOPC
1101 VOPDstOperand<VGPR_32>); // VOP1/2 32-bit dst
1104 // Returns the register class to use for source 0 of VOP[12C]
1105 // instructions for the given VT.
1106 class getVOPSrc0ForVT<ValueType VT> {
1107 bit isFP = !if(!eq(VT.Value, f16.Value), 1,
1108 !if(!eq(VT.Value, v2f16.Value), 1,
1109 !if(!eq(VT.Value, f32.Value), 1,
1110 !if(!eq(VT.Value, f64.Value), 1,
1113 RegisterOperand ret =
1115 !if(!eq(VT.Size, 64),
1117 !if(!eq(VT.Value, f16.Value),
1119 !if(!eq(VT.Value, v2f16.Value),
1125 !if(!eq(VT.Size, 64),
1127 !if(!eq(VT.Value, i16.Value),
1129 !if(!eq(VT.Value, v2i16.Value),
1138 // Returns the vreg register class to use for source operand given VT
1139 class getVregSrcForVT<ValueType VT> {
1140 RegisterClass ret = !if(!eq(VT.Size, 128), VReg_128,
1141 !if(!eq(VT.Size, 64), VReg_64, VGPR_32));
1144 class getSDWASrcForVT <ValueType VT> {
1145 bit isFP = !if(!eq(VT.Value, f16.Value), 1,
1146 !if(!eq(VT.Value, f32.Value), 1,
1148 RegisterOperand retFlt = !if(!eq(VT.Size, 16), SDWASrc_f16, SDWASrc_f32);
1149 RegisterOperand retInt = !if(!eq(VT.Size, 16), SDWASrc_i16, SDWASrc_i32);
1150 RegisterOperand ret = !if(isFP, retFlt, retInt);
1153 // Returns the register class to use for sources of VOP3 instructions for the
1155 class getVOP3SrcForVT<ValueType VT> {
1156 bit isFP = !if(!eq(VT.Value, f16.Value), 1,
1157 !if(!eq(VT.Value, v2f16.Value), 1,
1158 !if(!eq(VT.Value, f32.Value), 1,
1159 !if(!eq(VT.Value, f64.Value), 1,
1161 RegisterOperand ret =
1162 !if(!eq(VT.Size, 128),
1164 !if(!eq(VT.Size, 64),
1168 !if(!eq(VT.Value, i1.Value),
1171 !if(!eq(VT.Value, f16.Value),
1173 !if(!eq(VT.Value, v2f16.Value),
1178 !if(!eq(VT.Value, i16.Value),
1180 !if(!eq(VT.Value, v2i16.Value),
1191 // Float or packed int
1192 class isModifierType<ValueType SrcVT> {
1194 !if(!eq(SrcVT.Value, f16.Value), 1,
1195 !if(!eq(SrcVT.Value, f32.Value), 1,
1196 !if(!eq(SrcVT.Value, f64.Value), 1,
1197 !if(!eq(SrcVT.Value, v2f16.Value), 1,
1198 !if(!eq(SrcVT.Value, v2i16.Value), 1,
1202 // Return type of input modifiers operand for specified input operand
1203 class getSrcMod <ValueType VT> {
1204 bit isFP = !if(!eq(VT.Value, f16.Value), 1,
1205 !if(!eq(VT.Value, f32.Value), 1,
1206 !if(!eq(VT.Value, f64.Value), 1,
1208 bit isPacked = isPackedType<VT>.ret;
1209 Operand ret = !if(!eq(VT.Size, 64),
1210 !if(isFP, FP64InputMods, Int64InputMods),
1212 !if(!eq(VT.Value, f16.Value),
1220 class getOpSelMod <ValueType VT> {
1221 Operand ret = !if(!eq(VT.Value, f16.Value), FP16InputMods, IntOpSelMods);
1224 // Return type of input modifiers operand specified input operand for DPP
1225 class getSrcModExt <ValueType VT> {
1226 bit isFP = !if(!eq(VT.Value, f16.Value), 1,
1227 !if(!eq(VT.Value, f32.Value), 1,
1228 !if(!eq(VT.Value, f64.Value), 1,
1230 Operand ret = !if(isFP, FPVRegInputMods, IntVRegInputMods);
1233 // Return type of input modifiers operand specified input operand for SDWA
1234 class getSrcModSDWA <ValueType VT> {
1235 Operand ret = !if(!eq(VT.Value, f16.Value), FP16SDWAInputMods,
1236 !if(!eq(VT.Value, f32.Value), FP32SDWAInputMods,
1237 !if(!eq(VT.Value, i16.Value), Int16SDWAInputMods,
1238 Int32SDWAInputMods)));
1241 // Returns the input arguments for VOP[12C] instructions for the given SrcVT.
1242 class getIns32 <RegisterOperand Src0RC, RegisterClass Src1RC, int NumSrcArgs> {
1243 dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0), // VOP1
1244 !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2
1248 // Returns the input arguments for VOP3 instructions for the given SrcVT.
1249 class getIns64 <RegisterOperand Src0RC, RegisterOperand Src1RC,
1250 RegisterOperand Src2RC, int NumSrcArgs,
1251 bit HasIntClamp, bit HasModifiers, bit HasOMod,
1252 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
1255 !if (!eq(NumSrcArgs, 0),
1256 // VOP1 without input operands (V_NOP, V_CLREXCP)
1259 !if (!eq(NumSrcArgs, 1),
1260 !if (!eq(HasModifiers, 1),
1261 // VOP1 with modifiers
1262 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1263 clampmod:$clamp, omod:$omod)
1265 // VOP1 without modifiers
1266 !if (!eq(HasIntClamp, 1),
1267 (ins Src0RC:$src0, clampmod:$clamp),
1270 !if (!eq(NumSrcArgs, 2),
1271 !if (!eq(HasModifiers, 1),
1272 // VOP 2 with modifiers
1273 !if( !eq(HasOMod, 1),
1274 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1275 Src1Mod:$src1_modifiers, Src1RC:$src1,
1276 clampmod:$clamp, omod:$omod),
1277 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1278 Src1Mod:$src1_modifiers, Src1RC:$src1,
1281 // VOP2 without modifiers
1282 !if (!eq(HasIntClamp, 1),
1283 (ins Src0RC:$src0, Src1RC:$src1, clampmod:$clamp),
1284 (ins Src0RC:$src0, Src1RC:$src1))
1287 /* NumSrcArgs == 3 */,
1288 !if (!eq(HasModifiers, 1),
1289 // VOP3 with modifiers
1290 !if (!eq(HasOMod, 1),
1291 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1292 Src1Mod:$src1_modifiers, Src1RC:$src1,
1293 Src2Mod:$src2_modifiers, Src2RC:$src2,
1294 clampmod:$clamp, omod:$omod),
1295 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1296 Src1Mod:$src1_modifiers, Src1RC:$src1,
1297 Src2Mod:$src2_modifiers, Src2RC:$src2,
1300 // VOP3 without modifiers
1301 !if (!eq(HasIntClamp, 1),
1302 (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2, clampmod:$clamp),
1303 (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2))
1307 /// XXX - src1 may only allow VGPRs?
1309 // The modifiers (except clamp) are dummy operands for the benefit of
1310 // printing and parsing. They defer their values to looking at the
1311 // srcN_modifiers for what to print.
1312 class getInsVOP3P <RegisterOperand Src0RC, RegisterOperand Src1RC,
1313 RegisterOperand Src2RC, int NumSrcArgs,
1315 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
1316 dag ret = !if (!eq(NumSrcArgs, 2),
1318 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1319 Src1Mod:$src1_modifiers, Src1RC:$src1,
1321 op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1322 neg_lo:$neg_lo, neg_hi:$neg_hi),
1323 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1324 Src1Mod:$src1_modifiers, Src1RC:$src1,
1325 op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1326 neg_lo:$neg_lo, neg_hi:$neg_hi)),
1327 // else NumSrcArgs == 3
1329 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1330 Src1Mod:$src1_modifiers, Src1RC:$src1,
1331 Src2Mod:$src2_modifiers, Src2RC:$src2,
1333 op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1334 neg_lo:$neg_lo, neg_hi:$neg_hi),
1335 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1336 Src1Mod:$src1_modifiers, Src1RC:$src1,
1337 Src2Mod:$src2_modifiers, Src2RC:$src2,
1338 op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1339 neg_lo:$neg_lo, neg_hi:$neg_hi))
1343 class getInsVOP3OpSel <RegisterOperand Src0RC,
1344 RegisterOperand Src1RC,
1345 RegisterOperand Src2RC,
1351 dag ret = !if (!eq(NumSrcArgs, 2),
1353 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1354 Src1Mod:$src1_modifiers, Src1RC:$src1,
1357 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1358 Src1Mod:$src1_modifiers, Src1RC:$src1,
1360 // else NumSrcArgs == 3
1362 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1363 Src1Mod:$src1_modifiers, Src1RC:$src1,
1364 Src2Mod:$src2_modifiers, Src2RC:$src2,
1367 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1368 Src1Mod:$src1_modifiers, Src1RC:$src1,
1369 Src2Mod:$src2_modifiers, Src2RC:$src2,
1374 class getInsDPP <RegisterOperand DstRC, RegisterClass Src0RC, RegisterClass Src1RC,
1375 int NumSrcArgs, bit HasModifiers,
1376 Operand Src0Mod, Operand Src1Mod> {
1378 dag ret = !if (!eq(NumSrcArgs, 0),
1379 // VOP1 without input operands (V_NOP)
1380 (ins dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1381 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl),
1382 !if (!eq(NumSrcArgs, 1),
1383 !if (!eq(HasModifiers, 1),
1384 // VOP1_DPP with modifiers
1385 (ins DstRC:$old, Src0Mod:$src0_modifiers,
1386 Src0RC:$src0, dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1387 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1389 // VOP1_DPP without modifiers
1390 (ins DstRC:$old, Src0RC:$src0,
1391 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1392 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1394 /* NumSrcArgs == 2 */,
1395 !if (!eq(HasModifiers, 1),
1396 // VOP2_DPP with modifiers
1398 Src0Mod:$src0_modifiers, Src0RC:$src0,
1399 Src1Mod:$src1_modifiers, Src1RC:$src1,
1400 dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1401 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1403 // VOP2_DPP without modifiers
1405 Src0RC:$src0, Src1RC:$src1, dpp_ctrl:$dpp_ctrl,
1406 row_mask:$row_mask, bank_mask:$bank_mask,
1407 bound_ctrl:$bound_ctrl)
1414 class getInsSDWA <RegisterOperand Src0RC, RegisterOperand Src1RC, int NumSrcArgs,
1415 bit HasSDWAOMod, Operand Src0Mod, Operand Src1Mod,
1418 dag ret = !if(!eq(NumSrcArgs, 0),
1419 // VOP1 without input operands (V_NOP)
1421 !if(!eq(NumSrcArgs, 1),
1423 !if(!eq(HasSDWAOMod, 0),
1424 // VOP1_SDWA without omod
1425 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1427 dst_sel:$dst_sel, dst_unused:$dst_unused,
1428 src0_sel:$src0_sel),
1429 // VOP1_SDWA with omod
1430 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1431 clampmod:$clamp, omod:$omod,
1432 dst_sel:$dst_sel, dst_unused:$dst_unused,
1433 src0_sel:$src0_sel)),
1434 !if(!eq(NumSrcArgs, 2),
1435 !if(!eq(DstVT.Size, 1),
1437 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1438 Src1Mod:$src1_modifiers, Src1RC:$src1,
1439 clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel),
1441 !if(!eq(HasSDWAOMod, 0),
1442 // VOP2_SDWA without omod
1443 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1444 Src1Mod:$src1_modifiers, Src1RC:$src1,
1446 dst_sel:$dst_sel, dst_unused:$dst_unused,
1447 src0_sel:$src0_sel, src1_sel:$src1_sel),
1448 // VOP2_SDWA with omod
1449 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1450 Src1Mod:$src1_modifiers, Src1RC:$src1,
1451 clampmod:$clamp, omod:$omod,
1452 dst_sel:$dst_sel, dst_unused:$dst_unused,
1453 src0_sel:$src0_sel, src1_sel:$src1_sel))),
1454 (ins)/* endif */)));
1457 // Outs for DPP and SDWA
1458 class getOutsExt <bit HasDst, ValueType DstVT, RegisterOperand DstRCExt> {
1459 dag ret = !if(HasDst,
1460 !if(!eq(DstVT.Size, 1),
1461 (outs), // no dst for VOPC, we use "vcc"-token as dst in SDWA VOPC instructions
1462 (outs DstRCExt:$vdst)),
1467 class getOutsSDWA <bit HasDst, ValueType DstVT, RegisterOperand DstRCSDWA> {
1468 dag ret = !if(HasDst,
1469 !if(!eq(DstVT.Size, 1),
1470 (outs DstRCSDWA:$sdst),
1471 (outs DstRCSDWA:$vdst)),
1475 // Returns the assembly string for the inputs and outputs of a VOP[12C]
1476 // instruction. This does not add the _e32 suffix, so it can be reused
1478 class getAsm32 <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> {
1479 string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1480 string src0 = ", $src0";
1481 string src1 = ", $src1";
1482 string src2 = ", $src2";
1483 string ret = !if(HasDst, dst, "") #
1484 !if(!eq(NumSrcArgs, 1), src0, "") #
1485 !if(!eq(NumSrcArgs, 2), src0#src1, "") #
1486 !if(!eq(NumSrcArgs, 3), src0#src1#src2, "");
1489 // Returns the assembly string for the inputs and outputs of a VOP3
1491 class getAsm64 <bit HasDst, int NumSrcArgs, bit HasIntClamp, bit HasModifiers,
1492 bit HasOMod, ValueType DstVT = i32> {
1493 string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1494 string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1495 string src1 = !if(!eq(NumSrcArgs, 1), "",
1496 !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1497 " $src1_modifiers,"));
1498 string src2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", "");
1499 string iclamp = !if(HasIntClamp, "$clamp", "");
1501 !if(!eq(HasModifiers, 0),
1502 getAsm32<HasDst, NumSrcArgs, DstVT>.ret # iclamp,
1503 dst#", "#src0#src1#src2#"$clamp"#!if(HasOMod, "$omod", ""));
1506 // Returns the assembly string for the inputs and outputs of a VOP3P
1508 class getAsmVOP3P <bit HasDst, int NumSrcArgs, bit HasModifiers,
1509 bit HasClamp, ValueType DstVT = i32> {
1510 string dst = " $vdst";
1511 string src0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
1512 string src1 = !if(!eq(NumSrcArgs, 1), "",
1513 !if(!eq(NumSrcArgs, 2), " $src1",
1515 string src2 = !if(!eq(NumSrcArgs, 3), " $src2", "");
1517 string mods = !if(HasModifiers, "$neg_lo$neg_hi", "");
1518 string clamp = !if(HasClamp, "$clamp", "");
1520 // Each modifier is printed as an array of bits for each operand, so
1521 // all operands are printed as part of src0_modifiers.
1522 string ret = dst#", "#src0#src1#src2#"$op_sel$op_sel_hi"#mods#clamp;
1525 class getAsmVOP3OpSel <int NumSrcArgs,
1530 string dst = " $vdst";
1532 string isrc0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
1533 string isrc1 = !if(!eq(NumSrcArgs, 1), "",
1534 !if(!eq(NumSrcArgs, 2), " $src1",
1536 string isrc2 = !if(!eq(NumSrcArgs, 3), " $src2", "");
1538 string fsrc0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1539 string fsrc1 = !if(!eq(NumSrcArgs, 1), "",
1540 !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1541 " $src1_modifiers,"));
1542 string fsrc2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", "");
1544 string src0 = !if(Src0HasMods, fsrc0, isrc0);
1545 string src1 = !if(Src1HasMods, fsrc1, isrc1);
1546 string src2 = !if(Src2HasMods, fsrc2, isrc2);
1548 string clamp = !if(HasClamp, "$clamp", "");
1550 string ret = dst#", "#src0#src1#src2#"$op_sel"#clamp;
1553 class getAsmDPP <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> {
1554 string dst = !if(HasDst,
1555 !if(!eq(DstVT.Size, 1),
1558 ""); // use $sdst for VOPC
1559 string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1560 string src1 = !if(!eq(NumSrcArgs, 1), "",
1561 !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1562 " $src1_modifiers,"));
1563 string args = !if(!eq(HasModifiers, 0),
1564 getAsm32<0, NumSrcArgs, DstVT>.ret,
1566 string ret = dst#args#" $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
1569 class getAsmSDWA <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> {
1570 string dst = !if(HasDst,
1571 !if(!eq(DstVT.Size, 1),
1572 " vcc", // use vcc token as dst for VOPC instructioins
1575 string src0 = "$src0_modifiers";
1576 string src1 = "$src1_modifiers";
1577 string args = !if(!eq(NumSrcArgs, 0),
1579 !if(!eq(NumSrcArgs, 1),
1581 ", "#src0#", "#src1#"$clamp"
1584 string sdwa = !if(!eq(NumSrcArgs, 0),
1586 !if(!eq(NumSrcArgs, 1),
1587 " $dst_sel $dst_unused $src0_sel",
1588 !if(!eq(DstVT.Size, 1),
1589 " $src0_sel $src1_sel", // No dst_sel and dst_unused for VOPC
1590 " $dst_sel $dst_unused $src0_sel $src1_sel"
1594 string ret = dst#args#sdwa;
1597 class getAsmSDWA9 <bit HasDst, bit HasOMod, int NumSrcArgs,
1598 ValueType DstVT = i32> {
1599 string dst = !if(HasDst,
1600 !if(!eq(DstVT.Size, 1),
1604 string src0 = "$src0_modifiers";
1605 string src1 = "$src1_modifiers";
1606 string out_mods = !if(!eq(HasOMod, 0), "$clamp", "$clamp$omod");
1607 string args = !if(!eq(NumSrcArgs, 0), "",
1608 !if(!eq(NumSrcArgs, 1),
1613 string sdwa = !if(!eq(NumSrcArgs, 0), "",
1614 !if(!eq(NumSrcArgs, 1),
1615 out_mods#" $dst_sel $dst_unused $src0_sel",
1616 !if(!eq(DstVT.Size, 1),
1617 " $src0_sel $src1_sel", // No dst_sel, dst_unused and output modifiers for VOPC
1618 out_mods#" $dst_sel $dst_unused $src0_sel $src1_sel"
1622 string ret = dst#args#sdwa;
1626 // Function that checks if instruction supports DPP and SDWA
1627 class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
1628 ValueType Src1VT = i32> {
1629 bit ret = !if(!eq(NumSrcArgs, 3),
1630 0, // NumSrcArgs == 3 - No DPP or SDWA for VOP3
1631 !if(!eq(DstVT.Size, 64),
1632 0, // 64-bit dst - No DPP or SDWA for 64-bit operands
1633 !if(!eq(Src0VT.Size, 64),
1635 !if(!eq(Src0VT.Size, 64),
1644 class BitOr<bit a, bit b> {
1645 bit ret = !if(a, 1, !if(b, 1, 0));
1648 class BitAnd<bit a, bit b> {
1649 bit ret = !if(a, !if(b, 1, 0), 0);
1652 class VOPProfile <list<ValueType> _ArgVT> {
1654 field list<ValueType> ArgVT = _ArgVT;
1656 field ValueType DstVT = ArgVT[0];
1657 field ValueType Src0VT = ArgVT[1];
1658 field ValueType Src1VT = ArgVT[2];
1659 field ValueType Src2VT = ArgVT[3];
1660 field RegisterOperand DstRC = getVALUDstForVT<DstVT>.ret;
1661 field RegisterOperand DstRCDPP = getVALUDstForVT<DstVT>.ret;
1662 field RegisterOperand DstRCSDWA = getSDWADstForVT<DstVT>.ret;
1663 field RegisterOperand Src0RC32 = getVOPSrc0ForVT<Src0VT>.ret;
1664 field RegisterClass Src1RC32 = getVregSrcForVT<Src1VT>.ret;
1665 field RegisterOperand Src0RC64 = getVOP3SrcForVT<Src0VT>.ret;
1666 field RegisterOperand Src1RC64 = getVOP3SrcForVT<Src1VT>.ret;
1667 field RegisterOperand Src2RC64 = getVOP3SrcForVT<Src2VT>.ret;
1668 field RegisterClass Src0DPP = getVregSrcForVT<Src0VT>.ret;
1669 field RegisterClass Src1DPP = getVregSrcForVT<Src1VT>.ret;
1670 field RegisterOperand Src0SDWA = getSDWASrcForVT<Src0VT>.ret;
1671 field RegisterOperand Src1SDWA = getSDWASrcForVT<Src0VT>.ret;
1672 field Operand Src0Mod = getSrcMod<Src0VT>.ret;
1673 field Operand Src1Mod = getSrcMod<Src1VT>.ret;
1674 field Operand Src2Mod = getSrcMod<Src2VT>.ret;
1675 field Operand Src0ModDPP = getSrcModExt<Src0VT>.ret;
1676 field Operand Src1ModDPP = getSrcModExt<Src1VT>.ret;
1677 field Operand Src0ModSDWA = getSrcModSDWA<Src0VT>.ret;
1678 field Operand Src1ModSDWA = getSrcModSDWA<Src1VT>.ret;
1681 field bit HasDst = !if(!eq(DstVT.Value, untyped.Value), 0, 1);
1682 field bit HasDst32 = HasDst;
1683 field bit EmitDst = HasDst; // force dst encoding, see v_movreld_b32 special case
1684 field int NumSrcArgs = getNumSrcArgs<Src0VT, Src1VT, Src2VT>.ret;
1685 field bit HasSrc0 = !if(!eq(Src0VT.Value, untyped.Value), 0, 1);
1686 field bit HasSrc1 = !if(!eq(Src1VT.Value, untyped.Value), 0, 1);
1687 field bit HasSrc2 = !if(!eq(Src2VT.Value, untyped.Value), 0, 1);
1689 // TODO: Modifiers logic is somewhat adhoc here, to be refined later
1690 field bit HasModifiers = isModifierType<Src0VT>.ret;
1692 field bit HasSrc0FloatMods = isFloatType<Src0VT>.ret;
1693 field bit HasSrc1FloatMods = isFloatType<Src1VT>.ret;
1694 field bit HasSrc2FloatMods = isFloatType<Src2VT>.ret;
1696 field bit HasSrc0IntMods = isIntType<Src0VT>.ret;
1697 field bit HasSrc1IntMods = isIntType<Src1VT>.ret;
1698 field bit HasSrc2IntMods = isIntType<Src2VT>.ret;
1700 field bit HasSrc0Mods = HasModifiers;
1701 field bit HasSrc1Mods = !if(HasModifiers, BitOr<HasSrc1FloatMods, HasSrc1IntMods>.ret, 0);
1702 field bit HasSrc2Mods = !if(HasModifiers, BitOr<HasSrc2FloatMods, HasSrc2IntMods>.ret, 0);
1704 field bit HasClamp = HasModifiers;
1705 field bit HasSDWAClamp = EmitDst;
1706 field bit HasFPClamp = BitAnd<isFloatType<DstVT>.ret, HasClamp>.ret;
1707 field bit HasIntClamp = !if(isFloatType<DstVT>.ret, 0, HasClamp);
1708 field bit HasClampLo = HasClamp;
1709 field bit HasClampHi = BitAnd<isPackedType<DstVT>.ret, HasClamp>.ret;
1710 field bit HasHigh = 0;
1712 field bit IsPacked = isPackedType<Src0VT>.ret;
1713 field bit HasOpSel = IsPacked;
1714 field bit HasOMod = !if(HasOpSel, 0, isFloatType<DstVT>.ret);
1715 field bit HasSDWAOMod = isFloatType<DstVT>.ret;
1717 field bit HasExt = getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret;
1718 field bit HasSDWA9 = HasExt;
1720 field Operand Src0PackedMod = !if(HasSrc0FloatMods, PackedF16InputMods, PackedI16InputMods);
1721 field Operand Src1PackedMod = !if(HasSrc1FloatMods, PackedF16InputMods, PackedI16InputMods);
1722 field Operand Src2PackedMod = !if(HasSrc2FloatMods, PackedF16InputMods, PackedI16InputMods);
1724 field dag Outs = !if(HasDst,(outs DstRC:$vdst),(outs));
1726 // VOP3b instructions are a special case with a second explicit
1727 // output. This is manually overridden for them.
1728 field dag Outs32 = Outs;
1729 field dag Outs64 = Outs;
1730 field dag OutsDPP = getOutsExt<HasDst, DstVT, DstRCDPP>.ret;
1731 field dag OutsSDWA = getOutsSDWA<HasDst, DstVT, DstRCSDWA>.ret;
1733 field dag Ins32 = getIns32<Src0RC32, Src1RC32, NumSrcArgs>.ret;
1734 field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
1735 HasIntClamp, HasModifiers, HasOMod, Src0Mod, Src1Mod,
1737 field dag InsVOP3P = getInsVOP3P<Src0RC64, Src1RC64, Src2RC64,
1738 NumSrcArgs, HasClamp,
1739 Src0PackedMod, Src1PackedMod, Src2PackedMod>.ret;
1740 field dag InsVOP3OpSel = getInsVOP3OpSel<Src0RC64, Src1RC64, Src2RC64,
1743 getOpSelMod<Src0VT>.ret,
1744 getOpSelMod<Src1VT>.ret,
1745 getOpSelMod<Src2VT>.ret>.ret;
1746 field dag InsDPP = getInsDPP<DstRCDPP, Src0DPP, Src1DPP, NumSrcArgs,
1747 HasModifiers, Src0ModDPP, Src1ModDPP>.ret;
1748 field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs,
1749 HasSDWAOMod, Src0ModSDWA, Src1ModSDWA,
1753 field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret;
1754 field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasIntClamp, HasModifiers, HasOMod, DstVT>.ret;
1755 field string AsmVOP3P = getAsmVOP3P<HasDst, NumSrcArgs, HasModifiers, HasClamp, DstVT>.ret;
1756 field string AsmVOP3OpSel = getAsmVOP3OpSel<NumSrcArgs,
1760 HasSrc2FloatMods>.ret;
1761 field string AsmDPP = getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
1762 field string AsmSDWA = getAsmSDWA<HasDst, NumSrcArgs, DstVT>.ret;
1763 field string AsmSDWA9 = getAsmSDWA9<HasDst, HasSDWAOMod, NumSrcArgs, DstVT>.ret;
1766 class VOP_NO_EXT <VOPProfile p> : VOPProfile <p.ArgVT> {
1771 def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>;
1772 def VOP_F16_I16 : VOPProfile <[f16, i16, untyped, untyped]>;
1773 def VOP_I16_F16 : VOPProfile <[i16, f16, untyped, untyped]>;
1775 def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>;
1776 def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i16, untyped]>;
1777 def VOP_F16_F16_I32 : VOPProfile <[f16, f16, i32, untyped]>;
1778 def VOP_I16_I16_I16 : VOPProfile <[i16, i16, i16, untyped]>;
1780 def VOP_I16_I16_I16_I16 : VOPProfile <[i16, i16, i16, i16, untyped]>;
1781 def VOP_F16_F16_F16_F16 : VOPProfile <[f16, f16, f16, f16, untyped]>;
1783 def VOP_I32_I16_I16_I32 : VOPProfile <[i32, i16, i16, i32, untyped]>;
1785 def VOP_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, untyped]>;
1786 def VOP_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, untyped]>;
1787 def VOP_B32_F16_F16 : VOPProfile <[i32, f16, f16, untyped]>;
1789 def VOP_V2F16_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, v2f16]>;
1790 def VOP_V2I16_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, v2i16]>;
1792 def VOP_F32_V2F16_V2F16_V2F16 : VOPProfile <[f32, v2f16, v2f16, v2f16]>;
1794 def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>;
1796 def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>;
1797 def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>;
1798 def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>;
1799 def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>;
1800 def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>;
1801 def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>;
1802 def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>;
1803 def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>;
1804 def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>;
1805 def VOP_F16_F32 : VOPProfile <[f16, f32, untyped, untyped]>;
1806 def VOP_F32_F16 : VOPProfile <[f32, f16, untyped, untyped]>;
1808 def VOP_F32_F32_F16 : VOPProfile <[f32, f32, f16, untyped]>;
1809 def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>;
1810 def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>;
1811 def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>;
1812 def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>;
1813 def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>;
1814 def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>;
1815 def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>;
1816 def VOP_V2F16_F32_F32 : VOPProfile <[v2f16, f32, f32, untyped]>;
1817 def VOP_F32_F16_F16_F16 : VOPProfile <[f32, f16, f16, f16]>;
1819 def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>;
1820 def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>;
1821 def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>;
1823 def VOP_F16_F32_F16_F32 : VOPProfile <[f16, f32, f16, f32]>;
1824 def VOP_F32_F32_F16_F16 : VOPProfile <[f32, f32, f16, f16]>;
1825 def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>;
1826 def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>;
1827 def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>;
1828 def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>;
1829 def VOP_I32_F32_I32_I32 : VOPProfile <[i32, f32, i32, i32]>;
1830 def VOP_I64_I64_I32_I64 : VOPProfile <[i64, i64, i32, i64]>;
1831 def VOP_V4I32_I64_I32_V4I32 : VOPProfile <[v4i32, i64, i32, v4i32]>;
1833 def VOP_F32_V2F16_V2F16_F32 : VOPProfile <[f32, v2f16, v2f16, f32]>;
1834 def VOP_I32_V2I16_V2I16_I32 : VOPProfile <[i32, v2i16, v2i16, i32]>;
1836 class Commutable_REV <string revOp, bit isOrig> {
1837 string RevOp = revOp;
1838 bit IsOrig = isOrig;
1841 class AtomicNoRet <string noRetOp, bit isRet> {
1842 string NoRetOp = noRetOp;
1846 //===----------------------------------------------------------------------===//
1847 // Interpolation opcodes
1848 //===----------------------------------------------------------------------===//
1850 class VINTRPDstOperand <RegisterClass rc> : RegisterOperand <rc, "printVINTRPDst">;
1852 class VINTRP_Pseudo <string opName, dag outs, dag ins, list<dag> pattern> :
1853 VINTRPCommon <outs, ins, "", pattern>,
1854 SIMCInstr<opName, SIEncodingFamily.NONE> {
1856 let isCodeGenOnly = 1;
1859 class VINTRP_Real_si <bits <2> op, string opName, dag outs, dag ins,
1861 VINTRPCommon <outs, ins, asm, []>,
1863 SIMCInstr<opName, SIEncodingFamily.SI> {
1864 let AssemblerPredicate = SIAssemblerPredicate;
1865 let DecoderNamespace = "SICI";
1866 let DisableDecoder = DisableSIDecoder;
1869 class VINTRP_Real_vi <bits <2> op, string opName, dag outs, dag ins,
1871 VINTRPCommon <outs, ins, asm, []>,
1873 SIMCInstr<opName, SIEncodingFamily.VI> {
1874 let AssemblerPredicate = VIAssemblerPredicate;
1875 let DecoderNamespace = "VI";
1876 let DisableDecoder = DisableVIDecoder;
1879 multiclass VINTRP_m <bits <2> op, dag outs, dag ins, string asm,
1880 list<dag> pattern = []> {
1881 def "" : VINTRP_Pseudo <NAME, outs, ins, pattern>;
1883 def _si : VINTRP_Real_si <op, NAME, outs, ins, asm>;
1885 def _vi : VINTRP_Real_vi <op, NAME, outs, ins, asm>;
1888 //===----------------------------------------------------------------------===//
1889 // Vector instruction mappings
1890 //===----------------------------------------------------------------------===//
1892 // Maps an opcode in e32 form to its e64 equivalent
1893 def getVOPe64 : InstrMapping {
1894 let FilterClass = "VOP";
1895 let RowFields = ["OpName"];
1896 let ColFields = ["Size", "VOP3"];
1897 let KeyCol = ["4", "0"];
1898 let ValueCols = [["8", "1"]];
1901 // Maps an opcode in e64 form to its e32 equivalent
1902 def getVOPe32 : InstrMapping {
1903 let FilterClass = "VOP";
1904 let RowFields = ["OpName"];
1905 let ColFields = ["Size", "VOP3"];
1906 let KeyCol = ["8", "1"];
1907 let ValueCols = [["4", "0"]];
1910 // Maps ordinary instructions to their SDWA counterparts
1911 def getSDWAOp : InstrMapping {
1912 let FilterClass = "VOP";
1913 let RowFields = ["OpName"];
1914 let ColFields = ["AsmVariantName"];
1915 let KeyCol = ["Default"];
1916 let ValueCols = [["SDWA"]];
1919 // Maps SDWA instructions to their ordinary counterparts
1920 def getBasicFromSDWAOp : InstrMapping {
1921 let FilterClass = "VOP";
1922 let RowFields = ["OpName"];
1923 let ColFields = ["AsmVariantName"];
1924 let KeyCol = ["SDWA"];
1925 let ValueCols = [["Default"]];
1928 // Maps an commuted opcode to its original version
1929 def getCommuteOrig : InstrMapping {
1930 let FilterClass = "Commutable_REV";
1931 let RowFields = ["RevOp"];
1932 let ColFields = ["IsOrig"];
1934 let ValueCols = [["1"]];
1937 // Maps an original opcode to its commuted version
1938 def getCommuteRev : InstrMapping {
1939 let FilterClass = "Commutable_REV";
1940 let RowFields = ["RevOp"];
1941 let ColFields = ["IsOrig"];
1943 let ValueCols = [["0"]];
1946 def getMCOpcodeGen : InstrMapping {
1947 let FilterClass = "SIMCInstr";
1948 let RowFields = ["PseudoInstr"];
1949 let ColFields = ["Subtarget"];
1950 let KeyCol = [!cast<string>(SIEncodingFamily.NONE)];
1951 let ValueCols = [[!cast<string>(SIEncodingFamily.SI)],
1952 [!cast<string>(SIEncodingFamily.VI)],
1953 [!cast<string>(SIEncodingFamily.SDWA)],
1954 [!cast<string>(SIEncodingFamily.SDWA9)],
1955 // GFX80 encoding is added to work around a multiple matching
1956 // issue for buffer instructions with unpacked d16 data. This
1957 // does not actually change the encoding, and thus may be
1959 [!cast<string>(SIEncodingFamily.GFX80)],
1960 [!cast<string>(SIEncodingFamily.GFX9)]];
1963 // Get equivalent SOPK instruction.
1964 def getSOPKOp : InstrMapping {
1965 let FilterClass = "SOPKInstTable";
1966 let RowFields = ["BaseCmpOp"];
1967 let ColFields = ["IsSOPK"];
1969 let ValueCols = [["1"]];
1972 def getAddr64Inst : InstrMapping {
1973 let FilterClass = "MUBUFAddr64Table";
1974 let RowFields = ["OpName"];
1975 let ColFields = ["IsAddr64"];
1977 let ValueCols = [["1"]];
1980 def getMUBUFNoLdsInst : InstrMapping {
1981 let FilterClass = "MUBUFLdsTable";
1982 let RowFields = ["OpName"];
1983 let ColFields = ["IsLds"];
1985 let ValueCols = [["0"]];
1988 // Maps an atomic opcode to its version with a return value.
1989 def getAtomicRetOp : InstrMapping {
1990 let FilterClass = "AtomicNoRet";
1991 let RowFields = ["NoRetOp"];
1992 let ColFields = ["IsRet"];
1994 let ValueCols = [["1"]];
1997 // Maps an atomic opcode to its returnless version.
1998 def getAtomicNoRetOp : InstrMapping {
1999 let FilterClass = "AtomicNoRet";
2000 let RowFields = ["NoRetOp"];
2001 let ColFields = ["IsRet"];
2003 let ValueCols = [["0"]];
2006 include "SIInstructions.td"
2008 include "DSInstructions.td"
2009 include "MIMGInstructions.td"