Skip to content
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

[CIR][CUDA][NFC] Add NVPTX64 ABI info skeleton #1303

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions clang/lib/CIR/CodeGen/TargetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,30 @@ class SPIRVTargetCIRGenInfo : public CommonSPIRTargetCIRGenInfo {

} // namespace

//===----------------------------------------------------------------------===//
// NVPTX ABI Implementation
//===----------------------------------------------------------------------===//

namespace {

class NVPTXABIInfo : public ABIInfo {
public:
NVPTXABIInfo(CIRGenTypes &cgt) : ABIInfo(cgt) {}

cir::ABIArgInfo classifyReturnType(QualType retTy) const;
cir::ABIArgInfo classifyArgumentType(QualType ty) const;

void computeInfo(CIRGenFunctionInfo &fnInfo) const override;
};

class NVPTXTargetCIRGenInfo : public TargetCIRGenInfo {
public:
NVPTXTargetCIRGenInfo(CIRGenTypes &cgt)
: TargetCIRGenInfo(std::make_unique<NVPTXABIInfo>(cgt)) {}
};

} // namespace

// TODO(cir): remove the attribute once this gets used.
LLVM_ATTRIBUTE_UNUSED
static bool classifyReturnType(const CIRGenCXXABI &CXXABI,
Expand Down Expand Up @@ -443,6 +467,34 @@ cir::ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty,
return cir::ABIArgInfo::getDirect(ResType);
}

// Skeleton only. Implement when used in TargetLower stage.
cir::ABIArgInfo NVPTXABIInfo::classifyReturnType(QualType retTy) const {
llvm_unreachable("not yet implemented");
}

cir::ABIArgInfo NVPTXABIInfo::classifyArgumentType(QualType ty) const {
llvm_unreachable("not yet implemented");
}

void NVPTXABIInfo::computeInfo(CIRGenFunctionInfo &fnInfo) const {
// Top level CIR has unlimited arguments and return types. Lowering for ABI
// specific concerns should happen during a lowering phase. Assume everything
// is direct for now.
for (CIRGenFunctionInfo::arg_iterator it = fnInfo.arg_begin(),
ie = fnInfo.arg_end();
it != ie; ++it) {
if (testIfIsVoidTy(it->type))
it->info = cir::ABIArgInfo::getIgnore();
else
it->info = cir::ABIArgInfo::getDirect(CGT.convertType(it->type));
}
auto retTy = fnInfo.getReturnType();
if (testIfIsVoidTy(retTy))
fnInfo.getReturnInfo() = cir::ABIArgInfo::getIgnore();
else
fnInfo.getReturnInfo() = cir::ABIArgInfo::getDirect(CGT.convertType(retTy));
}

ABIInfo::~ABIInfo() {}

bool ABIInfo::isPromotableIntegerTypeForABI(QualType Ty) const {
Expand Down Expand Up @@ -634,5 +686,9 @@ const TargetCIRGenInfo &CIRGenModule::getTargetCIRGenInfo() {
case llvm::Triple::spirv64: {
return SetCIRGenInfo(new SPIRVTargetCIRGenInfo(genTypes));
}

case llvm::Triple::nvptx64: {
return SetCIRGenInfo(new NVPTXTargetCIRGenInfo(genTypes));
}
}
}