Repository navigation
[NVPTX] Model SM architectures as subtarget features (NFC) - #214335
Conversation
|
@llvm/pr-subscribers-backend-nvptx Author: Alex MacLean (AlexMaclean) ChangesPatch is 123.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/214335.diff 9 Files Affected:
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
index 9db838523fdcd..7e5dbfcea5588 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
@@ -29,9 +29,6 @@ using namespace llvm;
#define DEBUG_TYPE "asm-printer"
-#define GET_SUBTARGETINFO_ENUM
-#include "NVPTXGenSubtargetInfo.inc"
-
#include "NVPTXGenAsmWriter.inc"
static bool hasParamSubqualifiers(const MCSubtargetInfo &STI) {
diff --git a/llvm/lib/Target/NVPTX/NVPTX.h b/llvm/lib/Target/NVPTX/NVPTX.h
index 914295bf76e93..161afbc2be4ee 100644
--- a/llvm/lib/Target/NVPTX/NVPTX.h
+++ b/llvm/lib/Target/NVPTX/NVPTX.h
@@ -299,4 +299,7 @@ void initializeNVPTXDAGToDAGISelLegacyPass(PassRegistry &);
#define GET_INSTRINFO_OPERAND_ENUM
#include "NVPTXGenInstrInfo.inc"
+#define GET_SUBTARGETINFO_ENUM
+#include "NVPTXGenSubtargetInfo.inc"
+
#endif
diff --git a/llvm/lib/Target/NVPTX/NVPTX.td b/llvm/lib/Target/NVPTX/NVPTX.td
index cb9aef2a1cd42..8804e5c57e5fc 100644
--- a/llvm/lib/Target/NVPTX/NVPTX.td
+++ b/llvm/lib/Target/NVPTX/NVPTX.td
@@ -14,100 +14,111 @@
include "llvm/Target/Target.td"
-include "NVPTXRegisterInfo.td"
-include "NVPTXInstrInfo.td"
-
//===----------------------------------------------------------------------===//
-// Subtarget Features.
-// - We use the SM version number instead of explicit feature table.
-// - Need at least one feature to avoid generating zero sized array by
-// TableGen in NVPTXGenSubtarget.inc.
+// PTX ISA versions.
//===----------------------------------------------------------------------===//
-class FeatureSM<string sm, int value>:
- SubtargetFeature<"sm_"# sm, "FullSmVersion",
- "" # value,
- "Target SM " # sm>;
-
class FeaturePTX<int version>:
SubtargetFeature<"ptx"# version, "PTXVersion",
"" # version,
"Use PTX version " # version>;
-// NVPTX Architecture Hierarchy and Ordering:
-//
-// GPU architectures: sm_2Y/sm_3Y/sm_5Y/sm_6Y/sm_7Y/sm_8Y/sm_9Y/sm_10Y/sm_12Y
-// ('Y' represents version within the architecture)
-// The architectures have name of form sm_XYz where 'X' represent the generation
-// number, 'Y' represents the version within the architecture, and 'z' represents
-// the optional feature suffix.
-// If X1Y1 <= X2Y2, then GPU capabilities of sm_X1Y1 are included in sm_X2Y2.
-// For example, take sm_90 (9 represents 'X', 0 represents 'Y', and no feature
-// suffix) and sm_103 architectures (10 represents 'X', 3 represents 'Y', and no
-// feature suffix). Since 90 <= 103, sm_90 is compatible with sm_103.
-//
-// The family-specific variants have 'f' feature suffix and they follow
-// following order:
-// sm_X{Y2}f > sm_X{Y1}f iff Y2 > Y1
-// sm_XY{f} > sm_{XY}{}
-//
-// For example, take sm_100f (10 represents 'X', 0 represents 'Y', and 'f'
-// represents 'z') and sm_103f (10 represents 'X', 3 represents 'Y', and 'f'
-// represents 'z') architecture variants. Since Y1 < Y2, sm_100f is compatible with
-// sm_103f. Similarly based on the second rule, sm_90 is compatible with sm_103f.
+
+foreach version = [32, 40, 41, 42, 43, 50, 60, 61, 62, 63, 64, 65, 70, 71, 72,
+ 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88,
+ 90, 91, 92, 93, 94] in
+ def PTX#version : FeaturePTX<version>;
+
+//===----------------------------------------------------------------------===//
+// Target architectures.
//
-// Some counter examples, take sm_100f and sm_120f (12 represents 'X', 0
-// represents 'Y', and 'f' represents 'z') architecture variants. Since both
-// belongs to different family i.e. X1 != X2, sm_100f is not compatible with
-// sm_120f.
+// Architectures are named sm_XYz, where 'X' is the generation, 'Y' the version
+// within the generation, and 'z' an optional feature suffix. Together they form
+// a lattice, spelled out below as `Implies` edges: sm_A implies sm_B exactly
+// when PTX written against sm_B is accepted for sm_A. Every edge is listed
+// rather than leaning on `Implies` being transitive, which costs nothing
+// because a feature's implied set is a fixed-size bitset either way. Asking
+// whether a target may use what sm_B introduced is then a single bit test.
//
-// The architecture-specific variants have 'a' feature suffix and they follow
-// following order:
-// sm_XY{a} > sm_XY{f} > sm_{XY}{}
+// The three tiers below are the three portability guarantees the PTX ISA
+// defines for a `.target`; see the .target directive in the PTX ISA manual.
//
-// For example, take sm_103a (10 represents 'X', 3 represents 'Y', and 'a'
-// represents 'z'), sm_103f, and sm_103 architecture variants. The sm_103 is
-// compatible with sm_103a and sm_103f, and sm_103f is compatible with sm_103a.
+// * Base architectures are portable: what they introduce is supported on all
+// later architectures, including ones in other families. This is the "onion
+// layer" model, and it makes them totally ordered by their number, so sm_120
+// implies sm_110, which implies sm_107, and so on.
//
-// Encoding := Arch * 10 + ArchSuffixOffset
-// Arch := X * 10 + Y
-// ArchSuffixOffset := 0 (base), 2 ('f'), or 3 ('a')
+// * A family-specific variant sm_XYf is portable within its family only, so
+// sm_103f implies sm_100f. A family is the set of architectures sharing an
+// SM major version. There are no edges between families, which is what makes
+// sm_120f and sm_100f incomparable.
//
-// For example, sm_103a is encoded as 1033 (103 * 10 + 3) and sm_103f is
-// encoded as 1032 (103 * 10 + 2).
+// * An architecture-specific variant sm_XYa is not portable at all, so
+// sm_103a implies sm_103f and nothing implies sm_103a.
//
-// This encoding allows simple partial ordering of the architectures.
-// + Compare Family and Arch by dividing FullSMVersion by 100 and 10
-// respectively before the comparison.
-// + Compare within the family by comparing FullSMVersion, given both belongs to
-// the same family.
-// + Detect 'a' variants by checking FullSMVersion & 1.
+// There is deliberately no numeric encoding of an architecture. Asking whether a
+// target may use something is a bit test against the node that introduced it,
+// which is what the partial order above requires; a number would only invite the
+// ordered comparisons it cannot answer.
+//===----------------------------------------------------------------------===//
+
+class FeatureSM<list<SubtargetFeature> implies>:
+ SubtargetFeature<"sm_"# !substr(NAME, 2), "HasArchitecture", "true",
+ "Target SM " # !substr(NAME, 2), implies>,
+ Predicate<"Subtarget->hasFeature(NVPTX::" # NAME # ")"> {
+ assert !eq(!substr(NAME, 0, 2), "SM"),
+ "architecture record " # NAME # " must be named SM<version>";
+}
+
class Proc<FeatureSM SM>
: Processor<SM.Name, NoItineraries, [SM]>;
-foreach sm = [20, 21, 30, 32, 35, 37, 50, 52, 53, 60,
- 61, 62, 70, 72, 75, 80, 86, 87, 88, 89,
- 90, 100, 101, 103, 107, 110, 120, 121] in {
- // Base SM version (e.g. FullSMVersion for sm_100 is 1000)
- def SM#sm : FeatureSM<""#sm, !mul(sm, 10)>;
- def : Proc<!cast<FeatureSM>("SM"#sm)>;
-
- // Family-specific variants, compatible within same family (e.g. sm_100f = 1002)
- if !ge(sm, 100) then {
- def SM#sm#f : FeatureSM<""#sm#"f", !add(!mul(sm, 10), 2)>;
- def : Proc<!cast<FeatureSM>("SM"#sm#"f")>;
- }
-
- // Architecture-specific variants, incompatible across architectures (e.g. sm_100a = 1003)
- if !ge(sm, 90) then {
- def SM#sm#a : FeatureSM<""#sm#"a", !add(!mul(sm, 10), 3)>;
- def : Proc<!cast<FeatureSM>("SM"#sm#"a")>;
- }
+multiclass ProcSM<list<SubtargetFeature> implies> {
+ def NAME : FeatureSM<implies>;
+ def : Proc<!cast<FeatureSM>(NAME)>;
}
-foreach version = [32, 40, 41, 42, 43, 50, 60, 61, 62, 63, 64, 65, 70, 71, 72,
- 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88,
- 90, 91, 92, 93, 94] in
- def PTX#version : FeaturePTX<version>;
+// Base architectures, in increasing order. Each implies the features of every
+// earlier one.
+defvar SMVersions = [20, 21, 30, 32, 35, 37, 50, 52, 53, 60,
+ 61, 62, 70, 72, 75, 80, 86, 87, 88, 89,
+ 90, 100, 103, 107, 110, 120, 121];
+
+foreach sm = SMVersions in
+ defm SM#sm : ProcSM<!foreach(earlier, !filter(v, SMVersions, !lt(v, sm)),
+ !cast<SubtargetFeature>("SM"#earlier))>;
+
+// Defines the family-specific ('f') and architecture-specific ('a') variants of
+// the base architecture this is named after.
+multiclass FeatureSMVariants<list<SubtargetFeature> EarlierInFamily> {
+ defm f : ProcSM<[!cast<SubtargetFeature>(NAME)] # EarlierInFamily>;
+ defm a : ProcSM<[!cast<SubtargetFeature>(NAME # "f")]>;
+}
+
+// The families, each listed in increasing order, mirroring the architecture
+// family table in the PTX ISA manual.
+defvar SMFamilies = [[100, 103, 107], // sm_10x
+ [110], // sm_11x
+ [120, 121]]; // sm_12x
+
+foreach Family = SMFamilies in
+ foreach sm = Family in
+ defm SM#sm : FeatureSMVariants<
+ !foreach(earlier, !filter(v, Family, !lt(v, sm)),
+ !cast<SubtargetFeature>("SM" # earlier # "f"))>;
+
+// sm_90 predates family-specific variants, so sm_90a is the only member of the
+// sm_9x family and stands in for its 'f' variant, which does not exist.
+defm SM90a : ProcSM<[SM90]>;
+
+// sm_101 was the name PTX 8.6 through 8.8 used for what PTX 9.0 renamed to
+// sm_110. The two names describe the same hardware, so they share a node rather
+// than duplicating one.
+def : ProcessorAlias<"sm_101", "sm_110">;
+def : ProcessorAlias<"sm_101f", "sm_110f">;
+def : ProcessorAlias<"sm_101a", "sm_110a">;
+
+include "NVPTXRegisterInfo.td"
+include "NVPTXInstrInfo.td"
def Is64Bit : Predicate<"Subtarget->getTargetTriple().getArch() == Triple::nvptx64">;
def NVPTX64 : HwMode<[Is64Bit]>;
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 2b676bc239d86..43c36648c4ed6 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -989,7 +989,7 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F,
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
const NVPTXSubtarget *STI = &NTM.getSubtarget<NVPTXSubtarget>(F);
- if (STI->getSmVersion() >= 90) {
+ if (STI->hasFeature(NVPTX::SM90)) {
const auto ClusterDim = getClusterDim(F);
const bool BlocksAreClusters = hasBlocksAreClusters(F);
@@ -1232,7 +1232,8 @@ DwarfDebug *NVPTXAsmPrinter::createDwarfDebug() {
bool NVPTXAsmPrinter::doInitialization(Module &M) {
const NVPTXTargetMachine &NTM = static_cast<const NVPTXTargetMachine &>(TM);
const NVPTXSubtarget &STI = *NTM.getSubtargetImpl();
- if (M.alias_size() && (STI.getPTXVersion() < 63 || STI.getSmVersion() < 30))
+ if (M.alias_size() &&
+ (STI.getPTXVersion() < 63 || !STI.hasFeature(NVPTX::SM30)))
report_fatal_error(".alias requires PTX version >= 6.3 and sm_30");
// We need to call the parent's one explicitly.
@@ -1540,7 +1541,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariableDefinition(
emitPTXAddressSpace(GVar->getAddressSpace(), O);
if (isManaged(*GVar)) {
- if (STI.getPTXVersion() < 40 || STI.getSmVersion() < 30)
+ if (STI.getPTXVersion() < 40 || !STI.hasFeature(NVPTX::SM30))
report_fatal_error(
".attribute(.managed) requires PTX version >= 4.0 and sm_30");
O << " .attribute(.managed)";
@@ -1839,7 +1840,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
O << ".";
emitPTXAddressSpace(GVar->getType()->getAddressSpace(), O);
if (isManaged(*GVar)) {
- if (STI.getPTXVersion() < 40 || STI.getSmVersion() < 30)
+ if (STI.getPTXVersion() < 40 || !STI.hasFeature(NVPTX::SM30))
report_fatal_error(
".attribute(.managed) requires PTX version >= 4.0 and sm_30");
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
index 29921ff86b352..e5c5050cac34f 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -560,11 +560,11 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
case ISD::FMINIMUM:
case ISD::FMAXIMUMNUM:
case ISD::FMINIMUMNUM:
- IsOpSupported &= STI.getSmVersion() >= 80 && STI.getPTXVersion() >= 70;
+ IsOpSupported &= STI.hasFeature(NVPTX::SM80) && STI.getPTXVersion() >= 70;
break;
case ISD::FEXP2:
case ISD::FTANH:
- IsOpSupported &= STI.getSmVersion() >= 75 && STI.getPTXVersion() >= 70;
+ IsOpSupported &= STI.hasFeature(NVPTX::SM75) && STI.getPTXVersion() >= 70;
break;
}
setOperationAction(Op, VT, IsOpSupported ? Action : NoF16Action);
@@ -587,7 +587,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
case ISD::SMIN:
case ISD::UMIN:
case ISD::UMAX:
- IsOpSupported = STI.getSmVersion() >= 90 && STI.getPTXVersion() >= 80;
+ IsOpSupported = STI.hasFeature(NVPTX::SM90) && STI.getPTXVersion() >= 80;
break;
}
setOperationAction(Op, VT, IsOpSupported ? Action : NoI16x2Action);
@@ -618,7 +618,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v2f16, Expand);
setOperationAction(ISD::READCYCLECOUNTER, MVT::i64, Legal);
- if (STI.getSmVersion() >= 30 && STI.getPTXVersion() > 31)
+ if (STI.hasFeature(NVPTX::SM30) && STI.getPTXVersion() > 31)
setOperationAction(ISD::READSTEADYCOUNTER, MVT::i64, Legal);
setFP16OperationAction(ISD::SETCC, MVT::f16, Legal, Promote);
@@ -953,7 +953,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
}
// f16/f16x2 neg was introduced in PTX 60, SM_53.
- const bool IsFP16FP16x2NegAvailable = STI.getSmVersion() >= 53 &&
+ const bool IsFP16FP16x2NegAvailable = STI.hasFeature(NVPTX::SM53) &&
STI.getPTXVersion() >= 60 &&
STI.allowFP16Math();
for (const auto &VT : {MVT::f16, MVT::v2f16})
@@ -979,10 +979,10 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
AddPromotedToType(Op, MVT::bf16, MVT::f32);
}
- if (STI.getSmVersion() < 80 || STI.getPTXVersion() < 71) {
+ if (!STI.hasFeature(NVPTX::SM80) || STI.getPTXVersion() < 71) {
setOperationAction(ISD::BF16_TO_FP, MVT::f32, Expand);
}
- if (STI.getSmVersion() < 90 || STI.getPTXVersion() < 78) {
+ if (!STI.hasFeature(NVPTX::SM90) || STI.getPTXVersion() < 78) {
for (MVT VT : {MVT::bf16, MVT::f32, MVT::f64}) {
setOperationAction(ISD::FP_EXTEND, VT, Custom);
setOperationAction(ISD::FP_ROUND, VT, Custom);
@@ -996,7 +996,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
// sm_80 only has conversions between f32 and bf16. Custom lower all other
// bf16 conversions.
- if (STI.getSmVersion() < 90 || STI.getPTXVersion() < 78) {
+ if (!STI.hasFeature(NVPTX::SM90) || STI.getPTXVersion() < 78) {
for (MVT VT : {MVT::i1, MVT::i16, MVT::i32, MVT::i64}) {
setOperationAction(
{ISD::SINT_TO_FP, ISD::UINT_TO_FP, ISD::FP_TO_SINT, ISD::FP_TO_UINT},
@@ -1048,7 +1048,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
// - f16/f16x2 (sm_75+, PTX 7.0+)
// - bf16/bf16x2 (sm_90+, PTX 7.8+)
// When f16/bf16 types aren't supported, they are promoted/expanded to f32.
- if (STI.getSmVersion() >= 75 && STI.getPTXVersion() >= 70)
+ if (STI.hasFeature(NVPTX::SM75) && STI.getPTXVersion() >= 70)
setOperationAction(ISD::FTANH, MVT::f32, Legal);
setOperationAction(ISD::FTANH, MVT::v2f32, Expand);
@@ -1089,7 +1089,7 @@ NVPTXTargetLowering::NVPTXTargetLowering(const NVPTXTargetMachine &TM,
setOperationAction(Op, MVT::v2f32, Expand);
}
bool SupportsF32MinMaxNaN =
- STI.getSmVersion() >= 80 && STI.getPTXVersion() >= 70;
+ STI.hasFeature(NVPTX::SM80) && STI.getPTXVersion() >= 70;
for (const auto &Op : {ISD::FMINIMUM, ISD::FMAXIMUM}) {
setOperationAction(Op, MVT::f32, SupportsF32MinMaxNaN ? Legal : Expand);
setFP16OperationAction(Op, MVT::f16, Legal, Expand);
@@ -1278,7 +1278,8 @@ static SDValue correctParamType(SDValue V, EVT ExpectedVT,
SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
SmallVectorImpl<SDValue> &InVals) const {
- if (CLI.IsVarArg && (STI.getPTXVersion() < 60 || STI.getSmVersion() < 30))
+ if (CLI.IsVarArg &&
+ (STI.getPTXVersion() < 60 || !STI.hasFeature(NVPTX::SM30)))
report_fatal_error(
"Support for variadic functions (unsized array parameter) introduced "
"in PTX ISA version 6.0 and requires target sm_30.");
@@ -1681,7 +1682,7 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
SDValue NVPTXTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
SelectionDAG &DAG) const {
- if (STI.getPTXVersion() < 73 || STI.getSmVersion() < 52) {
+ if (STI.getPTXVersion() < 73 || !STI.hasFeature(NVPTX::SM52)) {
const Function &Fn = DAG.getMachineFunction().getFunction();
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
@@ -1722,7 +1723,7 @@ SDValue NVPTXTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
SDValue NVPTXTargetLowering::LowerSTACKRESTORE(SDValue Op,
SelectionDAG &DAG) const {
SDLoc DL(Op.getNode());
- if (STI.getPTXVersion() < 73 || STI.getSmVersion() < 52) {
+ if (STI.getPTXVersion() < 73 || !STI.hasFeature(NVPTX::SM52)) {
const Function &Fn = DAG.getMachineFunction().getFunction();
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
@@ -1744,7 +1745,7 @@ SDValue NVPTXTargetLowering::LowerSTACKRESTORE(SDValue Op,
SDValue NVPTXTargetLowering::LowerSTACKSAVE(SDValue Op,
SelectionDAG &DAG) const {
SDLoc DL(Op.getNode());
- if (STI.getPTXVersion() < 73 || STI.getSmVersion() < 52) {
+ if (STI.getPTXVersion() < 73 || !STI.hasFeature(NVPTX::SM52)) {
const Function &Fn = DAG.getMachineFunction().getFunction();
DAG.getContext()->diagnose(DiagnosticInfoUnsupported(
@@ -1900,7 +1901,7 @@ SDValue NVPTXTargetLowering::LowerVECREDUCE(SDValue Op,
// Whether we can use 3-input min/max when expanding the reduction.
const bool CanUseMinMax3 =
- EltTy == MVT::f32 && STI.getSmVersion() >= 100 &&
+ EltTy == MVT::f32 && STI.hasFeature(NVPTX::SM100) &&
STI.getPTXVersion() >= 88 &&
(Opcode == ISD::VECREDUCE_FMAX || Opcode == ISD::VECREDUCE_FMIN ||
Opcode == ISD::VECREDUCE_FMAXIMUM || Opcode == ISD::VECREDUCE_FMINIMUM);
@@ -2124,7 +2125,7 @@ SDValue NVPTXTargetLowering::LowerShiftRightParts(SDValue Op,
SDValue ShAmt = Op.getOperand(2);
unsigned Opc = (Op.getOpcode() == ISD::SRA_PARTS) ? ISD::SRA : ISD::SRL;
- if (VTBits == 32 && STI.getSmVersion() >= 35) {
+ if (VTBits == 32 && STI.hasFeature(NVPTX::SM35)) {
// For 32bit and sm35, we can use the funnel shift 'shf' instruction.
// {dHi, dLo} = {aHi, aLo} >> Amt
// dHi = aHi >> Amt
@@ -2184,7 +2185,7 @@ SDValue NVPTXTargetLowering::LowerShiftLeftParts(SDValue Op,
SDValue ShOpHi = Op.getOperand(1);
SDValue ShAmt = Op.getOperand(2);
- if (VTBits == 32 && STI.getSmVersion() >= 35) {
+ if (VTBits == 32 && STI.hasFeature(NVPTX::SM35)) {
// For 32bit and sm35, we can use the funnel shift 'shf' instruction.
// {dHi, dLo} = {aHi, aLo} << Amt
// dHi = shf.l.clamp aLo, aHi, Amt
@@ -2359,7 +2360,7 @@ SDValue NVPTXTargetLowering::PromoteBinOpIfF32FTZ(SDValue Op,
SDValue NVPTXTargetLowering::LowerINT_TO_FP(SDValue Op,
SelectionDAG &DAG) const {
- assert(STI.getSmVersion() < 90 || STI.getPTXVersion() < 78);
+ assert(!STI.hasFeature(NVPTX::SM90) || STI.getPTXVersion() < 78);
if (Op.getValueType() == MVT::bf16) {
SDLoc Loc(Op);
@@ -2375,7 +2376,7 @@ SDValue NVPTXTargetLowering...
[truncated]
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| // than duplicating one. | ||
| def : ProcessorAlias<"sm_101", "sm_110">; | ||
| def : ProcessorAlias<"sm_101f", "sm_110f">; | ||
| def : ProcessorAlias<"sm_101a", "sm_110a">; |
There was a problem hiding this comment.
So, this will generate .target as sm_110 (where we had sm_101 before) right?
I wonder why there are no updates to existing tests, corresponding to this change..
There was a problem hiding this comment.
So, this will generate .target as sm_110 (where we had sm_101 before) right?
No, there are 2 layers here which normally agree but diverge for the sm_101/sm_110 case. The .target directive is chosen by the "CPU" the user names. The feature set is determined by these TableGen features and processors. sm_101/sm_110 share the sm_110 feature set, simplifying feature selection predicates, but they don't share a name/enum value.
There was a problem hiding this comment.
ah ok, thanks for clarifying!
|
The general direction LGTM, Alex! Please double-check once the sm-101/sm-110 (test) updates. |
|
Could we do something similar for the PTX version as well, or is there something that blocks that? |
2adacbe to
ad6c1fa
Compare
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/234/builds/1664 Here is the relevant piece of the build log for the reference |
|
LGTM, nice cleanup! |
…name, r=folkertdev
rustc_codegen_llvm: handle sm_101* features being an alias
LLVM 24 [moved sm_101{,a,f} features](llvm/llvm-project#214335) to just be an alias for the matching sm_110 feature. Since the sm_110 feature already exists, we can do the remapping unconditionally rather than gating it on LLVM 24.
@rustbot label: +llvm-main
…name, r=folkertdev
rustc_codegen_llvm: handle sm_101* features being an alias
LLVM 24 [moved sm_101{,a,f} features](llvm/llvm-project#214335) to just be an alias for the matching sm_110 feature. Since the sm_110 feature already exists, we can do the remapping unconditionally rather than gating it on LLVM 24.
@rustbot label: +llvm-main
…olkertdev
rustc_codegen_llvm: handle sm_101* features being an alias
LLVM 24 [moved sm_101{,a,f} features](llvm/llvm-project#214335) to just be an alias for the matching sm_110 feature. Since the sm_110 feature already exists, we can do the remapping unconditionally rather than gating it on LLVM 24.
@rustbot label: +llvm-main
This change replaces the integer SM encoding used by the `NVVMRequiresSM` traits (e.g. `sm_100f` as 1002) with one TableGen record per architecture, related by the same `implies` lattice the NVPTX backend uses for its architecture features (llvm#214335). The `NVVMRequiresSMa`, `NVVMRequiresSMf` and `NVVMRequiresSMaOrSMf` classes are folded into a single `NVVMRequiresSM` that takes a list of architectures, e.g. `NVVMRequiresSM<[SM100f, SM110f]>`.
No description provided.