| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 1 | //===-- VOP3PInstructions.td - Vector Instruction Defintions --------------===// |
| 2 | // |
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | // VOP3P Classes |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | class VOP3PInst<string OpName, VOPProfile P, SDPatternOperator node = null_frag> : |
| 14 | VOP3P_Pseudo<OpName, P, |
| 15 | !if(P.HasModifiers, getVOP3PModPat<P, node>.ret, getVOP3Pat<P, node>.ret) |
| 16 | >; |
| 17 | |
| Dmitry Preobrazhensky | b2d24e2 | 2017-07-07 14:29:06 +0000 | [diff] [blame] | 18 | // Non-packed instructions that use the VOP3P encoding. |
| 19 | // VOP3 neg/abs and VOP3P opsel/opsel_hi modifiers are allowed. |
| Matt Arsenault | e135c4c | 2017-09-20 20:53:49 +0000 | [diff] [blame] | 20 | class VOP3_VOP3PInst<string OpName, VOPProfile P, bit UseTiedOutput = 0, |
| 21 | SDPatternOperator node = null_frag> : |
| Dmitry Preobrazhensky | b2d24e2 | 2017-07-07 14:29:06 +0000 | [diff] [blame] | 22 | VOP3P_Pseudo<OpName, P> { |
| Matt Arsenault | c8f8cda | 2017-08-30 22:18:40 +0000 | [diff] [blame] | 23 | // These operands are only sort of f16 operands. Depending on |
| 24 | // op_sel_hi, these may be interpreted as f32. The inline immediate |
| 25 | // values are really f16 converted to f32, so we treat these as f16 |
| 26 | // operands. |
| Dmitry Preobrazhensky | b2d24e2 | 2017-07-07 14:29:06 +0000 | [diff] [blame] | 27 | let InOperandList = |
| Matt Arsenault | e135c4c | 2017-09-20 20:53:49 +0000 | [diff] [blame] | 28 | !con( |
| 29 | !con( |
| 30 | (ins FP16InputMods:$src0_modifiers, VCSrc_f16:$src0, |
| 31 | FP16InputMods:$src1_modifiers, VCSrc_f16:$src1, |
| 32 | FP16InputMods:$src2_modifiers, VCSrc_f16:$src2, |
| 33 | clampmod:$clamp), |
| 34 | !if(UseTiedOutput, (ins VGPR_32:$vdst_in), (ins))), |
| 35 | (ins op_sel:$op_sel, op_sel_hi:$op_sel_hi)); |
| 36 | |
| 37 | let Constraints = !if(UseTiedOutput, "$vdst = $vdst_in", ""); |
| 38 | let DisableEncoding = !if(UseTiedOutput, "$vdst_in", ""); |
| Dmitry Preobrazhensky | b2d24e2 | 2017-07-07 14:29:06 +0000 | [diff] [blame] | 39 | let AsmOperands = |
| 40 | " $vdst, $src0_modifiers, $src1_modifiers, $src2_modifiers$op_sel$op_sel_hi$clamp"; |
| 41 | } |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 42 | |
| 43 | let isCommutable = 1 in { |
| Dmitry Preobrazhensky | 095ec3da | 2017-07-18 09:24:10 +0000 | [diff] [blame] | 44 | def V_PK_MAD_I16 : VOP3PInst<"v_pk_mad_i16", VOP3_Profile<VOP_V2I16_V2I16_V2I16_V2I16>>; |
| 45 | def V_PK_MAD_U16 : VOP3PInst<"v_pk_mad_u16", VOP3_Profile<VOP_V2I16_V2I16_V2I16_V2I16>>; |
| 46 | |
| Tim Corringham | 4c4d2fe | 2018-12-10 12:06:10 +0000 | [diff] [blame] | 47 | let FPDPRounding = 1 in { |
| 48 | def V_PK_FMA_F16 : VOP3PInst<"v_pk_fma_f16", VOP3_Profile<VOP_V2F16_V2F16_V2F16_V2F16>, fma>; |
| Matt Arsenault | eb522e6 | 2017-02-27 22:15:25 +0000 | [diff] [blame] | 49 | def V_PK_ADD_F16 : VOP3PInst<"v_pk_add_f16", VOP3_Profile<VOP_V2F16_V2F16_V2F16>, fadd>; |
| 50 | def V_PK_MUL_F16 : VOP3PInst<"v_pk_mul_f16", VOP3_Profile<VOP_V2F16_V2F16_V2F16>, fmul>; |
| Tim Corringham | 4c4d2fe | 2018-12-10 12:06:10 +0000 | [diff] [blame] | 51 | } // End FPDPRounding = 1 |
| Matt Arsenault | 687ec75 | 2018-10-22 16:27:27 +0000 | [diff] [blame] | 52 | def V_PK_MAX_F16 : VOP3PInst<"v_pk_max_f16", VOP3_Profile<VOP_V2F16_V2F16_V2F16>, fmaxnum_like>; |
| 53 | def V_PK_MIN_F16 : VOP3PInst<"v_pk_min_f16", VOP3_Profile<VOP_V2F16_V2F16_V2F16>, fminnum_like>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 54 | |
| Matt Arsenault | eb522e6 | 2017-02-27 22:15:25 +0000 | [diff] [blame] | 55 | def V_PK_ADD_U16 : VOP3PInst<"v_pk_add_u16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, add>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 56 | def V_PK_ADD_I16 : VOP3PInst<"v_pk_add_i16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>>; |
| Matt Arsenault | eb522e6 | 2017-02-27 22:15:25 +0000 | [diff] [blame] | 57 | def V_PK_MUL_LO_U16 : VOP3PInst<"v_pk_mul_lo_u16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, mul>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 58 | |
| Matt Arsenault | eb522e6 | 2017-02-27 22:15:25 +0000 | [diff] [blame] | 59 | def V_PK_MIN_I16 : VOP3PInst<"v_pk_min_i16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, smin>; |
| 60 | def V_PK_MIN_U16 : VOP3PInst<"v_pk_min_u16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, umin>; |
| 61 | def V_PK_MAX_I16 : VOP3PInst<"v_pk_max_i16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, smax>; |
| 62 | def V_PK_MAX_U16 : VOP3PInst<"v_pk_max_u16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, umax>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| Dmitry Preobrazhensky | 095ec3da | 2017-07-18 09:24:10 +0000 | [diff] [blame] | 65 | def V_PK_SUB_U16 : VOP3PInst<"v_pk_sub_u16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>>; |
| 66 | def V_PK_SUB_I16 : VOP3PInst<"v_pk_sub_i16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, sub>; |
| 67 | |
| Matt Arsenault | eb522e6 | 2017-02-27 22:15:25 +0000 | [diff] [blame] | 68 | def V_PK_LSHLREV_B16 : VOP3PInst<"v_pk_lshlrev_b16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, lshl_rev>; |
| 69 | def V_PK_ASHRREV_I16 : VOP3PInst<"v_pk_ashrrev_i16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, ashr_rev>; |
| 70 | def V_PK_LSHRREV_B16 : VOP3PInst<"v_pk_lshrrev_b16", VOP3_Profile<VOP_V2I16_V2I16_V2I16>, lshr_rev>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 71 | |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 72 | multiclass MadFmaMixPats<SDPatternOperator fma_like, |
| 73 | Instruction mix_inst, |
| 74 | Instruction mixlo_inst, |
| 75 | Instruction mixhi_inst> { |
| 76 | def : GCNPat < |
| 77 | (f16 (fpround (fma_like (f32 (VOP3PMadMixMods f16:$src0, i32:$src0_modifiers)), |
| 78 | (f32 (VOP3PMadMixMods f16:$src1, i32:$src1_modifiers)), |
| 79 | (f32 (VOP3PMadMixMods f16:$src2, i32:$src2_modifiers))))), |
| 80 | (mixlo_inst $src0_modifiers, $src0, |
| 81 | $src1_modifiers, $src1, |
| 82 | $src2_modifiers, $src2, |
| 83 | DSTCLAMP.NONE, |
| 84 | (i32 (IMPLICIT_DEF))) |
| 85 | >; |
| 86 | |
| 87 | // FIXME: Special case handling for maxhi (especially for clamp) |
| 88 | // because dealing with the write to high half of the register is |
| 89 | // difficult. |
| 90 | def : GCNPat < |
| 91 | (build_vector f16:$elt0, (fpround (fma_like (f32 (VOP3PMadMixMods f16:$src0, i32:$src0_modifiers)), |
| 92 | (f32 (VOP3PMadMixMods f16:$src1, i32:$src1_modifiers)), |
| 93 | (f32 (VOP3PMadMixMods f16:$src2, i32:$src2_modifiers))))), |
| 94 | (v2f16 (mixhi_inst $src0_modifiers, $src0, |
| 95 | $src1_modifiers, $src1, |
| 96 | $src2_modifiers, $src2, |
| 97 | DSTCLAMP.NONE, |
| 98 | $elt0)) |
| 99 | >; |
| 100 | |
| 101 | def : GCNPat < |
| 102 | (build_vector |
| 103 | f16:$elt0, |
| 104 | (AMDGPUclamp (fpround (fma_like (f32 (VOP3PMadMixMods f16:$src0, i32:$src0_modifiers)), |
| 105 | (f32 (VOP3PMadMixMods f16:$src1, i32:$src1_modifiers)), |
| 106 | (f32 (VOP3PMadMixMods f16:$src2, i32:$src2_modifiers)))))), |
| 107 | (v2f16 (mixhi_inst $src0_modifiers, $src0, |
| 108 | $src1_modifiers, $src1, |
| 109 | $src2_modifiers, $src2, |
| 110 | DSTCLAMP.ENABLE, |
| 111 | $elt0)) |
| 112 | >; |
| 113 | |
| 114 | def : GCNPat < |
| 115 | (AMDGPUclamp (build_vector |
| 116 | (fpround (fma_like (f32 (VOP3PMadMixMods f16:$lo_src0, i32:$lo_src0_modifiers)), |
| 117 | (f32 (VOP3PMadMixMods f16:$lo_src1, i32:$lo_src1_modifiers)), |
| 118 | (f32 (VOP3PMadMixMods f16:$lo_src2, i32:$lo_src2_modifiers)))), |
| 119 | (fpround (fma_like (f32 (VOP3PMadMixMods f16:$hi_src0, i32:$hi_src0_modifiers)), |
| 120 | (f32 (VOP3PMadMixMods f16:$hi_src1, i32:$hi_src1_modifiers)), |
| 121 | (f32 (VOP3PMadMixMods f16:$hi_src2, i32:$hi_src2_modifiers)))))), |
| 122 | (v2f16 (mixhi_inst $hi_src0_modifiers, $hi_src0, |
| 123 | $hi_src1_modifiers, $hi_src1, |
| 124 | $hi_src2_modifiers, $hi_src2, |
| 125 | DSTCLAMP.ENABLE, |
| 126 | (mixlo_inst $lo_src0_modifiers, $lo_src0, |
| 127 | $lo_src1_modifiers, $lo_src1, |
| 128 | $lo_src2_modifiers, $lo_src2, |
| 129 | DSTCLAMP.ENABLE, |
| 130 | (i32 (IMPLICIT_DEF))))) |
| 131 | >; |
| 132 | } |
| Matt Arsenault | 28f52e5 | 2017-10-25 07:00:51 +0000 | [diff] [blame] | 133 | |
| 134 | let SubtargetPredicate = HasMadMixInsts in { |
| Dmitry Preobrazhensky | b2d24e2 | 2017-07-07 14:29:06 +0000 | [diff] [blame] | 135 | // These are VOP3a-like opcodes which accept no omod. |
| 136 | // Size of src arguments (16/32) is controlled by op_sel. |
| 137 | // For 16-bit src arguments their location (hi/lo) are controlled by op_sel_hi. |
| Matt Arsenault | c8f8cda | 2017-08-30 22:18:40 +0000 | [diff] [blame] | 138 | let isCommutable = 1 in { |
| Matt Arsenault | 644883f | 2017-09-20 19:09:28 +0000 | [diff] [blame] | 139 | def V_MAD_MIX_F32 : VOP3_VOP3PInst<"v_mad_mix_f32", VOP3_Profile<VOP_F32_F16_F16_F16, VOP3_OPSEL>>; |
| Matt Arsenault | 7693512 | 2017-09-20 20:28:39 +0000 | [diff] [blame] | 140 | |
| Tim Corringham | 4c4d2fe | 2018-12-10 12:06:10 +0000 | [diff] [blame] | 141 | let FPDPRounding = 1 in { |
| Matt Arsenault | 7693512 | 2017-09-20 20:28:39 +0000 | [diff] [blame] | 142 | // Clamp modifier is applied after conversion to f16. |
| Matt Arsenault | e135c4c | 2017-09-20 20:53:49 +0000 | [diff] [blame] | 143 | def V_MAD_MIXLO_F16 : VOP3_VOP3PInst<"v_mad_mixlo_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, 1>; |
| Matt Arsenault | 8cbb488 | 2017-09-20 21:01:24 +0000 | [diff] [blame] | 144 | |
| 145 | let ClampLo = 0, ClampHi = 1 in { |
| Matt Arsenault | e135c4c | 2017-09-20 20:53:49 +0000 | [diff] [blame] | 146 | def V_MAD_MIXHI_F16 : VOP3_VOP3PInst<"v_mad_mixhi_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, 1>; |
| Matt Arsenault | c8f8cda | 2017-08-30 22:18:40 +0000 | [diff] [blame] | 147 | } |
| Tim Corringham | 4c4d2fe | 2018-12-10 12:06:10 +0000 | [diff] [blame] | 148 | } // End FPDPRounding = 1 |
| Matt Arsenault | 8cbb488 | 2017-09-20 21:01:24 +0000 | [diff] [blame] | 149 | } |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 150 | |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 151 | defm : MadFmaMixPats<fmad, V_MAD_MIX_F32, V_MAD_MIXLO_F16, V_MAD_MIXHI_F16>; |
| 152 | } // End SubtargetPredicate = HasMadMixInsts |
| Matt Arsenault | 7693512 | 2017-09-20 20:28:39 +0000 | [diff] [blame] | 153 | |
| Matt Arsenault | 8cbb488 | 2017-09-20 21:01:24 +0000 | [diff] [blame] | 154 | |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 155 | // Essentially the same as the mad_mix versions |
| 156 | let SubtargetPredicate = HasFmaMixInsts in { |
| 157 | let isCommutable = 1 in { |
| 158 | def V_FMA_MIX_F32 : VOP3_VOP3PInst<"v_fma_mix_f32", VOP3_Profile<VOP_F32_F16_F16_F16, VOP3_OPSEL>>; |
| Matt Arsenault | 8cbb488 | 2017-09-20 21:01:24 +0000 | [diff] [blame] | 159 | |
| Tim Corringham | 4c4d2fe | 2018-12-10 12:06:10 +0000 | [diff] [blame] | 160 | let FPDPRounding = 1 in { |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 161 | // Clamp modifier is applied after conversion to f16. |
| 162 | def V_FMA_MIXLO_F16 : VOP3_VOP3PInst<"v_fma_mixlo_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, 1>; |
| Matt Arsenault | 8cbb488 | 2017-09-20 21:01:24 +0000 | [diff] [blame] | 163 | |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 164 | let ClampLo = 0, ClampHi = 1 in { |
| 165 | def V_FMA_MIXHI_F16 : VOP3_VOP3PInst<"v_fma_mixhi_f16", VOP3_Profile<VOP_F16_F16_F16_F16, VOP3_OPSEL>, 1>; |
| 166 | } |
| Tim Corringham | 4c4d2fe | 2018-12-10 12:06:10 +0000 | [diff] [blame] | 167 | } // End FPDPRounding = 1 |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | defm : MadFmaMixPats<fma, V_FMA_MIX_F32, V_FMA_MIXLO_F16, V_FMA_MIXHI_F16>; |
| 171 | } |
| 172 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 173 | // Defines patterns that extract signed 4bit from each Idx[0]. |
| 174 | foreach Idx = [[0,28],[4,24],[8,20],[12,16],[16,12],[20,8],[24,4]] in |
| 175 | def ExtractSigned4bit_#Idx[0] : PatFrag<(ops node:$src), |
| 176 | (sra (shl node:$src, (i32 Idx[1])), (i32 28))>; |
| Farhana Aleen | 9250c92 | 2018-08-29 16:31:18 +0000 | [diff] [blame] | 177 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 178 | // Defines code pattern that extracts U(unsigned/signed) 4/8bit from FromBitIndex. |
| 179 | class Extract<int FromBitIndex, int BitMask, bit U>: PatFrag< |
| Farhana Aleen | f5a2848 | 2018-09-18 16:59:48 +0000 | [diff] [blame] | 180 | (ops node:$src), |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 181 | !if (!or (!and (!eq (BitMask, 255), !eq (FromBitIndex, 24)), !eq (FromBitIndex, 28)), // last element |
| 182 | !if (U, (srl node:$src, (i32 FromBitIndex)), (sra node:$src, (i32 FromBitIndex))), |
| Farhana Aleen | 9250c92 | 2018-08-29 16:31:18 +0000 | [diff] [blame] | 183 | !if (!eq (FromBitIndex, 0), // first element |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 184 | !if (U, (and node:$src, (i32 BitMask)), |
| 185 | !if (!eq (BitMask, 15), (!cast<PatFrag>("ExtractSigned4bit_"#FromBitIndex) node:$src), |
| 186 | (sext_inreg node:$src, i8))), |
| 187 | !if (U, (and (srl node:$src, (i32 FromBitIndex)), (i32 BitMask)), |
| 188 | !if (!eq (BitMask, 15), (!cast<PatFrag>("ExtractSigned4bit_"#FromBitIndex) node:$src), |
| 189 | (sext_inreg (srl node:$src, (i32 FromBitIndex)), i8)))))>; |
| Farhana Aleen | 9250c92 | 2018-08-29 16:31:18 +0000 | [diff] [blame] | 190 | |
| Farhana Aleen | 9250c92 | 2018-08-29 16:31:18 +0000 | [diff] [blame] | 191 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 192 | foreach Type = ["I", "U"] in |
| 193 | foreach Index = 0-3 in { |
| 194 | // Defines patterns that extract each Index'ed 8bit from an unsigned |
| 195 | // 32bit scalar value; |
| 196 | def #Type#Index#"_8bit" : Extract<!shl(Index, 3), 255, !if (!eq (Type, "U"), 1, 0)>; |
| 197 | |
| 198 | // Defines multiplication patterns where the multiplication is happening on each |
| 199 | // Index'ed 8bit of a 32bit scalar value. |
| 200 | |
| 201 | def Mul#Type#_Elt#Index : PatFrag< |
| 202 | (ops node:$src0, node:$src1), |
| 203 | (!cast<HasOneUseBinOp>(!if (!eq (Type, "I"), AMDGPUmul_i24_oneuse, AMDGPUmul_u24_oneuse)) |
| 204 | (!cast<Extract>(#Type#Index#"_8bit") node:$src0), |
| 205 | (!cast<Extract>(#Type#Index#"_8bit") node:$src1))>; |
| 206 | } |
| Farhana Aleen | f5a2848 | 2018-09-18 16:59:48 +0000 | [diff] [blame] | 207 | |
| 208 | // Different variants of dot8 patterns cause a huge increase in the compile time. |
| 209 | // Define non-associative/commutative add/mul to prevent permutation in the dot8 |
| 210 | // pattern. |
| 211 | def NonACAdd : SDNode<"ISD::ADD" , SDTIntBinOp>; |
| 212 | def NonACAdd_oneuse : HasOneUseBinOp<NonACAdd>; |
| 213 | |
| 214 | def NonACAMDGPUmul_u24 : SDNode<"AMDGPUISD::MUL_U24" , SDTIntBinOp>; |
| 215 | def NonACAMDGPUmul_u24_oneuse : HasOneUseBinOp<NonACAMDGPUmul_u24>; |
| 216 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 217 | def NonACAMDGPUmul_i24 : SDNode<"AMDGPUISD::MUL_I24" , SDTIntBinOp>; |
| 218 | def NonACAMDGPUmul_i24_oneuse : HasOneUseBinOp<NonACAMDGPUmul_i24>; |
| Farhana Aleen | f5a2848 | 2018-09-18 16:59:48 +0000 | [diff] [blame] | 219 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 220 | foreach Type = ["I", "U"] in |
| 221 | foreach Index = 0-7 in { |
| 222 | // Defines patterns that extract each Index'ed 4bit from an unsigned |
| 223 | // 32bit scalar value; |
| 224 | def #Type#Index#"_4bit" : Extract<!shl(Index, 2), 15, !if (!eq (Type, "U"), 1, 0)>; |
| 225 | |
| 226 | // Defines multiplication patterns where the multiplication is happening on each |
| 227 | // Index'ed 8bit of a 32bit scalar value. |
| 228 | def Mul#Type#Index#"_4bit" : PatFrag< |
| 229 | (ops node:$src0, node:$src1), |
| 230 | (!cast<HasOneUseBinOp>(!if (!eq (Type, "I"), NonACAMDGPUmul_i24_oneuse, NonACAMDGPUmul_u24_oneuse)) |
| 231 | (!cast<Extract>(#Type#Index#"_4bit") node:$src0), |
| 232 | (!cast<Extract>(#Type#Index#"_4bit") node:$src1))>; |
| 233 | } |
| Farhana Aleen | 9250c92 | 2018-08-29 16:31:18 +0000 | [diff] [blame] | 234 | |
| Farhana Aleen | 3528c80 | 2018-08-21 16:21:15 +0000 | [diff] [blame] | 235 | class UDot2Pat<Instruction Inst> : GCNPat < |
| 236 | (add (add_oneuse (AMDGPUmul_u24_oneuse (srl i32:$src0, (i32 16)), |
| 237 | (srl i32:$src1, (i32 16))), i32:$src2), |
| 238 | (AMDGPUmul_u24_oneuse (and i32:$src0, (i32 65535)), |
| 239 | (and i32:$src1, (i32 65535))) |
| 240 | ), |
| 241 | (Inst (i32 8), $src0, (i32 8), $src1, (i32 8), $src2, (i1 0)) |
| 242 | >; |
| 243 | |
| 244 | class SDot2Pat<Instruction Inst> : GCNPat < |
| 245 | (add (add_oneuse (AMDGPUmul_i24_oneuse (sra i32:$src0, (i32 16)), |
| 246 | (sra i32:$src1, (i32 16))), i32:$src2), |
| 247 | (AMDGPUmul_i24_oneuse (sext_inreg i32:$src0, i16), |
| 248 | (sext_inreg i32:$src1, i16))), |
| 249 | (Inst (i32 8), $src0, (i32 8), $src1, (i32 8), $src2, (i1 0)) |
| 250 | >; |
| 251 | |
| Stanislav Mekhanoshin | d3757d3 | 2019-01-10 03:25:20 +0000 | [diff] [blame] | 252 | let SubtargetPredicate = HasDotInsts in { |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 253 | |
| Konstantin Zhuravlyov | bb30ef7 | 2018-08-01 01:31:30 +0000 | [diff] [blame] | 254 | def V_DOT2_F32_F16 : VOP3PInst<"v_dot2_f32_f16", VOP3_Profile<VOP_F32_V2F16_V2F16_F32>>; |
| 255 | def V_DOT2_I32_I16 : VOP3PInst<"v_dot2_i32_i16", VOP3_Profile<VOP_I32_V2I16_V2I16_I32>>; |
| 256 | def V_DOT2_U32_U16 : VOP3PInst<"v_dot2_u32_u16", VOP3_Profile<VOP_I32_V2I16_V2I16_I32>>; |
| 257 | def V_DOT4_I32_I8 : VOP3PInst<"v_dot4_i32_i8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_PACKED>>; |
| 258 | def V_DOT4_U32_U8 : VOP3PInst<"v_dot4_u32_u8", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_PACKED>>; |
| 259 | def V_DOT8_I32_I4 : VOP3PInst<"v_dot8_i32_i4", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_PACKED>>; |
| 260 | def V_DOT8_U32_U4 : VOP3PInst<"v_dot8_u32_u4", VOP3_Profile<VOP_I32_I32_I32_I32, VOP3_PACKED>>; |
| 261 | |
| 262 | multiclass DotPats<SDPatternOperator dot_op, |
| 263 | VOP3PInst dot_inst> { |
| 264 | def : GCNPat < |
| 265 | (dot_op (dot_inst.Pfl.Src0VT (VOP3PMods0 dot_inst.Pfl.Src0VT:$src0, i32:$src0_modifiers)), |
| 266 | (dot_inst.Pfl.Src1VT (VOP3PMods dot_inst.Pfl.Src1VT:$src1, i32:$src1_modifiers)), |
| 267 | (dot_inst.Pfl.Src2VT (VOP3PMods dot_inst.Pfl.Src2VT:$src2, i32:$src2_modifiers)), i1:$clamp), |
| 268 | (dot_inst $src0_modifiers, $src0, $src1_modifiers, $src1, $src2_modifiers, $src2, (as_i1imm $clamp))>; |
| 269 | } |
| 270 | |
| 271 | defm : DotPats<AMDGPUfdot2, V_DOT2_F32_F16>; |
| 272 | defm : DotPats<int_amdgcn_sdot2, V_DOT2_I32_I16>; |
| 273 | defm : DotPats<int_amdgcn_udot2, V_DOT2_U32_U16>; |
| 274 | defm : DotPats<int_amdgcn_sdot4, V_DOT4_I32_I8>; |
| 275 | defm : DotPats<int_amdgcn_udot4, V_DOT4_U32_U8>; |
| 276 | defm : DotPats<int_amdgcn_sdot8, V_DOT8_I32_I4>; |
| 277 | defm : DotPats<int_amdgcn_udot8, V_DOT8_U32_U4>; |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 278 | |
| Farhana Aleen | 3528c80 | 2018-08-21 16:21:15 +0000 | [diff] [blame] | 279 | def : UDot2Pat<V_DOT2_U32_U16>; |
| 280 | def : SDot2Pat<V_DOT2_I32_I16>; |
| 281 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 282 | foreach Type = ["U", "I"] in |
| 283 | def : GCNPat < |
| 284 | !cast<dag>(!foldl((i32 i32:$src2), [0, 1, 2, 3], lhs, y, |
| 285 | (add_oneuse lhs, (!cast<PatFrag>("Mul"#Type#"_Elt"#y) i32:$src0, i32:$src1)))), |
| 286 | (!cast<VOP3PInst>("V_DOT4_"#Type#"32_"#Type#8) (i32 8), $src0, (i32 8), $src1, (i32 8), $src2, (i1 0))>; |
| Farhana Aleen | 9250c92 | 2018-08-29 16:31:18 +0000 | [diff] [blame] | 287 | |
| Farhana Aleen | 4bc597b | 2018-10-04 16:57:37 +0000 | [diff] [blame] | 288 | foreach Type = ["U", "I"] in |
| 289 | def : GCNPat < |
| 290 | !cast<dag>(!foldl((add_oneuse i32:$src2, (!cast<PatFrag>("Mul"#Type#"0_4bit") i32:$src0, i32:$src1)), |
| 291 | [1, 2, 3, 4, 5, 6, 7], lhs, y, |
| 292 | (NonACAdd_oneuse lhs, (!cast<PatFrag>("Mul"#Type#y#"_4bit") i32:$src0, i32:$src1)))), |
| 293 | (!cast<VOP3PInst>("V_DOT8_"#Type#"32_"#Type#4) (i32 8), $src0, (i32 8), $src1, (i32 8), $src2, (i1 0))>; |
| Farhana Aleen | f5a2848 | 2018-09-18 16:59:48 +0000 | [diff] [blame] | 294 | |
| Farhana Aleen | 5853762 | 2018-11-01 22:48:19 +0000 | [diff] [blame] | 295 | // Different variants of dot8 code-gen dag patterns are not generated through table-gen due to a huge increase |
| 296 | // in the compile time. Directly handle the pattern generated by the FE here. |
| 297 | foreach Type = ["U", "I"] in |
| 298 | def : GCNPat < |
| 299 | !cast<dag>(!foldl((add_oneuse i32:$src2, (!cast<PatFrag>("Mul"#Type#"0_4bit") i32:$src0, i32:$src1)), |
| 300 | [7, 1, 2, 3, 4, 5, 6], lhs, y, |
| 301 | (NonACAdd_oneuse lhs, (!cast<PatFrag>("Mul"#Type#y#"_4bit") i32:$src0, i32:$src1)))), |
| 302 | (!cast<VOP3PInst>("V_DOT8_"#Type#"32_"#Type#4) (i32 8), $src0, (i32 8), $src1, (i32 8), $src2, (i1 0))>; |
| 303 | |
| Stanislav Mekhanoshin | d3757d3 | 2019-01-10 03:25:20 +0000 | [diff] [blame] | 304 | } // End SubtargetPredicate = HasDotInsts |
| Matt Arsenault | 7693512 | 2017-09-20 20:28:39 +0000 | [diff] [blame] | 305 | |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 306 | multiclass VOP3P_Real_vi<bits<10> op> { |
| Nicolai Haehnle | 4f850ea | 2018-03-26 13:56:53 +0000 | [diff] [blame] | 307 | def _vi : VOP3P_Real<!cast<VOP3_Pseudo>(NAME), SIEncodingFamily.VI>, |
| 308 | VOP3Pe <op, !cast<VOP3_Pseudo>(NAME).Pfl> { |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 309 | let AssemblerPredicates = [HasVOP3PInsts]; |
| 310 | let DecoderNamespace = "VI"; |
| 311 | } |
| 312 | } |
| 313 | |
| Dmitry Preobrazhensky | 095ec3da | 2017-07-18 09:24:10 +0000 | [diff] [blame] | 314 | defm V_PK_MAD_I16 : VOP3P_Real_vi <0x380>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 315 | defm V_PK_MUL_LO_U16 : VOP3P_Real_vi <0x381>; |
| 316 | defm V_PK_ADD_I16 : VOP3P_Real_vi <0x382>; |
| 317 | defm V_PK_SUB_I16 : VOP3P_Real_vi <0x383>; |
| 318 | defm V_PK_LSHLREV_B16 : VOP3P_Real_vi <0x384>; |
| 319 | defm V_PK_LSHRREV_B16 : VOP3P_Real_vi <0x385>; |
| 320 | defm V_PK_ASHRREV_I16 : VOP3P_Real_vi <0x386>; |
| 321 | defm V_PK_MAX_I16 : VOP3P_Real_vi <0x387>; |
| 322 | defm V_PK_MIN_I16 : VOP3P_Real_vi <0x388>; |
| Dmitry Preobrazhensky | 095ec3da | 2017-07-18 09:24:10 +0000 | [diff] [blame] | 323 | defm V_PK_MAD_U16 : VOP3P_Real_vi <0x389>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 324 | |
| 325 | defm V_PK_ADD_U16 : VOP3P_Real_vi <0x38a>; |
| Dmitry Preobrazhensky | 095ec3da | 2017-07-18 09:24:10 +0000 | [diff] [blame] | 326 | defm V_PK_SUB_U16 : VOP3P_Real_vi <0x38b>; |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 327 | defm V_PK_MAX_U16 : VOP3P_Real_vi <0x38c>; |
| 328 | defm V_PK_MIN_U16 : VOP3P_Real_vi <0x38d>; |
| 329 | defm V_PK_FMA_F16 : VOP3P_Real_vi <0x38e>; |
| 330 | defm V_PK_ADD_F16 : VOP3P_Real_vi <0x38f>; |
| 331 | defm V_PK_MUL_F16 : VOP3P_Real_vi <0x390>; |
| 332 | defm V_PK_MIN_F16 : VOP3P_Real_vi <0x391>; |
| 333 | defm V_PK_MAX_F16 : VOP3P_Real_vi <0x392>; |
| 334 | |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 335 | |
| 336 | let SubtargetPredicate = HasMadMixInsts in { |
| Matt Arsenault | 9be7b0d | 2017-02-27 18:49:11 +0000 | [diff] [blame] | 337 | defm V_MAD_MIX_F32 : VOP3P_Real_vi <0x3a0>; |
| 338 | defm V_MAD_MIXLO_F16 : VOP3P_Real_vi <0x3a1>; |
| 339 | defm V_MAD_MIXHI_F16 : VOP3P_Real_vi <0x3a2>; |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | let SubtargetPredicate = HasFmaMixInsts in { |
| 343 | let DecoderNamespace = "GFX9_DL" in { |
| 344 | // The mad_mix instructions were renamed and their behaviors changed, |
| 345 | // but the opcode stayed the same so we need to put these in a |
| 346 | // different DecoderNamespace to avoid the ambiguity. |
| 347 | defm V_FMA_MIX_F32 : VOP3P_Real_vi <0x3a0>; |
| 348 | defm V_FMA_MIXLO_F16 : VOP3P_Real_vi <0x3a1>; |
| 349 | defm V_FMA_MIXHI_F16 : VOP3P_Real_vi <0x3a2>; |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | |
| Stanislav Mekhanoshin | d3757d3 | 2019-01-10 03:25:20 +0000 | [diff] [blame] | 354 | let SubtargetPredicate = HasDotInsts in { |
| Matt Arsenault | 0084adc | 2018-04-30 19:08:16 +0000 | [diff] [blame] | 355 | |
| 356 | defm V_DOT2_F32_F16 : VOP3P_Real_vi <0x3a3>; |
| 357 | defm V_DOT2_I32_I16 : VOP3P_Real_vi <0x3a6>; |
| 358 | defm V_DOT2_U32_U16 : VOP3P_Real_vi <0x3a7>; |
| 359 | defm V_DOT4_I32_I8 : VOP3P_Real_vi <0x3a8>; |
| 360 | defm V_DOT4_U32_U8 : VOP3P_Real_vi <0x3a9>; |
| 361 | defm V_DOT8_I32_I4 : VOP3P_Real_vi <0x3aa>; |
| 362 | defm V_DOT8_U32_U4 : VOP3P_Real_vi <0x3ab>; |
| 363 | |
| Stanislav Mekhanoshin | d3757d3 | 2019-01-10 03:25:20 +0000 | [diff] [blame] | 364 | } // End SubtargetPredicate = HasDotInsts |