Skip to content

[PowerPC][NFC] Define new alias for mma accumulate builtins #147382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 9, 2025

Conversation

lei137
Copy link
Contributor

@lei137 lei137 commented Jul 7, 2025

Initial clean up in prep for adding more accumulate builtins to clang.

@lei137 lei137 requested a review from maryammo July 7, 2025 19:49
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:PowerPC clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jul 7, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 7, 2025

@llvm/pr-subscribers-backend-powerpc

@llvm/pr-subscribers-clang

Author: Lei Huang (lei137)

Changes

Initial clean up in prep for adding more accumulate builtins to clang.


Full diff: https://github.com/llvm/llvm-project/pull/147382.diff

1 Files Affected:

  • (modified) clang/include/clang/Basic/BuiltinsPPC.def (+24-81)
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def
index 7c278d6841c74..3fa9961a9602c 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_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)                       \
+  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,74 +1067,6 @@ 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,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true,
-                         "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true,
-                         "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4, "vW1024*W256V", false,
                          "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4, "vW1024*W256Vi255i15i15", false,
@@ -1148,10 +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_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf32ger, "vW512*VV",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf64ger, "vW512*W256V",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvbf16ger2, "vW512*VV",
+                             "mma,paired-vector-memops")
+UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
+                             "mma,paired-vector-memops")
 
 // FIXME: Obviously incomplete.
 

@lei137 lei137 self-assigned this Jul 7, 2025
the macros are defined vs down below where the macro is first used.
@lei137 lei137 requested a review from amy-kwan July 8, 2025 20:54
Copy link
Contributor

@amy-kwan amy-kwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the added comments.

apply nit

Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
"mma,paired-vector-memops")
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
"mma,paired-vector-memops")

// MMA builtins with positive/negative multiply/accumulate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a list of builtin's name as a comment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that would be a bit of an overkill. I have added an example at the top to further document the new macro usage.

@lei137 lei137 merged commit d5da826 into main Jul 9, 2025
8 of 9 checks passed
@lei137 lei137 deleted the users/lei137/mmafltbuiltin branch July 9, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:PowerPC clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants