diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td index b29dc1edbaaff..7c278fd574ede 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPU.td +++ b/llvm/lib/Target/AMDGPU/AMDGPU.td @@ -9,6 +9,7 @@ include "llvm/TableGen/SearchableTable.td" include "llvm/Target/Target.td" include "AMDGPUFeatures.td" +include "AMDGPUPredicateControl.td" def p0 : PtrValueType; def p1 : PtrValueType; @@ -1895,10 +1896,10 @@ def NotHasTrue16BitInsts : Predicate<"!Subtarget->hasTrue16BitInsts()">; // True16 instructions as they are defined in the ISA. Fake True16 // instructions have the same encoding as real ones but syntactically // only allow 32-bit registers in operands and use low halves thereof. -def UseRealTrue16Insts : Predicate<"Subtarget->useRealTrue16Insts()">, +def UseRealTrue16Insts : True16PredicateClass<"Subtarget->useRealTrue16Insts()">, AssemblerPredicate<(all_of FeatureTrue16BitInsts, FeatureRealTrue16Insts)>; -def UseFakeTrue16Insts : Predicate<"Subtarget->hasTrue16BitInsts() && " - "!Subtarget->useRealTrue16Insts()">; +def UseFakeTrue16Insts : True16PredicateClass<"Subtarget->hasTrue16BitInsts() && " + "!Subtarget->useRealTrue16Insts()">; def HasVOP3PInsts : Predicate<"Subtarget->hasVOP3PInsts()">, AssemblerPredicate<(all_of FeatureVOP3P)>; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td index 360aafedc5224..5ed82c0c4b1b8 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructions.td @@ -76,33 +76,11 @@ class ILFormat pattern> let isCodeGenOnly = 1; } -def TruePredicate : Predicate<"">; - -// FIXME: Tablegen should specially supports this -def FalsePredicate : Predicate<"false">; - -// Add a predicate to the list if does not already exist to deduplicate it. -class PredConcat lst, Predicate pred> { - list ret = !listconcat(lst, !listremove([pred], lst)); -} - // Get the union of two Register lists class RegListUnion lstA, list lstB> { list ret = !listconcat(lstA, !listremove(lstB, lstA)); } -class PredicateControl { - Predicate SubtargetPredicate = TruePredicate; - Predicate AssemblerPredicate = TruePredicate; - Predicate WaveSizePredicate = TruePredicate; - list OtherPredicates = []; - list Predicates = PredConcat< - PredConcat.ret, - AssemblerPredicate>.ret, - WaveSizePredicate>.ret; -} - class AMDGPUPat : Pat, PredicateControl, GISelFlags; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td b/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td new file mode 100644 index 0000000000000..6c7c91ef464df --- /dev/null +++ b/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td @@ -0,0 +1,36 @@ +//===-- AMDGPUPredicateControl.td --------------------------*- tablegen -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +def TruePredicate : Predicate<"">; + +// FIXME: Tablegen should specially supports this +def FalsePredicate : Predicate<"false">; + +// Add a predicate to the list if does not already exist to deduplicate it. +class PredConcat lst> { + list ret = !listconcat(lst, !listremove([pred], lst)); +} + +// Prevent using other kinds of predicates where True16 predicates are +// expected by giving them their own class. +class True16PredicateClass : Predicate; +def NoTrue16Predicate : True16PredicateClass<"">; + +class PredicateControl { + Predicate SubtargetPredicate = TruePredicate; + Predicate AssemblerPredicate = TruePredicate; + Predicate WaveSizePredicate = TruePredicate; + True16PredicateClass True16Predicate = NoTrue16Predicate; + list OtherPredicates = []; + list Predicates = + PredConcat.ret>.ret>.ret>.ret; +} diff --git a/llvm/lib/Target/AMDGPU/R600.td b/llvm/lib/Target/AMDGPU/R600.td index 1e8e6f34fbc0c..9148edb92b084 100644 --- a/llvm/lib/Target/AMDGPU/R600.td +++ b/llvm/lib/Target/AMDGPU/R600.td @@ -35,6 +35,7 @@ include "R600Schedule.td" include "R600Processors.td" include "R600InstrInfo.td" include "AMDGPUInstrInfo.td" +include "AMDGPUPredicateControl.td" include "AMDGPUInstructions.td" include "R600Instructions.td" include "R700Instructions.td" diff --git a/llvm/lib/Target/AMDGPU/VOPInstructions.td b/llvm/lib/Target/AMDGPU/VOPInstructions.td index dc6a48b1df747..29c30bc019ed6 100644 --- a/llvm/lib/Target/AMDGPU/VOPInstructions.td +++ b/llvm/lib/Target/AMDGPU/VOPInstructions.td @@ -1484,8 +1484,8 @@ multiclass VOP3_Real_dpp8_with_name op, string opName, let AsmString = asmName # ps.Pfl.AsmVOP3DPP8, DecoderNamespace = "DPP8"#Gen.DecoderNamespace# !if(ps.Pfl.IsRealTrue16, "", "_FAKE16"), - OtherPredicates = !if(ps.Pfl.IsRealTrue16, [UseRealTrue16Insts], - [TruePredicate]) in { + True16Predicate = !if(ps.Pfl.IsRealTrue16, UseRealTrue16Insts, + NoTrue16Predicate) in { defm NAME : VOP3_Real_dpp8_Base; } }