1 //===-- VOPInstructions.td - Vector Instruction Defintions ----------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // dummies for outer let
12 bit isConvertibleToThreeAddress;
14 bit isReMaterializable;
16 bit VOPAsmPrefer32Bit;
17 Predicate SubtargetPredicate;
19 string DisableEncoding;
20 list<SchedReadWrite> SchedRW;
25 class VOP <string opName> {
26 string OpName = opName;
29 class VOPAnyCommon <dag outs, dag ins, string asm, list<dag> pattern> :
30 InstSI <outs, ins, asm, pattern> {
34 let hasSideEffects = 0;
35 let UseNamedOperandTable = 1;
40 class VOP_Pseudo <string opName, string suffix, VOPProfile P, dag outs, dag ins,
41 string asm, list<dag> pattern> :
42 InstSI <outs, ins, asm, pattern>,
44 SIMCInstr <opName#suffix, SIEncodingFamily.NONE>,
45 MnemonicAlias<opName#suffix, opName> {
48 let isCodeGenOnly = 1;
49 let UseNamedOperandTable = 1;
51 string Mnemonic = opName;
57 class VOP3Common <dag outs, dag ins, string asm = "",
58 list<dag> pattern = [], bit HasMods = 0,
60 VOPAnyCommon <outs, ins, asm, pattern> {
62 // Using complex patterns gives VOP3 patterns a very high complexity rating,
63 // but standalone patterns are almost always preferred, so we need to adjust the
64 // priority lower. The goal is to use a high number to reduce complexity to
65 // zero (or less than zero).
66 let AddedComplexity = -1000;
70 let AsmVariantName = AMDGPUAsmVariants.VOP3;
71 let AsmMatchConverter = !if(!eq(HasMods,1), "cvtVOP3", "");
73 let isCodeGenOnly = 0;
77 // Because SGPRs may be allowed if there are multiple operands, we
78 // need a post-isel hook to insert copies in order to avoid
79 // violating constant bus requirements.
80 let hasPostISelHook = 1;
83 class VOP3_Pseudo <string opName, VOPProfile P, list<dag> pattern = [],
84 bit VOP3Only = 0, bit isVOP3P = 0, bit isVop3OpSel = 0> :
85 VOP_Pseudo <opName, "_e64", P, P.Outs64,
88 !if(!and(isVOP3P, P.IsPacked), P.InsVOP3P, P.Ins64)),
91 let VOP3_OPSEL = isVop3OpSel;
92 let IsPacked = P.IsPacked;
95 let AsmOperands = !if(isVop3OpSel,
97 !if(!and(isVOP3P, P.IsPacked), P.AsmVOP3P, P.Asm64));
102 let hasSideEffects = 0;
104 // Because SGPRs may be allowed if there are multiple operands, we
105 // need a post-isel hook to insert copies in order to avoid
106 // violating constant bus requirements.
107 let hasPostISelHook = 1;
109 // Using complex patterns gives VOP3 patterns a very high complexity rating,
110 // but standalone patterns are almost always preferred, so we need to adjust the
111 // priority lower. The goal is to use a high number to reduce complexity to
112 // zero (or less than zero).
113 let AddedComplexity = -1000;
117 let FPClamp = P.HasFPClamp;
118 let IntClamp = P.HasIntClamp;
119 let ClampLo = P.HasClampLo;
120 let ClampHi = P.HasClampHi;
124 let AsmVariantName = AMDGPUAsmVariants.VOP3;
125 let AsmMatchConverter =
128 !if(!or(P.HasModifiers, !or(P.HasOMod, P.HasIntClamp)),
133 class VOP3P_Pseudo <string opName, VOPProfile P, list<dag> pattern = []> :
134 VOP3_Pseudo<opName, P, pattern, 1, 1> {
138 class VOP3_Real <VOP_Pseudo ps, int EncodingFamily> :
139 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>,
140 SIMCInstr <ps.PseudoInstr, EncodingFamily> {
143 let isCodeGenOnly = 0;
144 let UseNamedOperandTable = 1;
146 let Constraints = ps.Constraints;
147 let DisableEncoding = ps.DisableEncoding;
149 // copy relevant pseudo op flags
150 let SubtargetPredicate = ps.SubtargetPredicate;
151 let AsmMatchConverter = ps.AsmMatchConverter;
152 let AsmVariantName = ps.AsmVariantName;
153 let Constraints = ps.Constraints;
154 let DisableEncoding = ps.DisableEncoding;
155 let TSFlags = ps.TSFlags;
156 let UseNamedOperandTable = ps.UseNamedOperandTable;
160 VOPProfile Pfl = ps.Pfl;
163 // XXX - Is there any reason to distingusih this from regular VOP3
165 class VOP3P_Real<VOP_Pseudo ps, int EncodingFamily> :
166 VOP3_Real<ps, EncodingFamily>;
168 class VOP3a<VOPProfile P> : Enc64 {
169 bits<4> src0_modifiers;
171 bits<3> src1_modifiers;
173 bits<3> src2_modifiers;
178 let Inst{8} = !if(P.HasSrc0Mods, src0_modifiers{1}, 0);
179 let Inst{9} = !if(P.HasSrc1Mods, src1_modifiers{1}, 0);
180 let Inst{10} = !if(P.HasSrc2Mods, src2_modifiers{1}, 0);
182 let Inst{31-26} = 0x34; //encoding
183 let Inst{40-32} = !if(P.HasSrc0, src0, 0);
184 let Inst{49-41} = !if(P.HasSrc1, src1, 0);
185 let Inst{58-50} = !if(P.HasSrc2, src2, 0);
186 let Inst{60-59} = !if(P.HasOMod, omod, 0);
187 let Inst{61} = !if(P.HasSrc0Mods, src0_modifiers{0}, 0);
188 let Inst{62} = !if(P.HasSrc1Mods, src1_modifiers{0}, 0);
189 let Inst{63} = !if(P.HasSrc2Mods, src2_modifiers{0}, 0);
192 class VOP3a_gfx6_gfx7<bits<9> op, VOPProfile p> : VOP3a<p> {
193 let Inst{11} = !if(p.HasClamp, clamp{0}, 0);
194 let Inst{25-17} = op;
197 class VOP3a_gfx10<bits<10> op, VOPProfile p> : VOP3a<p> {
198 let Inst{15} = !if(p.HasClamp, clamp{0}, 0);
199 let Inst{25-16} = op;
200 let Inst{31-26} = 0x35;
203 class VOP3a_vi <bits<10> op, VOPProfile P> : VOP3a<P> {
204 let Inst{25-16} = op;
205 let Inst{15} = !if(P.HasClamp, clamp{0}, 0);
208 class VOP3e_gfx6_gfx7<bits<9> op, VOPProfile p> : VOP3a_gfx6_gfx7<op, p> {
210 let Inst{7-0} = !if(p.EmitDst, vdst{7-0}, 0);
213 class VOP3e_gfx10<bits<10> op, VOPProfile p> : VOP3a_gfx10<op, p> {
215 let Inst{7-0} = !if(p.EmitDst, vdst{7-0}, 0);
218 class VOP3e_vi <bits<10> op, VOPProfile P> : VOP3a_vi <op, P> {
220 let Inst{7-0} = !if(P.EmitDst, vdst{7-0}, 0);
223 class VOP3OpSel_gfx9 <bits<10> op, VOPProfile P> : VOP3e_vi <op, P> {
224 let Inst{11} = !if(P.HasSrc0, src0_modifiers{2}, 0);
225 let Inst{12} = !if(P.HasSrc1, src1_modifiers{2}, 0);
226 let Inst{13} = !if(P.HasSrc2, src2_modifiers{2}, 0);
227 let Inst{14} = !if(P.HasDst, src0_modifiers{3}, 0);
230 class VOP3OpSel_gfx10<bits<10> op, VOPProfile p> : VOP3e_gfx10<op, p> {
231 let Inst{11} = !if(p.HasSrc0, src0_modifiers{2}, 0);
232 let Inst{12} = !if(p.HasSrc1, src1_modifiers{2}, 0);
233 let Inst{13} = !if(p.HasSrc2, src2_modifiers{2}, 0);
234 let Inst{14} = !if(p.HasDst, src0_modifiers{3}, 0);
237 // NB: For V_INTERP* opcodes, src0 is encoded as src1 and vice versa
238 class VOP3Interp_vi <bits<10> op, VOPProfile P> : VOP3e_vi <op, P> {
243 let Inst{8} = 0; // No modifiers for src0
246 let Inst{9} = !if(P.HasSrc0Mods, src0_modifiers{1}, 0);
247 let Inst{62} = !if(P.HasSrc0Mods, src0_modifiers{0}, 0);
249 let Inst{37-32} = attr;
250 let Inst{39-38} = attrchan;
251 let Inst{40} = !if(P.HasHigh, high, 0);
253 let Inst{49-41} = src0;
256 class VOP3Interp_gfx10<bits<10> op, VOPProfile p> : VOP3e_gfx10<op, p> {
262 let Inst{9} = !if(p.HasSrc0Mods, src0_modifiers{1}, 0);
263 let Inst{37-32} = attr;
264 let Inst{39-38} = attrchan;
265 let Inst{40} = !if(p.HasHigh, high, 0);
266 let Inst{49-41} = src0;
268 let Inst{62} = !if(p.HasSrc0Mods, src0_modifiers{0}, 0);
271 class VOP3be <VOPProfile P> : Enc64 {
273 bits<2> src0_modifiers;
275 bits<2> src1_modifiers;
277 bits<2> src2_modifiers;
282 let Inst{7-0} = vdst;
283 let Inst{14-8} = sdst;
284 let Inst{31-26} = 0x34; //encoding
285 let Inst{40-32} = !if(P.HasSrc0, src0, 0);
286 let Inst{49-41} = !if(P.HasSrc1, src1, 0);
287 let Inst{58-50} = !if(P.HasSrc2, src2, 0);
288 let Inst{60-59} = !if(P.HasOMod, omod, 0);
289 let Inst{61} = !if(P.HasSrc0Mods, src0_modifiers{0}, 0);
290 let Inst{62} = !if(P.HasSrc1Mods, src1_modifiers{0}, 0);
291 let Inst{63} = !if(P.HasSrc2Mods, src2_modifiers{0}, 0);
294 class VOP3Pe <bits<10> op, VOPProfile P> : Enc64 {
296 // neg, neg_hi, op_sel put in srcN_modifiers
297 bits<4> src0_modifiers;
299 bits<4> src1_modifiers;
301 bits<4> src2_modifiers;
305 let Inst{7-0} = vdst;
306 let Inst{8} = !if(P.HasSrc0Mods, src0_modifiers{1}, 0); // neg_hi src0
307 let Inst{9} = !if(P.HasSrc1Mods, src1_modifiers{1}, 0); // neg_hi src1
308 let Inst{10} = !if(P.HasSrc2Mods, src2_modifiers{1}, 0); // neg_hi src2
310 let Inst{11} = !if(!and(P.HasSrc0, P.HasOpSel), src0_modifiers{2}, 0); // op_sel(0)
311 let Inst{12} = !if(!and(P.HasSrc1, P.HasOpSel), src1_modifiers{2}, 0); // op_sel(1)
312 let Inst{13} = !if(!and(P.HasSrc2, P.HasOpSel), src2_modifiers{2}, 0); // op_sel(2)
314 let Inst{14} = !if(!and(P.HasSrc2, P.HasOpSel), src2_modifiers{3}, 0); // op_sel_hi(2)
316 let Inst{15} = !if(P.HasClamp, clamp{0}, 0);
318 let Inst{25-16} = op;
319 let Inst{31-26} = 0x34; //encoding
320 let Inst{40-32} = !if(P.HasSrc0, src0, 0);
321 let Inst{49-41} = !if(P.HasSrc1, src1, 0);
322 let Inst{58-50} = !if(P.HasSrc2, src2, 0);
323 let Inst{59} = !if(!and(P.HasSrc0, P.HasOpSel), src0_modifiers{3}, 0); // op_sel_hi(0)
324 let Inst{60} = !if(!and(P.HasSrc1, P.HasOpSel), src1_modifiers{3}, 0); // op_sel_hi(1)
325 let Inst{61} = !if(P.HasSrc0Mods, src0_modifiers{0}, 0); // neg (lo)
326 let Inst{62} = !if(P.HasSrc1Mods, src1_modifiers{0}, 0); // neg (lo)
327 let Inst{63} = !if(P.HasSrc2Mods, src2_modifiers{0}, 0); // neg (lo)
330 class VOP3Pe_MAI <bits<10> op, VOPProfile P> : Enc64 {
340 let Inst{7-0} = vdst;
342 let Inst{10-8} = !if(P.HasSrc1, cbsz, 0);
343 let Inst{14-11} = !if(P.HasSrc1, abid, 0);
345 let Inst{15} = !if(P.HasClamp, clamp{0}, 0);
347 let Inst{25-16} = op;
348 let Inst{31-26} = 0x34; //encoding
349 let Inst{40-32} = !if(P.HasSrc0, src0{8-0}, 0);
350 let Inst{49-41} = !if(P.HasSrc1, src1{8-0}, 0);
351 let Inst{58-50} = !if(P.HasSrc2, src2, 0);
353 let Inst{59} = !if(P.HasSrc0, src0{9}, 0); // acc(0)
354 let Inst{60} = !if(P.HasSrc1, src1{9}, 0); // acc(1)
356 let Inst{63-61} = !if(P.HasSrc1, blgp, 0);
360 class VOP3Pe_gfx10 <bits<10> op, VOPProfile P> : VOP3Pe<op, P> {
361 let Inst{31-26} = 0x33; //encoding
364 class VOP3be_gfx6_gfx7<bits<9> op, VOPProfile p> : VOP3be<p> {
365 let Inst{25-17} = op;
368 class VOP3be_gfx10<bits<10> op, VOPProfile p> : VOP3be<p> {
370 let Inst{15} = !if(p.HasClamp, clamp{0}, 0);
371 let Inst{25-16} = op;
372 let Inst{31-26} = 0x35;
375 class VOP3be_vi <bits<10> op, VOPProfile P> : VOP3be<P> {
377 let Inst{25-16} = op;
378 let Inst{15} = !if(P.HasClamp, clamp{0}, 0);
394 int UNUSED_PRESERVE = 2;
397 class VOP_SDWAe<VOPProfile P> : Enc64 {
400 bits<2> src0_modifiers; // float: {abs,neg}, int {sext}
402 bits<2> src1_modifiers;
407 let Inst{39-32} = !if(P.HasSrc0, src0{7-0}, 0);
408 let Inst{42-40} = !if(P.EmitDst, dst_sel{2-0}, 0);
409 let Inst{44-43} = !if(P.EmitDst, dst_unused{1-0}, 0);
410 let Inst{45} = !if(P.HasSDWAClamp, clamp{0}, 0);
411 let Inst{50-48} = !if(P.HasSrc0, src0_sel{2-0}, 0);
412 let Inst{51} = !if(P.HasSrc0IntMods, src0_modifiers{0}, 0);
413 let Inst{53-52} = !if(P.HasSrc0FloatMods, src0_modifiers{1-0}, 0);
414 let Inst{58-56} = !if(P.HasSrc1, src1_sel{2-0}, 0);
415 let Inst{59} = !if(P.HasSrc1IntMods, src1_modifiers{0}, 0);
416 let Inst{61-60} = !if(P.HasSrc1FloatMods, src1_modifiers{1-0}, 0);
419 // GFX9 adds two features to SDWA:
420 // 1. Add 3 fields to the SDWA microcode word: S0, S1 and OMOD.
421 // a. S0 and S1 indicate that source 0 and 1 respectively are SGPRs rather
422 // than VGPRs (at most 1 can be an SGPR);
423 // b. OMOD is the standard output modifier (result *2, *4, /2)
424 // 2. Add a new version of the SDWA microcode word for VOPC: SDWAB. This
425 // replaces OMOD and the dest fields with SD and SDST (SGPR destination)
427 // a. When SD=1, the SDST is used as the destination for the compare result;
428 // b. When SD=0, VCC is used.
430 // In GFX9, V_MAC_F16, V_MAC_F32 opcodes cannot be used with SDWA
432 // gfx9 SDWA basic encoding
433 class VOP_SDWA9e<VOPProfile P> : Enc64 {
434 bits<9> src0; // {src0_sgpr{0}, src0{7-0}}
436 bits<2> src0_modifiers; // float: {abs,neg}, int {sext}
438 bits<2> src1_modifiers;
441 let Inst{39-32} = !if(P.HasSrc0, src0{7-0}, 0);
442 let Inst{50-48} = !if(P.HasSrc0, src0_sel{2-0}, 0);
443 let Inst{51} = !if(P.HasSrc0IntMods, src0_modifiers{0}, 0);
444 let Inst{53-52} = !if(P.HasSrc0FloatMods, src0_modifiers{1-0}, 0);
445 let Inst{55} = !if(P.HasSrc0, src0{8}, 0);
446 let Inst{58-56} = !if(P.HasSrc1, src1_sel{2-0}, 0);
447 let Inst{59} = !if(P.HasSrc1IntMods, src1_modifiers{0}, 0);
448 let Inst{61-60} = !if(P.HasSrc1FloatMods, src1_modifiers{1-0}, 0);
449 let Inst{63} = 0; // src1_sgpr - should be specified in subclass
453 class VOP_SDWA9Ae<VOPProfile P> : VOP_SDWA9e<P> {
459 let Inst{42-40} = !if(P.EmitDst, dst_sel{2-0}, 0);
460 let Inst{44-43} = !if(P.EmitDst, dst_unused{1-0}, 0);
461 let Inst{45} = !if(P.HasSDWAClamp, clamp{0}, 0);
462 let Inst{47-46} = !if(P.HasSDWAOMod, omod{1-0}, 0);
466 class VOP_SDWA9Be<VOPProfile P> : VOP_SDWA9e<P> {
467 bits<8> sdst; // {vcc_sdst{0}, sdst{6-0}}
469 let Inst{46-40} = !if(P.EmitDst, sdst{6-0}, ?);
470 let Inst{47} = !if(P.EmitDst, sdst{7}, 0);
473 class VOP_SDWA_Pseudo <string opName, VOPProfile P, list<dag> pattern=[]> :
474 InstSI <P.OutsSDWA, P.InsSDWA, "", pattern>,
476 SIMCInstr <opName#"_sdwa", SIEncodingFamily.NONE>,
477 MnemonicAlias <opName#"_sdwa", opName> {
480 let isCodeGenOnly = 1;
481 let UseNamedOperandTable = 1;
483 string Mnemonic = opName;
484 string AsmOperands = P.AsmSDWA;
485 string AsmOperands9 = P.AsmSDWA9;
490 let hasSideEffects = 0;
496 let SubtargetPredicate = !if(P.HasExtSDWA, HasSDWA, DisableInst);
497 let AssemblerPredicate = !if(P.HasExtSDWA, HasSDWA, DisableInst);
498 let AsmVariantName = !if(P.HasExtSDWA, AMDGPUAsmVariants.SDWA,
499 AMDGPUAsmVariants.Disable);
500 let DecoderNamespace = "SDWA";
505 class VOP_SDWA_Real <VOP_SDWA_Pseudo ps> :
506 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>,
507 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.SDWA> {
510 let isCodeGenOnly = 0;
514 let SchedRW = ps.SchedRW;
515 let hasSideEffects = ps.hasSideEffects;
517 let Constraints = ps.Constraints;
518 let DisableEncoding = ps.DisableEncoding;
520 // Copy relevant pseudo op flags
521 let SubtargetPredicate = ps.SubtargetPredicate;
522 let AssemblerPredicate = ps.AssemblerPredicate;
523 let AsmMatchConverter = ps.AsmMatchConverter;
524 let AsmVariantName = ps.AsmVariantName;
525 let UseNamedOperandTable = ps.UseNamedOperandTable;
526 let DecoderNamespace = ps.DecoderNamespace;
527 let Constraints = ps.Constraints;
528 let DisableEncoding = ps.DisableEncoding;
529 let TSFlags = ps.TSFlags;
532 class Base_VOP_SDWA9_Real <VOP_SDWA_Pseudo ps> :
533 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands9, []> {
536 let isCodeGenOnly = 0;
540 let SchedRW = ps.SchedRW;
541 let hasSideEffects = ps.hasSideEffects;
543 let Constraints = ps.Constraints;
544 let DisableEncoding = ps.DisableEncoding;
546 let SubtargetPredicate = !if(ps.Pfl.HasExtSDWA9, HasSDWA9, DisableInst);
547 let AssemblerPredicate = !if(ps.Pfl.HasExtSDWA9, HasSDWA9, DisableInst);
548 let AsmVariantName = !if(ps.Pfl.HasExtSDWA9, AMDGPUAsmVariants.SDWA9,
549 AMDGPUAsmVariants.Disable);
550 let DecoderNamespace = "SDWA9";
552 // Copy relevant pseudo op flags
553 let AsmMatchConverter = ps.AsmMatchConverter;
554 let UseNamedOperandTable = ps.UseNamedOperandTable;
555 let Constraints = ps.Constraints;
556 let DisableEncoding = ps.DisableEncoding;
557 let TSFlags = ps.TSFlags;
560 class VOP_SDWA9_Real <VOP_SDWA_Pseudo ps> :
561 Base_VOP_SDWA9_Real <ps >,
562 SIMCInstr <ps.PseudoInstr, SIEncodingFamily.SDWA9>;
564 class Base_VOP_SDWA10_Real<VOP_SDWA_Pseudo ps> : Base_VOP_SDWA9_Real<ps> {
565 let SubtargetPredicate = !if(ps.Pfl.HasExtSDWA9, HasSDWA10, DisableInst);
566 let AssemblerPredicate = !if(ps.Pfl.HasExtSDWA9, HasSDWA10, DisableInst);
567 let DecoderNamespace = "SDWA10";
570 class VOP_SDWA10_Real<VOP_SDWA_Pseudo ps> :
571 Base_VOP_SDWA10_Real<ps>, SIMCInstr<ps.PseudoInstr, SIEncodingFamily.SDWA10>;
573 class VOP_DPPe<VOPProfile P, bit IsDPP16=0> : Enc64 {
574 bits<2> src0_modifiers;
576 bits<2> src1_modifiers;
583 let Inst{39-32} = !if(P.HasSrc0, src0{7-0}, 0);
584 let Inst{48-40} = dpp_ctrl;
585 let Inst{50} = !if(IsDPP16, fi, ?);
586 let Inst{51} = bound_ctrl;
587 let Inst{52} = !if(P.HasSrc0Mods, src0_modifiers{0}, 0); // src0_neg
588 let Inst{53} = !if(P.HasSrc0Mods, src0_modifiers{1}, 0); // src0_abs
589 let Inst{54} = !if(P.HasSrc1Mods, src1_modifiers{0}, 0); // src1_neg
590 let Inst{55} = !if(P.HasSrc1Mods, src1_modifiers{1}, 0); // src1_abs
591 let Inst{59-56} = bank_mask;
592 let Inst{63-60} = row_mask;
595 class VOP_DPP_Pseudo <string OpName, VOPProfile P, list<dag> pattern=[]> :
596 InstSI <P.OutsDPP, P.InsDPP, OpName#P.AsmDPP, pattern>,
598 SIMCInstr <OpName#"_dpp", SIEncodingFamily.NONE>,
599 MnemonicAlias <OpName#"_dpp", OpName> {
602 let isCodeGenOnly = 1;
606 let hasSideEffects = 0;
607 let UseNamedOperandTable = 1;
613 let isConvergent = 1;
615 string Mnemonic = OpName;
616 string AsmOperands = P.AsmDPP;
618 let AsmMatchConverter = !if(!eq(P.HasModifiers,1), "cvtDPP", "");
619 let SubtargetPredicate = HasDPP;
620 let AssemblerPredicate = !if(P.HasExtDPP, HasDPP, DisableInst);
621 let AsmVariantName = !if(P.HasExtDPP, AMDGPUAsmVariants.DPP,
622 AMDGPUAsmVariants.Disable);
623 let Constraints = !if(P.NumSrcArgs, P.TieRegDPP # " = $vdst", "");
624 let DisableEncoding = !if(P.NumSrcArgs, P.TieRegDPP, "");
625 let DecoderNamespace = "DPP";
630 class VOP_DPP_Real <VOP_DPP_Pseudo ps, int EncodingFamily> :
631 InstSI <ps.OutOperandList, ps.InOperandList, ps.Mnemonic # ps.AsmOperands, []>,
632 SIMCInstr <ps.PseudoInstr, EncodingFamily> {
635 let isCodeGenOnly = 0;
639 let SchedRW = ps.SchedRW;
640 let hasSideEffects = ps.hasSideEffects;
642 let Constraints = ps.Constraints;
643 let DisableEncoding = ps.DisableEncoding;
645 // Copy relevant pseudo op flags
646 let isConvergent = ps.isConvergent;
647 let SubtargetPredicate = ps.SubtargetPredicate;
648 let AssemblerPredicate = ps.AssemblerPredicate;
649 let AsmMatchConverter = ps.AsmMatchConverter;
650 let AsmVariantName = ps.AsmVariantName;
651 let UseNamedOperandTable = ps.UseNamedOperandTable;
652 let DecoderNamespace = ps.DecoderNamespace;
653 let Constraints = ps.Constraints;
654 let DisableEncoding = ps.DisableEncoding;
655 let TSFlags = ps.TSFlags;
658 class VOP_DPP <string OpName, VOPProfile P, bit IsDPP16,
659 dag InsDPP = !if(IsDPP16, P.InsDPP16, P.InsDPP),
660 string AsmDPP = !if(IsDPP16, P.AsmDPP16, P.AsmDPP)> :
661 InstSI <P.OutsDPP, InsDPP, OpName#AsmDPP, []>,
662 VOP_DPPe<P, IsDPP16> {
666 let hasSideEffects = 0;
667 let UseNamedOperandTable = 1;
673 let AsmMatchConverter = !if(!eq(P.HasModifiers,1), "cvtDPP", "");
674 let SubtargetPredicate = HasDPP;
675 let AssemblerPredicate = !if(P.HasExtDPP, HasDPP, DisableInst);
676 let AsmVariantName = !if(P.HasExtDPP, AMDGPUAsmVariants.DPP,
677 AMDGPUAsmVariants.Disable);
678 let Constraints = !if(P.NumSrcArgs, P.TieRegDPP # " = $vdst", "");
679 let DisableEncoding = !if(P.NumSrcArgs, P.TieRegDPP, "");
680 let DecoderNamespace = "DPP";
683 class VOP_DPP8e<VOPProfile P> : Enc64 {
688 let Inst{39-32} = !if(P.HasSrc0, src0{7-0}, 0);
689 let Inst{63-40} = dpp8{23-0};
692 class VOP_DPP8<string OpName, VOPProfile P> :
693 InstSI<P.OutsDPP8, P.InsDPP8, OpName#P.AsmDPP8, []>,
698 let hasSideEffects = 0;
699 let UseNamedOperandTable = 1;
705 let AsmMatchConverter = "cvtDPP8";
706 let SubtargetPredicate = HasDPP8;
707 let AssemblerPredicate = !if(P.HasExt, HasDPP8, DisableInst);
708 let AsmVariantName = !if(P.HasExt, AMDGPUAsmVariants.DPP,
709 AMDGPUAsmVariants.Disable);
710 let Constraints = !if(P.NumSrcArgs, P.TieRegDPP # " = $vdst", "");
711 let DisableEncoding = !if(P.NumSrcArgs, P.TieRegDPP, "");
719 class getNumNodeArgs<SDPatternOperator Op> {
720 SDNode N = !cast<SDNode>(Op);
721 SDTypeProfile TP = N.TypeProfile;
722 int ret = TP.NumOperands;
726 class getDivergentFrag<SDPatternOperator Op> {
728 int NumSrcArgs = getNumNodeArgs<Op>.ret;
729 PatFrag ret = PatFrag <
730 !if(!eq(NumSrcArgs, 1),
732 !if(!eq(NumSrcArgs, 2),
733 (ops node:$src0, node:$src1),
734 (ops node:$src0, node:$src1, node:$src2))),
735 !if(!eq(NumSrcArgs, 1),
737 !if(!eq(NumSrcArgs, 2),
739 (Op $src0, $src1, $src2))),
740 [{ return N->isDivergent(); }]
744 class VOPPatGen<SDPatternOperator Op, VOPProfile P> {
746 PatFrag Operator = getDivergentFrag < Op >.ret;
748 dag Ins = !foreach(tmp, P.Ins32, !subst(ins, Operator,
749 !subst(P.Src0RC32, P.Src0VT,
750 !subst(P.Src1RC32, P.Src1VT, tmp))));
753 dag Outs = !foreach(tmp, P.Outs32, !subst(outs, set,
754 !subst(P.DstRC, P.DstVT, tmp)));
756 list<dag> ret = [!con(Outs, (set Ins))];
759 class VOPPatOrNull<SDPatternOperator Op, VOPProfile P> {
760 list<dag> ret = !if(!ne(P.NeedPatGen,PatGenMode.NoPattern), VOPPatGen<Op, P>.ret, []);
763 class DivergentFragOrOp<SDPatternOperator Op, VOPProfile P> {
764 SDPatternOperator ret = !if(!eq(P.NeedPatGen,PatGenMode.Pattern),
765 !if(!isa<SDNode>(Op), getDivergentFrag<Op>.ret, Op), Op);
768 include "VOPCInstructions.td"
769 include "VOP1Instructions.td"
770 include "VOP2Instructions.td"
771 include "VOP3Instructions.td"
772 include "VOP3PInstructions.td"