Skip to content

Commit 31c9ab2

Browse files
mshockwavegithub-actions[bot]
authored andcommitted
Automerge: [clang][Driver][RISCV] Rename getRISCFeaturesFromMcpu. NFCI (#162545)
This function, which has a typo in the name btw, is no longer doing what it was created to do: instead of deducting non-extension target features from `-mcpu` -- a task that was (more or less) subsumed by `riscv::getRISCVTargetFeatures` -- it is only checking if the `-mcpu` value is valid or not now. Therefore, this patch renames it into `isValidRISCVCPU` and exits early if it's not. NFCI.
2 parents 8cf76b1 + 86ad98c commit 31c9ab2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ static bool getArchFeatures(const Driver &D, StringRef Arch,
4949
return true;
5050
}
5151

52-
// Get features except standard extension feature
53-
static void getRISCFeaturesFromMcpu(const Driver &D, const Arg *A,
54-
const llvm::Triple &Triple,
55-
StringRef Mcpu,
56-
std::vector<StringRef> &Features) {
52+
static bool isValidRISCVCPU(const Driver &D, const Arg *A,
53+
const llvm::Triple &Triple, StringRef Mcpu) {
5754
bool Is64Bit = Triple.isRISCV64();
5855
if (!llvm::RISCV::parseCPU(Mcpu, Is64Bit)) {
5956
// Try inverting Is64Bit in case the CPU is valid, but for the wrong target.
@@ -63,7 +60,9 @@ static void getRISCFeaturesFromMcpu(const Driver &D, const Arg *A,
6360
else
6461
D.Diag(clang::diag::err_drv_unsupported_option_argument)
6562
<< A->getSpelling() << Mcpu;
63+
return false;
6664
}
65+
return true;
6766
}
6867

6968
void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
@@ -84,7 +83,8 @@ void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
8483
if (CPU == "native")
8584
CPU = llvm::sys::getHostCPUName();
8685

87-
getRISCFeaturesFromMcpu(D, A, Triple, CPU, Features);
86+
if (!isValidRISCVCPU(D, A, Triple, CPU))
87+
return;
8888

8989
if (llvm::RISCV::hasFastScalarUnalignedAccess(CPU))
9090
CPUFastScalarUnaligned = true;

0 commit comments

Comments
 (0)