]> granicus.if.org Git - clang/commitdiff
Simplify the control flow for predefined macro selection by using
authorChandler Carruth <chandlerc@gmail.com>
Wed, 28 Sep 2011 09:45:05 +0000 (09:45 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 28 Sep 2011 09:45:05 +0000 (09:45 +0000)
fallthrough now that we're working with a switch. Also remove a dubious
"feature" regarding k6 processors and 3dnow and leave a fixme... Not
that anyone is likely to care about correct tuning for k6 processors
with and w/o 3dnow...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140687 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp

index 26bfb5eb4a2a62f1d73c622f2ee7e51c704aea2c..b8a242bd0dba09c78c75077b4b62c350c52de28b 100644 (file)
@@ -1662,42 +1662,38 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("__i486__");
     Builder.defineMacro("__tune_i486__");
     break;
+  case CK_PentiumMMX:
+    Builder.defineMacro("__pentium_mmx__");
+    Builder.defineMacro("__tune_pentium_mmx__");
+    // Fallthrough
   case CK_i586:
   case CK_Pentium:
-  case CK_PentiumMMX:
     Builder.defineMacro("__i586");
     Builder.defineMacro("__i586__");
     Builder.defineMacro("__tune_i586__");
     Builder.defineMacro("__pentium");
     Builder.defineMacro("__pentium__");
     Builder.defineMacro("__tune_pentium__");
-    if (CPU == CK_PentiumMMX) {
-      Builder.defineMacro("__pentium_mmx__");
-      Builder.defineMacro("__tune_pentium_mmx__");
-    }
     break;
-  case CK_i686:
-  case CK_PentiumPro:
-  case CK_Pentium2:
   case CK_Pentium3:
   case CK_Pentium3M:
   case CK_PentiumM:
+    Builder.defineMacro("__tune_pentium3__");
+    // Fallthrough
+  case CK_Pentium2:
   case CK_C3_2:
+    Builder.defineMacro("__tune_pentium2__");
+    // Fallthrough
+  case CK_PentiumPro:
+    Builder.defineMacro("__tune_i686__");
+    Builder.defineMacro("__tune_pentiumpro__");
+    // Fallthrough
+  case CK_i686:
     Builder.defineMacro("__i686");
     Builder.defineMacro("__i686__");
     // Strangely, __tune_i686__ isn't defined by GCC when CPU == i686.
     Builder.defineMacro("__pentiumpro");
     Builder.defineMacro("__pentiumpro__");
-    if (CPU != CK_i686) {
-      Builder.defineMacro("__tune_i686__");
-      Builder.defineMacro("__tune_pentiumpro__");
-      if (CPU == CK_Pentium2 || CPU == CK_C3_2) {
-        Builder.defineMacro("__tune_pentium2__");
-      } else if (CPU == CK_Pentium3) {
-        Builder.defineMacro("__tune_pentium2__");
-        Builder.defineMacro("__tune_pentium3__");
-      }
-    }
     break;
   case CK_Pentium4:
   case CK_Pentium4M:
@@ -1730,20 +1726,23 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
     Builder.defineMacro("__corei7__");
     Builder.defineMacro("__tune_corei7__");
     break;
-  case CK_K6:
   case CK_K6_2:
+    Builder.defineMacro("__k6_2__");
+    Builder.defineMacro("__tune_k6_2__");
+    // Fallthrough
   case CK_K6_3:
-    Builder.defineMacro("__k6");
-    Builder.defineMacro("__k6__");
-    Builder.defineMacro("__tune_k6__");
-    if (CPU == CK_K6_2) {
-      Builder.defineMacro("__k6_2__");
-      Builder.defineMacro("__tune_k6_2__");
-      break;
-    } else if (CPU == CK_K6_3 || MMX3DNowLevel == AMD3DNow) {
+    if (CPU != CK_K6_2) {  // In case of fallthrough
+      // FIXME: GCC may be enabling these in cases where some other k6
+      // architecture is specified but -m3dnow is explicitly provided. The
+      // exact semantics need to be determined and emulated here.
       Builder.defineMacro("__k6_3__");
       Builder.defineMacro("__tune_k6_3__");
     }
+    // Fallthrough
+  case CK_K6:
+    Builder.defineMacro("__k6");
+    Builder.defineMacro("__k6__");
+    Builder.defineMacro("__tune_k6__");
     break;
   case CK_Athlon:
   case CK_AthlonThunderbird: