Skip to content

Commit d5da826

Browse files
lei137amy-kwan
andauthored
[PowerPC][NFC] Define new alias for mma accumulate builtins (#147382)
Move documentation for macros up to where the macros are initially defined and add new custom MMA builtin macro in prep for adding more accumulate builtins to clang. --------- Co-authored-by: Amy Kwan <amy.kwan1@ibm.com>
1 parent dd54b8e commit d5da826

File tree

1 file changed

+64
-105
lines changed

1 file changed

+64
-105
lines changed

clang/include/clang/Basic/BuiltinsPPC.def

Lines changed: 64 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,58 @@
2727
#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
2828
#endif
2929

30+
// Built-ins requiring custom code generation.
31+
// Because these built-ins rely on target-dependent types and to avoid pervasive
32+
// change, they are type checked manually in Sema using custom type descriptors.
33+
// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
34+
// with its prefix, the second argument is the name of the intrinsic this
35+
// built-in generates, the third argument specifies the type of the function
36+
// (result value, then each argument) as follows:
37+
// i -> Unsigned integer followed by the greatest possible value for that
38+
// argument or 0 if no constraint on the value.
39+
// (e.g. i15 for a 4-bits value)
40+
// V -> Vector type used with MMA built-ins (vector unsigned char)
41+
// W -> PPC Vector type followed by the size of the vector type.
42+
// (e.g. W512 for __vector_quad)
43+
// any other descriptor -> Fall back to generic type descriptor decoding.
44+
// The 'C' suffix can be used as a suffix to specify the const type.
45+
// The '*' suffix can be used as a suffix to specify a pointer to a type.
46+
// The fourth argument is set to true if the built-in accumulates its result
47+
// into its given accumulator.
48+
3049
#ifndef CUSTOM_BUILTIN
3150
#define CUSTOM_BUILTIN(ID, INTR, TYPES, ACCUMULATE, FEATURE) \
3251
TARGET_BUILTIN(__builtin_##ID, "i.", "t", FEATURE)
3352
#endif
3453

54+
// UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have
55+
// the same name as that of the intrinsic they generate, i.e. the
56+
// ID and INTR are the same.
57+
// This avoids repeating the ID and INTR in the macro expression.
3558
#define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE) \
3659
CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
3760

61+
// UNALIASED_CUSTOM_MMA_BUILTIN macro is used for MMA built-ins and its
62+
// corresponding 4 positive/negative multiply and positive/negative accumulate
63+
// built-in with the same ID concated with posfix [nn|np|pn|pp].
64+
// This avoids repeating the TYPES and FEATURE in the macro expression.
65+
// eg.
66+
// UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
67+
// "mma,paired-vector-memops")
68+
// Will generate built-ins:
69+
// * __builtin_mma_xvf16ger2()
70+
// * __builtin_mma_xvf16ger2nn()
71+
// * __builtin_mma_xvf16ger2np()
72+
// * __builtin_mma_xvf16ger2pn()
73+
// * __builtin_mma_xvf16ger2nn()
74+
// All with the same TYPES and FEATURE.
75+
#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE) \
76+
UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE) \
77+
UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE) \
78+
UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE) \
79+
UNALIASED_CUSTOM_BUILTIN(ID##pn, TYPES, true, FEATURE) \
80+
UNALIASED_CUSTOM_BUILTIN(ID##pp, TYPES, true, FEATURE)
81+
3882
// GCC predefined macros to rename builtins, undef them to keep original names.
3983
#if defined(__GNUC__) && !defined(__clang__)
4084
#undef __builtin_vsx_xvnmaddadp
@@ -967,25 +1011,6 @@ BUILTIN(__builtin_setflm, "dd", "")
9671011
// Cache built-ins
9681012
BUILTIN(__builtin_dcbf, "vvC*", "")
9691013

970-
// Built-ins requiring custom code generation.
971-
// Because these built-ins rely on target-dependent types and to avoid pervasive
972-
// change, they are type checked manually in Sema using custom type descriptors.
973-
// The first argument of the CUSTOM_BUILTIN macro is the name of the built-in
974-
// with its prefix, the second argument is the name of the intrinsic this
975-
// built-in generates, the third argument specifies the type of the function
976-
// (result value, then each argument) as follows:
977-
// i -> Unsigned integer followed by the greatest possible value for that
978-
// argument or 0 if no constraint on the value.
979-
// (e.g. i15 for a 4-bits value)
980-
// V -> Vector type used with MMA built-ins (vector unsigned char)
981-
// W -> PPC Vector type followed by the size of the vector type.
982-
// (e.g. W512 for __vector_quad)
983-
// any other descriptor -> Fall back to generic type descriptor decoding.
984-
// The 'C' suffix can be used as a suffix to specify the const type.
985-
// The '*' suffix can be used as a suffix to specify a pointer to a type.
986-
// The fourth argument is set to true if the built-in accumulates its result into
987-
// its given accumulator.
988-
9891014
// Provided builtins with _mma_ prefix for compatibility.
9901015
CUSTOM_BUILTIN(mma_lxvp, vsx_lxvp, "W256SLiW256C*", false,
9911016
"paired-vector-memops")
@@ -999,11 +1024,6 @@ CUSTOM_BUILTIN(vsx_build_pair, vsx_assemble_pair, "vW256*VV", false,
9991024
"paired-vector-memops")
10001025
CUSTOM_BUILTIN(mma_build_acc, mma_assemble_acc, "vW512*VVVV", false, "mma")
10011026

1002-
// UNALIASED_CUSTOM_BUILTIN macro is used for built-ins that have
1003-
// the same name as that of the intrinsic they generate, i.e. the
1004-
// ID and INTR are the same.
1005-
// This avoids repeating the ID and INTR in the macro expression.
1006-
10071027
UNALIASED_CUSTOM_BUILTIN(vsx_lxvp, "W256SLiW256C*", false,
10081028
"paired-vector-memops")
10091029
UNALIASED_CUSTOM_BUILTIN(vsx_stxvp, "vW256SLiW256*", false,
@@ -1032,12 +1052,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", false,
10321052
"mma,paired-vector-memops")
10331053
UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false,
10341054
"mma,paired-vector-memops")
1035-
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false,
1036-
"mma,paired-vector-memops")
1037-
UNALIASED_CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false,
1038-
"mma,paired-vector-memops")
1039-
UNALIASED_CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false,
1040-
"mma,paired-vector-memops")
10411055
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false,
10421056
"mma,paired-vector-memops")
10431057
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false,
@@ -1046,12 +1060,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2, "vW512*VVi15i15i3", false,
10461060
"mma,paired-vector-memops")
10471061
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false,
10481062
"mma,paired-vector-memops")
1049-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false,
1050-
"mma,paired-vector-memops")
1051-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false,
1052-
"mma,paired-vector-memops")
1053-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false,
1054-
"mma,paired-vector-memops")
10551063
UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true,
10561064
"mma,paired-vector-memops")
10571065
UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true,
@@ -1072,74 +1080,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2pp, "vW512*VVi15i15i3", true,
10721080
"mma,paired-vector-memops")
10731081
UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true,
10741082
"mma,paired-vector-memops")
1075-
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true,
1076-
"mma,paired-vector-memops")
1077-
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true,
1078-
"mma,paired-vector-memops")
1079-
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true,
1080-
"mma,paired-vector-memops")
1081-
UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true,
1082-
"mma,paired-vector-memops")
1083-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true,
1084-
"mma,paired-vector-memops")
1085-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true,
1086-
"mma,paired-vector-memops")
1087-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true,
1088-
"mma,paired-vector-memops")
1089-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true,
1090-
"mma,paired-vector-memops")
1091-
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true,
1092-
"mma,paired-vector-memops")
1093-
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true,
1094-
"mma,paired-vector-memops")
1095-
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true,
1096-
"mma,paired-vector-memops")
1097-
UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true,
1098-
"mma,paired-vector-memops")
1099-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true,
1100-
"mma,paired-vector-memops")
1101-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true,
1102-
"mma,paired-vector-memops")
1103-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true,
1104-
"mma,paired-vector-memops")
1105-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernn, "vW512*VVi15i15", true,
1106-
"mma,paired-vector-memops")
1107-
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpp, "vW512*W256V", true,
1108-
"mma,paired-vector-memops")
1109-
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gerpn, "vW512*W256V", true,
1110-
"mma,paired-vector-memops")
1111-
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernp, "vW512*W256V", true,
1112-
"mma,paired-vector-memops")
1113-
UNALIASED_CUSTOM_BUILTIN(mma_xvf64gernn, "vW512*W256V", true,
1114-
"mma,paired-vector-memops")
1115-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpp, "vW512*W256Vi15i3", true,
1116-
"mma,paired-vector-memops")
1117-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gerpn, "vW512*W256Vi15i3", true,
1118-
"mma,paired-vector-memops")
1119-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernp, "vW512*W256Vi15i3", true,
1120-
"mma,paired-vector-memops")
1121-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64gernn, "vW512*W256Vi15i3", true,
1122-
"mma,paired-vector-memops")
1123-
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2, "vW512*VV", false,
1124-
"mma,paired-vector-memops")
1125-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3", false,
1126-
"mma,paired-vector-memops")
1127-
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pp, "vW512*VV", true,
1128-
"mma,paired-vector-memops")
1129-
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2pn, "vW512*VV", true,
1130-
"mma,paired-vector-memops")
1131-
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2np, "vW512*VV", true,
1132-
"mma,paired-vector-memops")
1133-
UNALIASED_CUSTOM_BUILTIN(mma_xvbf16ger2nn, "vW512*VV", true,
1134-
"mma,paired-vector-memops")
1135-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pp, "vW512*VVi15i15i3", true,
1136-
"mma,paired-vector-memops")
1137-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2pn, "vW512*VVi15i15i3", true,
1138-
"mma,paired-vector-memops")
1139-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2np, "vW512*VVi15i15i3", true,
1140-
"mma,paired-vector-memops")
1141-
UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true,
1142-
"mma,paired-vector-memops")
11431083
UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4, "vW1024*W256V", false,
11441084
"mma,paired-vector-memops")
11451085
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4, "vW1024*W256Vi255i15i15", false,
@@ -1148,14 +1088,33 @@ UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4pp, "vW1024*W256V", true,
11481088
"mma,paired-vector-memops")
11491089
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4pp, "vW1024*W256Vi255i15i15", true,
11501090
"mma,paired-vector-memops")
1151-
UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
1091+
UNALIASED_CUSTOM_BUILTIN(mma_dmxvi8gerx4spp, "vW1024*W256V", true,
11521092
"mma,paired-vector-memops")
11531093
UNALIASED_CUSTOM_BUILTIN(mma_pmdmxvi8gerx4spp, "vW1024*W256Vi255i15i15", true,
11541094
"mma,paired-vector-memops")
11551095

1096+
// MMA builtins with positive/negative multiply/accumulate.
1097+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf16ger2, "vW512*VV",
1098+
"mma,paired-vector-memops")
1099+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf32ger, "vW512*VV",
1100+
"mma,paired-vector-memops")
1101+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvf64ger, "vW512*W256V",
1102+
"mma,paired-vector-memops")
1103+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3",
1104+
"mma,paired-vector-memops")
1105+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15",
1106+
"mma,paired-vector-memops")
1107+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3",
1108+
"mma,paired-vector-memops")
1109+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_xvbf16ger2, "vW512*VV",
1110+
"mma,paired-vector-memops")
1111+
UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmxvbf16ger2, "vW512*VVi15i15i3",
1112+
"mma,paired-vector-memops")
1113+
11561114
// FIXME: Obviously incomplete.
11571115

11581116
#undef BUILTIN
11591117
#undef TARGET_BUILTIN
11601118
#undef CUSTOM_BUILTIN
11611119
#undef UNALIASED_CUSTOM_BUILTIN
1120+
#undef UNALIASED_CUSTOM_MMA_BUILTIN

0 commit comments

Comments
 (0)