Skip to content

Commit 2529a8d

Browse files
authored
Mechanically port bulk of x86 builtins to TableGen (llvm#120831)
The goal is to make incremental (if small) progress towards fully TableGen'ed builtins, and to unblock llvm#120534 by gaining access to more powerful TableGen-based representations. The bulk `.td` file addition was generated with the help of a very rough Python script. That script made no attempt to be robust or reusable, it specifically handled only the cases in the X86 `.def` file. Four entries from the `.def` file were not handled automatically as they used `BUILTIN` rather than `TARGET_BUILTIN`. These were ported by hand to an empty-feature `TargetBuiltin` entry, which seems like a better match. For all the automatically ported entries, the results were compared by sorting and diffing the `.def` file and the generated `.inc` file. The only differences were: - Different horizontal whitespace - Additional entries that had already been ported to the `.td` file. - More systematically using `Oi` instead of `LLi` for the type `long long int` in the fully general `__builtin_ia32_...` builtins for OpenCL support. The `.def` file was only partially moved to this it seems, and the systematic migration has updated a few missed builtins.
1 parent fac4646 commit 2529a8d

File tree

6 files changed

+5427
-2239
lines changed

6 files changed

+5427
-2239
lines changed

clang/include/clang/Basic/BuiltinsBase.td

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,15 @@ class Builtin {
8888
// On some platforms, some functions are actually macros. In that case we need
8989
// to #undef them.
9090
bit RequiresUndef = 0;
91+
// Enables builtins to generate `long long` outside of OpenCL and `long` inside.
92+
bit EnableOpenCLLong = 0;
9193
}
9294

9395
class CustomEntry {
9496
string Entry;
9597
}
9698

9799
class AtomicBuiltin : Builtin;
98-
class TargetBuiltin : Builtin {
99-
string Features = "";
100-
}
101100

102101
class LibBuiltin<string header, string languages = "ALL_LANGUAGES"> : Builtin {
103102
string Header = header;
@@ -122,6 +121,14 @@ class OCL_DSELangBuiltin : LangBuiltin<"OCL_DSE">;
122121
class OCL_GASLangBuiltin : LangBuiltin<"OCL_GAS">;
123122
class OCLLangBuiltin : LangBuiltin<"ALL_OCL_LANGUAGES">;
124123

124+
class TargetBuiltin : Builtin {
125+
string Features = "";
126+
}
127+
class TargetLibBuiltin : TargetBuiltin {
128+
string Header;
129+
string Languages = "ALL_LANGUAGES";
130+
}
131+
125132
class Template<list<string> substitutions,
126133
list<string> affixes,
127134
bit as_prefix = 0> {

0 commit comments

Comments
 (0)