[PATCH] [2/2] Adding front-end options and macros for TBM instruction set

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Mon Sep 23 19:19:33 PDT 2013


  Hi Craig,
  Thanks for the hint! I did not realize that you can actually test a target
  feature without having to add instructions first. I think the other test that
  you were trying to mention is test/Preprocessor/predefined-arch-macros.c. I
  have updated my patch to include both test cases.
  And to answer your question in the other post, yes I will be submitting actual
  instruction patches soon.
  Thanks for reviewing,
  - Gao.

http://llvm-reviews.chandlerc.com/D1693

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1693?vs=4343&id=4453#toc

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

Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -973,6 +973,7 @@
 def mno_bmi : Flag<["-"], "mno-bmi">, Group<m_x86_Features_Group>;
 def mno_bmi2 : Flag<["-"], "mno-bmi2">, Group<m_x86_Features_Group>;
 def mno_popcnt : Flag<["-"], "mno-popcnt">, Group<m_x86_Features_Group>;
+def mno_tbm : Flag<["-"], "mno-tbm">, Group<m_x86_Features_Group>;
 def mno_fma4 : Flag<["-"], "mno-fma4">, Group<m_x86_Features_Group>;
 def mno_fma : Flag<["-"], "mno-fma">, Group<m_x86_Features_Group>;
 def mno_xop : Flag<["-"], "mno-xop">, Group<m_x86_Features_Group>;
@@ -1031,6 +1032,7 @@
 def mbmi : Flag<["-"], "mbmi">, Group<m_x86_Features_Group>;
 def mbmi2 : Flag<["-"], "mbmi2">, Group<m_x86_Features_Group>;
 def mpopcnt : Flag<["-"], "mpopcnt">, Group<m_x86_Features_Group>;
+def mtbm : Flag<["-"], "mtbm">, Group<m_x86_Features_Group>;
 def mfma4 : Flag<["-"], "mfma4">, Group<m_x86_Features_Group>;
 def mfma : Flag<["-"], "mfma">, Group<m_x86_Features_Group>;
 def mxop : Flag<["-"], "mxop">, Group<m_x86_Features_Group>;
Index: lib/Basic/Targets.cpp
===================================================================
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1584,6 +1584,7 @@
   bool HasRTM;
   bool HasPRFCHW;
   bool HasRDSEED;
+  bool HasTBM;
   bool HasFMA;
   bool HasF16C;
   bool HasAVX512CD, HasAVX512ER, HasAVX512PF;
@@ -1745,8 +1746,8 @@
       : 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), HasFMA(false),
-        HasF16C(false), HasAVX512CD(false), HasAVX512ER(false),
+        HasRTM(false), HasPRFCHW(false), HasRDSEED(false), HasTBM(false),
+        HasFMA(false), HasF16C(false), HasAVX512CD(false), HasAVX512ER(false),
         HasAVX512PF(false), CPU(CK_Generic), FPMath(FP_Default) {
     BigEndian = false;
     LongDoubleFormat = &llvm::APFloat::x87DoubleExtended;
@@ -2115,6 +2116,7 @@
     setFeatureEnabled(Features, "bmi", true);
     setFeatureEnabled(Features, "fma", true);
     setFeatureEnabled(Features, "f16c", true);
+    setFeatureEnabled(Features, "tbm", true);
     break;
   case CK_C3_2:
     setFeatureEnabled(Features, "sse", true);
@@ -2349,6 +2351,11 @@
       continue;
     }
 
+    if (Feature == "tbm") {
+      HasTBM = true;
+      continue;
+    }
+
     if (Feature == "fma") {
       HasFMA = true;
       continue;
@@ -2619,6 +2626,9 @@
   if (HasRDSEED)
     Builder.defineMacro("__RDSEED__");
 
+  if (HasTBM)
+    Builder.defineMacro("__TBM__");
+
   switch (XOPLevel) {
   case XOP:
     Builder.defineMacro("__XOP__");
@@ -2723,6 +2733,7 @@
       .Case("bmi2", HasBMI2)
       .Case("fma", HasFMA)
       .Case("fma4", XOPLevel >= FMA4)
+      .Case("tbm", HasTBM)
       .Case("lzcnt", HasLZCNT)
       .Case("rdrnd", HasRDRND)
       .Case("mm3dnow", MMX3DNowLevel >= AMD3DNow)
Index: test/Preprocessor/x86_target_features.c
===================================================================
--- test/Preprocessor/x86_target_features.c
+++ test/Preprocessor/x86_target_features.c
@@ -152,3 +152,12 @@
 // RUN: %clang -target i386-unknown-unknown -march=atom -msse -mno-mmx -x c -E -dM -o - %s | FileCheck --check-prefix=SSENOMMX %s
 
 // SSENOMMX-NOT: #define __MMX__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=bdver2 -mtbm -x c -E -dM -o - %s | FileCheck --check-prefix=TBM %s
+
+// TBM: #define __TBM__ 1
+
+// RUN: %clang -target i386-unknown-unknown -march=bdver2 -mno-tbm -x c -E -dM -o - %s | FileCheck --check-prefix=NOTBM %s
+
+// NOTBM-NOT: #define __TBM__ 1
+
Index: test/Preprocessor/predefined-arch-macros.c
===================================================================
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1326,6 +1326,7 @@
 // CHECK_BDVER2_M32: #define __SSE_MATH__ 1
 // CHECK_BDVER2_M32: #define __SSE__ 1
 // CHECK_BDVER2_M32: #define __SSSE3__ 1
+// CHECK_BDVER2_M32: #define __TBM__ 1
 // CHECK_BDVER2_M32: #define __XOP__ 1
 // CHECK_BDVER2_M32: #define __bdver2 1
 // CHECK_BDVER2_M32: #define __bdver2__ 1
@@ -1356,6 +1357,7 @@
 // CHECK_BDVER2_M64: #define __SSE_MATH__ 1
 // CHECK_BDVER2_M64: #define __SSE__ 1
 // CHECK_BDVER2_M64: #define __SSSE3__ 1
+// CHECK_BDVER2_M64: #define __TBM__ 1
 // CHECK_BDVER2_M64: #define __XOP__ 1
 // CHECK_BDVER2_M64: #define __amd64 1
 // CHECK_BDVER2_M64: #define __amd64__ 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1693.3.patch
Type: text/x-patch
Size: 4657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130923/30e0f0ec/attachment.bin>


More information about the cfe-commits mailing list