[clang] 8998fa6 - [clang] Change AMX macros to match names from GCC

Joe Loser via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 3 06:00:51 PST 2023


Author: Joe Loser
Date: 2023-02-03T07:00:16-07:00
New Revision: 8998fa6c14f1e19957858aa0e4b592d62ae56041

URL: https://github.com/llvm/llvm-project/commit/8998fa6c14f1e19957858aa0e4b592d62ae56041
DIFF: https://github.com/llvm/llvm-project/commit/8998fa6c14f1e19957858aa0e4b592d62ae56041.diff

LOG: [clang] Change AMX macros to match names from GCC

The current behavior for AMX macros is:

```
gcc -march=native -dM -E - < /dev/null | grep TILE

clang -march=native -dM -E - < /dev/null | grep TILE
```

which is not ideal.  Change `__AMXTILE__` and friends to `__AMX_TILE__` (i.e.
have an underscore in them).  This makes GCC and Clang agree on the naming of
these AMX macros to simplify downstream user code.

Fix this for `__AMXTILE__`, `__AMX_INT8__`, `__AMX_BF16__`, and `__AMX_FP16__`.

Differential Revision: https://reviews.llvm.org/D143094

Added: 
    

Modified: 
    clang/lib/Basic/Targets/X86.cpp
    clang/lib/Headers/immintrin.h
    clang/test/Preprocessor/predefined-arch-macros.c
    clang/test/Preprocessor/x86_amx_target_features.c
    clang/test/Preprocessor/x86_target_features.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index cb31712275301..490e20ce4514e 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -795,13 +795,13 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
   if (HasHRESET)
     Builder.defineMacro("__HRESET__");
   if (HasAMXTILE)
-    Builder.defineMacro("__AMXTILE__");
+    Builder.defineMacro("__AMX_TILE__");
   if (HasAMXINT8)
-    Builder.defineMacro("__AMXINT8__");
+    Builder.defineMacro("__AMX_INT8__");
   if (HasAMXBF16)
-    Builder.defineMacro("__AMXBF16__");
+    Builder.defineMacro("__AMX_BF16__");
   if (HasAMXFP16)
-    Builder.defineMacro("__AMXFP16__");
+    Builder.defineMacro("__AMX_FP16__");
   if (HasCMPCCXADD)
     Builder.defineMacro("__CMPCCXADD__");
   if (HasRAOINT)

diff  --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 6967b46fdb241..0d2e8be6e4862 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -524,7 +524,7 @@ _storebe_i64(void * __P, long long __D) {
 #include <invpcidintrin.h>
 #endif
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
-    defined(__AMXFP16__)
+    defined(__AMX_FP16__)
 #include <amxfp16intrin.h>
 #endif
 
@@ -534,7 +534,7 @@ _storebe_i64(void * __P, long long __D) {
 #endif
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||      \
-    defined(__AMXTILE__) || defined(__AMXINT8__) || defined(__AMXBF16__)
+    defined(__AMX_TILE__) || defined(__AMX_INT8__) || defined(__AMX_BF16__)
 #include <amxintrin.h>
 #endif
 

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c
index a78bac132db15..a64e5afa7aac3 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -1649,9 +1649,9 @@
 // RUN:     -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M32
 // CHECK_SPR_M32: #define __AES__ 1
-// CHECK_SPR_M32: #define __AMXBF16__ 1
-// CHECK_SPR_M32: #define __AMXINT8__ 1
-// CHECK_SPR_M32: #define __AMXTILE__ 1
+// CHECK_SPR_M32: #define __AMX_BF16__ 1
+// CHECK_SPR_M32: #define __AMX_INT8__ 1
+// CHECK_SPR_M32: #define __AMX_TILE__ 1
 // CHECK_SPR_M32: #define __AVX2__ 1
 // CHECK_SPR_M32: #define __AVX512BF16__ 1
 // CHECK_SPR_M32: #define __AVX512BITALG__ 1
@@ -1724,9 +1724,9 @@
 // RUN:     -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M64
 // CHECK_SPR_M64: #define __AES__ 1
-// CHECK_SPR_M64: #define __AMXBF16__ 1
-// CHECK_SPR_M64: #define __AMXINT8__ 1
-// CHECK_SPR_M64: #define __AMXTILE__ 1
+// CHECK_SPR_M64: #define __AMX_BF16__ 1
+// CHECK_SPR_M64: #define __AMX_INT8__ 1
+// CHECK_SPR_M64: #define __AMX_TILE__ 1
 // CHECK_SPR_M64: #define __AVX2__ 1
 // CHECK_SPR_M64: #define __AVX512BF16__ 1
 // CHECK_SPR_M64: #define __AVX512BITALG__ 1
@@ -1797,10 +1797,10 @@
 // RUN:     --target=i386 \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M32
 // CHECK_GNR_M32: #define __AES__ 1
-// CHECK_GNR_M32: #define __AMXBF16__ 1
-// CHECK_GNR_M32: #define __AMXFP16__ 1
-// CHECK_GNR_M32: #define __AMXINT8__ 1
-// CHECK_GNR_M32: #define __AMXTILE__ 1
+// CHECK_GNR_M32: #define __AMX_BF16__ 1
+// CHECK_GNR_M32: #define __AMX_FP16__ 1
+// CHECK_GNR_M32: #define __AMX_INT8__ 1
+// CHECK_GNR_M32: #define __AMX_TILE__ 1
 // CHECK_GNR_M32: #define __AVX2__ 1
 // CHECK_GNR_M32: #define __AVX512BF16__ 1
 // CHECK_GNR_M32: #define __AVX512BITALG__ 1
@@ -1871,10 +1871,10 @@
 // RUN:     --target=x86_64 \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M64
 // CHECK_GNR_M64: #define __AES__ 1
-// CHECK_GNR_M64: #define __AMXBF16__ 1
-// CHECK_GNR_M64: #define __AMXFP16__ 1
-// CHECK_GNR_M64: #define __AMXINT8__ 1
-// CHECK_GNR_M64: #define __AMXTILE__ 1
+// CHECK_GNR_M64: #define __AMX_BF16__ 1
+// CHECK_GNR_M64: #define __AMX_FP16__ 1
+// CHECK_GNR_M64: #define __AMX_INT8__ 1
+// CHECK_GNR_M64: #define __AMX_TILE__ 1
 // CHECK_GNR_M64: #define __AVX2__ 1
 // CHECK_GNR_M64: #define __AVX512BF16__ 1
 // CHECK_GNR_M64: #define __AVX512BITALG__ 1

diff  --git a/clang/test/Preprocessor/x86_amx_target_features.c b/clang/test/Preprocessor/x86_amx_target_features.c
index 644f160a0f6c5..d5e41d152eb59 100644
--- a/clang/test/Preprocessor/x86_amx_target_features.c
+++ b/clang/test/Preprocessor/x86_amx_target_features.c
@@ -1,35 +1,35 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=AMX-TILE %s
 
-// AMX-TILE: #define __AMXTILE__ 1
+// AMX-TILE: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s
 
-// AMX-BF16: #define __AMXBF16__ 1
-// AMX-BF16: #define __AMXTILE__ 1
+// AMX-BF16: #define __AMX_BF16__ 1
+// AMX-BF16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s
 
-// AMX-INT8: #define __AMXINT8__ 1
-// AMX-INT8: #define __AMXTILE__ 1
+// AMX-INT8: #define __AMX_INT8__ 1
+// AMX-INT8: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-TILE %s
 
-// NOAMX-TILE-NOT: #define __AMXTILE__ 1
+// NOAMX-TILE-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXTILE__ 1
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_TILE__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXTILE__ 1
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_TILE__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1

diff  --git a/clang/test/Preprocessor/x86_target_features.c b/clang/test/Preprocessor/x86_target_features.c
index 1b4a36a4b2505..326582446fcff 100644
--- a/clang/test/Preprocessor/x86_target_features.c
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -548,16 +548,16 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 -x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-FP16 %s
 
-// AMX-FP16: #define __AMXFP16__ 1
-// AMX-FP16: #define __AMXTILE__ 1
+// AMX-FP16: #define __AMX_FP16__ 1
+// AMX-FP16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mno-amx-fp16 \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 \
 // RUN: -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 
-// NO-AMX-FP16-NOT: #define __AMXFP16__ 1
-// NO-AMX-FP16-NOT: #define __AMXTILE__ 1
+// NO-AMX-FP16-NOT: #define __AMX_FP16__ 1
+// NO-AMX-FP16-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 


        


More information about the cfe-commits mailing list