[clang-tools-extra] [clang] [llvm] [clang] Refactor Builtins.def to be a tablegen file (PR #68324)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 30 14:06:39 PST 2024
================
@@ -0,0 +1,4537 @@
+//===--- Builtins.td - Builtins function info database-----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+include "clang/Basic/BuiltinsBase.td"
+
+class FPMathTemplate : Template<["float", "double", "long double"],
+ ["f", "", "l"]>;
+
+class FPMathWithF16Template :
+ Template<["float", "double", "long double", "__fp16", "__float128"],
+ ["f", "", "l", "f16", "f128"]>;
+
+class FPMathWithF16F128Template :
+ Template<["float", "double", "long double", "__fp16", "__float128"],
+ ["f", "", "l", "f16", "f128"]>;
+
+class F16F128MathTemplate : Template<["__fp16", "__float128"],
+ ["f16", "f128"]>;
+
+class IntMathTemplate : Template<["int", "long int", "long long int"],
+ ["", "l", "ll"], /*AsPrefix=*/1>;
+
+class MSInt8_16_32Template : Template<["char", "short", "msint32_t"],
+ ["8", "16", ""]>;
+
+class Int8_16_32_64Template
+ : Template<["char", "short", "int", "long long int"],
+ ["8", "16", "32", "64"]>;
+
+class MSInt8_16_32_64Template
+ : Template<["char", "short", "msint32_t", "long long int"],
+ ["8", "16", "", "64"]>;
+
+class MSInt16_32Template : Template<["short", "msint32_t"],
+ ["16", ""]>;
+
+class MSUInt16_32_64Template :
+ Template<["unsigned short", "unsigned int", "uint64_t"],
+ ["16", "", "64"]>;
+
+class MSInt32_64Template : Template<["msint32_t", "int64_t"],
+ ["", "64"]>;
+
+class FloatDoubleTemplate : Template<["float", "double"],
+ ["f", ""]>;
+
+// FIXME: These assume that char -> i8, short -> i16, int -> i32,
+// long long -> i64.
+class SyncBuiltinsTemplate :
+ Template<["char", "short", "int", "long long int", "__int128_t"],
+ ["1", "2", "4", "8", "16"]>;
+
+class BitInt8_16_32_64BuiltinsTemplate :
+ Template<["unsigned char", "unsigned short", "uint32_t", "uint64_t"],
+ ["8", "16", "32", "64"]>;
+
+class BitShort_Int_Long_LongLongTemplate :
+ Template<["short", "int", "long int", "long long int"],
+ ["s", "", "l", "ll"]>;
+
+class BitInt_Long_LongLongTemplate :
+ Template<["int", "long int", "long long int"],
+ ["", "l", "ll"]>;
+
+// Most of the types used in the prototypes are types from C, C++ or ObjC. There
+// are a few builtin-specific types and qualifiers.
+//
+// builtin-specific types:
+// - __builtin_va_list: This is the internal representation for va_lists
+// - __builtin_va_list_ref: A reference-like type to __builtin_va_list
+// - msint32_t: 'int' size if target is LP64, 'L' otherwise.
+//
+// builtin-specific qualifiers:
+// - _Constant: Argument has to constant-fold to an integer constant expression
+
+// __fp16 and __float128 builtin variants of libc/libm functions.
+def AcosF128 : Builtin {
+ let Spellings = ["__builtin_acosf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def AcoshF128 : Builtin {
+ let Spellings = ["__builtin_acoshf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def AsinF128 : Builtin {
+ let Spellings = ["__builtin_asinf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def AsinhF128 : Builtin {
+ let Spellings = ["__builtin_asinhf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def AtanF128 : Builtin {
+ let Spellings = ["__builtin_atanf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def AtanhF128 : Builtin {
+ let Spellings = ["__builtin_atanhf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
+ ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def CbrtF128 : Builtin {
+ let Spellings = ["__builtin_cbrtf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
+ let Prototype = "__float128(__float128)";
+}
+
+def CeilF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_ceil"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
+ let Prototype = "T(T)";
+}
+
+def CosF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_cos"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "T(T)";
+}
+
+def CoshF128 : Builtin {
+ let Spellings = ["__builtin_coshf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def ErfF128 : Builtin {
+ let Spellings = ["__builtin_erff128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def ErfcF128 : Builtin {
+ let Spellings = ["__builtin_erfcf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def ExpF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_exp"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "T(T)";
+}
+
+def Exp2F16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_exp2"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "T(T)";
+}
+
+def Exp10F16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_exp10"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "T(T)";
+}
+
+def Expm1F128 : Builtin {
+ let Spellings = ["__builtin_expm1f128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128)";
+}
+
+def FdimF128 : Builtin {
+ let Spellings = ["__builtin_fdimf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128, __float128)";
+}
+
+def FloorF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_floor"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
+ let Prototype = "T(T)";
+}
+
+def FmaF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_fma"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "T(T, T, T)";
+}
+
+def FmaxF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_fmax"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+ let Prototype = "T(T, T)";
+}
+
+def FminF16F128 : Builtin, F16F128MathTemplate {
+ let Spellings = ["__builtin_fmin"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+ let Prototype = "T(T, T)";
+}
+
+def Atan2F128 : Builtin {
+ let Spellings = ["__builtin_atan2f128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "__float128(__float128, __float128)";
+}
+
+def CopysignF16 : Builtin {
+ let Spellings = ["__builtin_copysignf16"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
+ let Prototype = "__fp16(__fp16, __fp16)";
+}
+
+def CopysignF128 : Builtin {
+ let Spellings = ["__builtin_copysignf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+ let Prototype = "__float128(__float128, __float128)";
+}
+
+def FabsF16 : Builtin {
+ let Spellings = ["__builtin_fabsf16"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const];
+ let Prototype = "__fp16(__fp16)";
+}
+
+def FabsF128 : Builtin {
+ let Spellings = ["__builtin_fabsf128"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
+ let Prototype = "__float128(__float128)";
+}
+
+def FmodF16F128 : F16F128MathTemplate, Builtin {
+ let Spellings = ["__builtin_fmod"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
+ let Prototype = "T(T, T)";
+}
+
+def FrexpF16F128 : F16F128MathTemplate, Builtin {
+ let Spellings = ["__builtin_frexp"];
+ let Attributes = [FunctionWithBuiltinPrefix, NoThrow];
+ let Prototype = "T(T, int*)";
+}
+
+def HugeVal : Builtin, FPMathWithF16F128Template {
+ let Spellings = ["__builtin_huge_val"];
+ let Attributes = [NoThrow, Const, Constexpr];
+ let Prototype = "T()";
+}
+
+def Inf : Builtin, FPMathWithF16F128Template {
----------------
michele-scandale wrote:
Before this change there was
```
BUILTIN(__builtin_inff16 , "x" , "ncE")
```
which means that the `f16` variant was using `_Float16` rather than `__fp16`.
Is this change intended?
https://github.com/llvm/llvm-project/pull/68324
More information about the cfe-commits
mailing list