Factor the repetitive cpu macro definition into a helper function.

llvm-svn: 147847
This commit is contained in:
Benjamin Kramer 2012-01-10 11:50:09 +00:00
parent 077ae1d760
commit e3b442d20c
1 changed files with 23 additions and 45 deletions

View File

@ -54,6 +54,14 @@ static void DefineStd(MacroBuilder &Builder, StringRef MacroName,
Builder.defineMacro("__" + MacroName + "__"); 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. // Defines specific to certain operating systems.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -1850,9 +1858,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
case CK_WinChipC6: case CK_WinChipC6:
case CK_WinChip2: case CK_WinChip2:
case CK_C3: case CK_C3:
Builder.defineMacro("__i486"); defineCPUMacros(Builder, "i486");
Builder.defineMacro("__i486__");
Builder.defineMacro("__tune_i486__");
break; break;
case CK_PentiumMMX: case CK_PentiumMMX:
Builder.defineMacro("__pentium_mmx__"); Builder.defineMacro("__pentium_mmx__");
@ -1860,12 +1866,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
// Fallthrough // Fallthrough
case CK_i586: case CK_i586:
case CK_Pentium: case CK_Pentium:
Builder.defineMacro("__i586"); defineCPUMacros(Builder, "i586");
Builder.defineMacro("__i586__"); defineCPUMacros(Builder, "pentium");
Builder.defineMacro("__tune_i586__");
Builder.defineMacro("__pentium");
Builder.defineMacro("__pentium__");
Builder.defineMacro("__tune_pentium__");
break; break;
case CK_Pentium3: case CK_Pentium3:
case CK_Pentium3M: case CK_Pentium3M:
@ -1889,35 +1891,25 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
break; break;
case CK_Pentium4: case CK_Pentium4:
case CK_Pentium4M: case CK_Pentium4M:
Builder.defineMacro("__pentium4"); defineCPUMacros(Builder, "pentium4");
Builder.defineMacro("__pentium4__");
Builder.defineMacro("__tune_pentium4__");
break; break;
case CK_Yonah: case CK_Yonah:
case CK_Prescott: case CK_Prescott:
case CK_Nocona: case CK_Nocona:
Builder.defineMacro("__nocona"); defineCPUMacros(Builder, "nocona");
Builder.defineMacro("__nocona__");
Builder.defineMacro("__tune_nocona__");
break; break;
case CK_Core2: case CK_Core2:
case CK_Penryn: case CK_Penryn:
Builder.defineMacro("__core2"); defineCPUMacros(Builder, "core2");
Builder.defineMacro("__core2__");
Builder.defineMacro("__tune_core2__");
break; break;
case CK_Atom: case CK_Atom:
Builder.defineMacro("__atom"); defineCPUMacros(Builder, "atom");
Builder.defineMacro("__atom__");
Builder.defineMacro("__tune_atom__");
break; break;
case CK_Corei7: case CK_Corei7:
case CK_Corei7AVX: case CK_Corei7AVX:
case CK_CoreAVXi: case CK_CoreAVXi:
case CK_CoreAVX2: case CK_CoreAVX2:
Builder.defineMacro("__corei7"); defineCPUMacros(Builder, "corei7");
Builder.defineMacro("__corei7__");
Builder.defineMacro("__tune_corei7__");
break; break;
case CK_K6_2: case CK_K6_2:
Builder.defineMacro("__k6_2__"); Builder.defineMacro("__k6_2__");
@ -1933,18 +1925,14 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
} }
// Fallthrough // Fallthrough
case CK_K6: case CK_K6:
Builder.defineMacro("__k6"); defineCPUMacros(Builder, "k6");
Builder.defineMacro("__k6__");
Builder.defineMacro("__tune_k6__");
break; break;
case CK_Athlon: case CK_Athlon:
case CK_AthlonThunderbird: case CK_AthlonThunderbird:
case CK_Athlon4: case CK_Athlon4:
case CK_AthlonXP: case CK_AthlonXP:
case CK_AthlonMP: case CK_AthlonMP:
Builder.defineMacro("__athlon"); defineCPUMacros(Builder, "athlon");
Builder.defineMacro("__athlon__");
Builder.defineMacro("__tune_athlon__");
if (SSELevel != NoSSE) { if (SSELevel != NoSSE) {
Builder.defineMacro("__athlon_sse__"); Builder.defineMacro("__athlon_sse__");
Builder.defineMacro("__tune_athlon_sse__"); Builder.defineMacro("__tune_athlon_sse__");
@ -1958,29 +1946,19 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
case CK_Athlon64: case CK_Athlon64:
case CK_Athlon64SSE3: case CK_Athlon64SSE3:
case CK_AthlonFX: case CK_AthlonFX:
Builder.defineMacro("__k8"); defineCPUMacros(Builder, "k8");
Builder.defineMacro("__k8__");
Builder.defineMacro("__tune_k8__");
break; break;
case CK_AMDFAM10: case CK_AMDFAM10:
Builder.defineMacro("__amdfam10"); defineCPUMacros(Builder, "amdfam10");
Builder.defineMacro("__amdfam10__");
Builder.defineMacro("__tune_amdfam10__");
break; break;
case CK_BDVER1: case CK_BDVER1:
Builder.defineMacro("__bdver1"); defineCPUMacros(Builder, "bdver1");
Builder.defineMacro("__bdver1__");
Builder.defineMacro("__tune__bdver1__");
break; break;
case CK_BDVER2: case CK_BDVER2:
Builder.defineMacro("__bdver2"); defineCPUMacros(Builder, "bdver2");
Builder.defineMacro("__bdver2__");
Builder.defineMacro("__tune__bdver2__");
break; break;
case CK_Geode: case CK_Geode:
Builder.defineMacro("__geode"); defineCPUMacros(Builder, "geode");
Builder.defineMacro("__geode__");
Builder.defineMacro("__tune_geode__");
break; break;
} }