- Notifications
You must be signed in to change notification settings - Fork 15.3k
[NVPTX] Remove sm_1x / non-ABI compilation support #125977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NVPTX] Remove sm_1x / non-ABI compilation support #125977
Conversation
| @llvm/pr-subscribers-backend-nvptx Author: Justin Fargnoli (justinfargnoli) Changes@Artem-B, I believe you said we don't intend to support Full diff: https://github.com/llvm/llvm-project/pull/125977.diff 3 Files Affected:
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index cb756246b8d116c..ad1433821036be6 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -343,61 +343,32 @@ void NVPTXAsmPrinter::printReturnValStr(const Function *F, raw_ostream &O) { const auto *TLI = cast<NVPTXTargetLowering>(STI.getTargetLowering()); Type *Ty = F->getReturnType(); - - bool isABI = (STI.getSmVersion() >= 20); - if (Ty->getTypeID() == Type::VoidTyID) return; O << " ("; - if (isABI) { - if ((Ty->isFloatingPointTy() || Ty->isIntegerTy()) && - !ShouldPassAsArray(Ty)) { - unsigned size = 0; - if (auto *ITy = dyn_cast<IntegerType>(Ty)) { - size = ITy->getBitWidth(); - } else { - assert(Ty->isFloatingPointTy() && "Floating point type expected here"); - size = Ty->getPrimitiveSizeInBits(); - } - size = promoteScalarArgumentSize(size); - O << ".param .b" << size << " func_retval0"; - } else if (isa<PointerType>(Ty)) { - O << ".param .b" << TLI->getPointerTy(DL).getSizeInBits() - << " func_retval0"; - } else if (ShouldPassAsArray(Ty)) { - unsigned totalsz = DL.getTypeAllocSize(Ty); - Align RetAlignment = TLI->getFunctionArgumentAlignment( - F, Ty, AttributeList::ReturnIndex, DL); - O << ".param .align " << RetAlignment.value() << " .b8 func_retval0[" - << totalsz << "]"; - } else - llvm_unreachable("Unknown return type"); - } else { - SmallVector<EVT, 16> vtparts; - ComputeValueVTs(*TLI, DL, Ty, vtparts); - unsigned idx = 0; - for (unsigned i = 0, e = vtparts.size(); i != e; ++i) { - unsigned elems = 1; - EVT elemtype = vtparts[i]; - if (vtparts[i].isVector()) { - elems = vtparts[i].getVectorNumElements(); - elemtype = vtparts[i].getVectorElementType(); - } - - for (unsigned j = 0, je = elems; j != je; ++j) { - unsigned sz = elemtype.getSizeInBits(); - if (elemtype.isInteger()) - sz = promoteScalarArgumentSize(sz); - O << ".reg .b" << sz << " func_retval" << idx; - if (j < je - 1) - O << ", "; - ++idx; - } - if (i < e - 1) - O << ", "; + if ((Ty->isFloatingPointTy() || Ty->isIntegerTy()) && + !ShouldPassAsArray(Ty)) { + unsigned size = 0; + if (auto *ITy = dyn_cast<IntegerType>(Ty)) { + size = ITy->getBitWidth(); + } else { + assert(Ty->isFloatingPointTy() && "Floating point type expected here"); + size = Ty->getPrimitiveSizeInBits(); } - } + size = promoteScalarArgumentSize(size); + O << ".param .b" << size << " func_retval0"; + } else if (isa<PointerType>(Ty)) { + O << ".param .b" << TLI->getPointerTy(DL).getSizeInBits() + << " func_retval0"; + } else if (ShouldPassAsArray(Ty)) { + unsigned totalsz = DL.getTypeAllocSize(Ty); + Align RetAlignment = TLI->getFunctionArgumentAlignment( + F, Ty, AttributeList::ReturnIndex, DL); + O << ".param .align " << RetAlignment.value() << " .b8 func_retval0[" + << totalsz << "]"; + } else + llvm_unreachable("Unknown return type"); O << ") "; } @@ -1513,7 +1484,6 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) { unsigned paramIndex = 0; bool first = true; bool isKernelFunc = isKernelFunction(*F); - bool isABI = (STI.getSmVersion() >= 20); if (F->arg_empty() && !F->isVarArg()) { O << "()"; @@ -1646,10 +1616,7 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) { sz = PTySizeInBits; } else sz = Ty->getPrimitiveSizeInBits(); - if (isABI) - O << "\t.param .b" << sz << " "; - else - O << "\t.reg .b" << sz << " "; + O << "\t.param .b" << sz << " "; O << TLI->getParamName(F, paramIndex); continue; } @@ -1658,53 +1625,20 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) { Type *ETy = PAL.getParamByValType(paramIndex); assert(ETy && "Param should have byval type"); - if (isABI || isKernelFunc) { - // Just print .param .align <a> .b8 .param[size]; - // <a> = optimal alignment for the element type; always multiple of - // PAL.getParamAlignment - // size = typeallocsize of element type - Align OptimalAlign = - isKernelFunc - ? getOptimalAlignForParam(ETy) - : TLI->getFunctionByValParamAlign( - F, ETy, PAL.getParamAlignment(paramIndex).valueOrOne(), DL); - - unsigned sz = DL.getTypeAllocSize(ETy); - O << "\t.param .align " << OptimalAlign.value() << " .b8 "; - O << TLI->getParamName(F, paramIndex); - O << "[" << sz << "]"; - continue; - } else { - // Split the ETy into constituent parts and - // print .param .b<size> <name> for each part. - // Further, if a part is vector, print the above for - // each vector element. - SmallVector<EVT, 16> vtparts; - ComputeValueVTs(*TLI, DL, ETy, vtparts); - for (unsigned i = 0, e = vtparts.size(); i != e; ++i) { - unsigned elems = 1; - EVT elemtype = vtparts[i]; - if (vtparts[i].isVector()) { - elems = vtparts[i].getVectorNumElements(); - elemtype = vtparts[i].getVectorElementType(); - } - - for (unsigned j = 0, je = elems; j != je; ++j) { - unsigned sz = elemtype.getSizeInBits(); - if (elemtype.isInteger()) - sz = promoteScalarArgumentSize(sz); - O << "\t.reg .b" << sz << " "; - O << TLI->getParamName(F, paramIndex); - if (j < je - 1) - O << ",\n"; - ++paramIndex; - } - if (i < e - 1) - O << ",\n"; - } - --paramIndex; - continue; - } + // Print .param .align <a> .b8 .param[size]; + // <a> = optimal alignment for the element type; always multiple of + // PAL.getParamAlignment + // size = typeallocsize of element type + Align OptimalAlign = + isKernelFunc + ? getOptimalAlignForParam(ETy) + : TLI->getFunctionByValParamAlign( + F, ETy, PAL.getParamAlignment(paramIndex).valueOrOne(), DL); + + unsigned sz = DL.getTypeAllocSize(ETy); + O << "\t.param .align " << OptimalAlign.value() << " .b8 "; + O << TLI->getParamName(F, paramIndex); + O << "[" << sz << "]"; } if (F->isVarArg()) { diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp index 9e7e1dbcea25d11..58ad92a8934a66d 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -1156,11 +1156,6 @@ std::string NVPTXTargetLowering::getPrototype( const CallBase &CB, unsigned UniqueCallSite) const { auto PtrVT = getPointerTy(DL); - bool isABI = (STI.getSmVersion() >= 20); - assert(isABI && "Non-ABI compilation is not supported"); - if (!isABI) - return ""; - std::string Prototype; raw_string_ostream O(Prototype); O << "prototype_" << UniqueCallSite << " : .callprototype "; @@ -1429,11 +1424,6 @@ SDValue NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, const CallBase *CB = CLI.CB; const DataLayout &DL = DAG.getDataLayout(); - bool isABI = (STI.getSmVersion() >= 20); - assert(isABI && "Non-ABI compilation is not supported"); - if (!isABI) - return Chain; - // Variadic arguments. // // Normally, for each argument, we declare a param scalar or a param @@ -3091,11 +3081,6 @@ SDValue NVPTXTargetLowering::LowerFormalArguments( SDValue Root = DAG.getRoot(); std::vector<SDValue> OutChains; - bool isABI = (STI.getSmVersion() >= 20); - assert(isABI && "Non-ABI compilation is not supported"); - if (!isABI) - return Chain; - std::vector<Type *> argTypes; std::vector<const Argument *> theArgs; for (const Argument &I : F->args()) { @@ -3310,11 +3295,6 @@ NVPTXTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, const Function &F = MF.getFunction(); Type *RetTy = MF.getFunction().getReturnType(); - bool isABI = (STI.getSmVersion() >= 20); - assert(isABI && "Non-ABI compilation is not supported"); - if (!isABI) - return Chain; - const DataLayout &DL = DAG.getDataLayout(); SmallVector<SDValue, 16> PromotedOutVals; SmallVector<EVT, 16> VTs; diff --git a/llvm/test/CodeGen/NVPTX/unrecognized-sm1x.ll b/llvm/test/CodeGen/NVPTX/unrecognized-sm1x.ll new file mode 100644 index 000000000000000..9a1dc122915dded --- /dev/null +++ b/llvm/test/CodeGen/NVPTX/unrecognized-sm1x.ll @@ -0,0 +1,9 @@ +; RUN: llc < %s -mtriple=nvptx -mcpu=sm_10 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM10 +; RUN: llc < %s -mtriple=nvptx -mcpu=sm_11 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM11 +; RUN: llc < %s -mtriple=nvptx -mcpu=sm_12 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM12 +; RUN: llc < %s -mtriple=nvptx -mcpu=sm_13 -debug-only=nvptx-subtarget -o /dev/null 2>&1 | FileCheck %s --check-prefix=SM13 + +; SM10: 'sm_10' is not a recognized processor for this target (ignoring processor) +; SM11: 'sm_11' is not a recognized processor for this target (ignoring processor) +; SM12: 'sm_12' is not a recognized processor for this target (ignoring processor) +; SM13: 'sm_13' is not a recognized processor for this target (ignoring processor) |
Artem-B left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
jholewinski left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@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`.
@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 forsm_1x.