Skip to content

[RISCV] Set Feature32Bit/Feature64Bit based on triple for -mcpu=help. #127031

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

Merged
merged 1 commit into from
Feb 13, 2025
Merged
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
17 changes: 16 additions & 1 deletion llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,22 @@ static MCSubtargetInfo *createRISCVMCSubtargetInfo(const Triple &TT,
if (CPU.empty() || CPU == "generic")
CPU = TT.isArch64Bit() ? "generic-rv64" : "generic-rv32";

return createRISCVMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
MCSubtargetInfo *X =
createRISCVMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);

// If the CPU is "help" fill in 64 or 32 bit feature so we can pass
// RISCVFeatures::validate.
// FIXME: Why does llvm-mc still expect a source file with -mcpu=help?
if (CPU == "help") {
llvm::FeatureBitset Features = X->getFeatureBits();
if (TT.isArch64Bit())
Features.set(RISCV::Feature64Bit);
else
Features.set(RISCV::Feature32Bit);
X->setFeatureBits(Features);
}

return X;
}

static MCInstPrinter *createRISCVMCInstPrinter(const Triple &T,
Expand Down