[libc-commits] [libc] ba24ba7 - [libc] Add LLVM libc specific functions to llvm_libc_ext.td.

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Oct 19 11:21:32 PDT 2020


Author: Michael Jones
Date: 2020-10-19T18:21:25Z
New Revision: ba24ba7e9c727793bdd760ed4e48d15e8b2712a2

URL: https://github.com/llvm/llvm-project/commit/ba24ba7e9c727793bdd760ed4e48d15e8b2712a2
DIFF: https://github.com/llvm/llvm-project/commit/ba24ba7e9c727793bdd760ed4e48d15e8b2712a2.diff

LOG: [libc] Add LLVM libc specific functions to llvm_libc_ext.td.

Also moved most of the common type definitions from libc/spec/stdc.td
to libc/spec/spec.td so that they can be used to list functions in llvm_libc_ext.td.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D89436

Added: 
    

Modified: 
    libc/spec/llvm_libc_ext.td
    libc/spec/spec.td
    libc/spec/stdc.td

Removed: 
    


################################################################################
diff  --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td
index d8a2b8bdc97b..a70eb18dd61b 100644
--- a/libc/spec/llvm_libc_ext.td
+++ b/libc/spec/llvm_libc_ext.td
@@ -14,7 +14,42 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
       ]
   >;
 
+  HeaderSpec Assert = HeaderSpec<
+      "assert.h",
+      [], // Macros
+      [], // Types
+      [], // Enumerations
+      [
+          FunctionSpec<
+              "__assert_fail",
+              RetValSpec<NoReturn>,
+              [ArgSpec<ConstCharPtr>,
+               ArgSpec<ConstCharPtr>,
+               ArgSpec<UnsignedType>,
+               ArgSpec<ConstCharPtr>,]
+
+          >,
+      ]
+  >;
+
+  HeaderSpec Errno = HeaderSpec<
+      "errno.h",
+      [], // Macros
+      [], // Types
+      [], // Enumerations
+      [
+          FunctionSpec<
+              "__errno_location",
+              RetValSpec<IntPtr>,
+              [ArgSpec<VoidType>]
+
+          >,
+      ]
+  >;
+
   let Headers = [
     String,
+    Assert,
+    Errno,
   ];
 }

diff  --git a/libc/spec/spec.td b/libc/spec/spec.td
index bfbeb6a6fe3d..35d51e206b09 100644
--- a/libc/spec/spec.td
+++ b/libc/spec/spec.td
@@ -48,12 +48,41 @@ def CharType : NamedType<"char">;
 def VoidPtr : PtrType<VoidType>;
 def ConstVoidPtr : ConstType<VoidPtr>;
 def SizeTType : NamedType<"size_t">;
-def FloatPtr : PtrType<FloatType>;
 def LongDoublePtr : PtrType<LongDoubleType>;
 
 // _Noreturn is really not a type, but it is convenient to treat it as a type.
 def NoReturn : NamedType<"_Noreturn void">;
 
+//types moved from stdc.td
+def VoidRestrictedPtr : RestrictedPtrType<VoidType>;
+def ConstVoidRestrictedPtr : ConstType<VoidRestrictedPtr>;
+
+def CharPtr : PtrType<CharType>;
+def ConstCharPtr : ConstType<CharPtr>;
+def CharRestrictedPtr : RestrictedPtrType<CharType>;
+def ConstCharRestrictedPtr : ConstType<CharRestrictedPtr>;
+
+def OnceFlagType : NamedType<"once_flag">;
+def OnceFlagTypePtr : PtrType<OnceFlagType>;
+// TODO(sivachandra): Remove this non-standard type when a formal
+// way to describe callable types is available.
+def CallOnceFuncType : NamedType<"__call_once_func_t">;
+def MtxTType : NamedType<"mtx_t">;
+def MtxTTypePtr : PtrType<MtxTType>;
+def ThrdStartTType : NamedType<"thrd_start_t">;
+def ThrdTType : NamedType<"thrd_t">;
+def ThrdTTypePtr : PtrType<ThrdTType>;
+
+def IntPtr : PtrType<IntType>;
+def FloatPtr : PtrType<FloatType>;
+def DoublePtr : PtrType<DoubleType>;
+
+def SigHandlerT : NamedType<"__sighandler_t">;
+
+//added because __assert_fail needs it.
+def UnsignedType : NamedType<"unsigned">;
+
+
 class Macro<string name> {
   string Name = name;
 }

diff  --git a/libc/spec/stdc.td b/libc/spec/stdc.td
index 61b3dcb24ef0..7d082d28b0eb 100644
--- a/libc/spec/stdc.td
+++ b/libc/spec/stdc.td
@@ -1,29 +1,4 @@
 def StdC : StandardSpec<"stdc"> {
-  ConstType ConstVoidPtr = ConstType<VoidPtr>;
-  RestrictedPtrType VoidRestrictedPtr = RestrictedPtrType<VoidType>;
-  ConstType ConstVoidRestrictedPtr = ConstType<VoidRestrictedPtr>;
-
-  PtrType CharPtr = PtrType<CharType>;
-  ConstType ConstCharPtr = ConstType<CharPtr>;
-  RestrictedPtrType CharRestrictedPtr = RestrictedPtrType<CharType>;
-  ConstType ConstCharRestrictedPtr = ConstType<CharRestrictedPtr>;
-
-  NamedType OnceFlagType = NamedType<"once_flag">;
-  PtrType OnceFlagTypePtr = PtrType<OnceFlagType>;
-  // TODO(sivachandra): Remove this non-standard type when a formal
-  // way to describe callable types is available.
-  NamedType CallOnceFuncType = NamedType<"__call_once_func_t">;
-  NamedType MtxTType = NamedType<"mtx_t">;
-  PtrType MtxTTypePtr = PtrType<MtxTType>;
-  NamedType ThrdStartTType = NamedType<"thrd_start_t">;
-  NamedType ThrdTType = NamedType<"thrd_t">;
-  PtrType ThrdTTypePtr = PtrType<ThrdTType>;
-
-  PtrType IntPtr = PtrType<IntType>;
-  PtrType FloatPtr = PtrType<FloatType>;
-  PtrType DoublePtr = PtrType<DoubleType>;
-
-  NamedType SigHandlerT = NamedType<"__sighandler_t">;
 
   NamedType FILE = NamedType<"FILE">;
   PtrType FILEPtr = PtrType<FILE>;


        


More information about the libc-commits mailing list