[clang] [Clang] Fixes of builtin definitions after PR #68324. (PR #81022)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 4 10:23:54 PST 2024
https://github.com/michele-scandale updated https://github.com/llvm/llvm-project/pull/81022
>From 016d9f113b891abd18a831f30440c77420c79bbc Mon Sep 17 00:00:00 2001
From: Michele Scandale <michele.scandale at gmail.com>
Date: Mon, 4 Mar 2024 10:23:26 -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 | 80 +++++++++++++++--------
clang/include/clang/Basic/BuiltinsBase.td | 2 +
2 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index 2c83dca248fb7d..384442e6a9359b 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];
@@ -1550,7 +1566,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 {
@@ -1562,7 +1578,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 {
@@ -1577,16 +1593,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 {
@@ -2569,6 +2585,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)";
@@ -3085,38 +3108,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)";
@@ -3286,22 +3309,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*)";
}
@@ -3371,13 +3394,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];
@@ -3996,8 +4012,16 @@ def BlockObjectDispose : LibBuiltin<"blocks.h"> {
}
// FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
+def __Addressof : LangBuiltin<"CXX_LANG"> {
+ let Spellings = ["__addressof"];
+ let Attributes = [FunctionWithoutBuiltinPrefix, NoThrow, Const,
+ IgnoreSignature, Constexpr];
+ let Prototype = "void*(void&)";
+ let Namespace = "std";
+}
+
def Addressof : CxxLibBuiltin<"memory"> {
- let Spellings = ["addressof", "__addressof"];
+ let Spellings = ["addressof"];
let Attributes = [NoThrow, Const, IgnoreSignature, RequireDeclaration,
Constexpr];
let Prototype = "void*(void&)";
@@ -4036,7 +4060,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];
diff --git a/clang/include/clang/Basic/BuiltinsBase.td b/clang/include/clang/Basic/BuiltinsBase.td
index bfccff5600ddb3..724747ec76d732 100644
--- a/clang/include/clang/Basic/BuiltinsBase.td
+++ b/clang/include/clang/Basic/BuiltinsBase.td
@@ -49,6 +49,8 @@ def UnevaluatedArguments : Attribute<"u">;
// is required for a builtin.
def FunctionWithBuiltinPrefix : Attribute<"F">;
+def FunctionWithoutBuiltinPrefix : Attribute<"f">;
+
// const, but only when -fno-math-errno and FP exceptions are ignored.
def ConstIgnoringErrnoAndExceptions : Attribute<"e">;
More information about the cfe-commits
mailing list