[Mips] Follow-up to r179481. Consider "single-float" as a separate
authorSimon Atanasyan <simon@atanasyan.com>
Sun, 14 Apr 2013 14:07:30 +0000 (14:07 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Sun, 14 Apr 2013 14:07:30 +0000 (14:07 +0000)
independent of float ABI feature in the MipsTargetInfoBase class.

llvm-svn: 179486

clang/lib/Basic/Targets.cpp
clang/test/Preprocessor/init.c

index 82ea656..9689193 100644 (file)
@@ -4405,8 +4405,9 @@ class MipsTargetInfoBase : public TargetInfo {
   static const Builtin::Info BuiltinInfo[];
   std::string CPU;
   bool IsMips16;
+  bool IsSingleFloat;
   enum MipsFloatABI {
-    HardFloat, SingleFloat, SoftFloat
+    HardFloat, SoftFloat
   } FloatABI;
   enum DspRevEnum {
     NoDSP, DSP1, DSP2
@@ -4422,6 +4423,7 @@ public:
     : TargetInfo(triple),
       CPU(CPUStr),
       IsMips16(false),
+      IsSingleFloat(false),
       FloatABI(HardFloat),
       DspRev(NoDSP),
       ABI(ABIStr)
@@ -4448,15 +4450,14 @@ public:
     case HardFloat:
       Builder.defineMacro("__mips_hard_float", Twine(1));
       break;
-    case SingleFloat:
-      Builder.defineMacro("__mips_hard_float", Twine(1));
-      Builder.defineMacro("__mips_single_float", Twine(1));
-      break;
     case SoftFloat:
       Builder.defineMacro("__mips_soft_float", Twine(1));
       break;
     }
 
+    if (IsSingleFloat)
+      Builder.defineMacro("__mips_single_float", Twine(1));
+
     if (IsMips16)
       Builder.defineMacro("__mips16", Twine(1));
 
@@ -4564,13 +4565,14 @@ public:
 
   virtual void HandleTargetFeatures(std::vector<std::string> &Features) {
     IsMips16 = false;
+    IsSingleFloat = false;
     FloatABI = HardFloat;
     DspRev = NoDSP;
 
     for (std::vector<std::string>::iterator it = Features.begin(),
          ie = Features.end(); it != ie; ++it) {
       if (*it == "+single-float")
-        FloatABI = SingleFloat;
+        IsSingleFloat = true;
       else if (*it == "+soft-float")
         FloatABI = SoftFloat;
       else if (*it == "+mips16")
index 90b8466..8ab1439 100644 (file)
 // MIPS-FABI-SINGLE:#define __mips_hard_float 1
 // MIPS-FABI-SINGLE:#define __mips_single_float 1
 //
+// RUN: %clang_cc1 -target-feature +soft-float -target-feature +single-float \
+// RUN:   -E -dM -ffreestanding -triple=mips-none-none < /dev/null \
+// RUN:   | FileCheck -check-prefix MIPS-FABI-SINGLE-SOFT %s
+// MIPS-FABI-SINGLE-SOFT:#define __mips_single_float 1
+// MIPS-FABI-SINGLE-SOFT:#define __mips_soft_float 1
+//
 // Check MIPS features macros
 //
 // RUN: %clang_cc1 -target-feature +mips16 \