[cfe-commits] r147847 - /cfe/trunk/lib/Basic/Targets.cpp
Benjamin Kramer
benny.kra at googlemail.com
Tue Jan 10 03:50:09 PST 2012
Author: d0k
Date: Tue Jan 10 05:50:09 2012
New Revision: 147847
URL: http://llvm.org/viewvc/llvm-project?rev=147847&view=rev
Log:
Factor the repetitive cpu macro definition into a helper function.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=147847&r1=147846&r2=147847&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jan 10 05:50:09 2012
@@ -54,6 +54,14 @@
Builder.defineMacro("__" + MacroName + "__");
}
+static void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName,
+ bool Tuning = true) {
+ Builder.defineMacro("__" + CPUName);
+ Builder.defineMacro("__" + CPUName + "__");
+ if (Tuning)
+ Builder.defineMacro("__tune_" + CPUName + "__");
+}
+
//===----------------------------------------------------------------------===//
// Defines specific to certain operating systems.
//===----------------------------------------------------------------------===//
@@ -1850,9 +1858,7 @@
case CK_WinChipC6:
case CK_WinChip2:
case CK_C3:
- Builder.defineMacro("__i486");
- Builder.defineMacro("__i486__");
- Builder.defineMacro("__tune_i486__");
+ defineCPUMacros(Builder, "i486");
break;
case CK_PentiumMMX:
Builder.defineMacro("__pentium_mmx__");
@@ -1860,12 +1866,8 @@
// Fallthrough
case CK_i586:
case CK_Pentium:
- Builder.defineMacro("__i586");
- Builder.defineMacro("__i586__");
- Builder.defineMacro("__tune_i586__");
- Builder.defineMacro("__pentium");
- Builder.defineMacro("__pentium__");
- Builder.defineMacro("__tune_pentium__");
+ defineCPUMacros(Builder, "i586");
+ defineCPUMacros(Builder, "pentium");
break;
case CK_Pentium3:
case CK_Pentium3M:
@@ -1889,35 +1891,25 @@
break;
case CK_Pentium4:
case CK_Pentium4M:
- Builder.defineMacro("__pentium4");
- Builder.defineMacro("__pentium4__");
- Builder.defineMacro("__tune_pentium4__");
+ defineCPUMacros(Builder, "pentium4");
break;
case CK_Yonah:
case CK_Prescott:
case CK_Nocona:
- Builder.defineMacro("__nocona");
- Builder.defineMacro("__nocona__");
- Builder.defineMacro("__tune_nocona__");
+ defineCPUMacros(Builder, "nocona");
break;
case CK_Core2:
case CK_Penryn:
- Builder.defineMacro("__core2");
- Builder.defineMacro("__core2__");
- Builder.defineMacro("__tune_core2__");
+ defineCPUMacros(Builder, "core2");
break;
case CK_Atom:
- Builder.defineMacro("__atom");
- Builder.defineMacro("__atom__");
- Builder.defineMacro("__tune_atom__");
+ defineCPUMacros(Builder, "atom");
break;
case CK_Corei7:
case CK_Corei7AVX:
case CK_CoreAVXi:
case CK_CoreAVX2:
- Builder.defineMacro("__corei7");
- Builder.defineMacro("__corei7__");
- Builder.defineMacro("__tune_corei7__");
+ defineCPUMacros(Builder, "corei7");
break;
case CK_K6_2:
Builder.defineMacro("__k6_2__");
@@ -1933,18 +1925,14 @@
}
// Fallthrough
case CK_K6:
- Builder.defineMacro("__k6");
- Builder.defineMacro("__k6__");
- Builder.defineMacro("__tune_k6__");
+ defineCPUMacros(Builder, "k6");
break;
case CK_Athlon:
case CK_AthlonThunderbird:
case CK_Athlon4:
case CK_AthlonXP:
case CK_AthlonMP:
- Builder.defineMacro("__athlon");
- Builder.defineMacro("__athlon__");
- Builder.defineMacro("__tune_athlon__");
+ defineCPUMacros(Builder, "athlon");
if (SSELevel != NoSSE) {
Builder.defineMacro("__athlon_sse__");
Builder.defineMacro("__tune_athlon_sse__");
@@ -1958,29 +1946,19 @@
case CK_Athlon64:
case CK_Athlon64SSE3:
case CK_AthlonFX:
- Builder.defineMacro("__k8");
- Builder.defineMacro("__k8__");
- Builder.defineMacro("__tune_k8__");
+ defineCPUMacros(Builder, "k8");
break;
case CK_AMDFAM10:
- Builder.defineMacro("__amdfam10");
- Builder.defineMacro("__amdfam10__");
- Builder.defineMacro("__tune_amdfam10__");
+ defineCPUMacros(Builder, "amdfam10");
break;
case CK_BDVER1:
- Builder.defineMacro("__bdver1");
- Builder.defineMacro("__bdver1__");
- Builder.defineMacro("__tune__bdver1__");
+ defineCPUMacros(Builder, "bdver1");
break;
case CK_BDVER2:
- Builder.defineMacro("__bdver2");
- Builder.defineMacro("__bdver2__");
- Builder.defineMacro("__tune__bdver2__");
+ defineCPUMacros(Builder, "bdver2");
break;
case CK_Geode:
- Builder.defineMacro("__geode");
- Builder.defineMacro("__geode__");
- Builder.defineMacro("__tune_geode__");
+ defineCPUMacros(Builder, "geode");
break;
}
More information about the cfe-commits
mailing list