[clang] [Clang] Fixes of builtins definitions after PR #68324. (PR #81022)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 7 10:40:11 PST 2024
https://github.com/michele-scandale created https://github.com/llvm/llvm-project/pull/81022
This commit addresses few differences between the `Builtins.def` file before the refactoring done in PR #68324 and the currently generated `Builtins.inc` file.
>From 5122fd9939ce70c3d3f6c841c859af6c78dbd51f Mon Sep 17 00:00:00 2001
From: Michele Scandale <michele.scandale at gmail.com>
Date: Wed, 7 Feb 2024 10:37:53 -0800
Subject: [PATCH] [Clang] Fixes of builtins definitions after PR #68324.
This commit addresses few differences between the `Builtins.def` file
before the refactoring done in PR #68324 and the currently generated
`Builtins.inc` file.
---
clang/include/clang/Basic/Builtins.td | 70 ++++++++++++++++-----------
1 file changed, 43 insertions(+), 27 deletions(-)
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index 31a2bdeb2d3e5e..a228334e069e5b 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -12,13 +12,17 @@ class FPMathTemplate : Template<["float", "double", "long double"],
["f", "", "l"]>;
class FPMathWithF16Template :
- Template<["float", "double", "long double", "__fp16", "__float128"],
- ["f", "", "l", "f16", "f128"]>;
+ Template<["float", "double", "long double", "__fp16"],
+ ["f", "", "l", "f16"]>;
class FPMathWithF16F128Template :
Template<["float", "double", "long double", "__fp16", "__float128"],
["f", "", "l", "f16", "f128"]>;
+class FPMathWithF128Template :
+ Template<["float", "double", "long double", "__float128"],
+ ["f", "", "l", "f128"]>;
+
class F16F128MathTemplate : Template<["__fp16", "__float128"],
["f16", "f128"]>;
@@ -253,18 +257,30 @@ def FrexpF16F128 : F16F128MathTemplate, Builtin {
let Prototype = "T(T, int*)";
}
-def HugeVal : Builtin, FPMathWithF16F128Template {
+def HugeVal : Builtin, FPMathWithF128Template {
let Spellings = ["__builtin_huge_val"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T()";
}
-def Inf : Builtin, FPMathWithF16F128Template {
+def HugeValF16 : Builtin {
+ let Spellings = ["__builtin_huge_valf16"];
+ let Attributes = [NoThrow, Const, Constexpr];
+ let Prototype = "_Float16()";
+}
+
+def Inf : Builtin, FPMathWithF128Template {
let Spellings = ["__builtin_inf"];
let Attributes = [NoThrow, Const, Constexpr];
let Prototype = "T()";
}
+def InfF16 : Builtin {
+ let Spellings = ["__builtin_inff16"];
+ let Attributes = [NoThrow, Const, Constexpr];
+ let Prototype = "_Float16()";
+}
+
def LdexpF16F128 : F16F128MathTemplate, Builtin {
let Spellings = ["__builtin_ldexp"];
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
@@ -1538,7 +1554,7 @@ def SyncBoolCompareAndSwap : Builtin {
def SyncBoolCompareAndSwapN : Builtin, SyncBuiltinsTemplate {
let Spellings = ["__sync_bool_compare_and_swap_"];
let Attributes = [CustomTypeChecking, NoThrow];
- let Prototype = "T(T volatile*, T, ...)";
+ let Prototype = "bool(T volatile*, T, T, ...)";
}
def SyncValCompareAndSwap : Builtin {
@@ -1550,7 +1566,7 @@ def SyncValCompareAndSwap : Builtin {
def SynLockValCompareAndSwapN : Builtin, SyncBuiltinsTemplate {
let Spellings = ["__sync_val_compare_and_swap_"];
let Attributes = [CustomTypeChecking, NoThrow];
- let Prototype = "T(T volatile*, T, ...)";
+ let Prototype = "T(T volatile*, T, T, ...)";
}
def SyncLockTestAndSet : Builtin {
@@ -1565,16 +1581,16 @@ def SynLockLockTestAndSetN : Builtin, SyncBuiltinsTemplate {
let Prototype = "T(T volatile*, T, ...)";
}
-def SyncLockReleaseN : Builtin {
+def SyncLockRelease : Builtin {
let Spellings = ["__sync_lock_release"];
let Attributes = [CustomTypeChecking];
let Prototype = "void(...)";
}
-def SynLockReleaseN : Builtin, SyncBuiltinsTemplate {
+def SyncLockReleaseN : Builtin, SyncBuiltinsTemplate {
let Spellings = ["__sync_lock_release_"];
let Attributes = [CustomTypeChecking, NoThrow];
- let Prototype = "T(T volatile*, T, ...)";
+ let Prototype = "void(T volatile*, ...)";
}
def SyncSwap : Builtin {
@@ -2557,6 +2573,13 @@ def Abort : LibBuiltin<"stdlib.h"> {
let AddBuiltinPrefixedAlias = 1;
}
+def Abs : IntMathTemplate, LibBuiltin<"stdlib.h"> {
+ let Spellings = ["abs"];
+ let Attributes = [NoThrow, Const];
+ let Prototype = "T(T)";
+ let AddBuiltinPrefixedAlias = 1;
+}
+
def Calloc : LibBuiltin<"stdlib.h"> {
let Spellings = ["calloc"];
let Prototype = "void*(size_t, size_t)";
@@ -3073,38 +3096,38 @@ def MemAlign : GNULibBuiltin<"malloc.h"> {
// POSIX string.h
-def MemcCpy : GNULibBuiltin<"stdlib.h"> {
+def MemcCpy : GNULibBuiltin<"string.h"> {
let Spellings = ["memccpy"];
let Prototype = "void*(void*, void const*, int, size_t)";
}
-def MempCpy : GNULibBuiltin<"stdlib.h"> {
+def MempCpy : GNULibBuiltin<"string.h"> {
let Spellings = ["mempcpy"];
let Prototype = "void*(void*, void const*, size_t)";
}
-def StpCpy : GNULibBuiltin<"stdlib.h"> {
+def StpCpy : GNULibBuiltin<"string.h"> {
let Spellings = ["stpcpy"];
let Attributes = [NoThrow];
let Prototype = "char*(char*, char const*)";
let AddBuiltinPrefixedAlias = 1;
}
-def StpnCpy : GNULibBuiltin<"stdlib.h"> {
+def StpnCpy : GNULibBuiltin<"string.h"> {
let Spellings = ["stpncpy"];
let Attributes = [NoThrow];
let Prototype = "char*(char*, char const*, size_t)";
let AddBuiltinPrefixedAlias = 1;
}
-def StrDup : GNULibBuiltin<"stdlib.h"> {
+def StrDup : GNULibBuiltin<"string.h"> {
let Spellings = ["strdup"];
let Attributes = [NoThrow];
let Prototype = "char*(char const*)";
let AddBuiltinPrefixedAlias = 1;
}
-def StrnDup : GNULibBuiltin<"stdlib.h"> {
+def StrnDup : GNULibBuiltin<"string.h"> {
let Spellings = ["strndup"];
let Attributes = [NoThrow];
let Prototype = "char*(char const*, size_t)";
@@ -3274,22 +3297,22 @@ def ObjcEnumerationMutation : ObjCLibBuiltin<"objc/runtime.h"> {
let Prototype = "void(id)";
}
-def ObjcReadWeak : ObjCLibBuiltin<"objc/message.h"> {
+def ObjcReadWeak : ObjCLibBuiltin<"objc/objc-auto.h"> {
let Spellings = ["objc_read_weak"];
let Prototype = "id(id*)";
}
-def ObjcAssignWeak : ObjCLibBuiltin<"objc/message.h"> {
+def ObjcAssignWeak : ObjCLibBuiltin<"objc/objc-auto.h"> {
let Spellings = ["objc_assign_weak"];
let Prototype = "id(id, id*)";
}
-def ObjcAssignIvar : ObjCLibBuiltin<"objc/message.h"> {
+def ObjcAssignIvar : ObjCLibBuiltin<"objc/objc-auto.h"> {
let Spellings = ["objc_assign_ivar"];
let Prototype = "id(id, id, ptrdiff_t)";
}
-def ObjcAssignGlobal : ObjCLibBuiltin<"objc/message.h"> {
+def ObjcAssignGlobal : ObjCLibBuiltin<"objc/objc-auto.h"> {
let Spellings = ["objc_assign_global"];
let Prototype = "id(id, id*)";
}
@@ -3359,13 +3382,6 @@ def Atan2 : FPMathTemplate, LibBuiltin<"math.h"> {
let AddBuiltinPrefixedAlias = 1;
}
-def Abs : IntMathTemplate, LibBuiltin<"math.h"> {
- let Spellings = ["abs"];
- let Attributes = [NoThrow, Const];
- let Prototype = "T(T)";
- let AddBuiltinPrefixedAlias = 1;
-}
-
def Copysign : FPMathTemplate, LibBuiltin<"math.h"> {
let Spellings = ["copysign"];
let Attributes = [NoThrow, Const];
@@ -4024,7 +4040,7 @@ def Move : CxxLibBuiltin<"utility"> {
let Namespace = "std";
}
-def MoveIfNsoexcept : CxxLibBuiltin<"memory"> {
+def MoveIfNsoexcept : CxxLibBuiltin<"utility"> {
let Spellings = ["move_if_noexcept"];
let Attributes = [NoThrow, Const, IgnoreSignature, RequireDeclaration,
Constexpr];
More information about the cfe-commits
mailing list