diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td index e16c104b27169..3020e3dec0648 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td @@ -77,18 +77,26 @@ class ILFormat pattern> def TruePredicate : Predicate<"">; +// Add a predicate to the list if does not already exist to deduplicate it. +class PredConcat lst, Predicate pred> { + list ret = + !foldl([pred], lst, acc, cur, + !listconcat(acc, !if(!eq(!cast(cur),!cast(pred)), + [], [cur]))); +} + class PredicateControl { Predicate SubtargetPredicate = TruePredicate; - list AssemblerPredicates = []; Predicate AssemblerPredicate = TruePredicate; Predicate WaveSizePredicate = TruePredicate; list OtherPredicates = []; - list Predicates = !listconcat([SubtargetPredicate, - AssemblerPredicate, - WaveSizePredicate], - AssemblerPredicates, - OtherPredicates); + list Predicates = PredConcat< + PredConcat.ret, + AssemblerPredicate>.ret, + WaveSizePredicate>.ret; } + class AMDGPUPat : Pat, PredicateControl; diff --git a/llvm/lib/Target/AMDGPU/DSInstructions.td b/llvm/lib/Target/AMDGPU/DSInstructions.td index 816ec14a0e98a..940ce33e9e133 100644 --- a/llvm/lib/Target/AMDGPU/DSInstructions.td +++ b/llvm/lib/Target/AMDGPU/DSInstructions.td @@ -1075,7 +1075,7 @@ defm DS_MAX_SRC2_F64 : DS_Real_gfx6_gfx7_gfx10<0x0d3>; class DS_Real_vi op, DS_Pseudo ds> : DS_Real , SIMCInstr { - let AssemblerPredicates = [isGFX8GFX9]; + let AssemblerPredicate = isGFX8GFX9; let DecoderNamespace = "GFX8"; // encoding diff --git a/llvm/lib/Target/AMDGPU/MIMGInstructions.td b/llvm/lib/Target/AMDGPU/MIMGInstructions.td index f33ad950d5d9b..4006a6205fb87 100644 --- a/llvm/lib/Target/AMDGPU/MIMGInstructions.td +++ b/llvm/lib/Target/AMDGPU/MIMGInstructions.td @@ -183,7 +183,7 @@ class MIMGNSAHelper { class MIMG_gfx6789 op, dag outs, string dns = ""> : MIMG, MIMGe_gfx6789 { let SubtargetPredicate = isGFX6GFX7GFX8GFX9; - let AssemblerPredicates = [isGFX6GFX7GFX8GFX9]; + let AssemblerPredicate = isGFX6GFX7GFX8GFX9; let MIMGEncoding = MIMGEncGfx6; @@ -194,7 +194,7 @@ class MIMG_gfx6789 op, dag outs, string dns = ""> class MIMG_gfx10 : MIMG, MIMGe_gfx10 { let SubtargetPredicate = isGFX10Plus; - let AssemblerPredicates = [isGFX10Plus]; + let AssemblerPredicate = isGFX10Plus; let MIMGEncoding = MIMGEncGfx10Default; @@ -207,7 +207,7 @@ class MIMG_gfx10 class MIMG_nsa_gfx10 : MIMG, MIMGe_gfx10 { let SubtargetPredicate = isGFX10Plus; - let AssemblerPredicates = [isGFX10Plus]; + let AssemblerPredicate = isGFX10Plus; let MIMGEncoding = MIMGEncGfx10NSA; @@ -416,13 +416,13 @@ class MIMG_Atomic_si : MIMG_Atomic_gfx6789_base { - let AssemblerPredicates = [isGFX6GFX7]; + let AssemblerPredicate = isGFX6GFX7; } class MIMG_Atomic_vi : MIMG_Atomic_gfx6789_base { - let AssemblerPredicates = [isGFX8GFX9]; + let AssemblerPredicate = isGFX8GFX9; let MIMGEncoding = MIMGEncGfx8; } diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.td b/llvm/lib/Target/AMDGPU/SIInstrInfo.td index 1eecbf5556133..2617372ed829a 100644 --- a/llvm/lib/Target/AMDGPU/SIInstrInfo.td +++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.td @@ -1381,7 +1381,7 @@ multiclass EXP_m { def _si : EXP_Helper, SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.SI>, EXPe { - let AssemblerPredicates = [isGFX6GFX7]; + let AssemblerPredicate = isGFX6GFX7; let DecoderNamespace = "GFX6GFX7"; let DisableDecoder = DisableSIDecoder; } @@ -1389,7 +1389,7 @@ multiclass EXP_m { def _vi : EXP_Helper, SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.VI>, EXPe_vi { - let AssemblerPredicates = [isGFX8GFX9]; + let AssemblerPredicate = isGFX8GFX9; let DecoderNamespace = "GFX8"; let DisableDecoder = DisableVIDecoder; } @@ -1397,7 +1397,7 @@ multiclass EXP_m { def _gfx10 : EXP_Helper, SIMCInstr <"exp"#!if(done, "_done", ""), SIEncodingFamily.GFX10>, EXPe { - let AssemblerPredicates = [isGFX10Plus]; + let AssemblerPredicate = isGFX10Plus; let DecoderNamespace = "GFX10"; let DisableDecoder = DisableSIDecoder; } diff --git a/llvm/lib/Target/AMDGPU/SMInstructions.td b/llvm/lib/Target/AMDGPU/SMInstructions.td index 1a74ebbf81651..79982d96c2c8e 100644 --- a/llvm/lib/Target/AMDGPU/SMInstructions.td +++ b/llvm/lib/Target/AMDGPU/SMInstructions.td @@ -417,7 +417,7 @@ class SMRD_Real_si op, SM_Pseudo ps> , SIMCInstr , Enc32 { - let AssemblerPredicates = [isGFX6GFX7]; + let AssemblerPredicate = isGFX6GFX7; let DecoderNamespace = "GFX6GFX7"; let Inst{7-0} = !if(ps.has_offset, offset{7-0}, ?); @@ -471,7 +471,7 @@ class SMEM_Real_vi op, SM_Pseudo ps> , Enc64 { bit glc; - let AssemblerPredicates = [isGFX8GFX9]; + let AssemblerPredicate = isGFX8GFX9; let DecoderNamespace = "GFX8"; let Inst{5-0} = !if(ps.has_sbase, sbase{6-1}, ?); @@ -660,7 +660,7 @@ class SMRD_Real_Load_IMM_ci op, SM_Load_Pseudo ps> : SM_Real, Enc64 { - let AssemblerPredicates = [isGFX7Only]; + let AssemblerPredicate = isGFX7Only; let DecoderNamespace = "GFX7"; let InOperandList = (ins ps.BaseClass:$sbase, smrd_literal_offset:$offset, GLC:$glc, DLC:$dlc); @@ -697,7 +697,7 @@ class SMRD_Real_ci op, SM_Pseudo ps> , SIMCInstr , Enc32 { - let AssemblerPredicates = [isGFX7Only]; + let AssemblerPredicate = isGFX7Only; let DecoderNamespace = "GFX7"; let Inst{7-0} = !if(ps.has_offset, offset{7-0}, ?); @@ -835,7 +835,7 @@ class SMEM_Real_gfx10 op, SM_Pseudo ps> : bit glc; bit dlc; - let AssemblerPredicates = [isGFX10Plus]; + let AssemblerPredicate = isGFX10Plus; let DecoderNamespace = "GFX10"; let Inst{5-0} = !if(ps.has_sbase, sbase{6-1}, ?); diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td b/llvm/lib/Target/AMDGPU/SOPInstructions.td index d31a49f428ee7..ab72a582710cc 100644 --- a/llvm/lib/Target/AMDGPU/SOPInstructions.td +++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td @@ -1503,7 +1503,7 @@ defm S_SETREG_IMM32_B32 : SOPK_Real64_gfx6_gfx7_gfx10<0x015>; class Select_vi : SIMCInstr { - list AssemblerPredicates = [isGFX8GFX9]; + Predicate AssemblerPredicate = isGFX8GFX9; string DecoderNamespace = "GFX8"; } diff --git a/llvm/lib/Target/AMDGPU/VOP1Instructions.td b/llvm/lib/Target/AMDGPU/VOP1Instructions.td index f1cdc3097dc04..5925292c555c8 100644 --- a/llvm/lib/Target/AMDGPU/VOP1Instructions.td +++ b/llvm/lib/Target/AMDGPU/VOP1Instructions.td @@ -699,7 +699,7 @@ class VOP1_DPPe op, VOP1_DPP_Pseudo ps, VOPProfile P = ps.Pfl> : } multiclass VOP1Only_Real_vi op> { - let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in { + let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in { def _vi : VOP1_Real(NAME), SIEncodingFamily.VI>, VOP1e(NAME).Pfl>; @@ -707,7 +707,7 @@ multiclass VOP1Only_Real_vi op> { } multiclass VOP1_Real_e32e64_vi op> { - let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in { + let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in { def _e32_vi : VOP1_Real(NAME#"_e32"), SIEncodingFamily.VI>, VOP1e(NAME#"_e32").Pfl>; @@ -899,7 +899,7 @@ def : GCNPat < //===----------------------------------------------------------------------===// multiclass VOP1_Real_gfx9 op> { - let AssemblerPredicates = [isGFX9Only], DecoderNamespace = "GFX9" in { + let AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in { defm NAME : VOP1_Real_e32e64_vi ; } diff --git a/llvm/lib/Target/AMDGPU/VOP2Instructions.td b/llvm/lib/Target/AMDGPU/VOP2Instructions.td index 1ab0fc1ab58d1..45928a54fd934 100644 --- a/llvm/lib/Target/AMDGPU/VOP2Instructions.td +++ b/llvm/lib/Target/AMDGPU/VOP2Instructions.td @@ -1282,7 +1282,7 @@ defm V_MADAK_F32 : VOP2Only_Real_MADK_gfx6_gfx7_gfx10<0x021>; // GFX8, GFX9 (VI). //===----------------------------------------------------------------------===// -let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in { +let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in { multiclass VOP2_Real_MADK_vi op> { def _vi : VOP2_Real(NAME), SIEncodingFamily.VI>, @@ -1316,7 +1316,7 @@ multiclass Base_VOP2_Real_e32e64_vi op> : VOP2_Real_e32_vi, VOP2_Real_e64_vi<{0, 1, 0, 0, op{5-0}}>; -} // End AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" +} // End AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" multiclass VOP2_SDWA_Real op> { foreach _ = BoolToList(NAME#"_e32").Pfl.HasExtSDWA>.ret in @@ -1332,7 +1332,7 @@ multiclass VOP2_SDWA9_Real op> { VOP2_SDWA9Ae (NAME#"_sdwa").Pfl>; } -let AssemblerPredicates = [isGFX8Only] in { +let AssemblerPredicate = isGFX8Only in { multiclass VOP2be_Real_e32e64_vi_only op, string OpName, string AsmName> { def _e32_vi : @@ -1366,7 +1366,7 @@ multiclass VOP2be_Real_e32e64_vi_only op, string OpName, string AsmName } } -let AssemblerPredicates = [isGFX9Only] in { +let AssemblerPredicate = isGFX9Only in { multiclass VOP2be_Real_e32e64_gfx9 op, string OpName, string AsmName> { def _e32_gfx9 : @@ -1424,7 +1424,7 @@ multiclass VOP2_Real_e32e64_gfx9 op> { } } -} // AssemblerPredicates = [isGFX9Only] +} // AssemblerPredicate = isGFX9Only multiclass VOP2_Real_e32e64_vi op> : Base_VOP2_Real_e32e64_vi, VOP2_SDWA_Real, VOP2_SDWA9_Real { diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td b/llvm/lib/Target/AMDGPU/VOP3Instructions.td index db8b8be843b35..d8e28cadd6233 100644 --- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td +++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td @@ -927,7 +927,7 @@ defm V_DIV_SCALE_F64 : VOP3be_Real_gfx6_gfx7_gfx10<0x16e>; // GFX8, GFX9 (VI). //===----------------------------------------------------------------------===// -let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in { +let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in { multiclass VOP3_Real_vi op> { def _vi : VOP3_Real(NAME), SIEncodingFamily.VI>, @@ -949,9 +949,9 @@ multiclass VOP3Interp_Real_vi op> { VOP3Interp_vi (NAME).Pfl>; } -} // End AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" +} // End AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" -let AssemblerPredicates = [isGFX8Only], DecoderNamespace = "GFX8" in { +let AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8" in { multiclass VOP3_F16_Real_vi op> { def _vi : VOP3_Real(NAME), SIEncodingFamily.VI>, @@ -963,9 +963,9 @@ multiclass VOP3Interp_F16_Real_vi op> { VOP3Interp_vi (NAME).Pfl>; } -} // End AssemblerPredicates = [isGFX8Only], DecoderNamespace = "GFX8" +} // End AssemblerPredicate = isGFX8Only, DecoderNamespace = "GFX8" -let AssemblerPredicates = [isGFX9Only], DecoderNamespace = "GFX9" in { +let AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" in { multiclass VOP3_F16_Real_gfx9 op, string OpName, string AsmName> { def _gfx9 : VOP3_Real(OpName), SIEncodingFamily.GFX9>, @@ -999,7 +999,7 @@ multiclass VOP3_Real_gfx9 op, string AsmName> { } } -} // End AssemblerPredicates = [isGFX9Only], DecoderNamespace = "GFX9" +} // End AssemblerPredicate = isGFX9Only, DecoderNamespace = "GFX9" defm V_MAD_U64_U32 : VOP3be_Real_vi <0x1E8>; defm V_MAD_I64_I32 : VOP3be_Real_vi <0x1E9>; diff --git a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td index 0c13f39fec029..933acc2278fd8 100644 --- a/llvm/lib/Target/AMDGPU/VOP3PInstructions.td +++ b/llvm/lib/Target/AMDGPU/VOP3PInstructions.td @@ -404,7 +404,7 @@ def : MnemonicAlias<"v_accvgpr_write", "v_accvgpr_write_b32">; multiclass VOP3P_Real_vi op> { def _vi : VOP3P_Real(NAME), SIEncodingFamily.VI>, VOP3Pe (NAME).Pfl> { - let AssemblerPredicates = [HasVOP3PInsts]; + let AssemblerPredicate = HasVOP3PInsts; let DecoderNamespace = "GFX8"; } } @@ -412,7 +412,7 @@ multiclass VOP3P_Real_vi op> { multiclass VOP3P_Real_MAI op> { def _vi : VOP3P_Real(NAME), SIEncodingFamily.VI>, VOP3Pe_MAI (NAME).Pfl> { - let AssemblerPredicates = [HasMAIInsts]; + let AssemblerPredicate = HasMAIInsts; let DecoderNamespace = "GFX8"; } } diff --git a/llvm/lib/Target/AMDGPU/VOPCInstructions.td b/llvm/lib/Target/AMDGPU/VOPCInstructions.td index 8ef0ec7b71f49..d611b8e93adec 100644 --- a/llvm/lib/Target/AMDGPU/VOPCInstructions.td +++ b/llvm/lib/Target/AMDGPU/VOPCInstructions.td @@ -1218,7 +1218,7 @@ defm V_CMPX_T_U64 : VOPCX_Real_gfx6_gfx7_gfx10<0x0f7>; //===----------------------------------------------------------------------===// multiclass VOPC_Real_vi op> { - let AssemblerPredicates = [isGFX8GFX9], DecoderNamespace = "GFX8" in { + let AssemblerPredicate = isGFX8GFX9, DecoderNamespace = "GFX8" in { def _e32_vi : VOPC_Real(NAME#"_e32"), SIEncodingFamily.VI>, VOPCe;