1//===-- VINTERPInstructions.td - VINTERP Instruction Definitions ----------===// 2// 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 6// 7//===----------------------------------------------------------------------===// 8 9//===----------------------------------------------------------------------===// 10// VINTERP encoding 11//===----------------------------------------------------------------------===// 12 13class VINTERPe_gfx11 <bits<7> op, VOPProfile P> : Enc64 { 14 bits<8> vdst; 15 bits<4> src0_modifiers; 16 bits<9> src0; 17 bits<3> src1_modifiers; 18 bits<9> src1; 19 bits<3> src2_modifiers; 20 bits<9> src2; 21 bits<1> clamp; 22 bits<3> waitexp; 23 24 let Inst{31-26} = 0x33; // VOP3P encoding 25 let Inst{25-24} = 0x1; // VINTERP sub-encoding 26 let Inst{23} = 0; // reserved 27 28 let Inst{7-0} = vdst; 29 let Inst{10-8} = waitexp; 30 let Inst{11} = !if(P.HasOpSel, src0_modifiers{2}, 0); // op_sel(0) 31 let Inst{12} = !if(P.HasOpSel, src1_modifiers{2}, 0); // op_sel(1) 32 let Inst{13} = !if(P.HasOpSel, src2_modifiers{2}, 0); // op_sel(2) 33 let Inst{14} = !if(P.HasOpSel, src0_modifiers{3}, 0); // op_sel(3) 34 let Inst{15} = clamp; 35 let Inst{22-16} = op; 36 let Inst{40-32} = src0; 37 let Inst{49-41} = src1; 38 let Inst{58-50} = src2; 39 let Inst{61} = src0_modifiers{0}; // neg(0) 40 let Inst{62} = src1_modifiers{0}; // neg(1) 41 let Inst{63} = src2_modifiers{0}; // neg(2) 42} 43 44//===----------------------------------------------------------------------===// 45// VOP3 VINTERP 46//===----------------------------------------------------------------------===// 47 48class VINTERP_Pseudo <string OpName, VOPProfile P, list<dag> pattern = []> : 49 VOP3_Pseudo<OpName, P, pattern, 0, 0> { 50 let AsmMatchConverter = "cvtVINTERP"; 51 let mayRaiseFPException = 0; 52 53 let VOP3_OPSEL = 1; 54 let VINTERP = 1; 55} 56 57class VINTERP_Real <VOP_Pseudo ps, int EncodingFamily> : 58 VOP3_Real <ps, EncodingFamily> { 59 let VINTERP = 1; 60} 61 62def VOP3_VINTERP_F32 : VOPProfile<[f32, f32, f32, f32]> { 63 let HasOpSel = 0; 64 let HasModifiers = 1; 65 66 let Outs64 = (outs VGPR_32:$vdst); 67 let Ins64 = (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0, 68 Src1Mod:$src1_modifiers, VRegSrc_32:$src1, 69 Src2Mod:$src2_modifiers, VRegSrc_32:$src2, 70 clampmod:$clamp, 71 wait_exp:$waitexp); 72 73 let Asm64 = " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$waitexp"; 74} 75 76class VOP3_VINTERP_F16 <list<ValueType> ArgVT> : VOPProfile<ArgVT> { 77 let HasOpSel = 1; 78 let HasModifiers = 1; 79 80 let Outs64 = (outs VGPR_32:$vdst); 81 let Ins64 = (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0, 82 Src1Mod:$src1_modifiers, VRegSrc_32:$src1, 83 Src2Mod:$src2_modifiers, VRegSrc_32:$src2, 84 clampmod:$clamp, op_sel0:$op_sel, 85 wait_exp:$waitexp); 86 87 let Asm64 = " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$op_sel$waitexp"; 88} 89 90//===----------------------------------------------------------------------===// 91// VINTERP Pseudo Instructions 92//===----------------------------------------------------------------------===// 93 94let SubtargetPredicate = isGFX11Plus in { 95 96let Uses = [M0, EXEC, MODE] in { 97def V_INTERP_P10_F32_inreg : VINTERP_Pseudo <"v_interp_p10_f32", VOP3_VINTERP_F32>; 98def V_INTERP_P2_F32_inreg : VINTERP_Pseudo <"v_interp_p2_f32", VOP3_VINTERP_F32>; 99def V_INTERP_P10_F16_F32_inreg : 100 VINTERP_Pseudo <"v_interp_p10_f16_f32", VOP3_VINTERP_F16<[f32, f32, f32, f32]>>; 101def V_INTERP_P2_F16_F32_inreg : 102 VINTERP_Pseudo <"v_interp_p2_f16_f32", VOP3_VINTERP_F16<[f16, f32, f32, f32]>>; 103} // Uses = [M0, EXEC, MODE] 104 105let Uses = [M0, EXEC] in { 106def V_INTERP_P10_RTZ_F16_F32_inreg : 107 VINTERP_Pseudo <"v_interp_p10_rtz_f16_f32", VOP3_VINTERP_F16<[f32, f32, f32, f32]>>; 108def V_INTERP_P2_RTZ_F16_F32_inreg : 109 VINTERP_Pseudo <"v_interp_p2_rtz_f16_f32", VOP3_VINTERP_F16<[f16, f32, f32, f32]>>; 110} // Uses = [M0, EXEC] 111 112} // SubtargetPredicate = isGFX11Plus 113 114class VInterpF32Pat <SDPatternOperator op, Instruction inst> : GCNPat < 115 (f32 (op 116 (VINTERPMods f32:$src0, i32:$src0_modifiers), 117 (VINTERPMods f32:$src1, i32:$src1_modifiers), 118 (VINTERPMods f32:$src2, i32:$src2_modifiers))), 119 (inst $src0_modifiers, $src0, 120 $src1_modifiers, $src1, 121 $src2_modifiers, $src2, 122 0, /* clamp */ 123 7) /* wait_exp */ 124>; 125 126def VINTERP_OPSEL { 127 int LOW = 0; 128 int HIGH = 0xa; 129} 130 131class VInterpF16Pat <SDPatternOperator op, Instruction inst, 132 ValueType dst_type, bit high, 133 list<ComplexPattern> pat> : GCNPat < 134 (dst_type (op 135 (pat[0] f32:$src0, i32:$src0_modifiers), 136 (pat[1] f32:$src1, i32:$src1_modifiers), 137 (pat[2] f32:$src2, i32:$src2_modifiers), 138 !if(high, (i1 -1), (i1 0)))), 139 (inst $src0_modifiers, $src0, 140 $src1_modifiers, $src1, 141 $src2_modifiers, $src2, 142 0, /* clamp */ 143 /* op_sel = 0 */ 144 7) /* wait_exp */ 145>; 146 147multiclass VInterpF16Pat <SDPatternOperator op, Instruction inst, 148 ValueType dst_type, list<ComplexPattern> high_pat> { 149 def : VInterpF16Pat<op, inst, dst_type, 0, 150 [VINTERPMods, VINTERPMods, VINTERPMods]>; 151 def : VInterpF16Pat<op, inst, dst_type, 1, high_pat>; 152} 153 154def : VInterpF32Pat<int_amdgcn_interp_inreg_p10, V_INTERP_P10_F32_inreg>; 155def : VInterpF32Pat<int_amdgcn_interp_inreg_p2, V_INTERP_P2_F32_inreg>; 156defm : VInterpF16Pat<int_amdgcn_interp_inreg_p10_f16, 157 V_INTERP_P10_F16_F32_inreg, f32, 158 [VINTERPModsHi, VINTERPMods, VINTERPModsHi]>; 159defm : VInterpF16Pat<int_amdgcn_interp_inreg_p2_f16, 160 V_INTERP_P2_F16_F32_inreg, f16, 161 [VINTERPModsHi, VINTERPMods, VINTERPMods]>; 162 163//===----------------------------------------------------------------------===// 164// VINTERP Real Instructions 165//===----------------------------------------------------------------------===// 166 167let AssemblerPredicate = isGFX11Plus, DecoderNamespace = "GFX11" in { 168 multiclass VINTERP_Real_gfx11 <bits<7> op> { 169 def _gfx11 : 170 VINTERP_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.GFX11>, 171 VINTERPe_gfx11<op, !cast<VOP3_Pseudo>(NAME).Pfl>; 172 } 173} 174 175defm V_INTERP_P10_F32_inreg : VINTERP_Real_gfx11<0x000>; 176defm V_INTERP_P2_F32_inreg : VINTERP_Real_gfx11<0x001>; 177defm V_INTERP_P10_F16_F32_inreg : VINTERP_Real_gfx11<0x002>; 178defm V_INTERP_P2_F16_F32_inreg : VINTERP_Real_gfx11<0x003>; 179defm V_INTERP_P10_RTZ_F16_F32_inreg : VINTERP_Real_gfx11<0x004>; 180defm V_INTERP_P2_RTZ_F16_F32_inreg : VINTERP_Real_gfx11<0x005>; 181