]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/AMDGPU/SIInstrInfo.td
Merge libc++ trunk r300890, and update build glue.
[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 VOP3NoMods0 : ComplexPattern<untyped, 4, "SelectVOP3NoMods0">;
650 def VOP3Mods0Clamp : ComplexPattern<untyped, 3, "SelectVOP3Mods0Clamp">;
651 def VOP3Mods0Clamp0OMod : ComplexPattern<untyped, 4, "SelectVOP3Mods0Clamp0OMod">;
652 def VOP3Mods  : ComplexPattern<untyped, 2, "SelectVOP3Mods">;
653 def VOP3NoMods : ComplexPattern<untyped, 2, "SelectVOP3NoMods">;
654 // VOP3Mods, but the input source is known to never be NaN.
655 def VOP3Mods_nnan : ComplexPattern<fAny, 2, "SelectVOP3Mods_NNaN">;
656
657 def VOP3OMods : ComplexPattern<untyped, 3, "SelectVOP3OMods">;
658
659 def VOP3PMods  : ComplexPattern<untyped, 2, "SelectVOP3PMods">;
660 def VOP3PMods0 : ComplexPattern<untyped, 3, "SelectVOP3PMods0">;
661
662
663 //===----------------------------------------------------------------------===//
664 // SI assembler operands
665 //===----------------------------------------------------------------------===//
666
667 def SIOperand {
668   int ZERO = 0x80;
669   int VCC = 0x6A;
670   int FLAT_SCR = 0x68;
671 }
672
673 // This should be kept in sync with SISrcMods enum
674 def SRCMODS {
675   int NONE = 0;
676   int NEG = 1;
677   int ABS = 2;
678   int NEG_ABS = 3;
679
680   int NEG_HI = ABS;
681   int OP_SEL_0 = 4;
682   int OP_SEL_1 = 8;
683 }
684
685 def DSTCLAMP {
686   int NONE = 0;
687   int ENABLE = 1;
688 }
689
690 def DSTOMOD {
691   int NONE = 0;
692 }
693
694 def TRAPID{
695   int LLVM_TRAP = 2;
696   int LLVM_DEBUG_TRAP = 3;
697 }
698
699 //===----------------------------------------------------------------------===//
700 //
701 // SI Instruction multiclass helpers.
702 //
703 // Instructions with _32 take 32-bit operands.
704 // Instructions with _64 take 64-bit operands.
705 //
706 // VOP_* instructions can use either a 32-bit or 64-bit encoding.  The 32-bit
707 // encoding is the standard encoding, but instruction that make use of
708 // any of the instruction modifiers must use the 64-bit encoding.
709 //
710 // Instructions with _e32 use the 32-bit encoding.
711 // Instructions with _e64 use the 64-bit encoding.
712 //
713 //===----------------------------------------------------------------------===//
714
715 class SIMCInstr <string pseudo, int subtarget> {
716   string PseudoInstr = pseudo;
717   int Subtarget = subtarget;
718 }
719
720 //===----------------------------------------------------------------------===//
721 // EXP classes
722 //===----------------------------------------------------------------------===//
723
724 class EXP_Helper<bit done, SDPatternOperator node = null_frag> : EXPCommon<
725   (outs),
726   (ins exp_tgt:$tgt,
727        ExpSrc0:$src0, ExpSrc1:$src1, ExpSrc2:$src2, ExpSrc3:$src3,
728        exp_vm:$vm, exp_compr:$compr, i8imm:$en),
729   "exp$tgt $src0, $src1, $src2, $src3"#!if(done, " done", "")#"$compr$vm",
730   [(node (i8 timm:$tgt), (i8 timm:$en),
731          f32:$src0, f32:$src1, f32:$src2, f32:$src3,
732          (i1 timm:$compr), (i1 timm:$vm))]> {
733   let AsmMatchConverter = "cvtExp";
734 }
735
736 // Split EXP instruction into EXP and EXP_DONE so we can set
737 // mayLoad for done=1.
738 multiclass EXP_m<bit done, SDPatternOperator node> {
739   let mayLoad = done in {
740     let isPseudo = 1, isCodeGenOnly = 1 in {
741       def "" : EXP_Helper<done, node>,
742                SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.NONE>;
743     }
744
745     let done = done in {
746       def _si : EXP_Helper<done>,
747                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.SI>,
748                 EXPe {
749         let AssemblerPredicates = [isSICI];
750         let DecoderNamespace = "SICI";
751         let DisableDecoder = DisableSIDecoder;
752       }
753
754       def _vi : EXP_Helper<done>,
755                 SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.VI>,
756                 EXPe_vi {
757         let AssemblerPredicates = [isVI];
758         let DecoderNamespace = "VI";
759         let DisableDecoder = DisableVIDecoder;
760       }
761     }
762   }
763 }
764
765 //===----------------------------------------------------------------------===//
766 // Vector ALU classes
767 //===----------------------------------------------------------------------===//
768
769 class getNumSrcArgs<ValueType Src0, ValueType Src1, ValueType Src2> {
770   int ret =
771     !if (!eq(Src0.Value, untyped.Value),      0,
772       !if (!eq(Src1.Value, untyped.Value),    1,   // VOP1
773          !if (!eq(Src2.Value, untyped.Value), 2,   // VOP2
774                                               3))); // VOP3
775 }
776
777 // Returns the register class to use for the destination of VOP[123C]
778 // instructions for the given VT.
779 class getVALUDstForVT<ValueType VT> {
780   RegisterOperand ret = !if(!eq(VT.Size, 32), VOPDstOperand<VGPR_32>,
781                           !if(!eq(VT.Size, 128), VOPDstOperand<VReg_128>,
782                             !if(!eq(VT.Size, 64), VOPDstOperand<VReg_64>,
783                               !if(!eq(VT.Size, 16), VOPDstOperand<VGPR_32>,
784                               VOPDstOperand<SReg_64>)))); // else VT == i1
785 }
786
787 // Returns the register class to use for source 0 of VOP[12C]
788 // instructions for the given VT.
789 class getVOPSrc0ForVT<ValueType VT> {
790   bit isFP = !if(!eq(VT.Value, f16.Value), 1,
791              !if(!eq(VT.Value, v2f16.Value), 1,
792              !if(!eq(VT.Value, f32.Value), 1,
793              !if(!eq(VT.Value, f64.Value), 1,
794              0))));
795
796   RegisterOperand ret =
797     !if(isFP,
798       !if(!eq(VT.Size, 64),
799          VSrc_f64,
800          !if(!eq(VT.Value, f16.Value),
801             VSrc_f16,
802             !if(!eq(VT.Value, v2f16.Value),
803                VCSrc_v2f16,
804                VSrc_f32
805             )
806          )
807        ),
808        !if(!eq(VT.Size, 64),
809           VSrc_b64,
810           !if(!eq(VT.Value, i16.Value),
811              VSrc_b16,
812              !if(!eq(VT.Value, v2i16.Value),
813                 VCSrc_v2b16,
814                 VSrc_b32
815              )
816           )
817        )
818     );
819 }
820
821 // Returns the vreg register class to use for source operand given VT
822 class getVregSrcForVT<ValueType VT> {
823   RegisterClass ret = !if(!eq(VT.Size, 128), VReg_128,
824                         !if(!eq(VT.Size, 64), VReg_64, VGPR_32));
825 }
826
827
828 // Returns the register class to use for sources of VOP3 instructions for the
829 // given VT.
830 class getVOP3SrcForVT<ValueType VT> {
831   bit isFP = !if(!eq(VT.Value, f16.Value), 1,
832              !if(!eq(VT.Value, v2f16.Value), 1,
833              !if(!eq(VT.Value, f32.Value), 1,
834              !if(!eq(VT.Value, f64.Value), 1,
835              0))));
836   RegisterOperand ret =
837   !if(!eq(VT.Size, 128),
838      VSrc_128,
839      !if(!eq(VT.Size, 64),
840         !if(isFP,
841            VCSrc_f64,
842            VCSrc_b64),
843         !if(!eq(VT.Value, i1.Value),
844            SCSrc_b64,
845            !if(isFP,
846               !if(!eq(VT.Value, f16.Value),
847                  VCSrc_f16,
848                  !if(!eq(VT.Value, v2f16.Value),
849                     VCSrc_v2f16,
850                     VCSrc_f32
851                  )
852               ),
853               !if(!eq(VT.Value, i16.Value),
854                  VCSrc_b16,
855                  !if(!eq(VT.Value, v2i16.Value),
856                     VCSrc_v2b16,
857                     VCSrc_b32
858                  )
859               )
860            )
861         )
862      )
863   );
864 }
865
866 // Returns 1 if the source arguments have modifiers, 0 if they do not.
867 // XXX - do f16 instructions?
868 class isFloatType<ValueType SrcVT> {
869   bit ret =
870     !if(!eq(SrcVT.Value, f16.Value), 1,
871     !if(!eq(SrcVT.Value, f32.Value), 1,
872     !if(!eq(SrcVT.Value, f64.Value), 1,
873     !if(!eq(SrcVT.Value, v2f16.Value), 1,
874     0))));
875 }
876
877 class isIntType<ValueType SrcVT> {
878   bit ret =
879     !if(!eq(SrcVT.Value, i16.Value), 1,
880     !if(!eq(SrcVT.Value, i32.Value), 1,
881     !if(!eq(SrcVT.Value, i64.Value), 1,
882     0)));
883 }
884
885 class isPackedType<ValueType SrcVT> {
886   bit ret =
887     !if(!eq(SrcVT.Value, v2i16.Value), 1,
888       !if(!eq(SrcVT.Value, v2f16.Value), 1, 0)
889     );
890 }
891
892 // Float or packed int
893 class isModifierType<ValueType SrcVT> {
894   bit ret =
895     !if(!eq(SrcVT.Value, f16.Value), 1,
896     !if(!eq(SrcVT.Value, f32.Value), 1,
897     !if(!eq(SrcVT.Value, f64.Value), 1,
898     !if(!eq(SrcVT.Value, v2f16.Value), 1,
899     !if(!eq(SrcVT.Value, v2i16.Value), 1,
900     0)))));
901 }
902
903 // Return type of input modifiers operand for specified input operand
904 class getSrcMod <ValueType VT> {
905   bit isFP = !if(!eq(VT.Value, f16.Value), 1,
906                !if(!eq(VT.Value, f32.Value), 1,
907                !if(!eq(VT.Value, f64.Value), 1,
908                0)));
909   bit isPacked = isPackedType<VT>.ret;
910   Operand ret =  !if(!eq(VT.Size, 64),
911                      !if(isFP, FP64InputMods, Int64InputMods),
912                        !if(isFP,
913                          !if(!eq(VT.Value, f16.Value),
914                             FP16InputMods,
915                             FP32InputMods
916                           ),
917                          Int32InputMods)
918                      );
919 }
920
921 // Return type of input modifiers operand specified input operand for SDWA/DPP
922 class getSrcModExt <ValueType VT> {
923     bit isFP = !if(!eq(VT.Value, f16.Value), 1,
924                !if(!eq(VT.Value, f32.Value), 1,
925                !if(!eq(VT.Value, f64.Value), 1,
926                0)));
927   Operand ret = !if(isFP, FPVRegInputMods, IntVRegInputMods);
928 }
929
930 // Returns the input arguments for VOP[12C] instructions for the given SrcVT.
931 class getIns32 <RegisterOperand Src0RC, RegisterClass Src1RC, int NumSrcArgs> {
932   dag ret = !if(!eq(NumSrcArgs, 1), (ins Src0RC:$src0),               // VOP1
933             !if(!eq(NumSrcArgs, 2), (ins Src0RC:$src0, Src1RC:$src1), // VOP2
934                                     (ins)));
935 }
936
937 // Returns the input arguments for VOP3 instructions for the given SrcVT.
938 class getIns64 <RegisterOperand Src0RC, RegisterOperand Src1RC,
939                 RegisterOperand Src2RC, int NumSrcArgs,
940                 bit HasModifiers, bit HasOMod,
941                 Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
942
943   dag ret =
944     !if (!eq(NumSrcArgs, 0),
945       // VOP1 without input operands (V_NOP, V_CLREXCP)
946       (ins),
947       /* else */
948     !if (!eq(NumSrcArgs, 1),
949       !if (!eq(HasModifiers, 1),
950         // VOP1 with modifiers
951         (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
952              clampmod:$clamp, omod:$omod)
953       /* else */,
954         // VOP1 without modifiers
955         (ins Src0RC:$src0)
956       /* endif */ ),
957     !if (!eq(NumSrcArgs, 2),
958       !if (!eq(HasModifiers, 1),
959         // VOP 2 with modifiers
960         !if( !eq(HasOMod, 1),
961           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
962                Src1Mod:$src1_modifiers, Src1RC:$src1,
963                clampmod:$clamp, omod:$omod),
964            (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
965                Src1Mod:$src1_modifiers, Src1RC:$src1,
966                clampmod:$clamp))
967       /* else */,
968         // VOP2 without modifiers
969         (ins Src0RC:$src0, Src1RC:$src1)
970       /* endif */ )
971     /* NumSrcArgs == 3 */,
972       !if (!eq(HasModifiers, 1),
973         // VOP3 with modifiers
974         !if (!eq(HasOMod, 1),
975           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
976                Src1Mod:$src1_modifiers, Src1RC:$src1,
977                Src2Mod:$src2_modifiers, Src2RC:$src2,
978                clampmod:$clamp, omod:$omod),
979           (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
980                Src1Mod:$src1_modifiers, Src1RC:$src1,
981                Src2Mod:$src2_modifiers, Src2RC:$src2,
982                clampmod:$clamp))
983       /* else */,
984         // VOP3 without modifiers
985         (ins Src0RC:$src0, Src1RC:$src1, Src2RC:$src2)
986       /* endif */ ))));
987 }
988
989 /// XXX - src1 may only allow VGPRs?
990
991 // The modifiers (except clamp) are dummy operands for the benefit of
992 // printing and parsing. They defer their values to looking at the
993 // srcN_modifiers for what to print.
994 class getInsVOP3P <RegisterOperand Src0RC, RegisterOperand Src1RC,
995                    RegisterOperand Src2RC, int NumSrcArgs,
996                    bit HasClamp,
997                    Operand Src0Mod, Operand Src1Mod, Operand Src2Mod> {
998   dag ret = !if (!eq(NumSrcArgs, 2),
999     !if (HasClamp,
1000       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1001            Src1Mod:$src1_modifiers, Src1RC:$src1,
1002            clampmod:$clamp,
1003            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1004            neg_lo:$neg_lo, neg_hi:$neg_hi),
1005       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1006            Src1Mod:$src1_modifiers, Src1RC:$src1,
1007            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1008            neg_lo:$neg_lo, neg_hi:$neg_hi)),
1009     // else NumSrcArgs == 3
1010     !if (HasClamp,
1011       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1012            Src1Mod:$src1_modifiers, Src1RC:$src1,
1013            Src2Mod:$src2_modifiers, Src2RC:$src2,
1014            clampmod:$clamp,
1015            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1016            neg_lo:$neg_lo, neg_hi:$neg_hi),
1017       (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1018            Src1Mod:$src1_modifiers, Src1RC:$src1,
1019            Src2Mod:$src2_modifiers, Src2RC:$src2,
1020            op_sel:$op_sel, op_sel_hi:$op_sel_hi,
1021            neg_lo:$neg_lo, neg_hi:$neg_hi))
1022   );
1023 }
1024
1025 class getInsDPP <RegisterClass Src0RC, RegisterClass Src1RC, int NumSrcArgs,
1026                  bit HasModifiers, Operand Src0Mod, Operand Src1Mod> {
1027
1028   dag ret = !if (!eq(NumSrcArgs, 0),
1029                 // VOP1 without input operands (V_NOP)
1030                 (ins dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1031                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl),
1032             !if (!eq(NumSrcArgs, 1),
1033               !if (!eq(HasModifiers, 1),
1034                 // VOP1_DPP with modifiers
1035                 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1036                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1037                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1038               /* else */,
1039                 // VOP1_DPP without modifiers
1040                 (ins Src0RC:$src0, dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1041                 bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1042               /* endif */)
1043               /* NumSrcArgs == 2 */,
1044               !if (!eq(HasModifiers, 1),
1045                 // VOP2_DPP with modifiers
1046                 (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1047                      Src1Mod:$src1_modifiers, Src1RC:$src1,
1048                      dpp_ctrl:$dpp_ctrl, row_mask:$row_mask,
1049                      bank_mask:$bank_mask, bound_ctrl:$bound_ctrl)
1050               /* else */,
1051                 // VOP2_DPP without modifiers
1052                 (ins Src0RC:$src0, Src1RC:$src1, dpp_ctrl:$dpp_ctrl,
1053                 row_mask:$row_mask, bank_mask:$bank_mask,
1054                 bound_ctrl:$bound_ctrl)
1055              /* endif */)));
1056 }
1057
1058 class getInsSDWA <RegisterClass Src0RC, RegisterClass Src1RC, int NumSrcArgs,
1059                   bit HasFloatModifiers, Operand Src0Mod, Operand Src1Mod,
1060                   ValueType DstVT> {
1061
1062   dag ret = !if(!eq(NumSrcArgs, 0),
1063                // VOP1 without input operands (V_NOP)
1064                (ins),
1065             !if(!eq(NumSrcArgs, 1),
1066                (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1067                     clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1068                     src0_sel:$src0_sel),
1069             !if(!eq(NumSrcArgs, 2),
1070                !if(!eq(DstVT.Size, 1),
1071                   // VOPC_SDWA with modifiers
1072                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1073                        Src1Mod:$src1_modifiers, Src1RC:$src1,
1074                        clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel),
1075                   // VOP2_SDWA or VOPC_SDWA with modifiers
1076                   (ins Src0Mod:$src0_modifiers, Src0RC:$src0,
1077                        Src1Mod:$src1_modifiers, Src1RC:$src1,
1078                        clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1079                        src0_sel:$src0_sel, src1_sel:$src1_sel)),
1080             (ins)/* endif */)));
1081 }
1082
1083 // Outs for DPP and SDWA
1084 class getOutsExt <bit HasDst, ValueType DstVT, RegisterOperand DstRCDPP> {
1085   dag ret = !if(HasDst,
1086                 !if(!eq(DstVT.Size, 1),
1087                     (outs), // no dst for VOPC, we use "vcc"-token as dst in SDWA VOPC instructions
1088                     (outs DstRCDPP:$vdst)),
1089                 (outs)); // V_NOP
1090 }
1091
1092 // Returns the assembly string for the inputs and outputs of a VOP[12C]
1093 // instruction.  This does not add the _e32 suffix, so it can be reused
1094 // by getAsm64.
1095 class getAsm32 <bit HasDst, int NumSrcArgs, ValueType DstVT = i32> {
1096   string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1097   string src0 = ", $src0";
1098   string src1 = ", $src1";
1099   string src2 = ", $src2";
1100   string ret = !if(HasDst, dst, "") #
1101                !if(!eq(NumSrcArgs, 1), src0, "") #
1102                !if(!eq(NumSrcArgs, 2), src0#src1, "") #
1103                !if(!eq(NumSrcArgs, 3), src0#src1#src2, "");
1104 }
1105
1106 // Returns the assembly string for the inputs and outputs of a VOP3
1107 // instruction.
1108 class getAsm64 <bit HasDst, int NumSrcArgs, bit HasModifiers,
1109                 bit HasOMod, ValueType DstVT = i32> {
1110   string dst = !if(!eq(DstVT.Size, 1), "$sdst", "$vdst"); // use $sdst for VOPC
1111   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1112   string src1 = !if(!eq(NumSrcArgs, 1), "",
1113                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1114                                            " $src1_modifiers,"));
1115   string src2 = !if(!eq(NumSrcArgs, 3), " $src2_modifiers", "");
1116   string ret =
1117   !if(!eq(HasModifiers, 0),
1118       getAsm32<HasDst, NumSrcArgs, DstVT>.ret,
1119       dst#", "#src0#src1#src2#"$clamp"#!if(HasOMod, "$omod", ""));
1120 }
1121
1122 // Returns the assembly string for the inputs and outputs of a VOP3P
1123 // instruction.
1124 class getAsmVOP3P <bit HasDst, int NumSrcArgs, bit HasModifiers,
1125                    bit HasClamp, ValueType DstVT = i32> {
1126   string dst = " $vdst";
1127   string src0 = !if(!eq(NumSrcArgs, 1), "$src0", "$src0,");
1128   string src1 = !if(!eq(NumSrcArgs, 1), "",
1129                    !if(!eq(NumSrcArgs, 2), " $src1",
1130                                            " $src1,"));
1131   string src2 = !if(!eq(NumSrcArgs, 3), " $src2", "");
1132
1133   string mods = !if(HasModifiers, "$neg_lo$neg_hi", "");
1134   string clamp = !if(HasClamp, "$clamp", "");
1135
1136   // Each modifier is printed as an array of bits for each operand, so
1137   // all operands are printed as part of src0_modifiers.
1138   string ret = dst#", "#src0#src1#src2#"$op_sel$op_sel_hi"#mods#clamp;
1139 }
1140
1141 class getAsmDPP <bit HasDst, int NumSrcArgs, bit HasModifiers, ValueType DstVT = i32> {
1142   string dst = !if(HasDst,
1143                    !if(!eq(DstVT.Size, 1),
1144                        "$sdst",
1145                        "$vdst"),
1146                     ""); // use $sdst for VOPC
1147   string src0 = !if(!eq(NumSrcArgs, 1), "$src0_modifiers", "$src0_modifiers,");
1148   string src1 = !if(!eq(NumSrcArgs, 1), "",
1149                    !if(!eq(NumSrcArgs, 2), " $src1_modifiers",
1150                                            " $src1_modifiers,"));
1151   string args = !if(!eq(HasModifiers, 0),
1152                      getAsm32<0, NumSrcArgs, DstVT>.ret,
1153                      ", "#src0#src1);
1154   string ret = dst#args#" $dpp_ctrl$row_mask$bank_mask$bound_ctrl";
1155 }
1156
1157 class getAsmSDWA <bit HasDst, int NumSrcArgs, bit HasFloatModifiers,
1158                   ValueType DstVT = i32> {
1159   string dst = !if(HasDst,
1160                    !if(!eq(DstVT.Size, 1),
1161                        " vcc", // use vcc token as dst for VOPC instructioins
1162                        "$vdst"),
1163                     "");
1164   string src0 = "$src0_modifiers";
1165   string src1 = "$src1_modifiers";
1166   string args = !if(!eq(NumSrcArgs, 0),
1167                     "",
1168                     !if(!eq(NumSrcArgs, 1),
1169                         ", "#src0#"$clamp",
1170                         ", "#src0#", "#src1#"$clamp"
1171                      )
1172                 );
1173   string sdwa = !if(!eq(NumSrcArgs, 0),
1174                     "",
1175                     !if(!eq(NumSrcArgs, 1),
1176                         " $dst_sel $dst_unused $src0_sel",
1177                         !if(!eq(DstVT.Size, 1),
1178                             " $src0_sel $src1_sel", // No dst_sel and dst_unused for VOPC
1179                             " $dst_sel $dst_unused $src0_sel $src1_sel"
1180                         )
1181                     )
1182                 );
1183   string ret = dst#args#sdwa;
1184 }
1185
1186 // Function that checks if instruction supports DPP and SDWA
1187 class getHasExt <int NumSrcArgs, ValueType DstVT = i32, ValueType Src0VT = i32,
1188                  ValueType Src1VT = i32> {
1189   bit ret = !if(!eq(NumSrcArgs, 3),
1190                 0, // NumSrcArgs == 3 - No DPP or SDWA for VOP3
1191                 !if(!eq(DstVT.Size, 64),
1192                     0, // 64-bit dst - No DPP or SDWA for 64-bit operands
1193                     !if(!eq(Src0VT.Size, 64),
1194                         0, // 64-bit src0
1195                         !if(!eq(Src0VT.Size, 64),
1196                             0, // 64-bit src2
1197                             1
1198                         )
1199                     )
1200                 )
1201             );
1202 }
1203
1204 class BitOr<bit a, bit b> {
1205   bit ret = !if(a, 1, !if(b, 1, 0));
1206 }
1207
1208 class BitAnd<bit a, bit b> {
1209   bit ret = !if(a, !if(b, 1, 0), 0);
1210 }
1211
1212 class VOPProfile <list<ValueType> _ArgVT> {
1213
1214   field list<ValueType> ArgVT = _ArgVT;
1215
1216   field ValueType DstVT = ArgVT[0];
1217   field ValueType Src0VT = ArgVT[1];
1218   field ValueType Src1VT = ArgVT[2];
1219   field ValueType Src2VT = ArgVT[3];
1220   field RegisterOperand DstRC = getVALUDstForVT<DstVT>.ret;
1221   field RegisterOperand DstRCDPP = getVALUDstForVT<DstVT>.ret;
1222   field RegisterOperand DstRCSDWA = getVALUDstForVT<DstVT>.ret;
1223   field RegisterOperand Src0RC32 = getVOPSrc0ForVT<Src0VT>.ret;
1224   field RegisterClass Src1RC32 = getVregSrcForVT<Src1VT>.ret;
1225   field RegisterOperand Src0RC64 = getVOP3SrcForVT<Src0VT>.ret;
1226   field RegisterOperand Src1RC64 = getVOP3SrcForVT<Src1VT>.ret;
1227   field RegisterOperand Src2RC64 = getVOP3SrcForVT<Src2VT>.ret;
1228   field RegisterClass Src0DPP = getVregSrcForVT<Src0VT>.ret;
1229   field RegisterClass Src1DPP = getVregSrcForVT<Src1VT>.ret;
1230   field RegisterClass Src0SDWA = getVregSrcForVT<Src0VT>.ret;
1231   field RegisterClass Src1SDWA = getVregSrcForVT<Src1VT>.ret;
1232   field Operand Src0Mod = getSrcMod<Src0VT>.ret;
1233   field Operand Src1Mod = getSrcMod<Src1VT>.ret;
1234   field Operand Src2Mod = getSrcMod<Src2VT>.ret;
1235   field Operand Src0ModDPP = getSrcModExt<Src0VT>.ret;
1236   field Operand Src1ModDPP = getSrcModExt<Src1VT>.ret;
1237   field Operand Src0ModSDWA = getSrcModExt<Src0VT>.ret;
1238   field Operand Src1ModSDWA = getSrcModExt<Src1VT>.ret;
1239
1240
1241   field bit HasDst = !if(!eq(DstVT.Value, untyped.Value), 0, 1);
1242   field bit HasDst32 = HasDst;
1243   field bit EmitDst = HasDst; // force dst encoding, see v_movreld_b32 special case
1244   field int NumSrcArgs = getNumSrcArgs<Src0VT, Src1VT, Src2VT>.ret;
1245   field bit HasSrc0 = !if(!eq(Src0VT.Value, untyped.Value), 0, 1);
1246   field bit HasSrc1 = !if(!eq(Src1VT.Value, untyped.Value), 0, 1);
1247   field bit HasSrc2 = !if(!eq(Src2VT.Value, untyped.Value), 0, 1);
1248
1249   // TODO: Modifiers logic is somewhat adhoc here, to be refined later
1250   field bit HasModifiers = isModifierType<Src0VT>.ret;
1251
1252   field bit HasSrc0FloatMods = isFloatType<Src0VT>.ret;
1253   field bit HasSrc1FloatMods = isFloatType<Src1VT>.ret;
1254   field bit HasSrc2FloatMods = isFloatType<Src2VT>.ret;
1255
1256   field bit HasSrc0IntMods = isIntType<Src0VT>.ret;
1257   field bit HasSrc1IntMods = isIntType<Src1VT>.ret;
1258   field bit HasSrc2IntMods = isIntType<Src2VT>.ret;
1259
1260   field bit HasSrc0Mods = HasModifiers;
1261   field bit HasSrc1Mods = !if(HasModifiers, BitOr<HasSrc1FloatMods, HasSrc1IntMods>.ret, 0);
1262   field bit HasSrc2Mods = !if(HasModifiers, BitOr<HasSrc2FloatMods, HasSrc2IntMods>.ret, 0);
1263
1264   field bit HasClamp = HasModifiers;
1265   field bit HasSDWAClamp = HasSrc0;
1266   field bit HasFPClamp = BitAnd<isFloatType<DstVT>.ret, HasClamp>.ret;
1267
1268   field bit IsPacked = isPackedType<Src0VT>.ret;
1269   field bit HasOpSel = IsPacked;
1270   field bit HasOMod = !if(HasOpSel, 0, HasModifiers);
1271
1272   field bit HasExt = getHasExt<NumSrcArgs, DstVT, Src0VT, Src1VT>.ret;
1273
1274   field Operand Src0PackedMod = !if(HasSrc0FloatMods, PackedF16InputMods, PackedI16InputMods);
1275   field Operand Src1PackedMod = !if(HasSrc1FloatMods, PackedF16InputMods, PackedI16InputMods);
1276   field Operand Src2PackedMod = !if(HasSrc2FloatMods, PackedF16InputMods, PackedI16InputMods);
1277
1278   field dag Outs = !if(HasDst,(outs DstRC:$vdst),(outs));
1279
1280   // VOP3b instructions are a special case with a second explicit
1281   // output. This is manually overridden for them.
1282   field dag Outs32 = Outs;
1283   field dag Outs64 = Outs;
1284   field dag OutsDPP = getOutsExt<HasDst, DstVT, DstRCDPP>.ret;
1285   field dag OutsSDWA = getOutsExt<HasDst, DstVT, DstRCSDWA>.ret;
1286
1287   field dag Ins32 = getIns32<Src0RC32, Src1RC32, NumSrcArgs>.ret;
1288   field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
1289                              HasModifiers, HasOMod, Src0Mod, Src1Mod,
1290                              Src2Mod>.ret;
1291   field dag InsVOP3P = getInsVOP3P<Src0RC64, Src1RC64, Src2RC64,
1292                                    NumSrcArgs, HasClamp,
1293                                    Src0PackedMod, Src1PackedMod, Src2PackedMod>.ret;
1294
1295   field dag InsDPP = getInsDPP<Src0DPP, Src1DPP, NumSrcArgs,
1296                                HasModifiers, Src0ModDPP, Src1ModDPP>.ret;
1297   field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs,
1298                                  HasModifiers, Src0ModSDWA, Src1ModSDWA,
1299                                  DstVT>.ret;
1300
1301   field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret;
1302   field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasModifiers, HasOMod, DstVT>.ret;
1303   field string AsmVOP3P = getAsmVOP3P<HasDst, NumSrcArgs, HasModifiers, HasClamp, DstVT>.ret;
1304   field string AsmDPP = getAsmDPP<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
1305   field string AsmSDWA = getAsmSDWA<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
1306 }
1307
1308 class VOP_NO_EXT <VOPProfile p> : VOPProfile <p.ArgVT> {
1309   let HasExt = 0;
1310 }
1311
1312 def VOP_F16_F16 : VOPProfile <[f16, f16, untyped, untyped]>;
1313 def VOP_F16_I16 : VOPProfile <[f16, i16, untyped, untyped]>;
1314 def VOP_I16_F16 : VOPProfile <[i16, f16, untyped, untyped]>;
1315
1316 def VOP_F16_F16_F16 : VOPProfile <[f16, f16, f16, untyped]>;
1317 def VOP_F16_F16_I16 : VOPProfile <[f16, f16, i16, untyped]>;
1318 def VOP_F16_F16_I32 : VOPProfile <[f16, f16, i32, untyped]>;
1319 def VOP_I16_I16_I16 : VOPProfile <[i16, i16, i16, untyped]>;
1320
1321 def VOP_I16_I16_I16_I16 : VOPProfile <[i16, i16, i16, i16, untyped]>;
1322 def VOP_F16_F16_F16_F16 : VOPProfile <[f16, f16, f16, f16, untyped]>;
1323
1324 def VOP_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, untyped]>;
1325 def VOP_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, untyped]>;
1326 def VOP_B32_F16_F16 : VOPProfile <[i32, f16, f16, untyped]>;
1327
1328 def VOP_V2F16_V2F16_V2F16_V2F16 : VOPProfile <[v2f16, v2f16, v2f16, v2f16]>;
1329 def VOP_V2I16_V2I16_V2I16_V2I16 : VOPProfile <[v2i16, v2i16, v2i16, v2i16]>;
1330
1331 def VOP_NONE : VOPProfile <[untyped, untyped, untyped, untyped]>;
1332
1333 def VOP_F32_F32 : VOPProfile <[f32, f32, untyped, untyped]>;
1334 def VOP_F32_F64 : VOPProfile <[f32, f64, untyped, untyped]>;
1335 def VOP_F32_I32 : VOPProfile <[f32, i32, untyped, untyped]>;
1336 def VOP_F64_F32 : VOPProfile <[f64, f32, untyped, untyped]>;
1337 def VOP_F64_F64 : VOPProfile <[f64, f64, untyped, untyped]>;
1338 def VOP_F64_I32 : VOPProfile <[f64, i32, untyped, untyped]>;
1339 def VOP_I32_F32 : VOPProfile <[i32, f32, untyped, untyped]>;
1340 def VOP_I32_F64 : VOPProfile <[i32, f64, untyped, untyped]>;
1341 def VOP_I32_I32 : VOPProfile <[i32, i32, untyped, untyped]>;
1342 def VOP_F16_F32 : VOPProfile <[f16, f32, untyped, untyped]>;
1343 def VOP_F32_F16 : VOPProfile <[f32, f16, untyped, untyped]>;
1344
1345 def VOP_F32_F32_F16 : VOPProfile <[f32, f32, f16, untyped]>;
1346 def VOP_F32_F32_F32 : VOPProfile <[f32, f32, f32, untyped]>;
1347 def VOP_F32_F32_I32 : VOPProfile <[f32, f32, i32, untyped]>;
1348 def VOP_F64_F64_F64 : VOPProfile <[f64, f64, f64, untyped]>;
1349 def VOP_F64_F64_I32 : VOPProfile <[f64, f64, i32, untyped]>;
1350 def VOP_I32_F32_F32 : VOPProfile <[i32, f32, f32, untyped]>;
1351 def VOP_I32_F32_I32 : VOPProfile <[i32, f32, i32, untyped]>;
1352 def VOP_I32_I32_I32 : VOPProfile <[i32, i32, i32, untyped]>;
1353 def VOP_V2F16_F32_F32 : VOPProfile <[v2f16, f32, f32, untyped]>;
1354
1355 def VOP_I64_I64_I32 : VOPProfile <[i64, i64, i32, untyped]>;
1356 def VOP_I64_I32_I64 : VOPProfile <[i64, i32, i64, untyped]>;
1357 def VOP_I64_I64_I64 : VOPProfile <[i64, i64, i64, untyped]>;
1358
1359 def VOP_F16_F32_F16_F32 : VOPProfile <[f16, f32, f16, f32]>;
1360 def VOP_F32_F32_F16_F16 : VOPProfile <[f32, f32, f16, f16]>;
1361 def VOP_F32_F32_F32_F32 : VOPProfile <[f32, f32, f32, f32]>;
1362 def VOP_F64_F64_F64_F64 : VOPProfile <[f64, f64, f64, f64]>;
1363 def VOP_I32_I32_I32_I32 : VOPProfile <[i32, i32, i32, i32]>;
1364 def VOP_I64_I32_I32_I64 : VOPProfile <[i64, i32, i32, i64]>;
1365 def VOP_I32_F32_I32_I32 : VOPProfile <[i32, f32, i32, i32]>;
1366 def VOP_I64_I64_I32_I64 : VOPProfile <[i64, i64, i32, i64]>;
1367 def VOP_V4I32_I64_I32_V4I32 : VOPProfile <[v4i32, i64, i32, v4i32]>;
1368
1369 class Commutable_REV <string revOp, bit isOrig> {
1370   string RevOp = revOp;
1371   bit IsOrig = isOrig;
1372 }
1373
1374 class AtomicNoRet <string noRetOp, bit isRet> {
1375   string NoRetOp = noRetOp;
1376   bit IsRet = isRet;
1377 }
1378
1379 //===----------------------------------------------------------------------===//
1380 // Interpolation opcodes
1381 //===----------------------------------------------------------------------===//
1382
1383 class VINTRP_Pseudo <string opName, dag outs, dag ins, list<dag> pattern> :
1384   VINTRPCommon <outs, ins, "", pattern>,
1385   SIMCInstr<opName, SIEncodingFamily.NONE> {
1386   let isPseudo = 1;
1387   let isCodeGenOnly = 1;
1388 }
1389
1390 class VINTRP_Real_si <bits <2> op, string opName, dag outs, dag ins,
1391                       string asm> :
1392   VINTRPCommon <outs, ins, asm, []>,
1393   VINTRPe <op>,
1394   SIMCInstr<opName, SIEncodingFamily.SI> {
1395   let AssemblerPredicate = SIAssemblerPredicate;
1396   let DecoderNamespace = "SICI";
1397   let DisableDecoder = DisableSIDecoder;
1398 }
1399
1400 class VINTRP_Real_vi <bits <2> op, string opName, dag outs, dag ins,
1401                       string asm> :
1402   VINTRPCommon <outs, ins, asm, []>,
1403   VINTRPe_vi <op>,
1404   SIMCInstr<opName, SIEncodingFamily.VI> {
1405   let AssemblerPredicate = VIAssemblerPredicate;
1406   let DecoderNamespace = "VI";
1407   let DisableDecoder = DisableVIDecoder;
1408 }
1409
1410 multiclass VINTRP_m <bits <2> op, dag outs, dag ins, string asm,
1411                      list<dag> pattern = []> {
1412   def "" : VINTRP_Pseudo <NAME, outs, ins, pattern>;
1413
1414   def _si : VINTRP_Real_si <op, NAME, outs, ins, asm>;
1415
1416   def _vi : VINTRP_Real_vi <op, NAME, outs, ins, asm>;
1417 }
1418
1419 //===----------------------------------------------------------------------===//
1420 // Vector instruction mappings
1421 //===----------------------------------------------------------------------===//
1422
1423 // Maps an opcode in e32 form to its e64 equivalent
1424 def getVOPe64 : InstrMapping {
1425   let FilterClass = "VOP";
1426   let RowFields = ["OpName"];
1427   let ColFields = ["Size", "VOP3"];
1428   let KeyCol = ["4", "0"];
1429   let ValueCols = [["8", "1"]];
1430 }
1431
1432 // Maps an opcode in e64 form to its e32 equivalent
1433 def getVOPe32 : InstrMapping {
1434   let FilterClass = "VOP";
1435   let RowFields = ["OpName"];
1436   let ColFields = ["Size", "VOP3"];
1437   let KeyCol = ["8", "1"];
1438   let ValueCols = [["4", "0"]];
1439 }
1440
1441 // Maps ordinary instructions to their SDWA counterparts
1442 def getSDWAOp : InstrMapping {
1443   let FilterClass = "VOP";
1444   let RowFields = ["OpName"];
1445   let ColFields = ["AsmVariantName"];
1446   let KeyCol = ["Default"];
1447   let ValueCols = [["SDWA"]];
1448 }
1449
1450 def getMaskedMIMGOp : InstrMapping {
1451   let FilterClass = "MIMG_Mask";
1452   let RowFields = ["Op"];
1453   let ColFields = ["Channels"];
1454   let KeyCol = ["4"];
1455   let ValueCols = [["1"], ["2"], ["3"] ];
1456 }
1457
1458 // Maps an commuted opcode to its original version
1459 def getCommuteOrig : InstrMapping {
1460   let FilterClass = "Commutable_REV";
1461   let RowFields = ["RevOp"];
1462   let ColFields = ["IsOrig"];
1463   let KeyCol = ["0"];
1464   let ValueCols = [["1"]];
1465 }
1466
1467 // Maps an original opcode to its commuted version
1468 def getCommuteRev : InstrMapping {
1469   let FilterClass = "Commutable_REV";
1470   let RowFields = ["RevOp"];
1471   let ColFields = ["IsOrig"];
1472   let KeyCol = ["1"];
1473   let ValueCols = [["0"]];
1474 }
1475
1476 def getMCOpcodeGen : InstrMapping {
1477   let FilterClass = "SIMCInstr";
1478   let RowFields = ["PseudoInstr"];
1479   let ColFields = ["Subtarget"];
1480   let KeyCol = [!cast<string>(SIEncodingFamily.NONE)];
1481   let ValueCols = [[!cast<string>(SIEncodingFamily.SI)],
1482                    [!cast<string>(SIEncodingFamily.VI)]];
1483 }
1484
1485 // Get equivalent SOPK instruction.
1486 def getSOPKOp : InstrMapping {
1487   let FilterClass = "SOPKInstTable";
1488   let RowFields = ["BaseCmpOp"];
1489   let ColFields = ["IsSOPK"];
1490   let KeyCol = ["0"];
1491   let ValueCols = [["1"]];
1492 }
1493
1494 def getAddr64Inst : InstrMapping {
1495   let FilterClass = "MUBUFAddr64Table";
1496   let RowFields = ["OpName"];
1497   let ColFields = ["IsAddr64"];
1498   let KeyCol = ["0"];
1499   let ValueCols = [["1"]];
1500 }
1501
1502 // Maps an atomic opcode to its version with a return value.
1503 def getAtomicRetOp : InstrMapping {
1504   let FilterClass = "AtomicNoRet";
1505   let RowFields = ["NoRetOp"];
1506   let ColFields = ["IsRet"];
1507   let KeyCol = ["0"];
1508   let ValueCols = [["1"]];
1509 }
1510
1511 // Maps an atomic opcode to its returnless version.
1512 def getAtomicNoRetOp : InstrMapping {
1513   let FilterClass = "AtomicNoRet";
1514   let RowFields = ["NoRetOp"];
1515   let ColFields = ["IsRet"];
1516   let KeyCol = ["1"];
1517   let ValueCols = [["0"]];
1518 }
1519
1520 include "SIInstructions.td"
1521 include "CIInstructions.td"
1522
1523 include "DSInstructions.td"
1524 include "MIMGInstructions.td"