Skip to content

Commit de5f643

Browse files
[NVPTX] Remove sm_1x / non-ABI compilation support (llvm#125977)
@Artem-B, I believe you said we don't intend to support `sm_1x`. Assuming that's correct, this PR will remove all remaining support I could find for `sm_1x`.
1 parent efa287d commit de5f643

File tree

3 files changed

+45
-122
lines changed

3 files changed

+45
-122
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 36 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -343,61 +343,32 @@ void NVPTXAsmPrinter::printReturnValStr(const Function *F, raw_ostream &O) {
343343
const auto *TLI = cast<NVPTXTargetLowering>(STI.getTargetLowering());
344344

345345
Type *Ty = F->getReturnType();
346-
347-
bool isABI = (STI.getSmVersion() >= 20);
348-
349346
if (Ty->getTypeID() == Type::VoidTyID)
350347
return;
351348
O << " (";
352349

353-
if (isABI) {
354-
if ((Ty->isFloatingPointTy() || Ty->isIntegerTy()) &&
355-
!ShouldPassAsArray(Ty)) {
356-
unsigned size = 0;
357-
if (auto *ITy = dyn_cast<IntegerType>(Ty)) {
358-
size = ITy->getBitWidth();
359-
} else {
360-
assert(Ty->isFloatingPointTy() && "Floating point type expected here");
361-
size = Ty->getPrimitiveSizeInBits();
362-
}
363-
size = promoteScalarArgumentSize(size);
364-
O << ".param .b" << size << " func_retval0";
365-
} else if (isa<PointerType>(Ty)) {
366-
O << ".param .b" << TLI->getPointerTy(DL).getSizeInBits()
367-
<< " func_retval0";
368-
} else if (ShouldPassAsArray(Ty)) {
369-
unsigned totalsz = DL.getTypeAllocSize(Ty);
370-
Align RetAlignment = TLI->getFunctionArgumentAlignment(
371-
F, Ty, AttributeList::ReturnIndex, DL);
372-
O << ".param .align " << RetAlignment.value() << " .b8 func_retval0["
373-
<< totalsz << "]";
374-
} else
375-
llvm_unreachable("Unknown return type");
376-
} else {
377-
SmallVector<EVT, 16> vtparts;
378-
ComputeValueVTs(*TLI, DL, Ty, vtparts);
379-
unsigned idx = 0;
380-
for (unsigned i = 0, e = vtparts.size(); i != e; ++i) {
381-
unsigned elems = 1;
382-
EVT elemtype = vtparts[i];
383-
if (vtparts[i].isVector()) {
384-
elems = vtparts[i].getVectorNumElements();
385-
elemtype = vtparts[i].getVectorElementType();
386-
}
387-
388-
for (unsigned j = 0, je = elems; j != je; ++j) {
389-
unsigned sz = elemtype.getSizeInBits();
390-
if (elemtype.isInteger())
391-
sz = promoteScalarArgumentSize(sz);
392-
O << ".reg .b" << sz << " func_retval" << idx;
393-
if (j < je - 1)
394-
O << ", ";
395-
++idx;
396-
}
397-
if (i < e - 1)
398-
O << ", ";
350+
if ((Ty->isFloatingPointTy() || Ty->isIntegerTy()) &&
351+
!ShouldPassAsArray(Ty)) {
352+
unsigned size = 0;
353+
if (auto *ITy = dyn_cast<IntegerType>(Ty)) {
354+
size = ITy->getBitWidth();
355+
} else {
356+
assert(Ty->isFloatingPointTy() && "Floating point type expected here");
357+
size = Ty->getPrimitiveSizeInBits();
399358
}
400-
}
359+
size = promoteScalarArgumentSize(size);
360+
O << ".param .b" << size << " func_retval0";
361+
} else if (isa<PointerType>(Ty)) {
362+
O << ".param .b" << TLI->getPointerTy(DL).getSizeInBits()
363+
<< " func_retval0";
364+
} else if (ShouldPassAsArray(Ty)) {
365+
unsigned totalsz = DL.getTypeAllocSize(Ty);
366+
Align RetAlignment = TLI->getFunctionArgumentAlignment(
367+
F, Ty, AttributeList::ReturnIndex, DL);
368+
O << ".param .align " << RetAlignment.value() << " .b8 func_retval0["
369+
<< totalsz << "]";
370+
} else
371+
llvm_unreachable("Unknown return type");
401372
O << ") ";
402373
}
403374

@@ -1513,7 +1484,6 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
15131484
unsigned paramIndex = 0;
15141485
bool first = true;
15151486
bool isKernelFunc = isKernelFunction(*F);
1516-
bool isABI = (STI.getSmVersion() >= 20);
15171487

15181488
if (F->arg_empty() && !F->isVarArg()) {
15191489
O << "()";
@@ -1646,10 +1616,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
16461616
sz = PTySizeInBits;
16471617
} else
16481618
sz = Ty->getPrimitiveSizeInBits();
1649-
if (isABI)
1650-
O << "\t.param .b" << sz << " ";
1651-
else
1652-
O << "\t.reg .b" << sz << " ";
1619+
O << "\t.param .b" << sz << " ";
16531620
O << TLI->getParamName(F, paramIndex);
16541621
continue;
16551622
}
@@ -1658,53 +1625,20 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
16581625
Type *ETy = PAL.getParamByValType(paramIndex);
16591626
assert(ETy && "Param should have byval type");
16601627

1661-
if (isABI || isKernelFunc) {
1662-
// Just print .param .align <a> .b8 .param[size];
1663-
// <a> = optimal alignment for the element type; always multiple of
1664-
// PAL.getParamAlignment
1665-
// size = typeallocsize of element type
1666-
Align OptimalAlign =
1667-
isKernelFunc
1668-
? getOptimalAlignForParam(ETy)
1669-
: TLI->getFunctionByValParamAlign(
1670-
F, ETy, PAL.getParamAlignment(paramIndex).valueOrOne(), DL);
1671-
1672-
unsigned sz = DL.getTypeAllocSize(ETy);
1673-
O << "\t.param .align " << OptimalAlign.value() << " .b8 ";
1674-
O << TLI->getParamName(F, paramIndex);
1675-
O << "[" << sz << "]";
1676-
continue;
1677-
} else {
1678-
// Split the ETy into constituent parts and
1679-
// print .param .b<size> <name> for each part.
1680-
// Further, if a part is vector, print the above for
1681-
// each vector element.
1682-
SmallVector<EVT, 16> vtparts;
1683-
ComputeValueVTs(*TLI, DL, ETy, vtparts);
1684-
for (unsigned i = 0, e = vtparts.size(); i != e; ++i) {
1685-
unsigned elems = 1;
1686-
EVT elemtype = vtparts[i];
1687-
if (vtparts[i].isVector()) {
1688-
elems = vtparts[i].getVectorNumElements();
1689-
elemtype = vtparts[i].getVectorElementType();
1690-
}
1691-
1692-
for (unsigned j = 0, je = elems; j != je; ++j) {
1693-
unsigned sz = elemtype.getSizeInBits();
1694-
if (elemtype.isInteger())
1695-
sz = promoteScalarArgumentSize(sz);
1696-
O << "\t.reg .b" << sz << " ";
1697-
O << TLI->getParamName(F, paramIndex);
1698-
if (j < je - 1)
1699-
O << ",\n";
1700-
++paramIndex;
1701-
}
1702-
if (i < e - 1)
1703-
O << ",\n";
1704-
}
1705-
--paramIndex;
1706-
continue;
1707-
}
1628+
// Print .param .align <a> .b8 .param[size];
1629+
// <a> = optimal alignment for the element type; always multiple of
1630+
// PAL.getParamAlignment
1631+
// size = typeallocsize of element type
1632+
Align OptimalAlign =
1633+
isKernelFunc
1634+
? getOptimalAlignForParam(ETy)
1635+
: TLI->getFunctionByValParamAlign(
1636+
F, ETy, PAL.getParamAlignment(paramIndex).valueOrOne(), DL);
1637+
1638+
unsigned sz = DL.getTypeAllocSize(ETy);
1639+
O << "\t.param .align " << OptimalAlign.value() << " .b8 ";
1640+
O << TLI->getParamName(F, paramIndex);
1641+
O << "[" << sz << "]";
17081642
}
17091643

17101644
if (F->isVarArg()) {

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,11 +1156,6 @@ std::string NVPTXTargetLowering::getPrototype(
11561156
const CallBase &CB, unsigned UniqueCallSite) const {
11571157
auto PtrVT = getPointerTy(DL);
11581158

1159-
bool isABI = (STI.getSmVersion() >= 20);
1160-
assert(isABI && "Non-ABI compilation is not supported");
1161-
if (!isABI)
1162-
return "";
1163-
11641159
std::string Prototype;
11651160
raw_string_ostream O(Prototype);
11661161
O << "prototype_" << UniqueCallSite << " : .callprototype ";
@@ -1429,11 +1424,6 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
14291424
const CallBase *CB = CLI.CB;
14301425
const DataLayout &DL = DAG.getDataLayout();
14311426

1432-
bool isABI = (STI.getSmVersion() >= 20);
1433-
assert(isABI && "Non-ABI compilation is not supported");
1434-
if (!isABI)
1435-
return Chain;
1436-
14371427
// Variadic arguments.
14381428
//
14391429
// Normally, for each argument, we declare a param scalar or a param
@@ -3091,11 +3081,6 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
30913081
SDValue Root = DAG.getRoot();
30923082
std::vector<SDValue> OutChains;
30933083

3094-
bool isABI = (STI.getSmVersion() >= 20);
3095-
assert(isABI && "Non-ABI compilation is not supported");
3096-
if (!isABI)
3097-
return Chain;
3098-
30993084
std::vector<Type *> argTypes;
31003085
std::vector<const Argument *> theArgs;
31013086
for (const Argument &I : F->args()) {
@@ -3310,11 +3295,6 @@ NVPTXTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
33103295
const Function &F = MF.getFunction();
33113296
Type *RetTy = MF.getFunction().getReturnType();
33123297

3313-
bool isABI = (STI.getSmVersion() >= 20);
3314-
assert(isABI && "Non-ABI compilation is not supported");
3315-
if (!isABI)
3316-
return Chain;
3317-
33183298
const DataLayout &DL = DAG.getDataLayout();
33193299
SmallVector<SDValue, 16> PromotedOutVals;
33203300
SmallVector<EVT, 16> VTs;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc < %s -mtriple=nvptx -mcpu=sm_10 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM10
2+
; RUN: llc < %s -mtriple=nvptx -mcpu=sm_11 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM11
3+
; RUN: llc < %s -mtriple=nvptx -mcpu=sm_12 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM12
4+
; RUN: llc < %s -mtriple=nvptx -mcpu=sm_13 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM13
5+
6+
; SM10: 'sm_10' is not a recognized processor for this target (ignoring processor)
7+
; SM11: 'sm_11' is not a recognized processor for this target (ignoring processor)
8+
; SM12: 'sm_12' is not a recognized processor for this target (ignoring processor)
9+
; SM13: 'sm_13' is not a recognized processor for this target (ignoring processor)

0 commit comments

Comments
 (0)