r368128 - [RISCV] Remove duplicated logic when determining the target ABI
Roger Ferrer Ibanez via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 00:08:01 PDT 2019
Author: rogfer01
Date: Wed Aug 7 00:08:00 2019
New Revision: 368128
URL: http://llvm.org/viewvc/llvm-project?rev=368128&view=rev
Log:
[RISCV] Remove duplicated logic when determining the target ABI
We were calculating twice ilp32/lp64. Do this in one place instead.
Differential Revision: https://reviews.llvm.org/D48357
Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=368128&r1=368127&r2=368128&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Aug 7 00:08:00 2019
@@ -372,8 +372,14 @@ void riscv::getRISCVTargetFeatures(const
}
StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
- if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
+ assert((Triple.getArch() == llvm::Triple::riscv32 ||
+ Triple.getArch() == llvm::Triple::riscv64) &&
+ "Unexpected triple");
+
+ if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
return A->getValue();
+ // FIXME: currently defaults to the soft-float ABIs. Will need to be
+ // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate.
return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64";
}
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=368128&r1=368127&r2=368128&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Aug 7 00:08:00 2019
@@ -1848,21 +1848,11 @@ void Clang::AddPPCTargetArgs(const ArgLi
void Clang::AddRISCVTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
- // FIXME: currently defaults to the soft-float ABIs. Will need to be
- // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate.
- const char *ABIName = nullptr;
const llvm::Triple &Triple = getToolChain().getTriple();
- if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
- ABIName = A->getValue();
- else if (Triple.getArch() == llvm::Triple::riscv32)
- ABIName = "ilp32";
- else if (Triple.getArch() == llvm::Triple::riscv64)
- ABIName = "lp64";
- else
- llvm_unreachable("Unexpected triple!");
+ StringRef ABIName = riscv::getRISCVABI(Args, Triple);
CmdArgs.push_back("-target-abi");
- CmdArgs.push_back(ABIName);
+ CmdArgs.push_back(ABIName.data());
}
void Clang::AddSparcTargetArgs(const ArgList &Args,
More information about the cfe-commits
mailing list