]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/SIInstrInfo.td
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r301441, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / AMDGPU / SIInstrInfo.td
1 //===-- SIInstrInfo.td - SI Instruction Infos -------------*- tablegen -*--===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 def isCI : Predicate<"Subtarget->getGeneration() "
10                       ">= SISubtarget::SEA_ISLANDS">;
11 def isCIOnly : Predicate<"Subtarget->getGeneration() =="
12                          "SISubtarget::SEA_ISLANDS">,
13   AssemblerPredicate <"FeatureSeaIslands">;
14
15 def DisableInst : Predicate <"false">, AssemblerPredicate<"FeatureDisable">;
16
17 // Execpt for the NONE field, this must be kept in sync with the
18 // SIEncodingFamily enum in AMDGPUInstrInfo.cpp
19 def SIEncodingFamily {
20   int NONE = -1;
21   int SI = 0;
22   int VI = 1;
23 }
24
25 //===----------------------------------------------------------------------===//
26 // SI DAG Nodes
27 //===----------------------------------------------------------------------===//
28
29 def SIload_constant : SDNode<"AMDGPUISD::LOAD_CONSTANT",
30   SDTypeProfile<1, 2, [SDTCisVT<0, f32>, SDTCisVT<1, v4i32>, SDTCisVT<2, i32>]>,
31                       [SDNPMayLoad, SDNPMemOperand]
32 >;
33
34 def SIatomic_inc : SDNode<"AMDGPUISD::ATOMIC_INC", SDTAtomic2,
35   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
36 >;
37
38 def SIatomic_dec : SDNode<"AMDGPUISD::ATOMIC_DEC", SDTAtomic2,
39   [SDNPMayLoad, SDNPMayStore, SDNPMemOperand, SDNPHasChain]
40 >;
41
42 def SItbuffer_store : SDNode<"AMDGPUISD::TBUFFER_STORE_FORMAT",
43   SDTypeProfile<0, 13,
44     [SDTCisVT<0, v4i32>,   // rsrc(SGPR)
45      SDTCisVT<1, iAny>,   // vdata(VGPR)
46      SDTCisVT<2, i32>,    // num_channels(imm)
47      SDTCisVT<3, i32>,    // vaddr(VGPR)
48      SDTCisVT<4, i32>,    // soffset(SGPR)
49      SDTCisVT<5, i32>,    // inst_offset(imm)
50      SDTCisVT<6, i32>,    // dfmt(imm)
51      SDTCisVT<7, i32>,    // nfmt(imm)
52      SDTCisVT<8, i32>,    // offen(imm)
53      SDTCisVT<9, i32>,    // idxen(imm)
54      SDTCisVT<10, i32>,   // glc(imm)
55      SDTCisVT<11, i32>,   // slc(imm)
56      SDTCisVT<12, i32>    // tfe(imm)
57     ]>,
58   [SDNPMayStore, SDNPMemOperand, SDNPHasChain]
59 >;
60
61 def SDTBufferLoad : SDTypeProfile<1, 5,
62     [                    // vdata
63      SDTCisVT<1, v4i32>, // rsrc
64      SDTCisVT<2, i32>,   // vindex
65      SDTCisVT<3, i32>,   // offset
66      SDTCisVT<4, i1>,    // glc
67      SDTCisVT<5, i1>]>;  // slc
68
69 def SIbuffer_load : SDNode <"AMDGPUISD::BUFFER_LOAD", SDTBufferLoad,
70                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
71 def SIbuffer_load_format : SDNode <"AMDGPUISD::BUFFER_LOAD_FORMAT", SDTBufferLoad,
72                             [SDNPMemOperand, SDNPHasChain, SDNPMayLoad]>;
73
74 class SDSample<string opcode> : SDNode <opcode,
75   SDTypeProfile<1, 4, [SDTCisVT<0, v4f32>, SDTCisVT<2, v8i32>,
76                        SDTCisVT<3, v4i32>, SDTCisVT<4, i32>]>
77 >;
78
79 def SIsample : SDSample<"AMDGPUISD::SAMPLE">;
80 def SIsampleb : SDSample<"AMDGPUISD::SAMPLEB">;
81 def SIsampled : SDSample<"AMDGPUISD::SAMPLED">;
82 def SIsamplel : SDSample<"AMDGPUISD::SAMPLEL">;
83
84 def SIpc_add_rel_offset : SDNode<"AMDGPUISD::PC_ADD_REL_OFFSET",
85   SDTypeProfile<1, 2, [SDTCisVT<0, iPTR>, SDTCisSameAs<0,1>, SDTCisSameAs<0,2>]>
86 >;
87
88 //===----------------------------------------------------------------------===//
89 // PatFrags for global memory operations
90 //===----------------------------------------------------------------------===//
91
92 defm atomic_inc_global : global_binary_atomic_op<SIatomic_inc>;
93 defm atomic_dec_global : global_binary_atomic_op<SIatomic_dec>;
94
95 //===----------------------------------------------------------------------===//
96 // SDNodes and PatFrag for local loads and stores to enable s_mov_b32 m0, -1
97 // to be glued to the memory instructions.
98 //===----------------------------------------------------------------------===//
99
100 def SIld_local : SDNode <"ISD::LOAD", SDTLoad,
101   [SDNPHasChain, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
102 >;
103
104 def si_ld_local : PatFrag <(ops node:$ptr), (SIld_local node:$ptr), [{
105   return cast<LoadSDNode>(N)->getAddressSpace() == AMDGPUASI.LOCAL_ADDRESS;
106 }]>;
107
108 def si_load_local : PatFrag <(ops node:$ptr), (si_ld_local node:$ptr), [{
109   return cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED &&
110          cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD;
111 }]>;
112
113 def si_load_local_align8 : Aligned8Bytes <
114   (ops node:$ptr), (si_load_local node:$ptr)
115 >;
116
117 def si_sextload_local : PatFrag <(ops node:$ptr), (si_ld_local node:$ptr), [{
118   return cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
119 }]>;
120 def si_az_extload_local : AZExtLoadBase <si_ld_local>;
121
122 multiclass SIExtLoadLocal <PatFrag ld_node> {
123
124   def _i8 : PatFrag <(ops node:$ptr), (ld_node node:$ptr),
125                      [{return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i8;}]
126   >;
127
128   def _i16 : PatFrag <(ops node:$ptr), (ld_node node:$ptr),
129                      [{return cast<LoadSDNode>(N)->getMemoryVT() == MVT::i16;}]
130   >;
131 }
132
133 defm si_sextload_local : SIExtLoadLocal <si_sextload_local>;
134 defm si_az_extload_local : SIExtLoadLocal <si_az_extload_local>;
135
136 def SIst_local : SDNode <"ISD::STORE", SDTStore,
137   [SDNPHasChain, SDNPMayStore, SDNPMemOperand, SDNPInGlue]
138 >;
139
140 def si_st_local : PatFrag <
141   (ops node:$val, node:$ptr), (SIst_local node:$val, node:$ptr), [{
142   return cast<StoreSDNode>(N)->getAddressSpace() == AMDGPUASI.LOCAL_ADDRESS;
143 }]>;
144
145 def si_store_local : PatFrag <
146   (ops node:$val, node:$ptr), (si_st_local node:$val, node:$ptr), [{
147   return cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED &&
148          !cast<StoreSDNode>(N)->isTruncatingStore();
149 }]>;
150
151 def si_store_local_align8 : Aligned8Bytes <
152   (ops node:$val, node:$ptr), (si_store_local node:$val, node:$ptr)
153 >;
154
155 def si_truncstore_local : PatFrag <
156   (ops node:$val, node:$ptr), (si_st_local node:$val, node:$ptr), [{
157   return cast<StoreSDNode>(N)->isTruncatingStore();
158 }]>;
159
160 def si_truncstore_local_i8 : PatFrag <
161   (ops node:$val, node:$ptr), (si_truncstore_local node:$val, node:$ptr), [{
162   return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i8;
163 }]>;
164
165 def si_truncstore_local_i16 : PatFrag <
166   (ops node:$val, node:$ptr), (si_truncstore_local node:$val, node:$ptr), [{
167   return cast<StoreSDNode>(N)->getMemoryVT() == MVT::i16;
168 }]>;
169
170 def si_setcc_uniform : PatFrag <
171   (ops node:$lhs, node:$rhs, node:$cond),
172   (setcc node:$lhs, node:$rhs, node:$cond), [{
173   for (SDNode *Use : N->uses()) {
174     if (Use->isMachineOpcode() || Use->getOpcode() != ISD::CopyToReg)
175       return false;
176
177     unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
178     if (Reg != AMDGPU::SCC)
179       return false;
180   }
181   return true;
182 }]>;
183
184 def si_uniform_br : PatFrag <
185   (ops node:$cond, node:$bb), (brcond node:$cond, node:$bb), [{
186   return isUniformBr(N);
187 }]>;
188
189 def si_uniform_br_scc : PatFrag <
190   (ops node:$cond, node:$bb), (si_uniform_br node:$cond, node:$bb), [{
191   return isCBranchSCC(N);
192 }]>;
193
194 def lshr_rev : PatFrag <
195   (ops node:$src1, node:$src0),
196   (srl $src0, $src1)
197 >;
198
199 def ashr_rev : PatFrag <
200   (ops node:$src1, node:$src0),
201   (sra $src0, $src1)
202 >;
203
204 def lshl_rev : PatFrag <
205   (ops node:$src1, node:$src0),
206   (shl $src0, $src1)
207 >;
208
209 multiclass SIAtomicM0Glue2 <string op_name, bit is_amdgpu = 0> {
210
211   def _glue : SDNode <
212     !if(is_amdgpu, "AMDGPUISD", "ISD")#"::ATOMIC_"#op_name, SDTAtomic2,
213     [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
214   >;
215
216   def _local : local_binary_atomic_op <!cast<SDNode>(NAME#"_glue")>;
217 }
218
219 defm si_atomic_load_add : SIAtomicM0Glue2 <"LOAD_ADD">;
220 defm si_atomic_load_sub : SIAtomicM0Glue2 <"LOAD_SUB">;
221 defm si_atomic_inc : SIAtomicM0Glue2 <"INC", 1>;
222 defm si_atomic_dec : SIAtomicM0Glue2 <"DEC", 1>;
223 defm si_atomic_load_and : SIAtomicM0Glue2 <"LOAD_AND">;
224 defm si_atomic_load_min : SIAtomicM0Glue2 <"LOAD_MIN">;
225 defm si_atomic_load_max : SIAtomicM0Glue2 <"LOAD_MAX">;
226 defm si_atomic_load_or : SIAtomicM0Glue2 <"LOAD_OR">;
227 defm si_atomic_load_xor : SIAtomicM0Glue2 <"LOAD_XOR">;
228 defm si_atomic_load_umin : SIAtomicM0Glue2 <"LOAD_UMIN">;
229 defm si_atomic_load_umax : SIAtomicM0Glue2 <"LOAD_UMAX">;
230 defm si_atomic_swap : SIAtomicM0Glue2 <"SWAP">;
231
232 def si_atomic_cmp_swap_glue : SDNode <"ISD::ATOMIC_CMP_SWAP", SDTAtomic3,
233   [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand, SDNPInGlue]
234 >;
235
236 defm si_atomic_cmp_swap : AtomicCmpSwapLocal <si_atomic_cmp_swap_glue>;
237
238 def as_i1imm : SDNodeXForm<imm, [{
239   return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i1);
240 }]>;
241
242 def as_i8imm : SDNodeXForm<imm, [{
243   return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i8);
244 }]>;
245
246 def as_i16imm : SDNodeXForm<imm, [{
247   return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i16);
248 }]>;
249
250 def as_i32imm: SDNodeXForm<imm, [{
251   return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i32);
252 }]>;
253
254 def as_i64imm: SDNodeXForm<imm, [{
255   return CurDAG->getTargetConstant(N->getSExtValue(), SDLoc(N), MVT::i64);
256 }]>;
257
258 // Copied from the AArch64 backend:
259 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
260 return CurDAG->getTargetConstant(
261   N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
262 }]>;
263
264 def frameindex_to_targetframeindex : SDNodeXForm<frameindex, [{
265   auto FI = cast<FrameIndexSDNode>(N);
266   return CurDAG->getTargetFrameIndex(FI->getIndex(), MVT::i32);
267 }]>;
268
269 // Copied from the AArch64 backend:
270 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
271 return CurDAG->getTargetConstant(
272   N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
273 }]>;
274
275 def SIMM16bit : PatLeaf <(imm),
276   [{return isInt<16>(N->getSExtValue());}]
277 >;
278
279 class InlineImm <ValueType vt> : PatLeaf <(vt imm), [{
280   return isInlineImmediate(N);
281 }]>;
282
283 class InlineFPImm <ValueType vt> : PatLeaf <(vt fpimm), [{
284   return isInlineImmediate(N);
285 }]>;
286
287 class VGPRImm <dag frag> : PatLeaf<frag, [{
288   if (Subtarget->getGeneration() < SISubtarget::SOUTHERN_ISLANDS) {
289     return false;
290   }
291   const SIRegisterInfo *SIRI =
292       static_cast<const SIRegisterInfo *>(Subtarget->getRegisterInfo());
293   unsigned Limit = 0;
294   for (SDNode::use_iterator U = N->use_begin(), E = SDNode::use_end();
295          Limit < 10 && U != E; ++U, ++Limit) {
296     const TargetRegisterClass *RC = getOperandRegClass(*U, U.getOperandNo());
297
298     // If the register class is unknown, it could be an unknown
299     // register class that needs to be an SGPR, e.g. an inline asm
300     // constraint
301     if (!RC || SIRI->isSGPRClass(RC))
302       return false;
303   }
304
305   return Limit < 10;
306 }]>;
307
308 def NegateImm : SDNodeXForm<imm, [{
309   return CurDAG->getConstant(-N->getSExtValue(), SDLoc(N), MVT::i32);
310 }]>;
311
312 // TODO: When FP inline imm values work?
313 def NegSubInlineConst32 : ImmLeaf<i32, [{
314   return Imm < -16 && Imm >= -64;
315 }], NegateImm>;
316
317 def NegSubInlineConst16 : ImmLeaf<i16, [{
318   return Imm < -16 && Imm >= -64;
319 }], NegateImm>;
320
321 //===----------------------------------------------------------------------===//
322 // Custom Operands
323 //===----------------------------------------------------------------------===//
324
325 def SoppBrTarget : AsmOperandClass {
326   let Name = "SoppBrTarget";
327   let ParserMethod = "parseSOppBrTarget";
328 }
329
330 def sopp_brtarget : Operand<OtherVT> {
331   let EncoderMethod = "getSOPPBrEncoding";
332   let DecoderMethod = "decodeSoppBrTarget";
333   let OperandType = "OPERAND_PCREL";
334   let ParserMatchClass = SoppBrTarget;
335 }
336
337 def si_ga : Operand<iPTR>;
338
339 def InterpSlotMatchClass : AsmOperandClass {
340   let Name = "InterpSlot";
341   let PredicateMethod = "isInterpSlot";
342   let ParserMethod = "parseInterpSlot";
343   let RenderMethod = "addImmOperands";
344 }
345
346 def InterpSlot : Operand<i32> {
347   let PrintMethod = "printInterpSlot";
348   let ParserMatchClass = InterpSlotMatchClass;
349   let OperandType = "OPERAND_IMMEDIATE";
350 }
351
352 def AttrMatchClass : AsmOperandClass {
353   let Name = "Attr";
354   let PredicateMethod = "isInterpAttr";
355   let ParserMethod = "parseInterpAttr";
356   let RenderMethod = "addImmOperands";
357 }
358
359 // It appears to be necessary to create a separate operand for this to
360 // be able to parse attr<num> with no space.
361 def Attr : Operand<i32> {
362   let PrintMethod = "printInterpAttr";
363   let ParserMatchClass = AttrMatchClass;
364   let OperandType = "OPERAND_IMMEDIATE";
365 }
366
367 def AttrChanMatchClass : AsmOperandClass {
368   let Name = "AttrChan";
369   let PredicateMethod = "isAttrChan";
370   let RenderMethod = "addImmOperands";
371 }
372
373 def AttrChan : Operand<i32> {
374   let PrintMethod = "printInterpAttrChan";
375   let ParserMatchClass = AttrChanMatchClass;
376   let OperandType = "OPERAND_IMMEDIATE";
377 }
378
379 def SendMsgMatchClass : AsmOperandClass {
380   let Name = "SendMsg";
381   let PredicateMethod = "isSendMsg";
382   let ParserMethod = "parseSendMsgOp";
383   let RenderMethod = "addImmOperands";
384 }
385
386 def ExpTgtMatchClass : AsmOperandClass {
387   let Name = "ExpTgt";
388   let PredicateMethod = "isExpTgt";
389   let ParserMethod = "parseExpTgt";
390   let RenderMethod = "printExpTgt";
391 }
392
393 def SendMsgImm : Operand<i32> {
394   let PrintMethod = "printSendMsg";
395   let ParserMatchClass = SendMsgMatchClass;
396 }
397
398 def SWaitMatchClass : AsmOperandClass {
399   let Name = "SWaitCnt";
400   let RenderMethod = "addImmOperands";
401   let ParserMethod = "parseSWaitCntOps";
402 }
403
404 def VReg32OrOffClass : AsmOperandClass {
405   let Name = "VReg32OrOff";
406   let ParserMethod = "parseVReg32OrOff";
407 }
408
409 def WAIT_FLAG : Operand <i32> {
410   let ParserMatchClass = SWaitMatchClass;
411   let PrintMethod = "printWaitFlag";
412 }
413
414 include "SIInstrFormats.td"
415 include "VIInstrFormats.td"
416
417 // ===----------------------------------------------------------------------===//
418 // ExpSrc* Special cases for exp src operands which are printed as
419 // "off" depending on en operand.
420 // ===----------------------------------------------------------------------===//
421
422 def ExpSrc0 : RegisterOperand<VGPR_32> {
423   let PrintMethod = "printExpSrc0";
424   let ParserMatchClass = VReg32OrOffClass;
425 }
426
427 def ExpSrc1 : RegisterOperand<VGPR_32> {
428   let PrintMethod = "printExpSrc1";
429   let ParserMatchClass = VReg32OrOffClass;
430 }
431
432 def ExpSrc2 : RegisterOperand<VGPR_32> {
433   let PrintMethod = "printExpSrc2";
434   let ParserMatchClass = VReg32OrOffClass;
435 }
436
437 def ExpSrc3 : RegisterOperand<VGPR_32> {
438   let PrintMethod = "printExpSrc3";
439   let ParserMatchClass = VReg32OrOffClass;
440 }
441
442 class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass {
443   let Name = "Imm"#CName;
444   let PredicateMethod = "is"#CName;
445   let ParserMethod = !if(Optional, "parseOptionalOperand", "parse"#CName);
446   let RenderMethod = "addImmOperands";
447   let IsOptional = Optional;
448   let DefaultMethod = !if(Optional, "default"#CName, ?);
449 }
450
451 class NamedOperandBit<string Name, AsmOperandClass MatchClass> : Operand<i1> {
452   let PrintMethod = "print"#Name;
453   let ParserMatchClass = MatchClass;
454 }
455
456 class NamedOperandU8<string Name, AsmOperandClass MatchClass> : Operand<i8> {
457   let PrintMethod = "print"#Name;
458   let ParserMatchClass = MatchClass;
459 }
460
461 class NamedOperandU16<string Name, AsmOperandClass MatchClass> : Operand<i16> {
462   let PrintMethod = "print"#Name;
463   let ParserMatchClass = MatchClass;
464 }
465
466 class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
467   let PrintMethod = "print"#Name;
468   let ParserMatchClass = MatchClass;
469 }
470
471 class NamedOperandU32Default0<string Name, AsmOperandClass MatchClass> :
472   OperandWithDefaultOps<i32, (ops (i32 0))> {
473   let PrintMethod = "print"#Name;
474   let ParserMatchClass = MatchClass;
475 }
476
477 let OperandType = "OPERAND_IMMEDIATE" in {
478
479 def offen : NamedOperandBit<"Offen", NamedMatchClass<"Offen">>;
480 def idxen : NamedOperandBit<"Idxen", NamedMatchClass<"Idxen">>;
481 def addr64 : NamedOperandBit<"Addr64", NamedMatchClass<"Addr64">>;
482
483 def offset : NamedOperandU16<"Offset", NamedMatchClass<"Offset">>;
484 def offset0 : NamedOperandU8<"Offset0", NamedMatchClass<"Offset0">>;
485 def offset1 : NamedOperandU8<"Offset1", NamedMatchClass<"Offset1">>;
486
487 def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>;
488
489 def omod : NamedOperandU32<"OModSI", NamedMatchClass<"OModSI">>;
490 def clampmod : NamedOperandBit<"ClampSI", NamedMatchClass<"ClampSI">>;
491
492 def GLC : NamedOperandBit<"GLC", NamedMatchClass<"GLC">>;
493 def slc : NamedOperandBit<"SLC", NamedMatchClass<"SLC">>;
494 def tfe : NamedOperandBit<"TFE", NamedMatchClass<"TFE">>;
495 def unorm : NamedOperandBit<"UNorm", NamedMatchClass<"UNorm">>;
496 def da : NamedOperandBit<"DA", NamedMatchClass<"DA">>;
497 def r128 : NamedOperandBit<"R128", NamedMatchClass<"R128">>;
498 def lwe : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>;
499 def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>;
500 def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>;
501
502 def dmask : NamedOperandU16<"DMask", NamedMatchClass<"DMask">>;
503
504 def dpp_ctrl : NamedOperandU32<"DPPCtrl", NamedMatchClass<"DPPCtrl", 0>>;
505 def row_mask : NamedOperandU32<"RowMask", NamedMatchClass<"RowMask">>;
506 def bank_mask : NamedOperandU32<"BankMask", NamedMatchClass<"BankMask">>;
507 def bound_ctrl : NamedOperandBit<"BoundCtrl", NamedMatchClass<"BoundCtrl">>;
508
509 def dst_sel : NamedOperandU32<"SDWADstSel", NamedMatchClass<"SDWADstSel">>;
510 def src0_sel : NamedOperandU32<"SDWASrc0Sel", NamedMatchClass<"SDWASrc0Sel">>;
511 def src1_sel : NamedOperandU32<"SDWASrc1Sel", NamedMatchClass<"SDWASrc1Sel">>;
512 def dst_unused : NamedOperandU32<"SDWADstUnused", NamedMatchClass<"SDWADstUnused">>;
513
514 def op_sel : NamedOperandU32Default0<"OpSel", NamedMatchClass<"OpSel">>;
515 def op_sel_hi : NamedOperandU32Default0<"OpSelHi", NamedMatchClass<"OpSelHi">>;
516 def neg_lo : NamedOperandU32Default0<"NegLo", NamedMatchClass<"NegLo">>;
517 def neg_hi : NamedOperandU32Default0<"NegHi", NamedMatchClass<"NegHi">>;
518
519 def hwreg : NamedOperandU16<"Hwreg", NamedMatchClass<"Hwreg", 0>>;
520
521 def exp_tgt : NamedOperandU8<"ExpTgt", NamedMatchClass<"ExpTgt", 0>> {
522
523 }
524
525 } // End OperandType = "OPERAND_IMMEDIATE"
526
527 class KImmMatchClass<int size> : AsmOperandClass {
528   let Name = "KImmFP"#size;
529   let PredicateMethod = "isKImmFP"#size;
530   let ParserMethod = "parseImm";
531   let RenderMethod = "addKImmFP"#size#"Operands";
532 }
533
534 class kimmOperand<ValueType vt> : Operand<vt> {
535   let OperandNamespace = "AMDGPU";
536   let OperandType = "OPERAND_KIMM"#vt.Size;
537   let PrintMethod = "printU"#vt.Size#"ImmOperand";
538   let ParserMatchClass = !cast<AsmOperandClass>("KImmFP"#vt.Size#"MatchClass");
539 }
540
541 // 32-bit VALU immediate operand that uses the constant bus.
542 def KImmFP32MatchClass : KImmMatchClass<32>;
543 def f32kimm : kimmOperand<i32>;
544
545 // 32-bit VALU immediate operand with a 16-bit value that uses the
546 // constant bus.
547 def KImmFP16MatchClass : KImmMatchClass<16>;
548 def f16kimm : kimmOperand<i16>;
549
550
551 def VOPDstS64 : VOPDstOperand <SReg_64>;
552
553 class FPInputModsMatchClass <int opSize> : AsmOperandClass {
554   let Name = "RegOrImmWithFP"#opSize#"InputMods";
555   let ParserMethod = "parseRegOrImmWithFPInputMods";
556   let PredicateMethod = "isRegOrImmWithFP"#opSize#"InputMods";
557 }
558
559 def FP16InputModsMatchClass : FPInputModsMatchClass<16>;
560 def FP32InputModsMatchClass : FPInputModsMatchClass<32>;
561 def FP64InputModsMatchClass : FPInputModsMatchClass<64>;
562
563 class InputMods <AsmOperandClass matchClass> : Operand <i32> {
564   let OperandNamespace = "AMDGPU";
565   let OperandType = "OPERAND_INPUT_MODS";
566   let ParserMatchClass = matchClass;
567 }
568
569 class FPInputMods <FPInputModsMatchClass matchClass> : InputMods <matchClass> {
570   let PrintMethod = "printOperandAndFPInputMods";
571 }
572
573 def FP16InputMods : FPInputMods<FP16InputModsMatchClass>;
574 def FP32InputMods : FPInputMods<FP32InputModsMatchClass>;
575 def FP64InputMods : FPInputMods<FP64InputModsMatchClass>;
576
577 class IntInputModsMatchClass <int opSize> : AsmOperandClass {
578   let Name = "RegOrImmWithInt"#opSize#"InputMods";
579   let ParserMethod = "parseRegOrImmWithIntInputMods";
580   let PredicateMethod = "isRegOrImmWithInt"#opSize#"InputMods";
581 }
582 def Int32InputModsMatchClass : IntInputModsMatchClass<32>;
583 def Int64InputModsMatchClass : IntInputModsMatchClass<64>;
584
585 class IntInputMods <IntInputModsMatchClass matchClass> : InputMods <matchClass> {
586   let PrintMethod = "printOperandAndIntInputMods";
587 }
588 def Int32InputMods : IntInputMods<Int32InputModsMatchClass>;
589 def Int64InputMods : IntInputMods<Int64InputModsMatchClass>;
590
591 def FPVRegInputModsMatchClass : AsmOperandClass {
592   let Name = "VRegWithFPInputMods";
593   let ParserMethod = "parseRegWithFPInputMods";
594   let PredicateMethod = "isVReg";
595 }
596
597 def FPVRegInputMods : InputMods <FPVRegInputModsMatchClass> {
598   let PrintMethod = "printOperandAndFPInputMods";
599 }
600
601 def IntVRegInputModsMatchClass : AsmOperandClass {
602   let Name = "VRegWithIntInputMods";
603   let ParserMethod = "parseRegWithIntInputMods";
604   let PredicateMethod = "isVReg";
605 }
606
607 def IntVRegInputMods : InputMods <IntVRegInputModsMatchClass> {
608   let PrintMethod = "printOperandAndIntInputMods";
609 }
610
611 class PackedFPInputModsMatchClass <int opSize> : AsmOperandClass {
612   let Name = "PackedFP"#opSize#"InputMods";
613   let ParserMethod = "parseRegOrImm";
614   let PredicateMethod = "isRegOrImm";
615 //  let PredicateMethod = "isPackedFP"#opSize#"InputMods";
616 }
617
618 class PackedIntInputModsMatchClass <int opSize> : AsmOperandClass {
619   let Name = "PackedInt"#opSize#"InputMods";
620   let ParserMethod = "parseRegOrImm";
621   let PredicateMethod = "isRegOrImm";
622 //  let PredicateMethod = "isPackedInt"#opSize#"InputMods";
623 }
624
625 def PackedF16InputModsMatchClass : PackedFPInputModsMatchClass<16>;
626 def PackedI16InputModsMatchClass : PackedIntInputModsMatchClass<16>;
627
628 class PackedFPInputMods <PackedFPInputModsMatchClass matchClass> : InputMods <matchClass> {
629 //  let PrintMethod = "printPackedFPInputMods";
630 }
631
632 class PackedIntInputMods <PackedIntInputModsMatchClass matchClass> : InputMods <matchClass> {
633   //let PrintMethod = "printPackedIntInputMods";
634 }
635
636 def PackedF16InputMods : PackedFPInputMods<PackedF16InputModsMatchClass>;
637 def PackedI16InputMods : PackedIntInputMods<PackedI16InputModsMatchClass>;
638
639 //===----------------------------------------------------------------------===//
640 // Complex patterns
641 //===----------------------------------------------------------------------===//
642
643 def DS1Addr1Offset : ComplexPattern<i32, 2, "SelectDS1Addr1Offset">;
644 def DS64Bit4ByteAligned : ComplexPattern<i32, 3, "SelectDS64Bit4ByteAligned">;
645
646 def MOVRELOffset : ComplexPattern<i32, 2, "SelectMOVRELOffset">;
647
648 def VOP3Mods0 : ComplexPattern<untyped, 4, "SelectVOP3Mods0">;
649 def VOP3Mods0Clamp : ComplexPattern<untyped, 3, "SelectVOP3Mods0Clamp">;
650 def VOP3Mods0Clamp0OMod : ComplexPattern<untyped, 4, "SelectVOP3Mods0Clamp0OMod">;
651 def VOP3Mods  : ComplexPattern<untyped, 2, "SelectVOP3Mods">;
652 def VOP3NoMods : ComplexPattern<untyped, 1, "SelectVOP3NoMods">;
653 // VOP3Mods, but the input source is known to never be NaN.
654 def VOP3Mods_nnan : ComplexPattern<fAny, 2, "SelectVOP3Mods_NNaN">;
655
656 def VOP3OMods : ComplexPattern<untyped, 3, "SelectVOP3OMods">;
657
658 def VOP3PMods  : ComplexPattern<untyped, 2, "SelectVOP3PMods">;
659 def VOP3PMods0 : ComplexPattern<untyped, 3, "SelectVOP3PMods0">;
660
661
662 //===----------------------------------------------------------------------===//
663 // SI assembler operands
664 //===----------------------------------------------------------------------===//
665
666 def SIOperand {
667   int ZERO = 0x80;
668   int VCC = 0x6A;
669   int FLAT_SCR = 0x68;
670 }
671
672 // This should be kept in sync with SISrcMods enum
673 def SRCMODS {
674   int NONE = 0;
675   int NEG = 1;
676   int ABS = 2;
677   int NEG_ABS = 3;
678
679   int NEG_HI = ABS;
680   int OP_SEL_0 = 4;
681   int OP_SEL_1 = 8;
682 }
683
684 def DSTCLAMP {
685   int NONE = 0;
686   int ENABLE = 1;
687 }
688
689 def DSTOMOD {
690   int NONE = 0;
691 }
692
693 def TRAPID{
694   int LLVM_TRAP = 2;
695   int LLVM_DEBUG_TRAP = 3;
696 }
697
698 //===----------------------------------------------------------------------===//
699 //
700 // SI Instruction multiclass helpers.
701 //
702 // Instructions with _32 take 32-bit operands.
703 // Instructions with _64 take 64-bit operands.
704 //
705 // VOP_* instructions can use either a 32-bit or 64-bit encoding.  The 32-bit
706 // encoding is the standard encoding, but instruction that make use of
707 // any of the instruction modifiers must use the 64-bit encoding.
708 //
709 // Instructions with _e32 use the 32-bit encoding.
710 // Instructions with _e64 use the 64-bit encoding.
711 //
712 //===----------------------------------------------------------------------===//
713
714 class SIMCInstr <string pseudo, int subtarget> {
715   string PseudoInstr = pseudo;
716   int Subtarget = subtarget;
717 }
718
719 //===----------------------------------------------------------------------===//
720 // EXP classes
721 //===----------------------------------------------------------------------===//
722
723 class EXP_Helper<bit done, SDPatternOperator node = null_frag> : EXPCommon<
724   (outs),
725   (ins exp_tgt:$tgt,
726        ExpSrc0:$src0, ExpSrc1:$src1, ExpSrc2:$src2, ExpSrc3:$src3,
727        exp_vm:$vm, exp_compr:$compr, i8imm:$en),
728   "exp$tgt $src0, $src1, $src2, $src3"#!if(done, " done", "")#"$compr$vm",
729   [(node (i8 timm:$tgt), (i8 timm:$en),
730          f32:$src0, f32:$src1, f32:$src2, f32:$src3,
731          (i1 timm:$compr), (i1 timm:$vm))]> {
732   let AsmMatchConverter = "cvtExp";
733 }
734
735 // Split EXP instruction into EXP and EXP_DONE so we can set
736 // mayLoad for done=1.
737 multiclass EXP_m<bit done, SDPatternOperator node> {
738   let mayLoad = done in {
739     let isPseudo = 1, isCodeGenOnly = 1 in {
740       def "" : EXP_Helper<done, node>,
741                SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.NONE>;
742     }
743
744     let done = done in {
745       def _si : EXP_Helper<done>,
746                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.SI>,
747                 EXPe {
748         let AssemblerPredicates = [isSICI];
749         let DecoderNamespace = "SICI";
750         let DisableDecoder = DisableSIDecoder;
751       }
752
753       def _vi : EXP_Helper<done>,
754                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.VI>,
755                 EXPe_vi {
756         let AssemblerPredicates = [isVI];
757         let DecoderNamespace = "VI";
758         let DisableDecoder = DisableVIDecoder;
759       }
760     }
761   }
762 }
763
764 //===----------------------------------------------------------------------===//
765 // Vector ALU classes
766 //===----------------------------------------------------------------------===//
767
768 class getNumSrcArgs<ValueType Src0, ValueType Src1, ValueType Src2> {
769   int ret =
770     !if (!eq(Src0.Value, untyped.Value),      0,
771       !if (!eq(Src1.Value, untyped.Value),    1,   // VOP1
772          !if (!eq(Src2.Value, untyped.Value), 2,   // VOP2
773                                               3))); // VOP3
774 }
775
776 // Returns the register class to use for the destination of VOP[123C]
777 // instructions for the given VT.
778 class getVALUDstForVT<ValueType VT> {
779   RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand<VGPR_32>,
780                           !if(!eq(VT.Size, 128), VOPDstOperand<VReg_128>,
781                             !if(!eq(VT.Size, 64), VOPDstOperand<VReg_64>,
782                               !if(!eq(VT.Size, 16), VOPDstOperand<VGPR_32>,
783                               VOPDstOperand<SReg_64>)))); // else VT == i1
784 }
785
786 // Returns the register class to use for source 0 of VOP[12C]
787 // instructions for the given VT.
788 class getVOPSrc0ForVT<ValueType VT> {
789   bit isFP = !if(!eq(VT.Value, f16.Value), 1,
790              !if(!eq(VT.Value, v2f16.Value), 1,
791              !if(!eq(VT.Value, f32.Value), 1,
792              !if(!eq(VT.Value, f64.Value), 1,
793              0))));
794
795   RegisterOperand ret =
796     !if(isFP,
797       !if(!eq(VT.Size, 64),
798          VSrc_f64,
799          !if(!eq(VT.Value, f16.Value),
800             VSrc_f16,
801             !if(!eq(VT.Value, v2f16.Value),
802                VCSrc_v2f16,
803                VSrc_f32
804             )
805          )
806        ),
807        !if(!eq(VT.Size, 64),
808           VSrc_b64,
809           !if(!eq(VT.Value, i16.Value),
810              VSrc_b16,
811              !if(!eq(VT.Value, v2i16.Value),
812                 VCSrc_v2b16,
813                 VSrc_b32
814              )
815           )
816        )
817     );
818 }
819
820 // Returns the vreg register class to use for source operand given VT
821 class getVregSrcForVT<ValueType VT> {
822   RegisterClass ret = !if(!eq(VT.Size, 128), VReg_128,
823                         !if(!eq(VT.Size, 64), VReg_64, VGPR_32));
824 }
825
826
827 // Returns the register class to use for sources of VOP3 instructions for the
828 // given VT.
829 class getVOP3SrcForVT<ValueType VT> {
830   bit isFP = !if(!eq(VT.Value, f16.Value), 1,
831              !if(!eq(VT.Value, v2f16.Value), 1,
832              !if(!eq(VT.Value, f32.Value), 1,
833              !if(!eq(VT.Value, f64.Value), 1,
834              0))));
835   RegisterOperand ret =
836   !if(!eq(VT.Size, 128),
837      VSrc_128,
838      !if(!eq(VT.Size, 64),
839         !if(isFP,
840            VCSrc_f64,
841            VCSrc_b64),
842         !if(!eq(VT.Value, i1.Value),
843            SCSrc_b64,
844            !if(isFP,
845               !if(!eq(VT.Value, f16.Value),
846                  VCSrc_f16,
847                  !if(!eq(VT.Value, v2f16.Value),
848                     VCSrc_v2f16,
849                     VCSrc_f32
850                  )
851               ),
852               !if(!eq(VT.Value, i16.Value),
853                  VCSrc_b16,
854                  !if(!eq(VT.Value, v2i16.Value),
855                     VCSrc_v2b16,
856                     VCSrc_b32
857                  )
858               )
859            )
860         )
861      )
862   );
863 }
864
865 // Returns 1 if the source arguments have modifiers, 0 if they do not.
866 // XXX - do f16 instructions?
867 class isFloatType<ValueType SrcVT> {
868   bit ret =
869     !if(!eq(SrcVT.Value, f16.Value), 1,
870     !if(!eq(SrcVT.Value, f32.Value), 1,
871     !if(!eq(SrcVT.Value, f64.Value), 1,
872     !if(!eq(SrcVT.Value, v2f16.Value), 1,
873     0))));
874 }
875
876 class isIntType<ValueType SrcVT> {
877   bit ret =
878     !if(!eq(SrcVT.Value, i16.Value), 1,
879     !if(!eq(SrcVT.Value, i32.Value), 1,
880     !if(!eq(SrcVT.Value, i64.Value), 1,
881     0)));
882 }
883
884 class isPackedType<ValueType SrcVT> {
885   bit ret =
886     !if(!eq(SrcVT.Value, v2i16.Value), 1,
887       !if(!eq(SrcVT.Value, v2f16.Value), 1, 0)
888     );
889 }
890
891 // Float or packed int
892 class isModifierType<ValueType SrcVT> {
893   bit ret =
894     !if(!eq(SrcVT.Value, f16.Value), 1,
895     !if(!eq(SrcVT.Value, f32.Value), 1,
896     !if(!eq(SrcVT.Value, f64.Value), 1,
897     !if(!eq(SrcVT.Value, v2f16.Value), 1,
898     !if(!eq(SrcVT.Value, v2i16.Value), 1,
899     0)))));
900 }
901
902 // Return type of input modifiers operand for specified input operand
903 class getSrcMod <ValueType VT> {
904   bit isFP = !if(!eq(VT.Value, f16.Value), 1,
905                !if(!eq(VT.Value, f32.Value), 1,
906                !if(!eq(VT.Value, f64.Value), 1,
907                0)));
908   bit isPacked = isPackedType<VT>.ret;
909   Operand ret =  !if(!eq(VT.Size, 64),
910                      !if(isFP, FP64InputMods, Int64InputMods),
911                        !if(isFP,
912                          !if(!eq(VT.Value, f16.Value),
913                             FP16InputMods,
914                             FP32InputMods
915                           ),
916                          Int32InputMods)
917                      );
918 }
919
920 // Return type of input modifiers operand specified input operand for SDWA/DPP
921 class getSrcModExt <ValueType VT> {
922     bit isFP = !if(!eq(VT.Value, f16.Value), 1,
923                !if(!eq(VT.Value, f32.Value), 1,
924                !if(!eq(VT.Value, f64.Value), 1,
925                0)));
926   Operand ret = !if(isFP, FPVRegInputMods, IntVRegInputMods);
927 }
928
929 // Returns the input arguments for VOP[12C] instructions for the given SrcVT.
930 class getIns32 <RegisterOperand Src0RC, RegisterClass Src1RC, int NumSrcArgs> {
931   dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0),               // VOP1
932             !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2
933                                     (ins)));
934 }
935
936 // Returns the input arguments for VOP3 instructions for the given SrcVT.
937 class getIns64 <RegisterOperand Src0RC, RegisterOperand Src1RC,
938                 RegisterOperand Src2RC, int NumSrcArgs,
939                 bit HasModifiers, bit HasOMod,
940                 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
941
942   dag ret =
943     !if (!eq(NumSrcArgs, 0),
944       // VOP1 without input operands (V_NOP, V_CLREXCP)
945       (ins),
946       /* else */
947     !if (!eq(NumSrcArgs, 1),
948       !if (!eq(HasModifiers, 1),
949         // VOP1 with modifiers
950         (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
951              clampmod:$clamp, omod:$omod)
952       /* else */,
953         // VOP1 without modifiers
954         (ins Src0RC:$src0)
955       /* endif */ ),
956     !if (!eq(NumSrcArgs, 2),
957       !if (!eq(HasModifiers, 1),
958         // VOP 2 with modifiers
959         !if( !eq(HasOMod, 1),
960           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
961                Src1Mod:$src1_modifiers, Src1RC:$src1,
962                clampmod:$clamp, omod:$omod),
963            (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
964                Src1Mod:$src1_modifiers, Src1RC:$src1,
965                clampmod:$clamp))
966       /* else */,
967         // VOP2 without modifiers
968         (ins Src0RC:$src0, Src1RC:$src1)
969       /* endif */ )
970     /* NumSrcArgs == 3 */,
971       !if (!eq(HasModifiers, 1),
972         // VOP3 with modifiers
973         !if (!eq(HasOMod, 1),
974           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
975                Src1Mod:$src1_modifiers, Src1RC:$src1,
976                Src2Mod:$src2_modifiers, Src2RC:$src2,
977                clampmod:$clamp, omod:$omod),
978           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
979                Src1Mod:$src1_modifiers, Src1RC:$src1,
980                Src2Mod:$src2_modifiers, Src2RC:$src2,
981                clampmod:$clamp))
982       /* else */,
983         // VOP3 without modifiers
984         (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2)
985       /* endif */ ))));
986 }
987
988 /// XXX - src1 may only allow VGPRs?
989
990 // The modifiers (except clamp) are dummy operands for the benefit of
991 // printing and parsing. They defer their values to looking at the
992 // srcN_modifiers for what to print.
993 class getInsVOP3P <RegisterOperand Src0RC, RegisterOperand Src1RC,
994                    RegisterOperand Src2RC, int NumSrcArgs,
995                    bit HasClamp,
996                    Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
997   dag ret = !if (!eq(NumSrcArgs, 2),
998     !if (HasClamp,
999       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1000            Src1Mod:$src1_modifiers, Src1RC:$src1,
1001            clampmod:$clamp,
1002            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1003            neg_lo:$neg_lo, neg_hi:$neg_hi),
1004       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1005            Src1Mod:$src1_modifiers, Src1RC:$src1,
1006            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1007            neg_lo:$neg_lo, neg_hi:$neg_hi)),
1008     // else NumSrcArgs == 3
1009     !if (HasClamp,
1010       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1011            Src1Mod:$src1_modifiers, Src1RC:$src1,
1012            Src2Mod:$src2_modifiers, Src2RC:$src2,
1013            clampmod:$clamp,
1014            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1015            neg_lo:$neg_lo, neg_hi:$neg_hi),
1016       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1017            Src1Mod:$src1_modifiers, Src1RC:$src1,
1018            Src2Mod:$src2_modifiers, Src2RC:$src2,
1019            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1020            neg_lo:$neg_lo, neg_hi:$neg_hi))
1021   );
1022 }
1023
1024 class getInsDPP <RegisterClass Src0RC, RegisterClass Src1RC, int NumSrcArgs,
1025                  bit HasModifiers, Operand Src0Mod, Operand Src1Mod> {
1026
1027   dag ret = !if (!eq(NumSrcArgs, 0),
1028                 // VOP1 without input operands (V_NOP)
1029                 (ins dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1030                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl),
1031             !if (!eq(NumSrcArgs, 1),
1032               !if (!eq(HasModifiers, 1),
1033                 // VOP1_DPP with modifiers
1034                 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1035                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1036                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1037               /* else */,
1038                 // VOP1_DPP without modifiers
1039                 (ins Src0RC:$src0, dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1040                 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1041               /* endif */)
1042               /* NumSrcArgs == 2 */,
1043               !if (!eq(HasModifiers, 1),
1044                 // VOP2_DPP with modifiers
1045                 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1046                      Src1Mod:$src1_modifiers, Src1RC:$src1,
1047                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1048                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1049               /* else */,
1050                 // VOP2_DPP without modifiers
1051                 (ins Src0RC:$src0, Src1RC:$src1, dpp_ctrl:$dpp_ctrl,
1052                 row_mask:$row_mask, bank_mask:$bank_mask,
1053                 bound_ctrl:$bound_ctrl)
1054              /* endif */)));
1055 }
1056
1057 class getInsSDWA <RegisterClass Src0RC, RegisterClass Src1RC, int NumSrcArgs,
1058                   bit HasFloatModifiers, Operand Src0Mod, Operand Src1Mod,
1059                   ValueType DstVT> {
1060
1061   dag ret = !if(!eq(NumSrcArgs, 0),
1062                // VOP1 without input operands (V_NOP)
1063                (ins),
1064             !if(!eq(NumSrcArgs, 1),
1065                (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1066                     clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1067                     src0_sel:$src0_sel),
1068             !if(!eq(NumSrcArgs, 2),
1069                !if(!eq(DstVT.Size, 1),
1070                   // VOPC_SDWA with modifiers
1071                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1072                        Src1Mod:$src1_modifiers, Src1RC:$src1,
1073                        clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel),
1074                   // VOP2_SDWA or VOPC_SDWA with modifiers
1075                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1076                        Src1Mod:$src1_modifiers, Src1RC:$src1,
1077                        clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1078                        src0_sel:$src0_sel, src1_sel:$src1_sel)),
1079             (ins)/* endif */)));
1080 }
1081
1082 // Outs for DPP and SDWA
1083 class getOutsExt <bit HasDst, ValueType DstVT, RegisterOperand DstRCDPP> {
1084   dag ret = !if(HasDst,
1085                 !if(!eq(DstVT.Size, 1),
1086                     (outs), // no dst for VOPC, we use "vcc"-token as dst in SDWA VOPC instructions
1087                     (outs DstRCDPP:$vdst)),
1088                 (outs)); // V_NOP
1089 }
1090
1091 // Returns the assembly string for the inputs and outputs of a VOP[12C]
1092 // instruction.  This does not add the _e32 suffix, so it can be reused
1093 // by getAsm64.
1094 class getAsm32 <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> {
1095   string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1096   string src0 = ", $src0";
1097   string src1 = ", $src1";
1098   string src2 = ", $src2";
1099   string ret = !if(HasDst, dst, "") #
1100                !if(!eq(NumSrcArgs, 1), src0, "") #
1101                !if(!eq(NumSrcArgs, 2), src0#src1, "") #
1102                !if(!eq(NumSrcArgs, 3), src0#src1#src2, "");
1103 }
1104
1105 // Returns the assembly string for the inputs and outputs of a VOP3
1106 // instruction.
1107 class getAsm64 <bit HasDst, int NumSrcArgs, bit HasModifiers,
1108                 bit HasOMod, ValueType DstVT = i32> {
1109   string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1110   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1111   string src1 = !if(!eq(NumSrcArgs, 1), "",
1112                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1113                                            " $src1_modifiers,"));
1114   string src2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", "");
1115   string ret =
1116   !if(!eq(HasModifiers, 0),
1117       getAsm32<HasDst, NumSrcArgs, DstVT>.ret,
1118       dst#", "#src0#src1#src2#"$clamp"#!if(HasOMod, "$omod", ""));
1119 }
1120
1121 // Returns the assembly string for the inputs and outputs of a VOP3P
1122 // instruction.
1123 class getAsmVOP3P <bit HasDst, int NumSrcArgs, bit HasModifiers,
1124                    bit HasClamp, ValueType DstVT = i32> {
1125   string dst = " $vdst";
1126   string src0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
1127   string src1 = !if(!eq(NumSrcArgs, 1), "",
1128                    !if(!eq(NumSrcArgs, 2), " $src1",
1129                                            " $src1,"));
1130   string src2 = !if(!eq(NumSrcArgs, 3), " $src2", "");
1131
1132   string mods = !if(HasModifiers, "$neg_lo$neg_hi", "");
1133   string clamp = !if(HasClamp, "$clamp", "");
1134
1135   // Each modifier is printed as an array of bits for each operand, so
1136   // all operands are printed as part of src0_modifiers.
1137   string ret = dst#", "#src0#src1#src2#"$op_sel$op_sel_hi"#mods#clamp;
1138 }
1139
1140 class getAsmDPP <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> {
1141   string dst = !if(HasDst,
1142                    !if(!eq(DstVT.Size, 1),
1143                        "$sdst",
1144                        "$vdst"),
1145                     ""); // use $sdst for VOPC
1146   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1147   string src1 = !if(!eq(NumSrcArgs, 1), "",
1148                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1149                                            " $src1_modifiers,"));
1150   string args = !if(!eq(HasModifiers, 0),
1151                      getAsm32<0, NumSrcArgs, DstVT>.ret,
1152                      ", "#src0#src1);
1153   string ret = dst#args#" $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
1154 }
1155
1156 class getAsmSDWA <bit HasDst, int NumSrcArgs, bit HasFloatModifiers,
1157                   ValueType DstVT = i32> {
1158   string dst = !if(HasDst,
1159                    !if(!eq(DstVT.Size, 1),
1160                        " vcc", // use vcc token as dst for VOPC instructioins
1161                        "$vdst"),
1162                     "");
1163   string src0 = "$src0_modifiers";
1164   string src1 = "$src1_modifiers";
1165   string args = !if(!eq(NumSrcArgs, 0),
1166                     "",
1167                     !if(!eq(NumSrcArgs, 1),
1168                         ", "#src0#"$clamp",
1169                         ", "#src0#", "#src1#"$clamp"
1170                      )
1171                 );
1172   string sdwa = !if(!eq(NumSrcArgs, 0),
1173                     "",
1174                     !if(!eq(NumSrcArgs, 1),
1175                         " $dst_sel $dst_unused $src0_sel",
1176                         !if(!eq(DstVT.Size, 1),
1177                             " $src0_sel $src1_sel", // No dst_sel and dst_unused for VOPC
1178                             " $dst_sel $dst_unused $src0_sel $src1_sel"
1179                         )
1180                     )
1181                 );
1182   string ret = dst#args#sdwa;
1183 }
1184
1185 // Function that checks if instruction supports DPP and SDWA
1186 class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
1187                  ValueType Src1VT = i32> {
1188   bit ret = !if(!eq(NumSrcArgs, 3),
1189                 0, // NumSrcArgs == 3 - No DPP or SDWA for VOP3
1190                 !if(!eq(DstVT.Size, 64),
1191                     0, // 64-bit dst - No DPP or SDWA for 64-bit operands
1192                     !if(!eq(Src0VT.Size, 64),
1193                         0, // 64-bit src0
1194                         !if(!eq(Src0VT.Size, 64),
1195                             0, // 64-bit src2
1196                             1
1197                         )
1198                     )
1199                 )
1200             );
1201 }
1202
1203 class BitOr<bit a, bit b> {
1204   bit ret = !if(a, 1, !if(b, 1, 0));
1205 }
1206
1207 class BitAnd<bit a, bit b> {
1208   bit ret = !if(a, !if(b, 1, 0), 0);
1209 }
1210
1211 class VOPProfile <list<ValueType> _ArgVT> {
1212
1213   field list<ValueType> ArgVT = _ArgVT;
1214
1215   field ValueType DstVT = ArgVT[0];
1216   field ValueType Src0VT = ArgVT[1];
1217   field ValueType Src1VT = ArgVT[2];
1218   field ValueType Src2VT = ArgVT[3];
1219   field RegisterOperand DstRC = getVALUDstForVT<DstVT>.ret;
1220   field RegisterOperand DstRCDPP = getVALUDstForVT<DstVT>.ret;
1221   field RegisterOperand DstRCSDWA = getVALUDstForVT<DstVT>.ret;
1222   field RegisterOperand Src0RC32 = getVOPSrc0ForVT<Src0VT>.ret;
1223   field RegisterClass Src1RC32 = getVregSrcForVT<Src1VT>.ret;
1224   field RegisterOperand Src0RC64 = getVOP3SrcForVT<Src0VT>.ret;
1225   field RegisterOperand Src1RC64 = getVOP3SrcForVT<Src1VT>.ret;
1226   field RegisterOperand Src2RC64 = getVOP3SrcForVT<Src2VT>.ret;
1227   field RegisterClass Src0DPP = getVregSrcForVT<Src0VT>.ret;
1228   field RegisterClass Src1DPP = getVregSrcForVT<Src1VT>.ret;
1229   field RegisterClass Src0SDWA = getVregSrcForVT<Src0VT>.ret;
1230   field RegisterClass Src1SDWA = getVregSrcForVT<Src1VT>.ret;
1231   field Operand Src0Mod = getSrcMod<Src0VT>.ret;
1232   field Operand Src1Mod = getSrcMod<Src1VT>.ret;
1233   field Operand Src2Mod = getSrcMod<Src2VT>.ret;
1234   field Operand Src0ModDPP = getSrcModExt<Src0VT>.ret;
1235   field Operand Src1ModDPP = getSrcModExt<Src1VT>.ret;
1236   field Operand Src0ModSDWA = getSrcModExt<Src0VT>.ret;
1237   field Operand Src1ModSDWA = getSrcModExt<Src1VT>.ret;
1238
1239
1240   field bit HasDst = !if(!eq(DstVT.Value, untyped.Value), 0, 1);
1241   field bit HasDst32 = HasDst;
1242   field bit EmitDst = HasDst; // force dst encoding, see v_movreld_b32 special case
1243   field int NumSrcArgs = getNumSrcArgs<Src0VT, Src1VT, Src2VT>.ret;
1244   field bit HasSrc0 = !if(!eq(Src0VT.Value, untyped.Value), 0, 1);
1245   field bit HasSrc1 = !if(!eq(Src1VT.Value, untyped.Value), 0, 1);
1246   field bit HasSrc2 = !if(!eq(Src2VT.Value, untyped.Value), 0, 1);
1247
1248   // TODO: Modifiers logic is somewhat adhoc here, to be refined later
1249   field bit HasModifiers = isModifierType<Src0VT>.ret;
1250
1251   field bit HasSrc0FloatMods = isFloatType<Src0VT>.ret;
1252   field bit HasSrc1FloatMods = isFloatType<Src1VT>.ret;
1253   field bit HasSrc2FloatMods = isFloatType<Src2VT>.ret;
1254
1255   field bit HasSrc0IntMods = isIntType<Src0VT>.ret;
1256   field bit HasSrc1IntMods = isIntType<Src1VT>.ret;
1257   field bit HasSrc2IntMods = isIntType<Src2VT>.ret;
1258
1259   field bit HasSrc0Mods = HasModifiers;
1260   field bit HasSrc1Mods = !if(HasModifiers, BitOr<HasSrc1FloatMods, HasSrc1IntMods>.ret, 0);
1261   field bit HasSrc2Mods = !if(HasModifiers, BitOr<HasSrc2FloatMods, HasSrc2IntMods>.ret, 0);
1262
1263   field bit HasClamp = HasModifiers;
1264   field bit HasSDWAClamp = HasSrc0;
1265   field bit HasFPClamp = BitAnd<isFloatType<DstVT>.ret, HasClamp>.ret;
1266
1267   field bit IsPacked = isPackedType<Src0VT>.ret;
1268   field bit HasOpSel = IsPacked;
1269   field bit HasOMod = !if(HasOpSel, 0, HasModifiers);
1270
1271   field bit HasExt = getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret;
1272
1273   field Operand Src0PackedMod = !if(HasSrc0FloatMods, PackedF16InputMods, PackedI16InputMods);
1274   field Operand Src1PackedMod = !if(HasSrc1FloatMods, PackedF16InputMods, PackedI16InputMods);
1275   field Operand Src2PackedMod = !if(HasSrc2FloatMods, PackedF16InputMods, PackedI16InputMods);
1276
1277   field dag Outs = !if(HasDst,(outs DstRC:$vdst),(outs));
1278
1279   // VOP3b instructions are a special case with a second explicit
1280   // output. This is manually overridden for them.
1281   field dag Outs32 = Outs;
1282   field dag Outs64 = Outs;
1283   field dag OutsDPP = getOutsExt<HasDst, DstVT, DstRCDPP>.ret;
1284   field dag OutsSDWA = getOutsExt<HasDst, DstVT, DstRCSDWA>.ret;
1285
1286   field dag Ins32 = getIns32<Src0RC32, Src1RC32, NumSrcArgs>.ret;
1287   field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
1288                              HasModifiers, HasOMod, Src0Mod, Src1Mod,
1289                              Src2Mod>.ret;
1290   field dag InsVOP3P = getInsVOP3P<Src0RC64, Src1RC64, Src2RC64,
1291                                    NumSrcArgs, HasClamp,
1292                                    Src0PackedMod, Src1PackedMod, Src2PackedMod>.ret;
1293
1294   field dag InsDPP = getInsDPP<Src0DPP, Src1DPP, NumSrcArgs,
1295                                HasModifiers, Src0ModDPP, Src1ModDPP>.ret;
1296   field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs,
1297                                  HasModifiers, Src0ModSDWA, Src1ModSDWA,
1298                                  DstVT>.ret;
1299
1300   field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret;
1301   field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasModifiers, HasOMod, DstVT>.ret;
1302   field string AsmVOP3P = getAsmVOP3P<HasDst, NumSrcArgs, HasModifiers, HasClamp, DstVT>.ret;
1303   field string AsmDPP = getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
1304   field string AsmSDWA = getAsmSDWA<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
1305 }
1306
1307 class VOP_NO_EXT <VOPProfile p> : VOPProfile <p.ArgVT> {
1308   let HasExt = 0;
1309 }
1310
1311 def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>;
1312 def VOP_F16_I16 : VOPProfile <[f16, i16, untyped, untyped]>;
1313 def VOP_I16_F16 : VOPProfile <[i16, f16, untyped, untyped]>;
1314
1315 def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>;
1316 def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i16, untyped]>;
1317 def VOP_F16_F16_I32 : VOPProfile <[f16, f16, i32, untyped]>;
1318 def VOP_I16_I16_I16 : VOPProfile <[i16, i16, i16, untyped]>;
1319
1320 def VOP_I16_I16_I16_I16 : VOPProfile <[i16, i16, i16, i16, untyped]>;
1321 def VOP_F16_F16_F16_F16 : VOPProfile <[f16, f16, f16, f16, untyped]>;
1322
1323 def VOP_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, untyped]>;
1324 def VOP_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, untyped]>;
1325 def VOP_B32_F16_F16 : VOPProfile <[i32, f16, f16, untyped]>;
1326
1327 def VOP_V2F16_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, v2f16]>;
1328 def VOP_V2I16_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, v2i16]>;
1329
1330 def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>;
1331
1332 def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>;
1333 def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>;
1334 def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>;
1335 def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>;
1336 def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>;
1337 def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>;
1338 def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>;
1339 def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>;
1340 def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>;
1341 def VOP_F16_F32 : VOPProfile <[f16, f32, untyped, untyped]>;
1342 def VOP_F32_F16 : VOPProfile <[f32, f16, untyped, untyped]>;
1343
1344 def VOP_F32_F32_F16 : VOPProfile <[f32, f32, f16, untyped]>;
1345 def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>;
1346 def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>;
1347 def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>;
1348 def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>;
1349 def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>;
1350 def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>;
1351 def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>;
1352 def VOP_V2F16_F32_F32 : VOPProfile <[v2f16, f32, f32, untyped]>;
1353
1354 def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>;
1355 def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>;
1356 def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>;
1357
1358 def VOP_F16_F32_F16_F32 : VOPProfile <[f16, f32, f16, f32]>;
1359 def VOP_F32_F32_F16_F16 : VOPProfile <[f32, f32, f16, f16]>;
1360 def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>;
1361 def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>;
1362 def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>;
1363 def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>;
1364 def VOP_I32_F32_I32_I32 : VOPProfile <[i32, f32, i32, i32]>;
1365 def VOP_I64_I64_I32_I64 : VOPProfile <[i64, i64, i32, i64]>;
1366 def VOP_V4I32_I64_I32_V4I32 : VOPProfile <[v4i32, i64, i32, v4i32]>;
1367
1368 class Commutable_REV <string revOp, bit isOrig> {
1369   string RevOp = revOp;
1370   bit IsOrig = isOrig;
1371 }
1372
1373 class AtomicNoRet <string noRetOp, bit isRet> {
1374   string NoRetOp = noRetOp;
1375   bit IsRet = isRet;
1376 }
1377
1378 //===----------------------------------------------------------------------===//
1379 // Interpolation opcodes
1380 //===----------------------------------------------------------------------===//
1381
1382 class VINTRP_Pseudo <string opName, dag outs, dag ins, list<dag> pattern> :
1383   VINTRPCommon <outs, ins, "", pattern>,
1384   SIMCInstr<opName, SIEncodingFamily.NONE> {
1385   let isPseudo = 1;
1386   let isCodeGenOnly = 1;
1387 }
1388
1389 class VINTRP_Real_si <bits <2> op, string opName, dag outs, dag ins,
1390                       string asm> :
1391   VINTRPCommon <outs, ins, asm, []>,
1392   VINTRPe <op>,
1393   SIMCInstr<opName, SIEncodingFamily.SI> {
1394   let AssemblerPredicate = SIAssemblerPredicate;
1395   let DecoderNamespace = "SICI";
1396   let DisableDecoder = DisableSIDecoder;
1397 }
1398
1399 class VINTRP_Real_vi <bits <2> op, string opName, dag outs, dag ins,
1400                       string asm> :
1401   VINTRPCommon <outs, ins, asm, []>,
1402   VINTRPe_vi <op>,
1403   SIMCInstr<opName, SIEncodingFamily.VI> {
1404   let AssemblerPredicate = VIAssemblerPredicate;
1405   let DecoderNamespace = "VI";
1406   let DisableDecoder = DisableVIDecoder;
1407 }
1408
1409 multiclass VINTRP_m <bits <2> op, dag outs, dag ins, string asm,
1410                      list<dag> pattern = []> {
1411   def "" : VINTRP_Pseudo <NAME, outs, ins, pattern>;
1412
1413   def _si : VINTRP_Real_si <op, NAME, outs, ins, asm>;
1414
1415   def _vi : VINTRP_Real_vi <op, NAME, outs, ins, asm>;
1416 }
1417
1418 //===----------------------------------------------------------------------===//
1419 // Vector instruction mappings
1420 //===----------------------------------------------------------------------===//
1421
1422 // Maps an opcode in e32 form to its e64 equivalent
1423 def getVOPe64 : InstrMapping {
1424   let FilterClass = "VOP";
1425   let RowFields = ["OpName"];
1426   let ColFields = ["Size", "VOP3"];
1427   let KeyCol = ["4", "0"];
1428   let ValueCols = [["8", "1"]];
1429 }
1430
1431 // Maps an opcode in e64 form to its e32 equivalent
1432 def getVOPe32 : InstrMapping {
1433   let FilterClass = "VOP";
1434   let RowFields = ["OpName"];
1435   let ColFields = ["Size", "VOP3"];
1436   let KeyCol = ["8", "1"];
1437   let ValueCols = [["4", "0"]];
1438 }
1439
1440 // Maps ordinary instructions to their SDWA counterparts
1441 def getSDWAOp : InstrMapping {
1442   let FilterClass = "VOP";
1443   let RowFields = ["OpName"];
1444   let ColFields = ["AsmVariantName"];
1445   let KeyCol = ["Default"];
1446   let ValueCols = [["SDWA"]];
1447 }
1448
1449 def getMaskedMIMGOp : InstrMapping {
1450   let FilterClass = "MIMG_Mask";
1451   let RowFields = ["Op"];
1452   let ColFields = ["Channels"];
1453   let KeyCol = ["4"];
1454   let ValueCols = [["1"], ["2"], ["3"] ];
1455 }
1456
1457 // Maps an commuted opcode to its original version
1458 def getCommuteOrig : InstrMapping {
1459   let FilterClass = "Commutable_REV";
1460   let RowFields = ["RevOp"];
1461   let ColFields = ["IsOrig"];
1462   let KeyCol = ["0"];
1463   let ValueCols = [["1"]];
1464 }
1465
1466 // Maps an original opcode to its commuted version
1467 def getCommuteRev : InstrMapping {
1468   let FilterClass = "Commutable_REV";
1469   let RowFields = ["RevOp"];
1470   let ColFields = ["IsOrig"];
1471   let KeyCol = ["1"];
1472   let ValueCols = [["0"]];
1473 }
1474
1475 def getMCOpcodeGen : InstrMapping {
1476   let FilterClass = "SIMCInstr";
1477   let RowFields = ["PseudoInstr"];
1478   let ColFields = ["Subtarget"];
1479   let KeyCol = [!cast<string>(SIEncodingFamily.NONE)];
1480   let ValueCols = [[!cast<string>(SIEncodingFamily.SI)],
1481                    [!cast<string>(SIEncodingFamily.VI)]];
1482 }
1483
1484 // Get equivalent SOPK instruction.
1485 def getSOPKOp : InstrMapping {
1486   let FilterClass = "SOPKInstTable";
1487   let RowFields = ["BaseCmpOp"];
1488   let ColFields = ["IsSOPK"];
1489   let KeyCol = ["0"];
1490   let ValueCols = [["1"]];
1491 }
1492
1493 def getAddr64Inst : InstrMapping {
1494   let FilterClass = "MUBUFAddr64Table";
1495   let RowFields = ["OpName"];
1496   let ColFields = ["IsAddr64"];
1497   let KeyCol = ["0"];
1498   let ValueCols = [["1"]];
1499 }
1500
1501 // Maps an atomic opcode to its version with a return value.
1502 def getAtomicRetOp : InstrMapping {
1503   let FilterClass = "AtomicNoRet";
1504   let RowFields = ["NoRetOp"];
1505   let ColFields = ["IsRet"];
1506   let KeyCol = ["0"];
1507   let ValueCols = [["1"]];
1508 }
1509
1510 // Maps an atomic opcode to its returnless version.
1511 def getAtomicNoRetOp : InstrMapping {
1512   let FilterClass = "AtomicNoRet";
1513   let RowFields = ["NoRetOp"];
1514   let ColFields = ["IsRet"];
1515   let KeyCol = ["1"];
1516   let ValueCols = [["0"]];
1517 }
1518
1519 include "SIInstructions.td"
1520 include "CIInstructions.td"
1521
1522 include "DSInstructions.td"
1523 include "MIMGInstructions.td"