dim created this revision. dim added reviewers: craig.topper, coby, efriedma, rsmith.
Make clang accept `-msahf` (and `-mno-sahf`) flags to activate the `+sahf` feature for the backend, for bug 36028 (Incorrect use of pushf/popf enables/disables interrupts on amd64 kernels). This was originally submitted in bug 36037 by Jonathan Looney <jonloo...@gmail.com>. As described there, GCC also uses `-msahf` for this feature, and the backend already recognizes the `+sahf` feature. All that is needed is to teach clang to pass this on to the backend. The mapping of feature support onto CPUs may not be complete; rather, it was chosen to match LLVM's idea of which CPUs support this feature (see lib/Target/X86/X86.td). I also updated the affected test cases (CodeGen/attr-target-x86.c and Preprocessor/predefined-arch-macros.c) to match the emitted output. Repository: rC Clang https://reviews.llvm.org/D43394 Files: include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h test/CodeGen/attr-target-x86.c test/Preprocessor/predefined-arch-macros.c
Index: test/Preprocessor/predefined-arch-macros.c =================================================================== --- test/Preprocessor/predefined-arch-macros.c +++ test/Preprocessor/predefined-arch-macros.c @@ -345,6 +345,7 @@ // RUN: %clang -march=core2 -m32 -E -dM %s -o - 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE2_M32 +// CHECK_CORE2_M32: #define __LAHFSAHF__ 1 // CHECK_CORE2_M32: #define __MMX__ 1 // CHECK_CORE2_M32: #define __SSE2__ 1 // CHECK_CORE2_M32: #define __SSE3__ 1 @@ -359,6 +360,7 @@ // RUN: %clang -march=core2 -m64 -E -dM %s -o - 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_CORE2_M64 +// CHECK_CORE2_M64: #define __LAHFSAHF__ 1 // CHECK_CORE2_M64: #define __MMX__ 1 // CHECK_CORE2_M64: #define __SSE2_MATH__ 1 // CHECK_CORE2_M64: #define __SSE2__ 1 @@ -377,6 +379,7 @@ // RUN: %clang -march=corei7 -m32 -E -dM %s -o - 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M32 +// CHECK_COREI7_M32: #define __LAHFSAHF__ 1 // CHECK_COREI7_M32: #define __MMX__ 1 // CHECK_COREI7_M32: #define __POPCNT__ 1 // CHECK_COREI7_M32: #define __SSE2__ 1 @@ -394,6 +397,7 @@ // RUN: %clang -march=corei7 -m64 -E -dM %s -o - 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_M64 +// CHECK_COREI7_M64: #define __LAHFSAHF__ 1 // CHECK_COREI7_M64: #define __MMX__ 1 // CHECK_COREI7_M64: #define __POPCNT__ 1 // CHECK_COREI7_M64: #define __SSE2_MATH__ 1 @@ -417,6 +421,7 @@ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M32 // CHECK_COREI7_AVX_M32: #define __AES__ 1 // CHECK_COREI7_AVX_M32: #define __AVX__ 1 +// CHECK_COREI7_AVX_M32: #define __LAHFSAHF__ 1 // CHECK_COREI7_AVX_M32: #define __MMX__ 1 // CHECK_COREI7_AVX_M32: #define __PCLMUL__ 1 // CHECK_COREI7_AVX_M32-NOT: __RDRND__ @@ -440,6 +445,7 @@ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_COREI7_AVX_M64 // CHECK_COREI7_AVX_M64: #define __AES__ 1 // CHECK_COREI7_AVX_M64: #define __AVX__ 1 +// CHECK_COREI7_AVX_M64: #define __LAHFSAHF__ 1 // CHECK_COREI7_AVX_M64: #define __MMX__ 1 // CHECK_COREI7_AVX_M64: #define __PCLMUL__ 1 // CHECK_COREI7_AVX_M64-NOT: __RDRND__ @@ -468,6 +474,7 @@ // CHECK_CORE_AVX_I_M32: #define __AES__ 1 // CHECK_CORE_AVX_I_M32: #define __AVX__ 1 // CHECK_CORE_AVX_I_M32: #define __F16C__ 1 +// CHECK_CORE_AVX_I_M32: #define __LAHFSAHF__ 1 // CHECK_CORE_AVX_I_M32: #define __MMX__ 1 // CHECK_CORE_AVX_I_M32: #define __PCLMUL__ 1 // CHECK_CORE_AVX_I_M32: #define __RDRND__ 1 @@ -491,6 +498,7 @@ // CHECK_CORE_AVX_I_M64: #define __AES__ 1 // CHECK_CORE_AVX_I_M64: #define __AVX__ 1 // CHECK_CORE_AVX_I_M64: #define __F16C__ 1 +// CHECK_CORE_AVX_I_M64: #define __LAHFSAHF__ 1 // CHECK_CORE_AVX_I_M64: #define __MMX__ 1 // CHECK_CORE_AVX_I_M64: #define __PCLMUL__ 1 // CHECK_CORE_AVX_I_M64: #define __RDRND__ 1 @@ -522,6 +530,7 @@ // CHECK_CORE_AVX2_M32: #define __BMI__ 1 // CHECK_CORE_AVX2_M32: #define __F16C__ 1 // CHECK_CORE_AVX2_M32: #define __FMA__ 1 +// CHECK_CORE_AVX2_M32: #define __LAHFSAHF__ 1 // CHECK_CORE_AVX2_M32: #define __LZCNT__ 1 // CHECK_CORE_AVX2_M32: #define __MMX__ 1 // CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1 @@ -551,6 +560,7 @@ // CHECK_CORE_AVX2_M64: #define __BMI__ 1 // CHECK_CORE_AVX2_M64: #define __F16C__ 1 // CHECK_CORE_AVX2_M64: #define __FMA__ 1 +// CHECK_CORE_AVX2_M64: #define __LAHFSAHF__ 1 // CHECK_CORE_AVX2_M64: #define __LZCNT__ 1 // CHECK_CORE_AVX2_M64: #define __MMX__ 1 // CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1 @@ -585,6 +595,7 @@ // CHECK_BROADWELL_M32: #define __BMI__ 1 // CHECK_BROADWELL_M32: #define __F16C__ 1 // CHECK_BROADWELL_M32: #define __FMA__ 1 +// CHECK_BROADWELL_M32: #define __LAHFSAHF__ 1 // CHECK_BROADWELL_M32: #define __LZCNT__ 1 // CHECK_BROADWELL_M32: #define __MMX__ 1 // CHECK_BROADWELL_M32: #define __PCLMUL__ 1 @@ -617,6 +628,7 @@ // CHECK_BROADWELL_M64: #define __BMI__ 1 // CHECK_BROADWELL_M64: #define __F16C__ 1 // CHECK_BROADWELL_M64: #define __FMA__ 1 +// CHECK_BROADWELL_M64: #define __LAHFSAHF__ 1 // CHECK_BROADWELL_M64: #define __LZCNT__ 1 // CHECK_BROADWELL_M64: #define __MMX__ 1 // CHECK_BROADWELL_M64: #define __PCLMUL__ 1 @@ -654,6 +666,7 @@ // CHECK_SKL_M32: #define __CLFLUSHOPT__ 1 // CHECK_SKL_M32: #define __F16C__ 1 // CHECK_SKL_M32: #define __FMA__ 1 +// CHECK_SKL_M32: #define __LAHFSAHF__ 1 // CHECK_SKL_M32: #define __LZCNT__ 1 // CHECK_SKL_M32: #define __MMX__ 1 // CHECK_SKL_M32: #define __MPX__ 1 @@ -688,6 +701,7 @@ // CHECK_SKL_M64: #define __CLFLUSHOPT__ 1 // CHECK_SKL_M64: #define __F16C__ 1 // CHECK_SKL_M64: #define __FMA__ 1 +// CHECK_SKL_M64: #define __LAHFSAHF__ 1 // CHECK_SKL_M64: #define __LZCNT__ 1 // CHECK_SKL_M64: #define __MMX__ 1 // CHECK_SKL_M64: #define __MPX__ 1 @@ -882,6 +896,7 @@ // CHECK_SKX_M32: #define __CLWB__ 1 // CHECK_SKX_M32: #define __F16C__ 1 // CHECK_SKX_M32: #define __FMA__ 1 +// CHECK_SKX_M32: #define __LAHFSAHF__ 1 // CHECK_SKX_M32: #define __LZCNT__ 1 // CHECK_SKX_M32: #define __MMX__ 1 // CHECK_SKX_M32: #define __MPX__ 1 @@ -927,6 +942,7 @@ // CHECK_SKX_M64: #define __CLWB__ 1 // CHECK_SKX_M64: #define __F16C__ 1 // CHECK_SKX_M64: #define __FMA__ 1 +// CHECK_SKX_M64: #define __LAHFSAHF__ 1 // CHECK_SKX_M64: #define __LZCNT__ 1 // CHECK_SKX_M64: #define __MMX__ 1 // CHECK_SKX_M64: #define __MPX__ 1 @@ -977,6 +993,7 @@ // CHECK_CNL_M32: #define __CLWB__ 1 // CHECK_CNL_M32: #define __F16C__ 1 // CHECK_CNL_M32: #define __FMA__ 1 +// CHECK_CNL_M32: #define __LAHFSAHF__ 1 // CHECK_CNL_M32: #define __LZCNT__ 1 // CHECK_CNL_M32: #define __MMX__ 1 // CHECK_CNL_M32: #define __MPX__ 1 @@ -1025,6 +1042,7 @@ // CHECK_CNL_M64: #define __CLWB__ 1 // CHECK_CNL_M64: #define __F16C__ 1 // CHECK_CNL_M64: #define __FMA__ 1 +// CHECK_CNL_M64: #define __LAHFSAHF__ 1 // CHECK_CNL_M64: #define __LZCNT__ 1 // CHECK_CNL_M64: #define __MMX__ 1 // CHECK_CNL_M64: #define __MPX__ 1 @@ -1079,6 +1097,7 @@ // CHECK_ICL_M32: #define __F16C__ 1 // CHECK_ICL_M32: #define __FMA__ 1 // CHECK_ICL_M32: #define __GFNI__ 1 +// CHECK_ICL_M32: #define __LAHFSAHF__ 1 // CHECK_ICL_M32: #define __LZCNT__ 1 // CHECK_ICL_M32: #define __MMX__ 1 // CHECK_ICL_M32: #define __MPX__ 1 @@ -1135,6 +1154,7 @@ // CHECK_ICL_M64: #define __F16C__ 1 // CHECK_ICL_M64: #define __FMA__ 1 // CHECK_ICL_M64: #define __GFNI__ 1 +// CHECK_ICL_M64: #define __LAHFSAHF__ 1 // CHECK_ICL_M64: #define __LZCNT__ 1 // CHECK_ICL_M64: #define __MMX__ 1 // CHECK_ICL_M64: #define __MPX__ 1 @@ -1171,6 +1191,7 @@ // RUN: %clang -march=atom -m32 -E -dM %s -o - 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ATOM_M32 +// CHECK_ATOM_M32: #define __LAHFSAHF__ 1 // CHECK_ATOM_M32: #define __MMX__ 1 // CHECK_ATOM_M32: #define __SSE2__ 1 // CHECK_ATOM_M32: #define __SSE3__ 1 @@ -1185,6 +1206,7 @@ // RUN: %clang -march=atom -m64 -E -dM %s -o - 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_ATOM_M64 +// CHECK_ATOM_M64: #define __LAHFSAHF__ 1 // CHECK_ATOM_M64: #define __MMX__ 1 // CHECK_ATOM_M64: #define __SSE2_MATH__ 1 // CHECK_ATOM_M64: #define __SSE2__ 1 @@ -1207,6 +1229,7 @@ // CHECK_GLM_M32: #define __CLFLUSHOPT__ 1 // CHECK_GLM_M32: #define __FSGSBASE__ 1 // CHECK_GLM_M32: #define __FXSR__ 1 +// CHECK_GLM_M32: #define __LAHFSAHF__ 1 // CHECK_GLM_M32: #define __MMX__ 1 // CHECK_GLM_M32: #define __MPX__ 1 // CHECK_GLM_M32: #define __PCLMUL__ 1 @@ -1240,6 +1263,7 @@ // CHECK_GLM_M64: #define __CLFLUSHOPT__ 1 // CHECK_GLM_M64: #define __FSGSBASE__ 1 // CHECK_GLM_M64: #define __FXSR__ 1 +// CHECK_GLM_M64: #define __LAHFSAHF__ 1 // CHECK_GLM_M64: #define __MMX__ 1 // CHECK_GLM_M64: #define __MPX__ 1 // CHECK_GLM_M64: #define __PCLMUL__ 1 @@ -1268,6 +1292,7 @@ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SLM_M32 // CHECK_SLM_M32: #define __AES__ 1 // CHECK_SLM_M32: #define __FXSR__ 1 +// CHECK_SLM_M32: #define __LAHFSAHF__ 1 // CHECK_SLM_M32: #define __MMX__ 1 // CHECK_SLM_M32: #define __PCLMUL__ 1 // CHECK_SLM_M32: #define __POPCNT__ 1 @@ -1290,6 +1315,7 @@ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SLM_M64 // CHECK_SLM_M64: #define __AES__ 1 // CHECK_SLM_M64: #define __FXSR__ 1 +// CHECK_SLM_M64: #define __LAHFSAHF__ 1 // CHECK_SLM_M64: #define __MMX__ 1 // CHECK_SLM_M64: #define __PCLMUL__ 1 // CHECK_SLM_M64: #define __POPCNT__ 1 @@ -1789,6 +1815,7 @@ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_BTVER1_M32 // CHECK_BTVER1_M32-NOT: #define __3dNOW_A__ 1 // CHECK_BTVER1_M32-NOT: #define __3dNOW__ 1 +// CHECK_BTVER1_M32: #define __LAHFSAHF__ 1 // CHECK_BTVER1_M32: #define __LZCNT__ 1 // CHECK_BTVER1_M32: #define __MMX__ 1 // CHECK_BTVER1_M32: #define __POPCNT__ 1 @@ -1810,6 +1837,7 @@ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_BTVER1_M64 // CHECK_BTVER1_M64-NOT: #define __3dNOW_A__ 1 // CHECK_BTVER1_M64-NOT: #define __3dNOW__ 1 +// CHECK_BTVER1_M64: #define __LAHFSAHF__ 1 // CHECK_BTVER1_M64: #define __LZCNT__ 1 // CHECK_BTVER1_M64: #define __MMX__ 1 // CHECK_BTVER1_M64: #define __POPCNT__ 1 @@ -1837,6 +1865,7 @@ // CHECK_BTVER2_M32: #define __AVX__ 1 // CHECK_BTVER2_M32: #define __BMI__ 1 // CHECK_BTVER2_M32: #define __F16C__ 1 +// CHECK_BTVER2_M32: #define __LAHFSAHF__ 1 // CHECK_BTVER2_M32: #define __LZCNT__ 1 // CHECK_BTVER2_M32: #define __MMX__ 1 // CHECK_BTVER2_M32: #define __PCLMUL__ 1 @@ -1865,6 +1894,7 @@ // CHECK_BTVER2_M64: #define __AVX__ 1 // CHECK_BTVER2_M64: #define __BMI__ 1 // CHECK_BTVER2_M64: #define __F16C__ 1 +// CHECK_BTVER2_M64: #define __LAHFSAHF__ 1 // CHECK_BTVER2_M64: #define __LZCNT__ 1 // CHECK_BTVER2_M64: #define __MMX__ 1 // CHECK_BTVER2_M64: #define __PCLMUL__ 1 @@ -1894,6 +1924,7 @@ // CHECK_BDVER1_M32: #define __AES__ 1 // CHECK_BDVER1_M32: #define __AVX__ 1 // CHECK_BDVER1_M32: #define __FMA4__ 1 +// CHECK_BDVER1_M32: #define __LAHFSAHF__ 1 // CHECK_BDVER1_M32: #define __LWP__ 1 // CHECK_BDVER1_M32: #define __LZCNT__ 1 // CHECK_BDVER1_M32: #define __MMX__ 1 @@ -1924,6 +1955,7 @@ // CHECK_BDVER1_M64: #define __AES__ 1 // CHECK_BDVER1_M64: #define __AVX__ 1 // CHECK_BDVER1_M64: #define __FMA4__ 1 +// CHECK_BDVER1_M64: #define __LAHFSAHF__ 1 // CHECK_BDVER1_M64: #define __LWP__ 1 // CHECK_BDVER1_M64: #define __LZCNT__ 1 // CHECK_BDVER1_M64: #define __MMX__ 1 @@ -1959,6 +1991,7 @@ // CHECK_BDVER2_M32: #define __F16C__ 1 // CHECK_BDVER2_M32: #define __FMA4__ 1 // CHECK_BDVER2_M32: #define __FMA__ 1 +// CHECK_BDVER2_M32: #define __LAHFSAHF__ 1 // CHECK_BDVER2_M32: #define __LWP__ 1 // CHECK_BDVER2_M32: #define __LZCNT__ 1 // CHECK_BDVER2_M32: #define __MMX__ 1 @@ -1993,6 +2026,7 @@ // CHECK_BDVER2_M64: #define __F16C__ 1 // CHECK_BDVER2_M64: #define __FMA4__ 1 // CHECK_BDVER2_M64: #define __FMA__ 1 +// CHECK_BDVER2_M64: #define __LAHFSAHF__ 1 // CHECK_BDVER2_M64: #define __LWP__ 1 // CHECK_BDVER2_M64: #define __LZCNT__ 1 // CHECK_BDVER2_M64: #define __MMX__ 1 @@ -2030,6 +2064,7 @@ // CHECK_BDVER3_M32: #define __FMA4__ 1 // CHECK_BDVER3_M32: #define __FMA__ 1 // CHECK_BDVER3_M32: #define __FSGSBASE__ 1 +// CHECK_BDVER3_M32: #define __LAHFSAHF__ 1 // CHECK_BDVER3_M32: #define __LWP__ 1 // CHECK_BDVER3_M32: #define __LZCNT__ 1 // CHECK_BDVER3_M32: #define __MMX__ 1 @@ -2066,6 +2101,7 @@ // CHECK_BDVER3_M64: #define __FMA4__ 1 // CHECK_BDVER3_M64: #define __FMA__ 1 // CHECK_BDVER3_M64: #define __FSGSBASE__ 1 +// CHECK_BDVER3_M64: #define __LAHFSAHF__ 1 // CHECK_BDVER3_M64: #define __LWP__ 1 // CHECK_BDVER3_M64: #define __LZCNT__ 1 // CHECK_BDVER3_M64: #define __MMX__ 1 @@ -2106,6 +2142,7 @@ // CHECK_BDVER4_M32: #define __FMA4__ 1 // CHECK_BDVER4_M32: #define __FMA__ 1 // CHECK_BDVER4_M32: #define __FSGSBASE__ 1 +// CHECK_BDVER4_M32: #define __LAHFSAHF__ 1 // CHECK_BDVER4_M32: #define __LWP__ 1 // CHECK_BDVER4_M32: #define __LZCNT__ 1 // CHECK_BDVER4_M32: #define __MMX__ 1 @@ -2143,6 +2180,7 @@ // CHECK_BDVER4_M64: #define __FMA4__ 1 // CHECK_BDVER4_M64: #define __FMA__ 1 // CHECK_BDVER4_M64: #define __FSGSBASE__ 1 +// CHECK_BDVER4_M64: #define __LAHFSAHF__ 1 // CHECK_BDVER4_M64: #define __LWP__ 1 // CHECK_BDVER4_M64: #define __LZCNT__ 1 // CHECK_BDVER4_M64: #define __MMX__ 1 @@ -2184,6 +2222,7 @@ // CHECK_ZNVER1_M32: #define __F16C__ 1 // CHECK_ZNVER1_M32: #define __FMA__ 1 // CHECK_ZNVER1_M32: #define __FSGSBASE__ 1 +// CHECK_ZNVER1_M32: #define __LAHFSAHF__ 1 // CHECK_ZNVER1_M32: #define __LZCNT__ 1 // CHECK_ZNVER1_M32: #define __MMX__ 1 // CHECK_ZNVER1_M32: #define __PCLMUL__ 1 @@ -2226,6 +2265,7 @@ // CHECK_ZNVER1_M64: #define __F16C__ 1 // CHECK_ZNVER1_M64: #define __FMA__ 1 // CHECK_ZNVER1_M64: #define __FSGSBASE__ 1 +// CHECK_ZNVER1_M64: #define __LAHFSAHF__ 1 // CHECK_ZNVER1_M64: #define __LZCNT__ 1 // CHECK_ZNVER1_M64: #define __MMX__ 1 // CHECK_ZNVER1_M64: #define __PCLMUL__ 1 Index: test/CodeGen/attr-target-x86.c =================================================================== --- test/CodeGen/attr-target-x86.c +++ test/CodeGen/attr-target-x86.c @@ -49,10 +49,10 @@ // CHECK: lake{{.*}} #7 // CHECK: use_before_def{{.*}} #7 // CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+x87" -// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" +// CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+aes,+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt" // CHECK: #2 = {{.*}}"target-cpu"="i686" "target-features"="+x87,-aes,-avx,-avx2,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vpopcntdq,-f16c,-fma,-fma4,-gfni,-pclmul,-sha,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-xop,-xsave,-xsaveopt" // CHECK: #3 = {{.*}}"target-cpu"="i686" "target-features"="+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" // CHECK: #4 = {{.*}}"target-cpu"="i686" "target-features"="+x87,-avx,-avx2,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vpopcntdq,-f16c,-fma,-fma4,-sse4.1,-sse4.2,-vaes,-vpclmulqdq,-xop,-xsave,-xsaveopt" -// CHECK: #5 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes,-vaes" +// CHECK: #5 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt,-aes,-vaes" // CHECK: #6 = {{.*}}"target-cpu"="i686" "target-features"="+x87,-3dnow,-3dnowa,-mmx" // CHECK: #7 = {{.*}}"target-cpu"="lakemont" "target-features"="+mmx" Index: lib/Basic/Targets/X86.h =================================================================== --- lib/Basic/Targets/X86.h +++ lib/Basic/Targets/X86.h @@ -99,6 +99,7 @@ bool HasRDPID = false; bool HasRetpoline = false; bool HasRetpolineExternalThunk = false; + bool HasLAHFSAHF = false; protected: /// \brief Enumeration of all of the X86 CPUs supported by Clang. Index: lib/Basic/Targets/X86.cpp =================================================================== --- lib/Basic/Targets/X86.cpp +++ lib/Basic/Targets/X86.cpp @@ -220,6 +220,7 @@ LLVM_FALLTHROUGH; case CK_Core2: setFeatureEnabledImpl(Features, "ssse3", true); + setFeatureEnabledImpl(Features, "sahf", true); LLVM_FALLTHROUGH; case CK_Yonah: case CK_Prescott: @@ -261,6 +262,7 @@ setFeatureEnabledImpl(Features, "ssse3", true); setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "cx16", true); + setFeatureEnabledImpl(Features, "sahf", true); break; case CK_KNM: @@ -337,6 +339,7 @@ setFeatureEnabledImpl(Features, "prfchw", true); setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "fxsr", true); + setFeatureEnabledImpl(Features, "sahf", true); break; case CK_ZNVER1: @@ -360,6 +363,7 @@ setFeatureEnabledImpl(Features, "prfchw", true); setFeatureEnabledImpl(Features, "rdrnd", true); setFeatureEnabledImpl(Features, "rdseed", true); + setFeatureEnabledImpl(Features, "sahf", true); setFeatureEnabledImpl(Features, "sha", true); setFeatureEnabledImpl(Features, "sse4a", true); setFeatureEnabledImpl(Features, "xsave", true); @@ -394,6 +398,7 @@ setFeatureEnabledImpl(Features, "cx16", true); setFeatureEnabledImpl(Features, "fxsr", true); setFeatureEnabledImpl(Features, "xsave", true); + setFeatureEnabledImpl(Features, "sahf", true); break; } if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec)) @@ -792,6 +797,8 @@ HasRetpoline = true; } else if (Feature == "+retpoline-external-thunk") { HasRetpolineExternalThunk = true; + } else if (Feature == "+sahf") { + HasLAHFSAHF = true; } X86SSEEnum Level = llvm::StringSwitch<X86SSEEnum>(Feature) @@ -1039,6 +1046,9 @@ if (HasPRFCHW) Builder.defineMacro("__PRFCHW__"); + if (HasLAHFSAHF) + Builder.defineMacro("__LAHFSAHF__"); + if (HasRDSEED) Builder.defineMacro("__RDSEED__"); @@ -1269,6 +1279,7 @@ .Case("rdrnd", true) .Case("rdseed", true) .Case("rtm", true) + .Case("sahf", true) .Case("sgx", true) .Case("sha", true) .Case("shstk", true) @@ -1343,6 +1354,7 @@ .Case("retpoline", HasRetpoline) .Case("retpoline-external-thunk", HasRetpolineExternalThunk) .Case("rtm", HasRTM) + .Case("sahf", HasLAHFSAHF) .Case("sgx", HasSGX) .Case("sha", HasSHA) .Case("shstk", HasSHSTK) Index: include/clang/Driver/Options.td =================================================================== --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2591,6 +2591,8 @@ def mno_rtm : Flag<["-"], "mno-rtm">, Group<m_x86_Features_Group>; def mrdseed : Flag<["-"], "mrdseed">, Group<m_x86_Features_Group>; def mno_rdseed : Flag<["-"], "mno-rdseed">, Group<m_x86_Features_Group>; +def msahf : Flag<["-"], "msahf">, Group<m_x86_Features_Group>; +def mno_sahf : Flag<["-"], "mno-sahf">, Group<m_x86_Features_Group>; def msgx : Flag<["-"], "msgx">, Group<m_x86_Features_Group>; def mno_sgx : Flag<["-"], "mno-sgx">, Group<m_x86_Features_Group>; def msha : Flag<["-"], "msha">, Group<m_x86_Features_Group>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits