Index: clang/lib/Basic/Targets/X86.cpp =================================================================== --- clang/lib/Basic/Targets/X86.cpp +++ clang/lib/Basic/Targets/X86.cpp @@ -423,6 +423,7 @@ defineCPUMacros(Builder, "pentiumpro"); break; case CK_Pentium4: + case CK_x86_32_sse2: defineCPUMacros(Builder, "pentium4"); break; case CK_Yonah: @@ -1252,6 +1253,7 @@ // Netburst case CK_Pentium4: + case CK_x86_32_sse2: case CK_Prescott: case CK_Nocona: // Atom Index: clang/lib/Driver/ToolChains/Arch/X86.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/X86.cpp +++ clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -44,7 +44,7 @@ CPU = llvm::StringSwitch(Arch) .Case("IA32", "i386") .Case("SSE", "pentium3") - .Case("SSE2", "pentium4") + .Case("SSE2", "x86-32-sse2") .Default(nullptr); } if (CPU == nullptr) { // 32-bit and 64-bit /arch: flags. @@ -101,8 +101,10 @@ case llvm::Triple::Haiku: return "i586"; default: - // Fallback to p4. - return "pentium4"; + // Fallback to generic 32-bit CPU with sse2. + // FIXME: If we supported mtune this should just be pentium4 with generic + // tuning. + return "x86-32-sse2"; } } Index: clang/test/Driver/nacl-direct.c =================================================================== --- clang/test/Driver/nacl-direct.c +++ clang/test/Driver/nacl-direct.c @@ -6,7 +6,7 @@ // RUN: | FileCheck --check-prefix=CHECK-I686 %s // CHECK-I686: {{.*}}clang{{.*}}" "-cc1" // CHECK-I686-NOT: "-fno-use-init-array" -// CHECK-I686: "-target-cpu" "pentium4" +// CHECK-I686: "-target-cpu" "x86-32-sse2" // CHECK-I686: "-resource-dir" "foo" // CHECK-I686: "-internal-isystem" "foo{{/|\\\\}}include" // CHECK-I686: "-internal-isystem" "{{.*}}{{/|\\\\}}..{{/|\\\\}}i686-nacl{{/|\\\\}}usr{{/|\\\\}}include" Index: clang/test/Driver/x86_features.c =================================================================== --- clang/test/Driver/x86_features.c +++ clang/test/Driver/x86_features.c @@ -1,5 +1,5 @@ // RUN: %clang -target i386-unknown-unknown -### -S %s -msse -msse4 -mno-sse -mno-mmx -msse 2>&1 | FileCheck %s -// CHECK: "pentium4" "-target-feature" "+sse4.2" "-target-feature" "-mmx" "-target-feature" "+sse" +// CHECK: "x86-32-sse2" "-target-feature" "+sse4.2" "-target-feature" "-mmx" "-target-feature" "+sse" // Note that we filter out all but the last -m(no)sse. // Test that we don't produce an error with -mieee-fp. Index: clang/test/Misc/target-invalid-cpu-note.c =================================================================== --- clang/test/Misc/target-invalid-cpu-note.c +++ clang/test/Misc/target-invalid-cpu-note.c @@ -20,7 +20,7 @@ // X86-SAME: athlon, athlon-tbird, athlon-xp, athlon-mp, athlon-4, k8, athlon64, // X86-SAME: athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, // X86-SAME: barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, -// X86-SAME: x86-64, geode +// X86-SAME: x86-64, x86-32-sse2, geode // RUN: not %clang_cc1 -triple x86_64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86_64 // X86_64: error: unknown target CPU 'not-a-cpu' Index: llvm/include/llvm/Support/X86TargetParser.h =================================================================== --- llvm/include/llvm/Support/X86TargetParser.h +++ llvm/include/llvm/Support/X86TargetParser.h @@ -119,6 +119,7 @@ CK_ZNVER1, CK_ZNVER2, CK_x86_64, + CK_x86_32_sse2, CK_Geode, }; Index: llvm/lib/Support/X86TargetParser.cpp =================================================================== --- llvm/lib/Support/X86TargetParser.cpp +++ llvm/lib/Support/X86TargetParser.cpp @@ -370,6 +370,8 @@ { {"znver2"}, CK_ZNVER2, FEATURE_AVX2, FeaturesZNVER2 }, // Generic 64-bit processor. { {"x86-64"}, CK_x86_64, ~0U, FeaturesX86_64 }, + // Generic 32-bit processor. + { {"x86-32-sse2"}, CK_x86_32_sse2, ~0U, FeaturesPentium4 }, // Geode processors. { {"geode"}, CK_Geode, ~0U, FeaturesGeode }, }; Index: llvm/lib/Target/X86/X86.td =================================================================== --- llvm/lib/Target/X86/X86.td +++ llvm/lib/Target/X86/X86.td @@ -1294,6 +1294,25 @@ FeatureInsertVZEROUPPER ]>; +// Provide a generic 32-bit sse2 CPU with modern tuning settings. This is the +// default for 32-bit mode. +// FIXME: If we supported mtune we could have generic tuning for modern with +// arch as pentium4. +def : ProcessorModel<"x86-32-sse2", SandyBridgeModel, [ + FeatureX87, + FeatureCMPXCHG8B, + FeatureCMOV, + FeatureMMX, + FeatureSSE2, + FeatureFXSR, + FeatureNOPL, + FeatureSlow3OpsLEA, + FeatureSlowDivide64, + FeatureSlowIncDec, + FeatureMacroFusion, + FeatureInsertVZEROUPPER +]>; + //===----------------------------------------------------------------------===// // Calling Conventions //===----------------------------------------------------------------------===//