From bc1dede5b76b749f62ef92e2754ffa879ed3a51e Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 8 Feb 2017 07:56:42 +0000 Subject: [PATCH] [X86] Add -mmpx/-mno-mpx command line options and __MPX__ define to match gcc. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294419 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ClangCommandLineReference.rst | 2 ++ include/clang/Driver/Options.td | 2 ++ lib/Basic/Targets.cpp | 2 ++ test/Driver/x86-target-features.c | 5 +++++ test/Preprocessor/predefined-arch-macros.c | 6 ++++++ 5 files changed, 17 insertions(+) diff --git a/docs/ClangCommandLineReference.rst b/docs/ClangCommandLineReference.rst index b8b3407bfe..0e055c1680 100644 --- a/docs/ClangCommandLineReference.rst +++ b/docs/ClangCommandLineReference.rst @@ -2181,6 +2181,8 @@ X86 .. option:: -mmmx, -mno-mmx +.. option:: -mmpx, -mno-mpx + .. option:: -mmwaitx, -mno-mwaitx .. option:: -mpclmul, -mno-pclmul diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 3ac9283305..62bee0b4dd 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1718,6 +1718,7 @@ def mno_pku : Flag<["-"], "mno-pku">, Group; def mno_clflushopt : Flag<["-"], "mno-clflushopt">, Group; def mno_clwb : Flag<["-"], "mno-clwb">, Group; def mno_movbe : Flag<["-"], "mno-movbe">, Group; +def mno_mpx : Flag<["-"], "mno-mpx">, Group; def munaligned_access : Flag<["-"], "munaligned-access">, Group, HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">; @@ -1913,6 +1914,7 @@ def mmwaitx : Flag<["-"], "mmwaitx">, Group; def mclflushopt : Flag<["-"], "mclflushopt">, Group; def mclwb : Flag<["-"], "mclwb">, Group; def mmovbe : Flag<["-"], "mmovbe">, Group; +def mmpx : Flag<["-"], "mmpx">, Group; def mips16 : Flag<["-"], "mips16">, Group; def mno_mips16 : Flag<["-"], "mno-mips16">, Group; def mmicromips : Flag<["-"], "mmicromips">, Group; diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 45ce531e74..6124bdb5fd 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3881,6 +3881,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__CLFLUSHOPT__"); if (HasCLWB) Builder.defineMacro("__CLWB__"); + if (HasMPX) + Builder.defineMacro("__MPX__"); // Each case falls through to the previous one here. switch (SSELevel) { diff --git a/test/Driver/x86-target-features.c b/test/Driver/x86-target-features.c index d78bc28b8b..5d0c9faee7 100644 --- a/test/Driver/x86-target-features.c +++ b/test/Driver/x86-target-features.c @@ -64,3 +64,8 @@ // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movbe %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVBE %s // MOVBE: "-target-feature" "+movbe" // NO-MOVBE: "-target-feature" "-movbe" + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmpx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=MPX %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-mpx %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MPX %s +// MPX: "-target-feature" "+mpx" +// NO-MPX: "-target-feature" "-mpx" diff --git a/test/Preprocessor/predefined-arch-macros.c b/test/Preprocessor/predefined-arch-macros.c index f32482297d..0ead8eaefd 100644 --- a/test/Preprocessor/predefined-arch-macros.c +++ b/test/Preprocessor/predefined-arch-macros.c @@ -656,6 +656,7 @@ // CHECK_SKL_M32: #define __FMA__ 1 // CHECK_SKL_M32: #define __LZCNT__ 1 // CHECK_SKL_M32: #define __MMX__ 1 +// CHECK_SKL_M32: #define __MPX__ 1 // CHECK_SKL_M32: #define __PCLMUL__ 1 // CHECK_SKL_M32: #define __POPCNT__ 1 // CHECK_SKL_M32: #define __RDRND__ 1 @@ -687,6 +688,7 @@ // CHECK_SKL_M64: #define __FMA__ 1 // CHECK_SKL_M64: #define __LZCNT__ 1 // CHECK_SKL_M64: #define __MMX__ 1 +// CHECK_SKL_M64: #define __MPX__ 1 // CHECK_SKL_M64: #define __PCLMUL__ 1 // CHECK_SKL_M64: #define __POPCNT__ 1 // CHECK_SKL_M64: #define __RDRND__ 1 @@ -801,6 +803,7 @@ // CHECK_SKX_M32: #define __FMA__ 1 // CHECK_SKX_M32: #define __LZCNT__ 1 // CHECK_SKX_M32: #define __MMX__ 1 +// CHECK_SKX_M32: #define __MPX__ 1 // CHECK_SKX_M32: #define __PCLMUL__ 1 // CHECK_SKX_M32: #define __POPCNT__ 1 // CHECK_SKX_M32: #define __RDRND__ 1 @@ -841,6 +844,7 @@ // CHECK_SKX_M64: #define __FMA__ 1 // CHECK_SKX_M64: #define __LZCNT__ 1 // CHECK_SKX_M64: #define __MMX__ 1 +// CHECK_SKX_M64: #define __MPX__ 1 // CHECK_SKX_M64: #define __PCLMUL__ 1 // CHECK_SKX_M64: #define __POPCNT__ 1 // CHECK_SKX_M64: #define __RDRND__ 1 @@ -885,6 +889,7 @@ // CHECK_CNL_M32: #define __FMA__ 1 // CHECK_CNL_M32: #define __LZCNT__ 1 // CHECK_CNL_M32: #define __MMX__ 1 +// CHECK_CNL_M32: #define __MPX__ 1 // CHECK_CNL_M32: #define __PCLMUL__ 1 // CHECK_CNL_M32: #define __POPCNT__ 1 // CHECK_CNL_M32: #define __RDRND__ 1 @@ -924,6 +929,7 @@ // CHECK_CNL_M64: #define __FMA__ 1 // CHECK_CNL_M64: #define __LZCNT__ 1 // CHECK_CNL_M64: #define __MMX__ 1 +// CHECK_CNL_M64: #define __MPX__ 1 // CHECK_CNL_M64: #define __PCLMUL__ 1 // CHECK_CNL_M64: #define __POPCNT__ 1 // CHECK_CNL_M64: #define __RDRND__ 1 -- 2.40.0