[clang] [PowerPC][NFC] Define new alias for mma accumulate builtins (PR #147382)
Lei Huang via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 9 09:27:10 PDT 2025
https://github.com/lei137 updated https://github.com/llvm/llvm-project/pull/147382
>From 36d2b8fc61ab67b8d8010e8b33e3e871f8e1c4f2 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Fri, 4 Jul 2025 14:53:15 -0500
Subject: [PATCH 1/7] define new alias for accumulate builtins
---
clang/include/clang/Basic/BuiltinsPPC.def | 99 +++++------------------
1 file changed, 21 insertions(+), 78 deletions(-)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 7c278d6841c74..67ba4394b9ed7 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -35,6 +35,13 @@
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
+#define UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(ID, TYPES, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##pn, TYPES, true, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##pp, TYPES, true, FEATURE)
+
// GCC predefined macros to rename builtins, undef them to keep original names.
#if defined(__GNUC__) && !defined(__clang__)
#undef __builtin_vsx_xvnmaddadp
@@ -1032,12 +1039,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false,
- "mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false,
@@ -1046,12 +1047,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false,
- "mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true,
@@ -1072,85 +1067,33 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2pp, "vW512*VVi15i15i3", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernn, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpp, "vW512*W256V", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpn, "vW512*W256V", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernp, "vW512*W256V", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernn, "vW512*W256V", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpp, "vW512*W256Vi15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpn, "vW512*W256Vi15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernp, "vW512*W256Vi15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernn, "vW512*W256Vi15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2, "vW512*VV", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pp, "vW512*VV", true,
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4, "vW1024*W256V", false,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true,
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4, "vW1024*W256Vi255i15i15", false,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true,
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4pp, "vW1024*W256V", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true,
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4pp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true,
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true,
+UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf16ger2, "vW512*VV",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf32ger, "vW512*VV",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4, "vW1024*W256V", false,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf64ger, "vW512*W256V",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4, "vW1024*W256Vi255i15i15", false,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4pp, "vW1024*W256V", true,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4pp, "vW1024*W256Vi255i15i15", true,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvbf16ger2, "vW512*VV",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
+UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
"mma,paired-vector-memops")
// FIXME: Obviously incomplete.
>From 9b390b4b7f243babb7d020a234c70ca705c2edff Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Fri, 4 Jul 2025 15:03:19 -0500
Subject: [PATCH 2/7] apply clang-format
---
clang/include/clang/Basic/BuiltinsPPC.def | 28 +++++++++++------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 67ba4394b9ed7..9aeb97e51450d 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -35,11 +35,11 @@
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
-#define UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(ID, TYPES, FEATURE) \
- UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
- UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
- UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE) \
- UNALIASED_CUSTOM_BUILTIN(ID##pn, TYPES, true, FEATURE) \
+#define UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(ID, TYPES, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE) \
+ UNALIASED_CUSTOM_BUILTIN(ID##pn, TYPES, true, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##pp, TYPES, true, FEATURE)
// GCC predefined macros to rename builtins, undef them to keep original names.
@@ -1075,26 +1075,26 @@ UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4pp, "vW1024*W256V", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4pp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
+UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf16ger2, "vW512*VV",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf32ger, "vW512*VV",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf64ger, "vW512*W256V",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvbf16ger2, "vW512*VV",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
// FIXME: Obviously incomplete.
>From 332e9ab0745ca1e209bd06a540789e32cc18c10e Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Fri, 4 Jul 2025 15:48:28 -0500
Subject: [PATCH 3/7] rename builtin
---
clang/include/clang/Basic/BuiltinsPPC.def | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 9aeb97e51450d..2bea995d3f0fc 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -35,7 +35,7 @@
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
-#define UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(ID, TYPES, FEATURE) \
+#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE) \
@@ -1079,21 +1079,21 @@ UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf16ger2, "vW512*VV",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf32ger, "vW512*VV",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf32ger, "vW512*VV",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvf64ger, "vW512*W256V",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf64ger, "vW512*W256V",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_xvbf16ger2, "vW512*VV",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvbf16ger2, "vW512*VV",
"mma,paired-vector-memops")
-UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
"mma,paired-vector-memops")
// FIXME: Obviously incomplete.
>From 70ed0deb168f48a9d2d53b610ca1058cf37d09dd Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Fri, 4 Jul 2025 15:49:30 -0500
Subject: [PATCH 4/7] apply clang-format
---
clang/include/clang/Basic/BuiltinsPPC.def | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 2bea995d3f0fc..3fa9961a9602c 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -35,7 +35,7 @@
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
-#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE) \
+#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE) \
@@ -1080,21 +1080,21 @@ UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf32ger, "vW512*VV",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf64ger, "vW512*W256V",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvbf16ger2, "vW512*VV",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
- "mma,paired-vector-memops")
+ "mma,paired-vector-memops")
// FIXME: Obviously incomplete.
>From 6c03e97ba02ba64ac2444d2534753cfd4b675978 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Tue, 8 Jul 2025 15:53:26 -0500
Subject: [PATCH 5/7] Add documentation for the new macro and move older doc up
to where the macros are defined vs down below where the macro is first used.
---
clang/include/clang/Basic/BuiltinsPPC.def | 54 +++++++++++++----------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 3fa9961a9602c..cf50c317ce754 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -27,14 +27,41 @@
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
#endif
+// Built-ins requiring custom code generation.
+// Because these built-ins rely on target-dependent types and to avoid pervasive
+// change, they are type checked manually in Sema using custom type descriptors.
+// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
+// with its prefix, the second argument is the name of the intrinsic this
+// built-in generates, the third argument specifies the type of the function
+// (result value, then each argument) as follows:
+// i -> Unsigned integer followed by the greatest possible value for that
+// argument or 0 if no constraint on the value.
+// (e.g. i15 for a 4-bits value)
+// V -> Vector type used with MMA built-ins (vector unsigned char)
+// W -> PPC Vector type followed by the size of the vector type.
+// (e.g. W512 for __vector_quad)
+// any other descriptor -> Fall back to generic type descriptor decoding.
+// The 'C' suffix can be used as a suffix to specify the const type.
+// The '*' suffix can be used as a suffix to specify a pointer to a type.
+// The fourth argument is set to true if the built-in accumulates its result
+// into its given accumulator.
+
#ifndef CUSTOM_BUILTIN
#define CUSTOM_BUILTIN(ID, INTR, TYPES, ACCUMULATE, FEATURE) \
TARGET_BUILTIN(__builtin_##ID, "i.", "t", FEATURE)
#endif
+// UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have
+// the same name as that of the intrinsic they generate, i.e. the
+// ID and INTR are the same.
+// This avoids repeating the ID and INTR in the macro expression.
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
+// UNALIASED_CUSTOM_MMA_BUILTIN macro is used for MMA built-ins and it's
+// corresponding 4 positive/negative multiply and positive/negative accumulate
+// built-in with the same ID concated with posfix [nn|np|pn|pp].
+// This avoids repeating the TYPES and FEATURE in the macro expression.
#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
@@ -974,25 +1001,6 @@ BUILTIN(__builtin_setflm, "dd", "")
// Cache built-ins
BUILTIN(__builtin_dcbf, "vvC*", "")
-// Built-ins requiring custom code generation.
-// Because these built-ins rely on target-dependent types and to avoid pervasive
-// change, they are type checked manually in Sema using custom type descriptors.
-// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
-// with its prefix, the second argument is the name of the intrinsic this
-// built-in generates, the third argument specifies the type of the function
-// (result value, then each argument) as follows:
-// i -> Unsigned integer followed by the greatest possible value for that
-// argument or 0 if no constraint on the value.
-// (e.g. i15 for a 4-bits value)
-// V -> Vector type used with MMA built-ins (vector unsigned char)
-// W -> PPC Vector type followed by the size of the vector type.
-// (e.g. W512 for __vector_quad)
-// any other descriptor -> Fall back to generic type descriptor decoding.
-// The 'C' suffix can be used as a suffix to specify the const type.
-// The '*' suffix can be used as a suffix to specify a pointer to a type.
-// The fourth argument is set to true if the built-in accumulates its result into
-// its given accumulator.
-
// Provided builtins with _mma_ prefix for compatibility.
CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLiW256C*", false,
"paired-vector-memops")
@@ -1006,11 +1014,6 @@ CUSTOM_BUILTIN(vsx_build_pair, vsx_assemble_pair, "vW256*VV", false,
"paired-vector-memops")
CUSTOM_BUILTIN(mma_build_acc, mma_assemble_acc, "vW512*VVVV", false, "mma")
-// UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have
-// the same name as that of the intrinsic they generate, i.e. the
-// ID and INTR are the same.
-// This avoids repeating the ID and INTR in the macro expression.
-
UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLiW256C*", false,
"paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLiW256*", false,
@@ -1079,6 +1082,8 @@ UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")
+
+// MMA builtins with positive/negative multiply/accumulate.
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
"mma,paired-vector-memops")
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf32ger, "vW512*VV",
@@ -1102,3 +1107,4 @@ UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
#undef TARGET_BUILTIN
#undef CUSTOM_BUILTIN
#undef UNALIASED_CUSTOM_BUILTIN
+#undef UNALIASED_CUSTOM_MMA_BUILTIN
>From 4ff4f643b09842e0c7c14601547e9eb720603d99 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Wed, 9 Jul 2025 09:56:17 -0400
Subject: [PATCH 6/7] Update clang/include/clang/Basic/BuiltinsPPC.def
apply nit
Co-authored-by: Amy Kwan <amy.kwan1 at ibm.com>
---
clang/include/clang/Basic/BuiltinsPPC.def | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index cf50c317ce754..97befe1eaf585 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -58,7 +58,7 @@
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
-// UNALIASED_CUSTOM_MMA_BUILTIN macro is used for MMA built-ins and it's
+// UNALIASED_CUSTOM_MMA_BUILTIN macro is used for MMA built-ins and its
// corresponding 4 positive/negative multiply and positive/negative accumulate
// built-in with the same ID concated with posfix [nn|np|pn|pp].
// This avoids repeating the TYPES and FEATURE in the macro expression.
>From 958fe174b35a30d788b4cc20107637775e7ebf77 Mon Sep 17 00:00:00 2001
From: Lei Huang <lei at ca.ibm.com>
Date: Wed, 9 Jul 2025 11:26:55 -0500
Subject: [PATCH 7/7] add an example in the doc of the new maro
---
clang/include/clang/Basic/BuiltinsPPC.def | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 97befe1eaf585..354531e83991d 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -62,6 +62,16 @@
// corresponding 4 positive/negative multiply and positive/negative accumulate
// built-in with the same ID concated with posfix [nn|np|pn|pp].
// This avoids repeating the TYPES and FEATURE in the macro expression.
+// eg.
+// UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
+// "mma,paired-vector-memops")
+// Will generate built-ins:
+// * __builtin_mma_xvf16ger2()
+// * __builtin_mma_xvf16ger2nn()
+// * __builtin_mma_xvf16ger2np()
+// * __builtin_mma_xvf16ger2pn()
+// * __builtin_mma_xvf16ger2nn()
+// All with the same TYPES and FEATURE.
#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
More information about the cfe-commits
mailing list