[Mips] Finetuning MIPS32 Android default variants

MIPS32 Android defaults to FPXX ("-fpxx").
MIPS32R6 Android defaults to FP64A ("-mfp64 -mno-odd-spreg").

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

llvm-svn: 269914
This commit is contained in:
Petar Jovanovic 2016-05-18 12:46:06 +00:00
parent 016e6c4354
commit 3ca1622a90
3 changed files with 30 additions and 3 deletions

View File

@ -1359,8 +1359,9 @@ static void getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
AddTargetFeature(Args, Features, options::OPT_mmsa, options::OPT_mno_msa,
"msa");
// Add the last -mfp32/-mfpxx/-mfp64 or if none are given and the ABI is O32
// pass -mfpxx
// Add the last -mfp32/-mfpxx/-mfp64, if none are given and the ABI is O32
// pass -mfpxx, or if none are given and fp64a is default, pass fp64 and
// nooddspreg.
if (Arg *A = Args.getLastArg(options::OPT_mfp32, options::OPT_mfpxx,
options::OPT_mfp64)) {
if (A->getOption().matches(options::OPT_mfp32))
@ -1373,6 +1374,9 @@ static void getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
} else if (mips::shouldUseFPXX(Args, Triple, CPUName, ABIName, FloatABI)) {
Features.push_back(Args.MakeArgString("+fpxx"));
Features.push_back(Args.MakeArgString("+nooddspreg"));
} else if (mips::isFP64ADefault(Triple, CPUName)) {
Features.push_back(Args.MakeArgString("+fp64"));
Features.push_back(Args.MakeArgString("+nooddspreg"));
}
AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
@ -7039,10 +7043,21 @@ bool mips::isNaN2008(const ArgList &Args, const llvm::Triple &Triple) {
return false;
}
bool mips::isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName) {
if (!Triple.isAndroid())
return false;
// Android MIPS32R6 defaults to FP64A.
return llvm::StringSwitch<bool>(CPUName)
.Case("mips32r6", true)
.Default(false);
}
bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
StringRef ABIName, mips::FloatABI FloatABI) {
if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
Triple.getVendor() != llvm::Triple::MipsTechnologies)
Triple.getVendor() != llvm::Triple::MipsTechnologies &&
!Triple.isAndroid())
return false;
if (ABIName != "32")

View File

@ -299,6 +299,7 @@ std::string getMipsABILibSuffix(const llvm::opt::ArgList &Args,
bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value);
bool isUCLibc(const llvm::opt::ArgList &Args);
bool isNaN2008(const llvm::opt::ArgList &Args, const llvm::Triple &Triple);
bool isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName);
bool isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
StringRef ABIName, mips::FloatABI FloatABI);
bool shouldUseFPXX(const llvm::opt::ArgList &Args, const llvm::Triple &Triple,

View File

@ -246,8 +246,19 @@
// MIPSEL-ANDROID: clang
// MIPSEL-ANDROID: "-cc1"
// MIPSEL-ANDROID: "-target-cpu" "mips32"
// MIPSEL-ANDROID: "-target-feature" "+fpxx"
// MIPSEL-ANDROID: "-target-feature" "+nooddspreg"
// MIPSEL-ANDROID: "-mfloat-abi" "hard"
// RUN: %clang -target mipsel-linux-android -### -S %s -mcpu=mips32r6 2>&1 | \
// RUN: FileCheck -check-prefix=MIPSEL-ANDROID-R6 %s
// MIPSEL-ANDROID-R6: clang
// MIPSEL-ANDROID-R6: "-cc1"
// MIPSEL-ANDROID-R6: "-target-cpu" "mips32r6"
// MIPSEL-ANDROID-R6: "-target-feature" "+fp64"
// MIPSEL-ANDROID-R6: "-target-feature" "+nooddspreg"
// MIPSEL-ANDROID-R6: "-mfloat-abi" "hard"
// RUN: %clang -target mips64-linux-gnu -### -S %s 2>&1 | \
// RUN: FileCheck -check-prefix=MIPS64 %s
// MIPS64: clang