]> granicus.if.org Git - clang/commitdiff
[x86] Enable broadwell target in clang.
authorRobert Khasanov <rob.khasanov@gmail.com>
Fri, 19 Sep 2014 09:53:48 +0000 (09:53 +0000)
committerRobert Khasanov <rob.khasanov@gmail.com>
Fri, 19 Sep 2014 09:53:48 +0000 (09:53 +0000)
Added -madx option

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218116 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Basic/Targets.cpp
test/Preprocessor/predefined-arch-macros.c
test/Preprocessor/x86_target_features.c

index 43428b8e692d78d35c653429a79107ffdd0674af..db611b6ed8133c1fb7e031f1c5f13a0fa1b24250 100644 (file)
@@ -1134,6 +1134,7 @@ def mno_f16c : Flag<["-"], "mno-f16c">, Group<m_x86_Features_Group>;
 def mno_rtm : Flag<["-"], "mno-rtm">, Group<m_x86_Features_Group>;
 def mno_prfchw : Flag<["-"], "mno-prfchw">, Group<m_x86_Features_Group>;
 def mno_rdseed : Flag<["-"], "mno-rdseed">, Group<m_x86_Features_Group>;
+def mno_adx : Flag<["-"], "mno-adx">, Group<m_x86_Features_Group>;
 def mno_sha : Flag<["-"], "mno-sha">, Group<m_x86_Features_Group>;
 
 def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>,
@@ -1231,6 +1232,7 @@ def mf16c : Flag<["-"], "mf16c">, Group<m_x86_Features_Group>;
 def mrtm : Flag<["-"], "mrtm">, Group<m_x86_Features_Group>;
 def mprfchw : Flag<["-"], "mprfchw">, Group<m_x86_Features_Group>;
 def mrdseed : Flag<["-"], "mrdseed">, Group<m_x86_Features_Group>;
+def madx : Flag<["-"], "madx">, Group<m_x86_Features_Group>;
 def msha : Flag<["-"], "msha">, Group<m_x86_Features_Group>;
 def mcx16 : Flag<["-"], "mcx16">, Group<m_x86_Features_Group>;
 def mips16 : Flag<["-"], "mips16">, Group<m_Group>;
index b4b8ec007db40f6d09e82abb5c88adc2e8b2bdab..7ccd646a238233af82fa91b5aaa0b2994d391650 100644 (file)
@@ -1696,6 +1696,7 @@ class X86TargetInfo : public TargetInfo {
   bool HasRTM;
   bool HasPRFCHW;
   bool HasRDSEED;
+  bool HasADX;
   bool HasTBM;
   bool HasFMA;
   bool HasF16C;
@@ -1785,6 +1786,7 @@ class X86TargetInfo : public TargetInfo {
     CK_Corei7AVX,
     CK_CoreAVXi,
     CK_CoreAVX2,
+    CK_Broadwell,
     //@}
 
     /// \name Knights Landing
@@ -1866,11 +1868,11 @@ public:
       : TargetInfo(Triple), SSELevel(NoSSE), MMX3DNowLevel(NoMMX3DNow),
         XOPLevel(NoXOP), HasAES(false), HasPCLMUL(false), HasLZCNT(false),
         HasRDRND(false), HasBMI(false), HasBMI2(false), HasPOPCNT(false),
-        HasRTM(false), HasPRFCHW(false), HasRDSEED(false), HasTBM(false),
-        HasFMA(false), HasF16C(false), HasAVX512CD(false), HasAVX512ER(false),
-        HasAVX512PF(false), HasAVX512DQ(false), HasAVX512BW(false), HasAVX512VL(false),
-        HasSHA(false), HasCX16(false), CPU(CK_Generic),
-        FPMath(FP_Default) {
+        HasRTM(false), HasPRFCHW(false), HasRDSEED(false), HasADX(false),
+        HasTBM(false), HasFMA(false), HasF16C(false), HasAVX512CD(false),
+        HasAVX512ER(false), HasAVX512PF(false), HasAVX512DQ(false),
+        HasAVX512BW(false), HasAVX512VL(false), HasSHA(false), HasCX16(false),
+        CPU(CK_Generic), FPMath(FP_Default) {
     BigEndian = false;
     LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
   }
@@ -1969,6 +1971,7 @@ public:
       .Case("corei7-avx", CK_Corei7AVX)
       .Case("core-avx-i", CK_CoreAVXi)
       .Case("core-avx2", CK_CoreAVX2)
+      .Case("broadwell", CK_Broadwell)
       .Case("knl", CK_KNL)
       .Case("skx", CK_SKX)
       .Case("k6", CK_K6)
@@ -2048,6 +2051,7 @@ public:
     case CK_Corei7AVX:
     case CK_CoreAVXi:
     case CK_CoreAVX2:
+    case CK_Broadwell:
     case CK_KNL:
     case CK_SKX:
     case CK_Athlon64:
@@ -2183,6 +2187,21 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
     setFeatureEnabledImpl(Features, "fma", true);
     setFeatureEnabledImpl(Features, "cx16", true);
     break;
+  case CK_Broadwell:
+    setFeatureEnabledImpl(Features, "avx2", true);
+    setFeatureEnabledImpl(Features, "aes", true);
+    setFeatureEnabledImpl(Features, "pclmul", true);
+    setFeatureEnabledImpl(Features, "lzcnt", true);
+    setFeatureEnabledImpl(Features, "rdrnd", true);
+    setFeatureEnabledImpl(Features, "f16c", true);
+    setFeatureEnabledImpl(Features, "bmi", true);
+    setFeatureEnabledImpl(Features, "bmi2", true);
+    setFeatureEnabledImpl(Features, "rtm", true);
+    setFeatureEnabledImpl(Features, "fma", true);
+    setFeatureEnabledImpl(Features, "cx16", true);
+    setFeatureEnabledImpl(Features, "rdseed", true);
+    setFeatureEnabledImpl(Features, "adx", true);
+    break;
   case CK_KNL:
     setFeatureEnabledImpl(Features, "avx512f", true);
     setFeatureEnabledImpl(Features, "avx512cd", true);
@@ -2197,6 +2216,8 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
     setFeatureEnabledImpl(Features, "bmi2", true);
     setFeatureEnabledImpl(Features, "rtm", true);
     setFeatureEnabledImpl(Features, "fma", true);
+    setFeatureEnabledImpl(Features, "rdseed", true);
+    setFeatureEnabledImpl(Features, "adx", true);
     break;
   case CK_SKX:
     setFeatureEnabledImpl(Features, "avx512f", true);
@@ -2213,6 +2234,8 @@ void X86TargetInfo::getDefaultFeatures(llvm::StringMap<bool> &Features) const {
     setFeatureEnabledImpl(Features, "bmi2", true);
     setFeatureEnabledImpl(Features, "rtm", true);
     setFeatureEnabledImpl(Features, "fma", true);
+    setFeatureEnabledImpl(Features, "rdseed", true);
+    setFeatureEnabledImpl(Features, "adx", true);
     break;
   case CK_K6:
   case CK_WinChipC6:
@@ -2539,6 +2562,11 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       continue;
     }
 
+    if (Feature == "adx") {
+      HasADX = true;
+      continue;
+    }
+
     if (Feature == "tbm") {
       HasTBM = true;
       continue;
@@ -2749,6 +2777,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
   case CK_Corei7AVX:
   case CK_CoreAVXi:
   case CK_CoreAVX2:
+  case CK_Broadwell:
     defineCPUMacros(Builder, "corei7");
     break;
   case CK_KNL:
@@ -2858,6 +2887,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
   if (HasRDSEED)
     Builder.defineMacro("__RDSEED__");
 
+  if (HasADX)
+    Builder.defineMacro("__ADX__");
+
   if (HasTBM)
     Builder.defineMacro("__TBM__");
 
index 4d052128f6c515c7db67b93859d39a8bc07bfa9c..5f5380926dcacc10388ec937bfbe87a6e6950260 100644 (file)
 // CHECK_CORE_AVX2_M64: #define __x86_64 1
 // CHECK_CORE_AVX2_M64: #define __x86_64__ 1
 //
+// RUN: %clang -march=broadwell -m32 -E -dM %s -o - 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_BROADWELL_M32
+// CHECK_BROADWELL_M32: #define __ADX__ 1
+// CHECK_BROADWELL_M32: #define __AES__ 1
+// CHECK_BROADWELL_M32: #define __AVX2__ 1
+// CHECK_BROADWELL_M32: #define __AVX__ 1
+// CHECK_BROADWELL_M32: #define __BMI2__ 1
+// CHECK_BROADWELL_M32: #define __BMI__ 1
+// CHECK_BROADWELL_M32: #define __F16C__ 1
+// CHECK_BROADWELL_M32: #define __FMA__ 1
+// CHECK_BROADWELL_M32: #define __LZCNT__ 1
+// CHECK_BROADWELL_M32: #define __MMX__ 1
+// CHECK_BROADWELL_M32: #define __PCLMUL__ 1
+// CHECK_BROADWELL_M32: #define __POPCNT__ 1
+// CHECK_BROADWELL_M32: #define __RDRND__ 1
+// CHECK_BROADWELL_M32: #define __RDSEED__ 1
+// CHECK_BROADWELL_M32: #define __RTM__ 1
+// CHECK_BROADWELL_M32: #define __SSE2__ 1
+// CHECK_BROADWELL_M32: #define __SSE3__ 1
+// CHECK_BROADWELL_M32: #define __SSE4_1__ 1
+// CHECK_BROADWELL_M32: #define __SSE4_2__ 1
+// CHECK_BROADWELL_M32: #define __SSE__ 1
+// CHECK_BROADWELL_M32: #define __SSSE3__ 1
+// CHECK_BROADWELL_M32: #define __corei7 1
+// CHECK_BROADWELL_M32: #define __corei7__ 1
+// CHECK_BROADWELL_M32: #define __i386 1
+// CHECK_BROADWELL_M32: #define __i386__ 1
+// CHECK_BROADWELL_M32: #define __tune_corei7__ 1
+// CHECK_BROADWELL_M32: #define i386 1
+// RUN: %clang -march=broadwell -m64 -E -dM %s -o - 2>&1 \
+// RUN:     -target i386-unknown-linux \
+// RUN:   | FileCheck %s -check-prefix=CHECK_BROADWELL_M64
+// CHECK_BROADWELL_M64: #define __ADX__ 1
+// CHECK_BROADWELL_M64: #define __AES__ 1
+// CHECK_BROADWELL_M64: #define __AVX2__ 1
+// CHECK_BROADWELL_M64: #define __AVX__ 1
+// CHECK_BROADWELL_M64: #define __BMI2__ 1
+// CHECK_BROADWELL_M64: #define __BMI__ 1
+// CHECK_BROADWELL_M64: #define __F16C__ 1
+// CHECK_BROADWELL_M64: #define __FMA__ 1
+// CHECK_BROADWELL_M64: #define __LZCNT__ 1
+// CHECK_BROADWELL_M64: #define __MMX__ 1
+// CHECK_BROADWELL_M64: #define __PCLMUL__ 1
+// CHECK_BROADWELL_M64: #define __POPCNT__ 1
+// CHECK_BROADWELL_M64: #define __RDRND__ 1
+// CHECK_BROADWELL_M64: #define __RDSEED__ 1
+// CHECK_BROADWELL_M64: #define __RTM__ 1
+// CHECK_BROADWELL_M64: #define __SSE2_MATH__ 1
+// CHECK_BROADWELL_M64: #define __SSE2__ 1
+// CHECK_BROADWELL_M64: #define __SSE3__ 1
+// CHECK_BROADWELL_M64: #define __SSE4_1__ 1
+// CHECK_BROADWELL_M64: #define __SSE4_2__ 1
+// CHECK_BROADWELL_M64: #define __SSE_MATH__ 1
+// CHECK_BROADWELL_M64: #define __SSE__ 1
+// CHECK_BROADWELL_M64: #define __SSSE3__ 1
+// CHECK_BROADWELL_M64: #define __amd64 1
+// CHECK_BROADWELL_M64: #define __amd64__ 1
+// CHECK_BROADWELL_M64: #define __corei7 1
+// CHECK_BROADWELL_M64: #define __corei7__ 1
+// CHECK_BROADWELL_M64: #define __tune_corei7__ 1
+// CHECK_BROADWELL_M64: #define __x86_64 1
+// CHECK_BROADWELL_M64: #define __x86_64__ 1
+//
 // RUN: %clang -march=knl -m32 -E -dM %s -o - 2>&1 \
 // RUN:     -target i386-unknown-linux \
 // RUN:   | FileCheck %s -check-prefix=CHECK_KNL_M32
index 23fa493fdf5d47901759fc28ac3e41ca66216fbb..806eeec961d69e14a8870d60b6a0ec694c620216 100644 (file)
 
 // NO3DNOWPRFCHW: #define __PRFCHW__ 1
 
+// RUN: %clang -target i386-unknown-unknown -march=atom -madx -x c -E -dM -o - %s | FileCheck --check-prefix=ADX %s
+
+// ADX: #define __ADX__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=atom -mrdseed -x c -E -dM -o - %s | FileCheck --check-prefix=RDSEED %s
+
+// RDSEED: #define __RDSEED__ 1
+