Merge pull request #162 from wenhu1024/feat/target-cpu

[ventus][NFC] Pick VentusRISCVABI or RISCVABI conditionally according…
This commit is contained in:
ZiliangZhang 2025-02-11 09:47:28 +08:00 committed by GitHub
commit c8e4d01ce3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View File

@ -11502,11 +11502,14 @@ ABIArgInfo VentusRISCVABIInfo::classifyArgumentType(QualType Ty,
namespace {
class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
public:
// TODO: Pick VentusRISCVABI or RISCVABI conditionally according to
// Pick VentusRISCVABI or RISCVABI conditionally according to
// target CPU.
RISCVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, unsigned XLen,
unsigned FLen)
: TargetCodeGenInfo(std::make_unique<VentusRISCVABIInfo>(CGT, XLen)) {}
CodeGen::CodeGenTypes &CGT;
RISCVTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT, unsigned XLen, unsigned FLen)
: TargetCodeGenInfo(CGT.getTarget().getTargetOpts().CPU == "ventus-gpgpu"
? std::unique_ptr<ABIInfo>(std::make_unique<VentusRISCVABIInfo>(CGT, XLen))
: std::unique_ptr<ABIInfo>(std::make_unique<RISCVABIInfo>(CGT, XLen, FLen))),
CGT(CGT) {}
void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override {
@ -11530,8 +11533,10 @@ public:
}
unsigned getOpenCLKernelCallingConv() const override;
};
unsigned RISCVTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
return llvm::CallingConv::VENTUS_KERNEL;
unsigned RISCVTargetCodeGenInfo::getOpenCLKernelCallingConv() const {
if (CGT.getTarget().getTargetOpts().CPU == "ventus-gpgpu")
return llvm::CallingConv::VENTUS_KERNEL;
return TargetCodeGenInfo::getOpenCLKernelCallingConv();
}
} // namespace

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -no-opaque-pointers -triple riscv32-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -no-opaque-pointers -triple riscv32-unknown-unknown -target-cpu ventus-gpgpu -S -emit-llvm -o - %s | FileCheck %s
kernel void test_kernel(global int *out)
{