Skip to content

Commit 2b57b9b

Browse files
committed
remove AnyPred and define predicate in NVPTXSubTarget.h
1 parent d54f68e commit 2b57b9b

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,6 @@ def PrmtMode : Operand<i32> {
101101
// NVPTX Instruction Predicate Definitions
102102
//===----------------------------------------------------------------------===//
103103

104-
// AnyPred - helper class to create an OR condition between multiple predicates.
105-
class AnyPred<list<Predicate> predicates> : Predicate<""> {
106-
let CondString = !foldl("false", predicates, acc, pred,
107-
acc # " || (" # pred.CondString # ")");
108-
}
109-
110104
// Checks PTX version and family-specific and architecture-specific SM versions.
111105
// For example, sm_100{f/a} and any future variants in the same family will match
112106
// for any PTX version greater than or equal to `PTXVersion`.

llvm/lib/Target/NVPTX/NVPTXIntrinsics.td

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,7 +2008,7 @@ def : Pat<(int_nvvm_ull2d_rp i64:$a), (CVT_f64_u64 $a, CvtRP)>;
20082008
def : Pat<(int_nvvm_f2h_rn_ftz f32:$a), (CVT_f16_f32 $a, CvtRN_FTZ)>;
20092009
def : Pat<(int_nvvm_f2h_rn f32:$a), (CVT_f16_f32 $a, CvtRN)>;
20102010

2011-
let Predicates = [hasPTX<81>, hasSM<89>] in {
2011+
let Predicates = [callSubtarget<"hasFP8ConversionSupport">] in {
20122012
def : Pat<(int_nvvm_ff_to_e4m3x2_rn f32:$a, f32:$b),
20132013
(CVT_e4m3x2_f32 $a, $b, CvtRN)>;
20142014
def : Pat<(int_nvvm_ff_to_e4m3x2_rn_relu f32:$a, f32:$b),
@@ -2037,11 +2037,7 @@ let Predicates = [hasPTX<81>, hasSM<89>] in {
20372037
(CVT_f16x2_e5m2x2 $a, CvtRN_RELU)>;
20382038
}
20392039

2040-
let Predicates = [AnyPred<[
2041-
PTXWithFamilySMs<90, [100, 110, 120]>,
2042-
PTXWithFamilySMs<88, [100, 101, 120]>,
2043-
PTXWithAccelSMs<86, [100, 101, 120]>
2044-
]>] in {
2040+
let Predicates = [callSubtarget<"hasNarrowFPConversionSupport">] in {
20452041
def : Pat<(int_nvvm_ff_to_e2m3x2_rn_satfinite f32:$a, f32:$b),
20462042
(CVT_e2m3x2_f32_sf $a, $b, CvtRN)>;
20472043
def : Pat<(int_nvvm_ff_to_e2m3x2_rn_relu_satfinite f32:$a, f32:$b),

llvm/lib/Target/NVPTX/NVPTXSubtarget.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,27 @@ class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
177177
hasPTXWithAccelSMs(86, {100, 101});
178178
}
179179

180+
// Checks support for conversions involving e4m3x2 and e5m2x2.
181+
bool hasFP8ConversionSupport() const {
182+
if (PTXVersion >= 81)
183+
return SmVersion >= 89;
184+
185+
if (PTXVersion >= 78)
186+
return SmVersion >= 90;
187+
188+
return false;
189+
}
190+
191+
// Checks support for conversions involving the following types:
192+
// - e2m3x2/e3m2x2
193+
// - e2m1x2
194+
// - ue8m0x2
195+
bool hasNarrowFPConversionSupport() const {
196+
return hasPTXWithFamilySMs(90, {100, 110, 120}) ||
197+
hasPTXWithFamilySMs(88, {100, 101, 120}) ||
198+
hasPTXWithAccelSMs(86, {100, 101, 120});
199+
}
200+
180201
// Prior to CUDA 12.3 ptxas did not recognize that the trap instruction
181202
// terminates a basic block. Instead, it would assume that control flow
182203
// continued to the next instruction. The next instruction could be in the

0 commit comments

Comments
 (0)