Removing spurious whitespace & adding soft-float-abi.
Hi mcrosier, bogden, joey,
http://llvm-reviews.chandlerc.com/D2817
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2817?vs=7163&id=7173#toc
Files:
include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/Tools.cpp
test/Driver/arm-mfpu.c
Index: include/clang/Basic/DiagnosticDriverKinds.td
===================================================================
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -156,6 +156,10 @@
InGroup<DiagGroup<"missing-sysroot">>;
def warn_missing_debug_compression : Warning<"DWARF compression is not implemented">,
InGroup<DiagGroup<"missing-debug-compression">>;
+def warn_duplicated_fpu_flag : Warning<"Duplicated -mfpu and -Wa,-mfpu options; using -mfpu's value">,
+ InGroup<GccCompat>;
+def warn_inconsistent_fpu_flag : Warning<"Inconsistent -mfpu flag with target triple">,
+ InGroup<GccCompat>;
def note_drv_command_failed_diag_msg : Note<
"diagnostic msg: %0">;
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -546,16 +546,29 @@
// frontend target.
static void getARMFPUFeatures(const Driver &D, const Arg *A,
const ArgList &Args,
- std::vector<const char *> &Features) {
+ std::vector<const char *> &Features,
+ const StringRef &FloatABI) {
StringRef FPU = A->getValue();
+ // Parse out softvfp before, if any
+ if (FPU.find("softvfp") != StringRef::npos) {
+ if (FloatABI == "hard")
+ D.Diag(diag::warn_inconsistent_fpu_flag);
+ else
+ Features.push_back("+soft-float-abi");
+ // If in format -Wa,-mfpu=softvfp+something, drops -Wa,-mfpu=
+ FPU = FPU.drop_front(FPU.find("=") + 1);
+ // If in format softvfp+something, drops softvfp+
+ FPU = FPU.drop_front(FPU.find("+") + 1);
+ }
+
// Set the target features based on the FPU.
if (FPU == "fpa" || FPU == "fpe2" || FPU == "fpe3" || FPU == "maverick") {
// Disable any default FPU support.
Features.push_back("-vfp2");
Features.push_back("-vfp3");
Features.push_back("-neon");
- } else if (FPU == "vfp") {
+ } else if (FPU == "vfp" || FPU == "vfpv2") {
Features.push_back("+vfp2");
Features.push_back("-neon");
} else if (FPU == "vfp3-d16" || FPU == "vfpv3-d16") {
@@ -586,7 +599,7 @@
Features.push_back("+crypto");
} else if (FPU == "neon") {
Features.push_back("+neon");
- } else if (FPU == "none") {
+ } else if (FPU == "none" || FPU == "softvfp") {
Features.push_back("-vfp2");
Features.push_back("-vfp3");
Features.push_back("-vfp4");
@@ -686,7 +699,7 @@
static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
std::vector<const char *> &Features,
- bool ForAS) {
+ bool ForAS, bool IntegratedAS) {
StringRef FloatABI = tools::arm::getARMFloatABI(D, Args, Triple);
if (!ForAS) {
// FIXME: Note, this is a hack, the LLVM backend doesn't actually use these
@@ -710,9 +723,34 @@
Features.push_back("+soft-float-abi");
}
+ // -Wa,-mfpu=something should split into target-features for integrated-as
+ // or just pass directly to external assembler.
+ Arg* AsFPUArg = 0;
+ if (IntegratedAS) {
+ for (arg_iterator it = Args.filtered_begin(options::OPT_Wa_COMMA,
+ options::OPT_Xassembler),
+ ie = Args.filtered_end(); it != ie; ++it) {
+ Arg *A = *it;
+ StringRef Value = A->getValue();
+ if (Value.startswith("-mfpu=")) {
+ AsFPUArg = A;
+ A->claim();
+ break;
+ }
+ }
+ }
+
// Honor -mfpu=.
- if (const Arg *A = Args.getLastArg(options::OPT_mfpu_EQ))
- getARMFPUFeatures(D, A, Args, Features);
+ Arg* FPUArg = Args.getLastArg(options::OPT_mfpu_EQ);
+ if (AsFPUArg && FPUArg) {
+ D.Diag(diag::warn_duplicated_fpu_flag);
+ getARMFPUFeatures(D, (const Arg*)FPUArg, Args, Features, FloatABI);
+ } else if (FPUArg)
+ getARMFPUFeatures(D, (const Arg*)FPUArg, Args, Features, FloatABI);
+ else if (AsFPUArg)
+ getARMFPUFeatures(D, (const Arg*)AsFPUArg, Args, Features, FloatABI);
+
+ // Honor -mhwdiv=.
if (const Arg *A = Args.getLastArg(options::OPT_mhwdiv_EQ))
getARMHWDivFeatures(D, A, Args, Features);
@@ -1453,7 +1491,7 @@
static void getTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args, ArgStringList &CmdArgs,
- bool ForAS) {
+ bool ForAS, bool IntegratedAS) {
std::vector<const char *> Features;
switch (Triple.getArch()) {
default:
@@ -1467,7 +1505,7 @@
case llvm::Triple::arm:
case llvm::Triple::thumb:
- getARMTargetFeatures(D, Triple, Args, Features, ForAS);
+ getARMTargetFeatures(D, Triple, Args, Features, ForAS, IntegratedAS);
break;
case llvm::Triple::ppc:
@@ -1727,6 +1765,8 @@
// Do nothing, this is the default and we don't support anything else.
} else if (Value == "-L") {
CmdArgs.push_back("-msave-temp-labels");
+ } else if (Value.startswith("-mfpu=")) {
+ // Ignore -Wa,-mfpu=something, targets should set target-features
} else if (Value == "--fatal-warnings") {
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-fatal-assembler-warnings");
@@ -2575,7 +2615,12 @@
}
// Add the target features
- getTargetFeatures(D, ETriple, Args, CmdArgs, false);
+ bool IntegratedAS = getToolChain().useIntegratedAs();
+ if (!IntegratedAS)
+ Args.AddAllArgs(CmdArgs, options::OPT_Wa_COMMA,
+ options::OPT_Xassembler);
+
+ getTargetFeatures(D, ETriple, Args, CmdArgs, false, IntegratedAS);
// Add target specific flags.
switch(getToolChain().getArch()) {
@@ -4152,7 +4197,8 @@
// Add the target features
const Driver &D = getToolChain().getDriver();
- getTargetFeatures(D, Triple, Args, CmdArgs, true);
+ bool IntegratedAS = getToolChain().useIntegratedAs();
+ getTargetFeatures(D, Triple, Args, CmdArgs, true, IntegratedAS);
// Ignore explicit -force_cpusubtype_ALL option.
(void) Args.hasArg(options::OPT_force__cpusubtype__ALL);
Index: test/Driver/arm-mfpu.c
===================================================================
--- test/Driver/arm-mfpu.c
+++ test/Driver/arm-mfpu.c
@@ -102,10 +102,70 @@
// CHECK-NO-FP: "-target-feature" "-crypto"
// CHECK-NO-FP: "-target-feature" "-neon"
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT %s
+// CHECK-SOFT: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT: "-target-feature" "-vfp2"
+// CHECK-SOFT: "-target-feature" "-vfp3"
+// CHECK-SOFT: "-target-feature" "-vfp4"
+// CHECK-SOFT: "-target-feature" "-fp-armv8"
+// CHECK-SOFT: "-target-feature" "-crypto"
+// CHECK-SOFT: "-target-feature" "-neon"
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+vfp %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-V2 %s
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+vfpv2 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-V2 %s
+// CHECK-SOFT-V2: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT-V2: "-target-feature" "+vfp2"
+// CHECK-SOFT-V2: "-target-feature" "-neon"
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+vfpv3 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-V3 %s
+// CHECK-SOFT-V3: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT-V3: "-target-feature" "+vfp3"
+// CHECK-SOFT-V3: "-target-feature" "-neon"
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+vfpv3-d16 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-V316 %s
+// CHECK-SOFT-V316: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT-V316: "-target-feature" "+vfp3"
+// CHECK-SOFT-V316: "-target-feature" "+d16"
+// CHECK-SOFT-V316: "-target-feature" "-neon"
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+vfpv4 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-V4 %s
+// CHECK-SOFT-V4: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT-V4: "-target-feature" "+vfp4"
+// CHECK-SOFT-V4: "-target-feature" "-neon"
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+vfpv4-d16 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-V416 %s
+// CHECK-SOFT-V416: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT-V416: "-target-feature" "+vfp4"
+// CHECK-SOFT-V416: "-target-feature" "+d16"
+// CHECK-SOFT-V416: "-target-feature" "-neon"
+
+// RUN: %clang -target armv7-linux-gnueabi -mfpu=softvfp+neon %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-NEON %s
+// CHECK-SOFT-NEON: "-target-feature" "+soft-float-abi"
+// CHECK-SOFT-NEON: "-target-feature" "+neon"
+
// RUN: %clang -target arm-linux-gnueabihf %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-HF %s
// CHECK-HF: "-target-cpu" "arm1136jf-s"
// RUN: %clang -target armv7-apple-darwin -x assembler %s -### -c 2>&1 \
// RUN: | FileCheck --check-prefix=ASM %s
// ASM-NOT: -target-feature
+
+// RUN: %clang -integrated-as -target armv7-linux-gnueabi -Wa,-mfpu=softvfp+neon %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-WA-IAS-NEON %s
+// CHECK-SOFT-WA-IAS-NEON: "-target-feature" "+neon"
+
+// RUN: %clang -no-integrated-as -target armv7-linux-gnueabi -Wa,-mfpu=softvfp+neon %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SOFT-WA-NEON %s
+// CHECK-SOFT-WA-NEON: "-Wa,-mfpu=softvfp+neon"
+// CHECK-SOFT-WA-NEON: bin/as"
+// CHECK-SOFT-WA-NEON: "-mfpu=softvfp+neon"
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits