1 //===-- VINTERPInstructions.td - VINTERP Instruction Definitions ----------===//
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 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class VINTERPe <VOPProfile P> : Enc64 {
15 bits<4> src0_modifiers;
17 bits<3> src1_modifiers;
19 bits<3> src2_modifiers;
24 let Inst{31-26} = 0x33; // VOP3P encoding
25 let Inst{25-24} = 0x1; // VINTERP sub-encoding
28 let Inst{10-8} = waitexp;
29 let Inst{11} = !if(P.HasOpSel, src0_modifiers{2}, 0); // op_sel(0)
30 let Inst{12} = !if(P.HasOpSel, src1_modifiers{2}, 0); // op_sel(1)
31 let Inst{13} = !if(P.HasOpSel, src2_modifiers{2}, 0); // op_sel(2)
32 let Inst{14} = !if(P.HasOpSel, src0_modifiers{3}, 0); // op_sel(3)
34 let Inst{40-32} = src0;
35 let Inst{49-41} = src1;
36 let Inst{58-50} = src2;
37 let Inst{61} = src0_modifiers{0}; // neg(0)
38 let Inst{62} = src1_modifiers{0}; // neg(1)
39 let Inst{63} = src2_modifiers{0}; // neg(2)
42 class VINTERPe_gfx11 <bits<7> op, VOPProfile P> : VINTERPe<P> {
46 class VINTERPe_gfx12 <bits<7> op, VOPProfile P> : VINTERPe<P> {
47 let Inst{20-16} = op{4-0};
50 //===----------------------------------------------------------------------===//
52 //===----------------------------------------------------------------------===//
54 class VINTERP_Pseudo <string OpName, VOPProfile P, list<dag> pattern = []> :
55 VOP3_Pseudo<OpName, P, pattern, 0, 0> {
56 let AsmMatchConverter = "cvtVINTERP";
57 let mayRaiseFPException = 0;
63 class VINTERP_Real <VOP_Pseudo ps, int EncodingFamily> :
64 VOP3_Real <ps, EncodingFamily> {
68 def VOP3_VINTERP_F32 : VOPProfile<[f32, f32, f32, f32]> {
72 let Src0Mod = FPVRegInputMods;
73 let Src1Mod = FPVRegInputMods;
74 let Src2Mod = FPVRegInputMods;
76 let Outs64 = (outs VGPR_32:$vdst);
77 let Ins64 = (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
78 Src1Mod:$src1_modifiers, VRegSrc_32:$src1,
79 Src2Mod:$src2_modifiers, VRegSrc_32:$src2,
83 let Asm64 = " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$waitexp";
86 class VOP3_VINTERP_F16 <list<ValueType> ArgVT> : VOPProfile<ArgVT> {
90 let Src0Mod = FPVRegInputMods;
91 let Src1Mod = FPVRegInputMods;
92 let Src2Mod = FPVRegInputMods;
94 let Outs64 = (outs VGPR_32:$vdst);
95 let Ins64 = (ins Src0Mod:$src0_modifiers, VRegSrc_32:$src0,
96 Src1Mod:$src1_modifiers, VRegSrc_32:$src1,
97 Src2Mod:$src2_modifiers, VRegSrc_32:$src2,
98 Clamp:$clamp, op_sel0:$op_sel,
101 let Asm64 = " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$clamp$op_sel$waitexp";
104 //===----------------------------------------------------------------------===//
105 // VINTERP Pseudo Instructions
106 //===----------------------------------------------------------------------===//
108 let SubtargetPredicate = HasVINTERPEncoding in {
110 let Uses = [M0, EXEC, MODE] in {
111 def V_INTERP_P10_F32_inreg : VINTERP_Pseudo <"v_interp_p10_f32", VOP3_VINTERP_F32>;
112 def V_INTERP_P2_F32_inreg : VINTERP_Pseudo <"v_interp_p2_f32", VOP3_VINTERP_F32>;
113 def V_INTERP_P10_F16_F32_inreg :
114 VINTERP_Pseudo <"v_interp_p10_f16_f32", VOP3_VINTERP_F16<[f32, f32, f32, f32]>>;
115 def V_INTERP_P2_F16_F32_inreg :
116 VINTERP_Pseudo <"v_interp_p2_f16_f32", VOP3_VINTERP_F16<[f16, f32, f32, f32]>>;
117 } // Uses = [M0, EXEC, MODE]
119 let Uses = [M0, EXEC] in {
120 def V_INTERP_P10_RTZ_F16_F32_inreg :
121 VINTERP_Pseudo <"v_interp_p10_rtz_f16_f32", VOP3_VINTERP_F16<[f32, f32, f32, f32]>>;
122 def V_INTERP_P2_RTZ_F16_F32_inreg :
123 VINTERP_Pseudo <"v_interp_p2_rtz_f16_f32", VOP3_VINTERP_F16<[f16, f32, f32, f32]>>;
124 } // Uses = [M0, EXEC]
126 } // SubtargetPredicate = HasVINTERPEncoding.
128 class VInterpF32Pat <SDPatternOperator op, Instruction inst> : GCNPat <
130 (VINTERPMods f32:$src0, i32:$src0_modifiers),
131 (VINTERPMods f32:$src1, i32:$src1_modifiers),
132 (VINTERPMods f32:$src2, i32:$src2_modifiers))),
133 (inst $src0_modifiers, $src0,
134 $src1_modifiers, $src1,
135 $src2_modifiers, $src2,
145 class VInterpF16Pat <SDPatternOperator op, Instruction inst,
146 ValueType dst_type, bit high,
147 list<ComplexPattern> pat> : GCNPat <
149 (pat[0] f32:$src0, i32:$src0_modifiers),
150 (pat[1] f32:$src1, i32:$src1_modifiers),
151 (pat[2] f32:$src2, i32:$src2_modifiers),
152 !if(high, (i1 -1), (i1 0)))),
153 (inst $src0_modifiers, $src0,
154 $src1_modifiers, $src1,
155 $src2_modifiers, $src2,
161 multiclass VInterpF16Pat <SDPatternOperator op, Instruction inst,
162 ValueType dst_type, list<ComplexPattern> high_pat> {
163 def : VInterpF16Pat<op, inst, dst_type, 0,
164 [VINTERPMods, VINTERPMods, VINTERPMods]>;
165 def : VInterpF16Pat<op, inst, dst_type, 1, high_pat>;
168 def : VInterpF32Pat<int_amdgcn_interp_inreg_p10, V_INTERP_P10_F32_inreg>;
169 def : VInterpF32Pat<int_amdgcn_interp_inreg_p2, V_INTERP_P2_F32_inreg>;
170 defm : VInterpF16Pat<int_amdgcn_interp_inreg_p10_f16,
171 V_INTERP_P10_F16_F32_inreg, f32,
172 [VINTERPModsHi, VINTERPMods, VINTERPModsHi]>;
173 defm : VInterpF16Pat<int_amdgcn_interp_inreg_p2_f16,
174 V_INTERP_P2_F16_F32_inreg, f16,
175 [VINTERPModsHi, VINTERPMods, VINTERPMods]>;
176 defm : VInterpF16Pat<int_amdgcn_interp_p10_rtz_f16,
177 V_INTERP_P10_RTZ_F16_F32_inreg, f32,
178 [VINTERPModsHi, VINTERPMods, VINTERPModsHi]>;
179 defm : VInterpF16Pat<int_amdgcn_interp_p2_rtz_f16,
180 V_INTERP_P2_RTZ_F16_F32_inreg, f16,
181 [VINTERPModsHi, VINTERPMods, VINTERPMods]>;
183 //===----------------------------------------------------------------------===//
184 // VINTERP Real Instructions
185 //===----------------------------------------------------------------------===//
187 multiclass VINTERP_Real_gfx11 <bits<7> op> {
188 let AssemblerPredicate = isGFX11Only, DecoderNamespace = "GFX11" in {
190 VINTERP_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.GFX11>,
191 VINTERPe_gfx11<op, !cast<VOP3_Pseudo>(NAME).Pfl>;
195 multiclass VINTERP_Real_gfx12 <bits<7> op> {
196 let AssemblerPredicate = isGFX12Only, DecoderNamespace = "GFX12" in {
198 VINTERP_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.GFX12>,
199 VINTERPe_gfx12<op, !cast<VOP3_Pseudo>(NAME).Pfl>;
203 multiclass VINTERP_Real_gfx11_gfx12 <bits<7> op> :
204 VINTERP_Real_gfx11<op>, VINTERP_Real_gfx12<op>;
206 defm V_INTERP_P10_F32_inreg : VINTERP_Real_gfx11_gfx12<0x000>;
207 defm V_INTERP_P2_F32_inreg : VINTERP_Real_gfx11_gfx12<0x001>;
208 defm V_INTERP_P10_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x002>;
209 defm V_INTERP_P2_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x003>;
210 defm V_INTERP_P10_RTZ_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x004>;
211 defm V_INTERP_P2_RTZ_F16_F32_inreg : VINTERP_Real_gfx11_gfx12<0x005>;