[mips] Pass ABI name via -target-abi instead of target-features

Patch by Vladimir Medic

Reviewers: echristo, atanasyan, dsanders

Reviewed By: atanasyan, dsanders

Subscribers: llvm-commits, echristo, atanasyan

Differential Revision: http://reviews.llvm.org/D6091

llvm-svn: 227583
This commit is contained in:
Daniel Sanders 2015-01-30 17:35:23 +00:00
parent e4ca47875f
commit 7f933f4c5e
4 changed files with 30 additions and 30 deletions

View File

@ -5696,14 +5696,6 @@ public:
}
const std::string& getCPU() const { return CPU; }
void getDefaultFeatures(llvm::StringMap<bool> &Features) const override {
// The backend enables certain ABI's by default according to the
// architecture.
// Disable both possible defaults so that we don't end up with multiple
// ABI's selected and trigger an assertion.
Features["o32"] = false;
Features["n64"] = false;
Features[ABI] = true;
if (CPU == "octeon")
Features["mips64r2"] = Features["cnmips"] = true;
else

View File

@ -1095,17 +1095,6 @@ static void getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
ABIName = getGnuCompatibleMipsABIName(ABIName);
// Always override the backend's default ABI.
std::string ABIFeature = llvm::StringSwitch<StringRef>(ABIName)
.Case("32", "+o32")
.Case("n32", "+n32")
.Case("64", "+n64")
.Case("eabi", "+eabi")
.Default(("+" + ABIName).str());
Features.push_back("-o32");
Features.push_back("-n64");
Features.push_back(Args.MakeArgString(ABIFeature));
AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
options::OPT_mabicalls, "noabicalls");
@ -4874,6 +4863,17 @@ visualstudio::Compile *Clang::getCLFallback() const {
return CLFallback.get();
}
void ClangAs::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
StringRef CPUName;
StringRef ABIName;
const llvm::Triple &Triple = getToolChain().getTriple();
mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
CmdArgs.push_back("-target-abi");
CmdArgs.push_back(ABIName.data());
}
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
@ -4981,6 +4981,19 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
// FIXME: Add -static support, once we have it.
// Add target specific flags.
switch(getToolChain().getArch()) {
default:
break;
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
AddMIPSTargetArgs(Args, CmdArgs);
break;
}
// Consume all the warning flags. Usually this would be handled more
// gracefully by -cc1 (warning about unknown warning flags, etc) but -cc1as
// doesn't handle that so rather than warning about unused flags that are

View File

@ -109,7 +109,8 @@ using llvm::opt::ArgStringList;
ClangAs(const ToolChain &TC) : Tool("clang::as",
"clang integrated assembler", TC,
RF_Full) {}
void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
bool hasGoodDiagnostics() const override { return true; }
bool hasIntegratedAssembler() const override { return false; }
bool hasIntegratedCPP() const override { return false; }

View File

@ -5,24 +5,19 @@
// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=o32 2>&1 | \
// RUN: FileCheck -check-prefix=ABI-O32 %s
// ABI-O32: -cc1as
// ABI-O32: "-target-feature" "-n64"
// ABI-O32: "-target-feature" "+o32"
// ABI-O32: "-target-abi" "o32"
// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=eabi 2>&1 | \
// RUN: FileCheck -check-prefix=ABI-EABI32 %s
// ABI-EABI32: -cc1as
// ABI-EABI32: "-target-feature" "-o32"
// ABI-EABI32: "-target-feature" "-n64"
// ABI-EABI32: "-target-feature" "+eabi"
// ABI-EABI32: "-target-abi" "eabi"
// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n32 2>&1 | \
// RUN: FileCheck -check-prefix=ABI-N32 %s
// RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mabi=n32 2>&1 | \
// RUN: FileCheck -check-prefix=ABI-N32 %s
// ABI-N32: -cc1as
// ABI-N32: "-target-feature" "-o32"
// ABI-N32: "-target-feature" "-n64"
// ABI-N32: "-target-feature" "+n32"
// ABI-N32: "-target-abi" "n32"
// FIXME: We should also test '-target mips-linux-gnu -mips64' defaults to the
// default 64-bit ABI (N64 but GCC uses N32). It currently selects O32
@ -39,8 +34,7 @@
// RUN: %clang -target mips64-linux-gnu -### -fintegrated-as -c %s -mips64 -mabi=n64 2>&1 | \
// RUN: FileCheck -check-prefix=ABI-N64 %s
// ABI-N64: -cc1as
// ABI-N64: "-target-feature" "-o32"
// ABI-N64: "-target-feature" "+n64"
// ABI-N64: "-target-abi" "n64"
// RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -msoft-float 2>&1 | \
// RUN: FileCheck -check-prefix=SOFTFLOAT %s