From 9e0e0abcb4b3a6614a592b0924b164385b1a3c41 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Thu, 21 Nov 2024 11:26:40 -0800 Subject: [PATCH 1/5] [libc] delete hdrgen Thanks to the effort of @RoseZhang03 and @aaryanshukla under the guidance of @michaelrj-google and @amykhuang, we now have newhdrgen and no longer have a dependency on TableGen and thus LLVM in order to start bootstrapping a full build. This PR removes: - LIBC_HDRGEN_EXE; the in tree newhdrgen is the only hdrgen that can be used. - LIBC_USE_NEW_HEADER_GEN; newhdrgen is the default and only option. - LIBC_HDRGEN_ONLY; there is no need to have a distinct build step for old hdrgen. - libc-api-test and libc-api-test-tidy build targets. - Deletes all .td files. It does not rename newhdrgen to just hdrgen. Will follow up with a distinct PR for that. Link: #117209 Fixes: #117208 --- libc/CMakeLists.txt | 18 +- libc/cmake/modules/LLVMLibCHeaderRules.cmake | 33 - libc/config/baremetal/api.td | 59 - libc/config/gpu/api.td | 50 - libc/config/linux/api.td | 276 --- libc/config/public_api.td | 26 - libc/docs/dev/header_generation.rst | 3 - libc/docs/gpu/building.rst | 13 +- libc/include/CMakeLists.txt | 26 +- libc/spec/bsd_ext.td | 87 - libc/spec/gnu_ext.td | 316 --- libc/spec/gpu_ext.td | 18 - libc/spec/linux.td | 328 --- libc/spec/llvm_libc_ext.td | 116 - libc/spec/llvm_libc_stdfix_ext.td | 27 - libc/spec/posix.td | 1867 ----------------- libc/spec/spec.td | 253 --- libc/spec/stdc.td | 1819 ---------------- libc/spec/stdc_ext.td | 82 - libc/test/src/CMakeLists.txt | 78 - libc/utils/HdrGen/CMakeLists.txt | 22 - libc/utils/HdrGen/Command.cpp | 15 - libc/utils/HdrGen/Command.h | 54 - libc/utils/HdrGen/Generator.cpp | 203 -- libc/utils/HdrGen/Generator.h | 60 - libc/utils/HdrGen/IncludeFileCommand.cpp | 50 - libc/utils/HdrGen/IncludeFileCommand.h | 32 - libc/utils/HdrGen/Main.cpp | 62 - .../HdrGen/PrototypeTestGen/CMakeLists.txt | 5 - .../PrototypeTestGen/PrototypeTestGen.cpp | 106 - libc/utils/HdrGen/PublicAPICommand.cpp | 331 --- libc/utils/HdrGen/PublicAPICommand.h | 48 - libc/utils/HdrGen/README.md | 5 - libc/utils/LibcTableGenUtil/APIIndexer.cpp | 173 -- libc/utils/LibcTableGenUtil/APIIndexer.h | 86 - libc/utils/LibcTableGenUtil/CMakeLists.txt | 13 - 36 files changed, 13 insertions(+), 6747 deletions(-) delete mode 100644 libc/config/baremetal/api.td delete mode 100644 libc/config/gpu/api.td delete mode 100644 libc/config/linux/api.td delete mode 100644 libc/config/public_api.td delete mode 100644 libc/spec/bsd_ext.td delete mode 100644 libc/spec/gnu_ext.td delete mode 100644 libc/spec/gpu_ext.td delete mode 100644 libc/spec/linux.td delete mode 100644 libc/spec/llvm_libc_ext.td delete mode 100644 libc/spec/llvm_libc_stdfix_ext.td delete mode 100644 libc/spec/posix.td delete mode 100644 libc/spec/spec.td delete mode 100644 libc/spec/stdc.td delete mode 100644 libc/spec/stdc_ext.td delete mode 100644 libc/utils/HdrGen/CMakeLists.txt delete mode 100644 libc/utils/HdrGen/Command.cpp delete mode 100644 libc/utils/HdrGen/Command.h delete mode 100644 libc/utils/HdrGen/Generator.cpp delete mode 100644 libc/utils/HdrGen/Generator.h delete mode 100644 libc/utils/HdrGen/IncludeFileCommand.cpp delete mode 100644 libc/utils/HdrGen/IncludeFileCommand.h delete mode 100644 libc/utils/HdrGen/Main.cpp delete mode 100644 libc/utils/HdrGen/PrototypeTestGen/CMakeLists.txt delete mode 100644 libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp delete mode 100644 libc/utils/HdrGen/PublicAPICommand.cpp delete mode 100644 libc/utils/HdrGen/PublicAPICommand.h delete mode 100644 libc/utils/HdrGen/README.md delete mode 100644 libc/utils/LibcTableGenUtil/APIIndexer.cpp delete mode 100644 libc/utils/LibcTableGenUtil/APIIndexer.h delete mode 100644 libc/utils/LibcTableGenUtil/CMakeLists.txt diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 77b659b2ef2322..d00888b8801dc5 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -54,27 +54,12 @@ set(LIBC_NAMESPACE ${default_namespace} add_subdirectory(newhdrgen) -if(LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD) - if(NOT LIBC_HDRGEN_EXE) - # We need to set up hdrgen first since other targets depend on it. - add_subdirectory(utils/LibcTableGenUtil) - add_subdirectory(utils/HdrGen) - # Calling add_tablegen sets variables like LIBC_TABLEGEN_EXE in - # PARENT_SCOPE which get lost until saved in the cache. - set(LIBC_TABLEGEN_EXE "${LIBC_TABLEGEN_EXE}" CACHE INTERNAL "") - set(LIBC_TABLEGEN_TARGET "${LIBC_TABLEGEN_TARGET}" CACHE INTERNAL "") - else() - message(STATUS "Will use ${LIBC_HDRGEN_EXE} for libc header generation.") - endif() -endif() # We will build the GPU utilities if we are not doing a runtimes build. option(LIBC_BUILD_GPU_LOADER "Always build the GPU loader utilities" OFF) if(LIBC_BUILD_GPU_LOADER OR (LLVM_LIBC_GPU_BUILD AND NOT LLVM_RUNTIMES_BUILD)) add_subdirectory(utils/gpu) endif() -option(LIBC_USE_NEW_HEADER_GEN "Generate header files using new headergen instead of the old one" ON) - set(NEED_LIBC_HDRGEN FALSE) if(NOT LLVM_RUNTIMES_BUILD) if("libc" IN_LIST LLVM_ENABLE_RUNTIMES) @@ -88,8 +73,7 @@ if(NOT LLVM_RUNTIMES_BUILD) endforeach() endif() endif() -option(LIBC_HDRGEN_ONLY "Only build the 'libc-hdrgen' executable" OFF) -if(LIBC_HDRGEN_ONLY OR NEED_LIBC_HDRGEN) +if(NEED_LIBC_HDRGEN) # When libc is build as part of the runtimes/bootstrap build's CMake run, we # only need to build the host tools to build the libc. So, we just do enough # to build libc-hdrgen and return. diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake index 76c4e1f2d3244c..766225cbeab404 100644 --- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake +++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake @@ -220,46 +220,13 @@ function(add_gen_header target_name) set(gen_hdr_script "${LIBC_BUILD_SCRIPTS_DIR}/gen_hdr.py") - file(GLOB td_includes ${LIBC_SOURCE_DIR}/spec/*.td) - set(ENTRYPOINT_NAME_LIST_ARG ${TARGET_ENTRYPOINT_NAME_LIST}) list(TRANSFORM ENTRYPOINT_NAME_LIST_ARG PREPEND "--e=") - if(LIBC_HDRGEN_EXE) - set(hdrgen_exe ${LIBC_HDRGEN_EXE}) - else() - set(hdrgen_exe ${LIBC_TABLEGEN_EXE}) - set(hdrgen_deps "${LIBC_TABLEGEN_EXE};${LIBC_TABLEGEN_TARGET}") - endif() - add_custom_command( - OUTPUT ${out_file} - COMMAND ${hdrgen_exe} -o ${out_file} --header ${ADD_GEN_HDR_GEN_HDR} - --def ${in_file} ${replacement_params} -I ${LIBC_SOURCE_DIR} - ${ENTRYPOINT_NAME_LIST_ARG} - ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td - - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${in_file} ${fq_data_files} ${td_includes} - ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td - ${hdrgen_deps} - ) - if(LIBC_TARGET_OS_IS_GPU) file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls) file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls/gpu) set(decl_out_file ${LIBC_INCLUDE_DIR}/llvm-libc-decls/${relative_path}) - add_custom_command( - OUTPUT ${decl_out_file} - COMMAND ${hdrgen_exe} -o ${decl_out_file} - --header ${ADD_GEN_HDR_GEN_HDR} --def ${in_file} --export-decls - ${replacement_params} -I ${LIBC_SOURCE_DIR} ${ENTRYPOINT_NAME_LIST_ARG} - ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td - - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${in_file} ${fq_data_files} ${td_includes} - ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td - ${hdrgen_deps} - ) endif() if(ADD_GEN_HDR_DEPENDS) diff --git a/libc/config/baremetal/api.td b/libc/config/baremetal/api.td deleted file mode 100644 index 7421d86fabeb08..00000000000000 --- a/libc/config/baremetal/api.td +++ /dev/null @@ -1,59 +0,0 @@ -include "config/public_api.td" - -include "spec/stdc.td" -include "spec/stdc_ext.td" -include "spec/bsd_ext.td" -include "spec/llvm_libc_stdfix_ext.td" - - -def CTypeAPI : PublicAPI<"ctype.h"> { -} - -def FEnvAPI : PublicAPI<"fenv.h"> { - let Types = ["fenv_t", "fexcept_t"]; -} - -def IntTypesAPI : PublicAPI<"inttypes.h"> { - let Types = ["imaxdiv_t"]; -} - -def MathAPI : PublicAPI<"math.h"> { - let Types = ["double_t", "float_t"]; -} - -def StdIOAPI : PublicAPI<"stdio.h"> { - let Types = ["size_t"]; -} - -def StdlibAPI : PublicAPI<"stdlib.h"> { - let Types = [ - "div_t", - "ldiv_t", - "lldiv_t", - "size_t", - "__bsearchcompare_t", - "__qsortcompare_t", - ]; -} - -def StringAPI : PublicAPI<"string.h"> { - let Types = ["size_t"]; -} - -def TimeAPI : PublicAPI<"time.h"> { - let Types = [ - "clock_t", - "time_t", - "struct tm", - "struct timespec", - ]; -} - -def UCharAPI : PublicAPI<"uchar.h"> { - let Types = [ - "mbstate_t", - "char8_t", - "char16_t", - "char32_t", - ]; -} diff --git a/libc/config/gpu/api.td b/libc/config/gpu/api.td deleted file mode 100644 index 995ff31c4ac9e9..00000000000000 --- a/libc/config/gpu/api.td +++ /dev/null @@ -1,50 +0,0 @@ -include "config/public_api.td" - -include "spec/stdc.td" -include "spec/posix.td" -include "spec/gpu_ext.td" -include "spec/gnu_ext.td" -include "spec/stdc_ext.td" -include "spec/llvm_libc_ext.td" - - -def StringAPI : PublicAPI<"string.h"> { - let Types = ["size_t"]; -} - -def StdlibAPI : PublicAPI<"stdlib.h"> { - let Types = [ - "div_t", - "ldiv_t", - "lldiv_t", - "size_t", - "__bsearchcompare_t", - "__qsortcompare_t", - "__qsortrcompare_t", - "__atexithandler_t", - ]; -} - -def FenvAPI: PublicAPI<"fenv.h"> { - let Types = ["fenv_t"]; -} - -def StdIOAPI : PublicAPI<"stdio.h"> { - let Types = [ - "FILE", - "off_t", - "size_t", - ]; -} - -def IntTypesAPI : PublicAPI<"inttypes.h"> { - let Types = ["imaxdiv_t"]; -} - -def TimeAPI : PublicAPI<"time.h"> { - let Types = [ - "clock_t", - "time_t", - "struct timespec", - ]; -} diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td deleted file mode 100644 index a00e0f61b90df7..00000000000000 --- a/libc/config/linux/api.td +++ /dev/null @@ -1,276 +0,0 @@ -include "config/public_api.td" - -include "spec/stdc.td" -include "spec/posix.td" -include "spec/linux.td" -include "spec/gnu_ext.td" -include "spec/bsd_ext.td" -include "spec/stdc_ext.td" -include "spec/llvm_libc_ext.td" -include "spec/llvm_libc_stdfix_ext.td" - -def CTypeAPI : PublicAPI<"ctype.h"> { -} - -def FCntlAPI : PublicAPI<"fcntl.h"> { - let Types = [ - "mode_t", - "off_t", - ]; -} - -def IntTypesAPI : PublicAPI<"inttypes.h"> { - let Types = ["imaxdiv_t"]; -} - -def MathAPI : PublicAPI<"math.h"> { - let Types = ["double_t", "float_t", "float128"]; -} - -def FenvAPI: PublicAPI<"fenv.h"> { - let Types = ["fenv_t", "fexcept_t"]; -} - -def StringAPI : PublicAPI<"string.h"> { - let Types = ["size_t"]; -} - -def StdIOAPI : PublicAPI<"stdio.h"> { - let Macros = [ - SimpleMacroDef<"stderr", "stderr">, - SimpleMacroDef<"stdin", "stdin">, - SimpleMacroDef<"stdout", "stdout">, - ]; - let Types = [ - "FILE", - "cookie_io_functions_t", - "off_t", - "size_t", - ]; -} - -def StdlibAPI : PublicAPI<"stdlib.h"> { - let Types = [ - "div_t", - "ldiv_t", - "lldiv_t", - "size_t", - "__bsearchcompare_t", - "__qsortcompare_t", - "__qsortrcompare_t", - "__atexithandler_t", - ]; -} - -def TimeAPI : PublicAPI<"time.h"> { - let Types = [ - "clock_t", - "time_t", - "struct tm", - "struct timespec", - "struct timeval", - "clockid_t", - ]; -} - -def SchedAPI : PublicAPI<"sched.h"> { - let Types = [ - "pid_t", - "size_t", - "cpu_set_t", - "struct sched_param", - // Needed according to posix standard - "time_t", - "struct timespec", - ]; -} - -def SysMManAPI : PublicAPI<"sys/mman.h"> { - let Types = ["off_t", "size_t", "mode_t"]; -} - -def SignalAPI : PublicAPI<"signal.h"> { - let Types = [ - "sig_atomic_t", - "sigset_t", - "struct sigaction", - "union sigval", - "siginfo_t", - "stack_t", - "pid_t", - ]; -} - -def ThreadsAPI : PublicAPI<"threads.h"> { - let Macros = [ - SimpleMacroDef<"ONCE_FLAG_INIT", "{0}">, - ]; - - let Types = [ - "__call_once_func_t", - "once_flag", - "cnd_t", - "mtx_t", - "thrd_t", - "thrd_start_t", - "tss_t", - "tss_dtor_t", - ]; - - let Enumerations = [ - "mtx_plain", - "mtx_recursive", - "mtx_timed", - "thrd_timedout", - "thrd_success", - "thrd_busy", - "thrd_error", - "thrd_nomem", - ]; -} - -def PThreadAPI : PublicAPI<"pthread.h"> { - let Types = [ - "__atfork_callback_t", - "__pthread_once_func_t", - "__pthread_start_t", - "__pthread_tss_dtor_t", - "pthread_attr_t", - "pthread_condattr_t", - "pthread_key_t", - "pthread_mutex_t", - "pthread_mutexattr_t", - "pthread_once_t", - "pthread_rwlockattr_t", - "pthread_rwlock_t", - "pthread_spinlock_t", - "pthread_t", - ]; -} - -def DirentAPI : PublicAPI<"dirent.h"> { - let Types = [ - "ino_t", - "DIR", - "struct dirent", - ]; -} - -def UniStdAPI : PublicAPI<"unistd.h"> { - let Types = ["__exec_argv_t", "__exec_envp_t", "off_t", "pid_t", "size_t", - "ssize_t", "uid_t", "__getoptargv_t"]; -} - -def WCharAPI : PublicAPI<"wchar.h"> { - let Types = [ - "wchar_t", - "wint_t", - "size_t", - ]; -} - -def UCharAPI : PublicAPI<"uchar.h"> { - let Types = [ - "mbstate_t", - "char8_t", - "char16_t", - "char32_t", - ]; -} - -def SysRandomAPI : PublicAPI<"sys/random.h"> { - let Types = ["size_t", "ssize_t"]; -} - -def SysSelectAPI : PublicAPI<"sys/select.h"> { - let Types = ["fd_set", "sigset_t", "suseconds_t", "time_t", "struct timespec", - "struct timeval"]; -} - -def SysSocketAPI : PublicAPI<"sys/socket.h"> { - let Types = [ - "sa_family_t", - "socklen_t", - "struct sockaddr", - "struct sockaddr_un", - "struct msghdr", - "struct iovec", - "size_t", - "ssize_t", - ]; -} - -def SysResourceAPI : PublicAPI<"sys/resource.h"> { - let Types = ["rlim_t", "struct rlimit"]; -} - -def SysStatAPI : PublicAPI<"sys/stat.h"> { - let Types = ["mode_t", "dev_t", "ino_t", "nlink_t", "uid_t", "gid_t", "off_t", - "struct timespec", "struct timeval", "blksize_t", "blkcnt_t", - "struct stat"]; -} - -def SysWaitAPI : PublicAPI<"sys/wait.h"> { - let Types = ["pid_t", "struct rusage", "siginfo_t"]; -} - -def SysSendfileAPI : PublicAPI<"sys/sendfile.h"> { - let Types = ["off_t", "size_t", "ssize_t"]; -} - -def SysTypesAPI : PublicAPI<"sys/types.h"> { - let Types = [ - "blkcnt_t", - "blksize_t", - "clockid_t", - "dev_t", - "gid_t", - "ino_t", - "mode_t", - "nlink_t", - "off_t", - "pid_t", - "pthread_attr_t", - "pthread_condattr_t", - "pthread_key_t", - "pthread_mutex_t", - "pthread_mutexattr_t", - "pthread_once_t", - "pthread_rwlockattr_t", - "pthread_rwlock_t", - "pthread_t", - "size_t", - "ssize_t", - "suseconds_t", - "time_t", - "uid_t" - ]; -} - -def SysUtsNameAPI : PublicAPI<"sys/utsname.h"> { - let Types = ["struct utsname"]; -} - -def SysEpollAPI : PublicAPI<"sys/epoll.h"> { - let Types = ["struct epoll_event", "struct epoll_data", "sigset_t", "struct timespec"]; -} - -def SpawnAPI : PublicAPI<"spawn.h"> { - let Types = ["mode_t", "pid_t", "posix_spawnattr_t", "posix_spawn_file_actions_t"]; -} - -def TermiosAPI : PublicAPI<"termios.h"> { - let Types = ["cc_t", "pid_t", "speed_t", "struct termios", "tcflag_t"]; -} - -def SetJmpAPI : PublicAPI<"setjmp.h"> { - let Types = ["jmp_buf"]; -} - -def SearchAPI : PublicAPI<"search.h"> { - let Types = ["ACTION", "ENTRY", "struct hsearch_data", "__lsearchcompare_t"]; -} - -def SysStatvfsAPI : PublicAPI<"sys/statvfs.h"> { - let Types = ["struct statvfs"]; -} diff --git a/libc/config/public_api.td b/libc/config/public_api.td deleted file mode 100644 index 1b34506c643c32..00000000000000 --- a/libc/config/public_api.td +++ /dev/null @@ -1,26 +0,0 @@ -include "spec/spec.td" - -class MacroDef { - string Name = name; - string Defn = ""; -} - -class SimpleMacroDef : MacroDef { - let Defn = !strconcat("#define ", name, " ", value); -} - -class MacroDefineIfNot : MacroDef { - let Defn = !strconcat("#ifndef ", name, "\n", - "#define " , name, " ", value, "\n", - "#endif // ", name); -} - -class PublicAPI { - string HeaderName = name; - list Macros = []; - list Types = []; - list Enumerations = []; - list Structs = []; - list Functions = []; - list Objects = []; -} diff --git a/libc/docs/dev/header_generation.rst b/libc/docs/dev/header_generation.rst index ec4206217ca777..0730b9a40c26a1 100644 --- a/libc/docs/dev/header_generation.rst +++ b/libc/docs/dev/header_generation.rst @@ -38,9 +38,6 @@ Required Versions: ``build/projects/libc/include/sys``. -New Headergen is turned on by default, but if you want to use old Headergen, -you can include this statement when building: ``-DLIBC_USE_NEW_HEADER_GEN=OFF`` - To add a function to the YAML files, you can either manually enter it in the YAML file corresponding to the header it belongs to or add it through the command line. diff --git a/libc/docs/gpu/building.rst b/libc/docs/gpu/building.rst index 37dccdab6dc340..6a2d1f23c0bcdf 100644 --- a/libc/docs/gpu/building.rst +++ b/libc/docs/gpu/building.rst @@ -86,16 +86,13 @@ compiler. These tools must all be up-to-date with the libc source. -DCMAKE_C_COMPILER=$HOST_C_COMPILER \ -DCMAKE_CXX_COMPILER=$HOST_CXX_COMPILER \ -DLLVM_LIBC_FULL_BUILD=ON \ - -DLIBC_HDRGEN_ONLY=ON \ # Only build the 'libc-hdrgen' tool -DCMAKE_BUILD_TYPE=Release # Release suggested to make "clang" fast $> ninja # Build the 'clang' compiler - $> ninja libc-hdrgen # Build the 'libc-hdrgen' tool -Once this has finished the build directory should contain the ``clang`` compiler -and the ``libc-hdrgen`` executable. We will use the ``clang`` compiler to build -the GPU code and the ``libc-hdrgen`` tool to create the necessary headers. We -use these tools to bootstrap the build out of the runtimes directory targeting a -GPU architecture. +Once this has finished the build directory should contain the ``clang`` +compiler executable. We will use the ``clang`` compiler to build the GPU code. +We use these tools to bootstrap the build out of the runtimes directory +targeting a GPU architecture. .. code-block:: sh @@ -105,7 +102,6 @@ GPU architecture. $> TARGET_TRIPLE= $> TARGET_C_COMPILER= $> TARGET_CXX_COMPILER= - $> HDRGEN= $> cmake ../runtimes \ # Point to the runtimes build -G Ninja \ -DLLVM_ENABLE_RUNTIMES=libc \ @@ -113,7 +109,6 @@ GPU architecture. -DCMAKE_CXX_COMPILER=$TARGET_CXX_COMPILER \ -DLLVM_LIBC_FULL_BUILD=ON \ -DLLVM_RUNTIMES_TARGET=$TARGET_TRIPLE \ - -DLIBC_HDRGEN_EXE=$HDRGEN \ -DCMAKE_BUILD_TYPE=Release $> ninja install diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 91611026df105c..483e63da48deae 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -18,24 +18,14 @@ add_header( ) macro(add_header_macro TARGET_NAME YAML_FILE DEF_FILE GEN_HDR DEPENDS) - if (LIBC_USE_NEW_HEADER_GEN) - add_gen_header2( - ${TARGET_NAME} - YAML_FILE ${YAML_FILE} - DEF_FILE ${DEF_FILE} - GEN_HDR ${GEN_HDR} - ${DEPENDS} - ${ARGN} - ) - else() - add_gen_header( - ${TARGET_NAME} - DEF_FILE ${DEF_FILE} - GEN_HDR ${GEN_HDR} - ${DEPENDS} - ${ARGN} - ) - endif() + add_gen_header2( + ${TARGET_NAME} + YAML_FILE ${YAML_FILE} + DEF_FILE ${DEF_FILE} + GEN_HDR ${GEN_HDR} + ${DEPENDS} + ${ARGN} + ) endmacro() add_header_macro( diff --git a/libc/spec/bsd_ext.td b/libc/spec/bsd_ext.td deleted file mode 100644 index 2b91324e36db9a..00000000000000 --- a/libc/spec/bsd_ext.td +++ /dev/null @@ -1,87 +0,0 @@ -def BsdExtensions : StandardSpec<"BSDExtensions"> { - HeaderSpec Math = HeaderSpec< - "math.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec<"isnan", RetValSpec, [ArgSpec]>, - FunctionSpec<"isnanf", RetValSpec, [ArgSpec]>, - FunctionSpec<"isnanl", RetValSpec, [ArgSpec]>, - ] - >; - - HeaderSpec String = HeaderSpec< - "string.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "strlcat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strlcpy", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strsep", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Strings = HeaderSpec< - "strings.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "strcasecmp", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strncasecmp", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "index", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "rindex", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec SysWait = HeaderSpec< - "sys/wait.h", - [], // Macros - [StructRUsage], // Types - [], // Enumerations - [ - FunctionSpec< - "wait4", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - > - ] - >; - - let Headers = [ - Math, - String, - Strings, - SysWait, - ]; -} diff --git a/libc/spec/gnu_ext.td b/libc/spec/gnu_ext.td deleted file mode 100644 index 64121aed9574f2..00000000000000 --- a/libc/spec/gnu_ext.td +++ /dev/null @@ -1,316 +0,0 @@ -def CpuSetT : NamedType<"cpu_set_t">; -def CpuSetPtr : PtrType; -def ConstCpuSetPtr : ConstType; - -def QSortRCompareT : NamedType<"__qsortrcompare_t">; -def StructHsearchData : NamedType<"struct hsearch_data">; -def StructHsearchDataPtr : PtrType; - -def GnuExtensions : StandardSpec<"GNUExtensions"> { - NamedType CookieIOFunctionsT = NamedType<"cookie_io_functions_t">; - HeaderSpec CType = HeaderSpec< - "ctype.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "toascii", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec Malloc = HeaderSpec< - "malloc.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec<"mallopt", RetValSpec, [ArgSpec, ArgSpec]>, - ] - >; - - HeaderSpec Math = HeaderSpec< - "math.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "sincosf", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "lgamma_r", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "lgammaf_r", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "lgammal_r", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Sched = HeaderSpec< - "sched.h", - [], // Macros - [PidT, SizeTType, CpuSetT], // Types - [], // Enumerations - [ - FunctionSpec< - "sched_getaffinity", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "sched_setaffinity", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - HeaderSpec String = HeaderSpec< - "string.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "memmem", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "memrchr", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strerror_r", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strcasestr", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strchrnul", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Search = HeaderSpec< - "search.h", - [], // Macros - [ - StructHsearchData - ], - [], // Enumerations - [ - FunctionSpec< - "hcreate_r", - RetValSpec, - [ - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "hdestroy_r", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "hsearch_r", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - ] - >; - - HeaderSpec FEnv = HeaderSpec< - "fenv.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "fedisableexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "feenableexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fegetexcept", - RetValSpec, - [] - > - ] - >; - - HeaderSpec StdIO = HeaderSpec< - "stdio.h", - [], // Macros - [CookieIOFunctionsT], // Types - [], // Enumerations - [ - FunctionSpec< - "clearerr_unlocked", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "feof_unlocked", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ferror_unlocked", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fopencookie", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "fread_unlocked", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fwrite_unlocked", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fgetc_unlocked", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec StdLib = HeaderSpec< - "stdlib.h", - [], // Macros - [QSortRCompareT], // Types - [], // Enumerations - [ - FunctionSpec< - "qsort_r", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec PThread = HeaderSpec< - "pthread.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "pthread_setname_np", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_getname_np", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec SysAuxv = HeaderSpec< - "sys/auxv.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "getauxval", - RetValSpec, - [ArgSpec] - >, - ] // Functions - >; - - HeaderSpec SendFile = HeaderSpec< - "sys/sendfile.h", - [], // Macros - [OffTType, SizeTType, SSizeTType,], // Types - [], // Enumerations - [ - FunctionSpec< - "sendfile", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec UniStd = HeaderSpec< - "unistd.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "dup2", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - let Headers = [ - CType, - FEnv, - Malloc, - Math, - PThread, - Sched, - SendFile, - SysAuxv, - StdIO, - StdLib, - String, - Search, - UniStd, - ]; -} diff --git a/libc/spec/gpu_ext.td b/libc/spec/gpu_ext.td deleted file mode 100644 index d99531dc06bcd6..00000000000000 --- a/libc/spec/gpu_ext.td +++ /dev/null @@ -1,18 +0,0 @@ -def GPUExtensions : StandardSpec<"GPUExtensions"> { - HeaderSpec RPC = HeaderSpec< - "gpu/rpc.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "rpc_host_call", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - let Headers = [ - RPC, - ]; -} diff --git a/libc/spec/linux.td b/libc/spec/linux.td deleted file mode 100644 index 9b5dc8e30c95e4..00000000000000 --- a/libc/spec/linux.td +++ /dev/null @@ -1,328 +0,0 @@ -def StructEpollEvent : NamedType<"struct epoll_event">; -def StructEpollEventPtr : PtrType; - -def StructEpollData : NamedType<"struct epoll_data">; - -def Linux : StandardSpec<"Linux"> { - HeaderSpec Errno = HeaderSpec< - "errno.h", - [ - Macro<"ENOMEDIUM">, - Macro<"ENOTBLK">, - Macro<"EMEDIUMTYPE">, - Macro<"EBADSLT">, - Macro<"ECHRNG">, - Macro<"ERFKILL">, - Macro<"EUSERS">, - Macro<"EBADR">, - Macro<"EL3HLT">, - Macro<"ENOTUNIQ">, - Macro<"EXFULL">, - Macro<"EHOSTDOWN">, - Macro<"EL3RST">, - Macro<"ENOPKG">, - Macro<"ENOCSI">, - Macro<"EUNATCH">, - Macro<"EREMCHG">, - Macro<"ETOOMANYREFS">, - Macro<"EL2HLT">, - Macro<"EBADFD">, - Macro<"EREMOTEIO">, - Macro<"ENAVAIL">, - Macro<"ELIBEXEC">, - Macro<"ESHUTDOWN">, - Macro<"ENOKEY">, - Macro<"ESTRPIPE">, - Macro<"EKEYREJECTED">, - Macro<"ESRMNT">, - Macro<"EKEYREVOKED">, - Macro<"EBADE">, - Macro<"ELIBBAD">, - Macro<"EISNAM">, - Macro<"EBFONT">, - Macro<"EPFNOSUPPORT">, - Macro<"EREMOTE">, - Macro<"EDEADLOCK">, - Macro<"ENONET">, - Macro<"EDOTDOT">, - Macro<"EKEYEXPIRED">, - Macro<"ELIBSCN">, - Macro<"ERESTART">, - Macro<"EBADRQC">, - Macro<"EUCLEAN">, - Macro<"ENOANO">, - Macro<"ELIBACC">, - Macro<"EHWPOISON">, - Macro<"ELIBMAX">, - Macro<"ESOCKTNOSUPPORT">, - Macro<"ENOTNAM">, - Macro<"ELNRNG">, - Macro<"EL2NSYNC">, - Macro<"EADV">, - Macro<"ECOMM">, - ] - >; - - HeaderSpec Sched = HeaderSpec< - "sched.h", - [ - Macro<"SCHED_OTHER">, - Macro<"SCHED_FIFO">, - Macro<"SCHED_RR">, - Macro<"SCHED_BATCH">, - Macro<"SCHED_ISO">, - Macro<"SCHED_IDLE">, - Macro<"SCHED_DEADLINE">, - ], - [], // Types - [], // Enumerations - [] // Functions - >; - - HeaderSpec SysMMan = HeaderSpec< - "sys/mman.h", - [Macro<"MAP_ANONYMOUS">], - [], // Types - [], // Enumerations - [ - FunctionSpec< - "mincore", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "mlock2", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "remap_file_pages", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "mremap", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - ] // Functions - >; - - - HeaderSpec SysPrctl = HeaderSpec< - "sys/prctl.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "prctl", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - ] // Functions - >; - - HeaderSpec SysRandom = HeaderSpec< - "sys/random.h", - [ - Macro<"GRND_RANDOM">, - Macro<"GRND_NONBLOCK">, - Macro<"GRND_INSECURE">, - ], - [SizeTType, SSizeTType], // Types - [], // Enumerations - [ - FunctionSpec< - "getrandom", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - ] - >; - - HeaderSpec SysTime = HeaderSpec< - "sys/time.h", - [ - Macro<"timeradd">, - Macro<"timersub">, - Macro<"timerclear">, - Macro<"timerisset">, - Macro<"timercmp">, - ], - [StructTimevalType], // Types - [], // Enumerations - [] // Functions - >; - - - HeaderSpec SysEpoll = HeaderSpec< - "sys/epoll.h", - [], // Macros - [ - StructEpollEvent, - StructEpollData, - SigSetType, - StructTimeSpec, - ], // Types - [], // Enumerations - [ - FunctionSpec< - "epoll_create", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "epoll_create1", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "epoll_ctl", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "epoll_wait", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "epoll_pwait", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "epoll_pwait2", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - ] // Functions - >; - - HeaderSpec Signal = HeaderSpec< - "signal.h", - [ - Macro<"NSIG">, - - Macro<"SIGHUP">, - Macro<"SIGINT">, - Macro<"SIGQUIT">, - Macro<"SIGILL">, - Macro<"SIGTRAP">, - Macro<"SIGABRT">, - Macro<"SIGIOT">, - Macro<"SIGBUS">, - Macro<"SIGFPE">, - Macro<"SIGKILL">, - Macro<"SIGUSR1">, - Macro<"SIGSEGV">, - Macro<"SIGUSR2">, - Macro<"SIGPIPE">, - Macro<"SIGALRM">, - Macro<"SIGTERM">, - Macro<"SIGSTKFLT">, - Macro<"SIGCHLD">, - Macro<"SIGCONT">, - Macro<"SIGSTOP">, - Macro<"SIGTSTP">, - Macro<"SIGTTIN">, - Macro<"SIGTTOU">, - Macro<"SIGURG">, - Macro<"SIGXCPU">, - Macro<"SIGXFSZ">, - Macro<"SIGVTALRM">, - Macro<"SIGPROF">, - Macro<"SIGWINCH">, - Macro<"SIGIO">, - Macro<"SIGPOLL">, - Macro<"SIGPWR">, - Macro<"SIGSYS">, - Macro<"SIGUNUSED">, - ] - >; - - - HeaderSpec UniStd = HeaderSpec< - "unistd.h", - [], // Macros - [], - [], // Enumerations - [ - FunctionSpec< - "pipe2", - RetValSpec, - [ArgSpec, ArgSpec] //TODO: make this int[2] - >, - ], - [] - >; - - - let Headers = [ - Errno, - SysEpoll, - SysMMan, - SysPrctl, - SysRandom, - SysTime, - Signal, - UniStd, - ]; -} diff --git a/libc/spec/llvm_libc_ext.td b/libc/spec/llvm_libc_ext.td deleted file mode 100644 index cd63e34a44ef0a..00000000000000 --- a/libc/spec/llvm_libc_ext.td +++ /dev/null @@ -1,116 +0,0 @@ -def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> { - HeaderSpec Strings = HeaderSpec< - "strings.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "bcopy", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "bzero", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "bcmp", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Assert = HeaderSpec< - "assert.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "__assert_fail", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Sched = HeaderSpec< - "sched.h", - [], // Macros - [PidT, SizeTType, CpuSetT], // Types - [], // Enumerations - [ - FunctionSpec< - "__sched_getcpucount", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Math = HeaderSpec< - "math.h", - [], // Macros - [], // Types - [], // Enumerations - [ - GuardedFunctionSpec<"daddf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"ddivf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"dfmaf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"dsqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"dsubf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - - GuardedFunctionSpec<"f16add", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16addf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16addl", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - GuardedFunctionSpec<"f16sub", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16subf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16subl", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - GuardedFunctionSpec<"faddf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"fdivf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"ffmaf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"fmulf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"dmulf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"f16mul", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16mulf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16mull", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - GuardedFunctionSpec<"f16div", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16divf", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16divl", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - GuardedFunctionSpec<"f16fma", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16fmaf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16fmal", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - GuardedFunctionSpec<"f16sqrt", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16sqrtf", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"f16sqrtl", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - GuardedFunctionSpec<"fsqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"fsubf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"powi", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"powif", RetValSpec, [ArgSpec, ArgSpec]>, - ] - >; - - let Headers = [ - Assert, - Math, - Sched, - Strings, - ]; -} diff --git a/libc/spec/llvm_libc_stdfix_ext.td b/libc/spec/llvm_libc_stdfix_ext.td deleted file mode 100644 index 7bc7ec5464081b..00000000000000 --- a/libc/spec/llvm_libc_stdfix_ext.td +++ /dev/null @@ -1,27 +0,0 @@ -def LLVMLibcStdfixExt : StandardSpec<"llvm_libc_stdfix_ext"> { - HeaderSpec StdFix = HeaderSpec< - "stdfix.h", - [], // macros - [], // types - [], // enums - [ // functions - GuardedFunctionSpec<"exphk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"expk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"sqrtuhr", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"sqrtur", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"sqrtulr", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"sqrtuhk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"sqrtuk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"sqrtulk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"uhksqrtus", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"uksqrtui", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - ] - >; - - let Headers = [ - StdFix, - ]; -} diff --git a/libc/spec/posix.td b/libc/spec/posix.td deleted file mode 100644 index e354deef340f1b..00000000000000 --- a/libc/spec/posix.td +++ /dev/null @@ -1,1867 +0,0 @@ -def SigSetType : NamedType<"sigset_t">; -def SigSetPtrType : PtrType; -def ConstSigSetPtrType : ConstType; -def RestrictedSigSetType : RestrictedPtrType; -def ConstRestrictedSigSetType : ConstType; - -def SigInfoType : NamedType<"siginfo_t">; -def UnionSigVal : NamedType<"union sigval">; - -def StructSigaction : NamedType<"struct sigaction">; -def StructSigactionPtr : PtrType; -def ConstStructSigactionPtr : ConstType; -def RestrictedStructSigactionPtr : RestrictedPtrType; -def ConstRestrictedStructSigactionPtr : ConstType; - -def PThreadStartT : NamedType<"__pthread_start_t">; -def PThreadTSSDtorT : NamedType<"__pthread_tss_dtor_t">; -def PThreadKeyT : NamedType<"pthread_key_t">; -def PThreadKeyTPtr : PtrType; -def PThreadOnceT : NamedType<"pthread_once_t">; -def PThreadOnceTPtr : PtrType; -def PThreadOnceCallback : NamedType<"__pthread_once_func_t">; - -def InoT : NamedType<"ino_t">; -def UidT : NamedType<"uid_t">; -def GidT : NamedType<"gid_t">; -def DevT : NamedType<"dev_t">; -def ClockIdT : NamedType<"clockid_t">; -def RestrictedClockIdTPtr : RestrictedPtrType; -def BlkSizeT : NamedType<"blksize_t">; -def BlkCntT : NamedType<"blkcnt_t">; -def NLinkT : NamedType<"nlink_t">; - -def StatType : NamedType<"struct stat">; -def StatTypePtr : PtrType; -def RestrictedStatTypePtr : RestrictedPtrType; - -def DIR : NamedType<"DIR">; -def DIRPtr : PtrType; -def DIRRestrictedPtr : RestrictedPtrType; -def StructDirent : NamedType<"struct dirent">; -def StructDirentPtr : PtrType; -def StructDirentPtrPtr : PtrType; -def ConstStructDirentPtrPtr : ConstType; - -def StructSchedParam : NamedType<"struct sched_param">; -def StructSchedParamPtr : PtrType; -def ConstStructSchedParamPtr : ConstType; - -def ExecArgvT : NamedType<"__exec_argv_t">; -def ExecEnvpT : NamedType<"__exec_envp_t">; - -def AtForkCallbackT : NamedType<"__atfork_callback_t">; - -def PosixSpawnFileActionsT : NamedType<"posix_spawn_file_actions_t">; -def PosixSpawnFileActionsTPtr : PtrType; -def ConstPosixSpawnFileActionsTPtr : ConstType; -def PosixSpawnFileActionsTRestrictedPtr : RestrictedPtrType; - -def PosixSpawnAttrT : NamedType<"posix_spawnattr_t">; -def RestrictedPosixSpawnAttrTPtrType : RestrictedPtrType; - -def CcT : NamedType<"cc_t">; -def SpeedT : NamedType<"speed_t">; -def StructTermios : NamedType<"struct termios">; -def StructTermiosPtr : PtrType; -def ConstStructTermiosPtr : ConstType; -def TcFlagT : NamedType<"tcflag_t">; - -def StackT : NamedType<"stack_t">; -def StackTPtr : PtrType; -def RestrictedStackTPtr : RestrictedPtrType; -def ConstRestrictedStackTPtr : ConstType; - -def FdSet : NamedType<"fd_set">; -def FdSetPtr : PtrType; -def RestrictedFdSetPtr : RestrictedPtrType; - -def GetoptArgvT : NamedType<"__getoptargv_t">; - -def SAFamilyType : NamedType<"sa_family_t">; -def SocklenType : NamedType<"socklen_t">; -def SocklenPtr : PtrType; - -def StructSockAddr : NamedType<"struct sockaddr">; -def StructSockAddrPtr : PtrType; -def ConstStructSockAddrPtr : ConstType; - -def StructMsghdr : NamedType<"struct msghdr">; -def StructMsghdrPtr : PtrType; -def ConstStructMsghdrPtr : ConstType; - -def StructIovec : NamedType<"struct iovec">; -def StructIovecPtr : PtrType; -def ConstStructIovecPtr : ConstType; - -def StructSockAddrUn : NamedType<"struct sockaddr_un">; - -def StructStatvfs : NamedType<"struct statvfs">; -def StructStatvfsPtr : PtrType; -def RestrictedStructStatvfsPtr : RestrictedPtrType; - -// The function pointer type for the predicate for lsearch, lfind -def LSearchCompareT : NamedType<"__lsearchcompare_t">; - -def POSIX : StandardSpec<"POSIX"> { - PtrType CharPtr = PtrType; - RestrictedPtrType RestrictedCharPtr = RestrictedPtrType; - RestrictedPtrType CharRestrictedDoublePtr = RestrictedPtrType; - ConstType ConstCharPtr = ConstType; - ConstType ConstRestrictedCharPtr = ConstType; - - NamedType ModeTType = NamedType<"mode_t">; - - NamedType PThreadAttrTType = NamedType<"pthread_attr_t">; - PtrType PThreadAttrTPtr = PtrType; - RestrictedPtrType RestrictedPThreadAttrTPtr = RestrictedPtrType; - ConstType ConstPThreadAttrTPtr = ConstType; - ConstType ConstRestrictedPThreadAttrTPtr = ConstType; - - NamedType PThreadCondAttrTType = NamedType<"pthread_condattr_t">; - PtrType PThreadCondAttrTPtr = PtrType; - ConstType ConstRestrictedPThreadCondAttrTPtr = ConstType>; - - NamedType PThreadRWLockAttrTType = NamedType<"pthread_rwlockattr_t">; - PtrType PThreadRWLockAttrTPtr = PtrType; - ConstType ConstPThreadRWLockAttrTPtr = ConstType; - RestrictedPtrType RestrictedPThreadRWLockAttrTPtr = RestrictedPtrType; - ConstType ConstRestrictedPThreadRWLockAttrTPtr = ConstType; - - NamedType PThreadMutexAttrTType = NamedType<"pthread_mutexattr_t">; - PtrType PThreadMutexAttrTPtr = PtrType; - RestrictedPtrType RestrictedPThreadMutexAttrTPtr = RestrictedPtrType; - ConstType ConstPThreadMutexAttrTPtr = ConstType; - ConstType ConstRestrictedPThreadMutexAttrTPtr = ConstType; - - NamedType PThreadMutexTType = NamedType<"pthread_mutex_t">; - PtrType PThreadMutexTPtr = PtrType; - RestrictedPtrType RestrictedPThreadMutexTPtr = RestrictedPtrType; - ConstType ConstPThreadMutexTPtr = ConstType; - ConstType ConstRestrictedPThreadMutexTPtr = ConstType; - - NamedType PThreadRWLockTType = NamedType<"pthread_rwlock_t">; - PtrType PThreadRWLockTPtr = PtrType; - RestrictedPtrType RestrictedPThreadRWLockTPtr = RestrictedPtrType; - - NamedType PThreadSpinLockTType = NamedType<"pthread_spinlock_t">; - PtrType PThreadSpinLockTPtr = PtrType; - - PtrType PThreadTPtr = PtrType; - RestrictedPtrType RestrictedPThreadTPtr = RestrictedPtrType; - - HeaderSpec Errno = HeaderSpec< - "errno.h", - [ - Macro<"E2BIG">, - Macro<"EACCES">, - Macro<"EADDRINUSE">, - Macro<"EADDRNOTAVAIL">, - Macro<"EAFNOSUPPORT">, - Macro<"EAGAIN">, - Macro<"EALREADY">, - Macro<"EBADF">, - Macro<"EBADMSG">, - Macro<"EBUSY">, - Macro<"ECANCELED">, - Macro<"ECHILD">, - Macro<"ECONNABORTED">, - Macro<"ECONNREFUSED">, - Macro<"ECONNRESET">, - Macro<"EDEADLK">, - Macro<"EDESTADDRREQ">, - Macro<"EDQUOT">, - Macro<"EEXIST">, - Macro<"EFAULT">, - Macro<"EFBIG">, - Macro<"EHOSTUNREACH">, - Macro<"EIDRM">, - Macro<"EINPROGRESS">, - Macro<"EINTR">, - Macro<"EINVAL">, - Macro<"EIO">, - Macro<"EISCONN">, - Macro<"EISDIR">, - Macro<"ELOOP">, - Macro<"EMFILE">, - Macro<"EMLINK">, - Macro<"EMSGSIZE">, - Macro<"EMULTIHOP">, - Macro<"ENAMETOOLONG">, - Macro<"ENETDOWN">, - Macro<"ENETRESET">, - Macro<"ENETUNREACH">, - Macro<"ENFILE">, - Macro<"ENOBUFS">, - Macro<"ENODATA">, - Macro<"ENODEV">, - Macro<"ENOENT">, - Macro<"ENOEXEC">, - Macro<"ENOLCK">, - Macro<"ENOLINK">, - Macro<"ENOMEM">, - Macro<"ENOMSG">, - Macro<"ENOPROTOOPT">, - Macro<"ENOSPC">, - Macro<"ENOSR">, - Macro<"ENOSTR">, - Macro<"ENOSYS">, - Macro<"ENOTCONN">, - Macro<"ENOTDIR">, - Macro<"ENOTEMPTY">, - Macro<"ENOTRECOVERABLE">, - Macro<"ENOTSOCK">, - Macro<"ENOTSUP">, - Macro<"ENOTTY">, - Macro<"ENXIO">, - Macro<"EOPNOTSUPP">, - Macro<"EOVERFLOW">, - Macro<"EOWNERDEAD">, - Macro<"EPERM">, - Macro<"EPIPE">, - Macro<"EPROTO">, - Macro<"EPROTONOSUPPORT">, - Macro<"EPROTOTYPE">, - Macro<"EROFS">, - Macro<"ESPIPE">, - Macro<"ESRCH">, - Macro<"ESTALE">, - Macro<"ETIME">, - Macro<"ETIMEDOUT">, - Macro<"ETXTBSY">, - Macro<"EWOULDBLOCK">, - Macro<"EXDEV">, - ], - [], // Types - [], // Enumerations - [] // Functions - >; - - HeaderSpec DlFcn = HeaderSpec< - "dlfcn.h", - [ - Macro<"RTLD_LAZY">, - Macro<"RTLD_NOW">, - Macro<"RTLD_GLOBAL">, - Macro<"RTLD_LOCAL">, - ], - [], // Types - [], // Enumerations - [ - FunctionSpec< - "dlclose", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "dlerror", - RetValSpec, - [] - >, - FunctionSpec< - "dlopen", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "dlsym", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec FCntl = HeaderSpec< - "fcntl.h", - [], // Macros - [ - ModeTType, - OffTType, - ], - [], // Enumerations - [ - FunctionSpec< - "creat", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "fcntl", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "open", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "openat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec SysMMan = HeaderSpec< - "sys/mman.h", - [ - // TODO: Add a facility to bunch macros into bitwise-or-able groups. - // POSIX requires it, so such thing should be captured in this spec. - Macro<"PROT_EXEC">, - Macro<"PROT_NONE">, - Macro<"PROT_READ">, - Macro<"PROT_WRITE">, - - Macro<"MAP_FIXED">, - Macro<"MAP_PRIVATE">, - Macro<"MAP_SHARED">, - - Macro<"MAP_FAILED">, - ], - [ - SizeTType, - OffTType, - ModeTType, - ], - [], // Enumerations - [ - FunctionSpec< - "madvise", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "mmap", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "mprotect", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "munmap", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "posix_madvise", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "mlock", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "munlock", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "mlockall", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "munlockall", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "msync", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "shm_open", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "shm_unlink", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec Signal = HeaderSpec< - "signal.h", - [], // Macros - [ - SigInfoType, - SigSetType, - StackT, - StructSigaction, - UnionSigVal, - PidT, - ], - [], // Enumerations - [ - FunctionSpec< - "kill", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "sigaction", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "sigaltstack", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "sigdelset", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "sigprocmask", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "sigemptyset", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "sigaddset", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "sigfillset", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec UniStd = HeaderSpec< - "unistd.h", - [], // Macros - [ - ExecArgvT, - ExecEnvpT, - OffTType, - SSizeTType, - SizeTType, - PidT, - UidT, - GetoptArgvT, - ], - [], // Enumerations - [ - FunctionSpec< - "_exit", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "access", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "chdir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "dup", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "dup2", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "dup3", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "fchdir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getcwd", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "close", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "execv", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "execve", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "fork", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fsync", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ftruncate", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "geteuid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getpid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getppid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "gettid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getuid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isatty", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "link", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "linkat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "lseek", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pread", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pwrite", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "read", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "readlink", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "readlinkat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "rmdir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getpid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getppid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "link", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "linkat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "lseek", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pipe", - RetValSpec, - [ArgSpec] //TODO: make this int[2] - >, - FunctionSpec< - "pread", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pwrite", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "read", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "readlink", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "readlinkat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "rmdir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "swab", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "symlink", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "symlinkat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "sysconf", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "__llvm_libc_syscall", - RetValSpec, - [ArgSpec,ArgSpec,ArgSpec,ArgSpec,ArgSpec,ArgSpec,ArgSpec] - >, - FunctionSpec< - "truncate", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "unlink", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "unlinkat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "write", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "getopt", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ], - [ - ObjectSpec<"environ", "char **">, - ObjectSpec< - "optarg", - "char *" - >, - ObjectSpec< - "optind", - "int" - >, - ObjectSpec< - "opterr", - "int" - >, - ObjectSpec< - "optopt", - "int" - >, - ] - >; - - HeaderSpec StdLib = HeaderSpec< - "stdlib.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "getenv", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec Sched = HeaderSpec< - "sched.h", - [], // Macros - [PidT, TimeTType, StructTimeSpec, StructSchedParam], // Types - [], // Enumerations - [ - FunctionSpec< - "sched_yield", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "sched_setparam", - RetValSpec, - [ArgSpec, ArgSpec] - >, - - FunctionSpec< - "sched_getparam", - RetValSpec, - [ArgSpec, ArgSpec] - >, - - FunctionSpec< - "sched_setscheduler", - RetValSpec, - [ArgSpec] - >, - - FunctionSpec< - "sched_getscheduler", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - - FunctionSpec< - "sched_get_priority_min", - RetValSpec, - [ArgSpec] - >, - - FunctionSpec< - "sched_get_priority_max", - RetValSpec, - [ArgSpec] - >, - - FunctionSpec< - "sched_rr_get_interval", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec String = HeaderSpec< - "string.h", - [ - Macro<"NULL">, - ], - [ - SizeTType, - ], - [], // Enumerations - [ - FunctionSpec< - "memccpy", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "mempcpy", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "stpcpy", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "stpncpy", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "strnlen", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strtok_r", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "strsignal", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec CType = HeaderSpec< - "ctype.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "isascii", - RetValSpec, - [ArgSpec] - >, - ] - >; - - NamedType RLimTType = NamedType<"rlim_t">; - NamedType StructRLimitType = NamedType<"struct rlimit">; - PtrType StructRLimitPtr = PtrType; - ConstType ConstStructRLimitPtr = ConstType; - HeaderSpec SysResource = HeaderSpec< - "sys/resource.h", - [], // Macros - [RLimTType, StructRLimitType], // Types - [], // Enumerations - [ - FunctionSpec< - "getrlimit", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "setrlimit", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec SysStat = HeaderSpec< - "sys/stat.h", - [], // Macros - [ - ModeTType, - DevT, - InoT, - UidT, - GidT, - StructTimeSpec, - StructTimevalType, - BlkSizeT, - BlkCntT, - OffTType, - NLinkT, - StatType, - ], // Types - [], // Enumerations - [ - FunctionSpec< - "chmod", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "fchmod", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "fchmodat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "fstat", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "lstat", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "mkdir", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "mkdirat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "stat", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec SysStatvfs = HeaderSpec< - "sys/statvfs.h", - [], // Macros - [StructStatvfs], // Types - [], // Enumerations - [ - FunctionSpec< - "statvfs", - RetValSpec, - [ - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "fstatvfs", - RetValSpec, - [ - ArgSpec, - ArgSpec - ] - >, - ] // Functions - >; - - NamedType StructUtsName = NamedType<"struct utsname">; - PtrType StructUtsNamePtr = PtrType; - HeaderSpec SysUtsName = HeaderSpec< - "sys/utsname.h", - [], // Macros - [StructUtsName], // Types - [], // Enumerations - [ - FunctionSpec< - "uname", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec ArpaInet = HeaderSpec< - "arpa/inet.h", - [], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec< - "htonl", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "htons", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ntohl", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ntohs", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec PThread = HeaderSpec< - "pthread.h", - [], // Macros - [ - AtForkCallbackT, - ClockIdT, - PThreadAttrTType, - PThreadCondAttrTType, - PThreadKeyT, - PThreadMutexAttrTType, - PThreadMutexTType, - PThreadOnceCallback, - PThreadOnceT, - PThreadRWLockAttrTType, - PThreadRWLockTType, - PThreadSpinLockTType, - PThreadStartT, - PThreadTSSDtorT, - PThreadTType, - ], // Types - [], // Enumerations - [ - FunctionSpec< - "pthread_atfork", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_init", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_attr_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_attr_getdetachstate", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_setdetachstate", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_getguardsize", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_setguardsize", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_getstacksize", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_setstacksize", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_getstack", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_attr_setstack", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_condattr_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_condattr_getclock", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_condattr_getpshared", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_condattr_init", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_condattr_setclock", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_condattr_setpshared", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_create", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_join", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_detach", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_exit", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_self", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_equal", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_init", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_gettype", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_settype", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_getrobust", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_setrobust", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_getpshared", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_setpshared", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_getprotocol", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_setprotocol", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_getprioceiling", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutexattr_setprioceiling", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutex_init", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_mutex_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_mutex_lock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_mutex_unlock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_key_create", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_key_delete", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_getspecific", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_setspecific", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_once", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlockattr_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlockattr_getkind_np", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlockattr_getpshared", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlockattr_init", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlockattr_setkind_np", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlockattr_setpshared", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_init", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_tryrdlock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_trywrlock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_timedrdlock", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_timedwrlock", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_clockrdlock", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_clockwrlock", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_rdlock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_wrlock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_unlock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_rwlock_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_spin_init", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "pthread_spin_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_spin_lock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_spin_trylock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "pthread_spin_unlock", - RetValSpec, - [ArgSpec] - > - ] - >; - - HeaderSpec StdIO = HeaderSpec< - "stdio.h", - [], // Macros - [OffTType], // Types - [], // Enumerations - [ - FunctionSpec< - "flockfile", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "funlockfile", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getc_unlocked", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getchar_unlocked", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fileno", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fdopen", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Dirent = HeaderSpec< - "dirent.h", - [], // Macros - [InoT, StructDirent, DIR], // Types - [], // Enumerations - [ - FunctionSpec< - "alphasort", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "closedir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "dirfd", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fdopendir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "opendir", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "readdir", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec Time = HeaderSpec< - "time.h", - [], // Macros - [ClockIdT, StructTimeSpec, StructTimevalType], // Types - [], // Enumerations - [ - FunctionSpec< - "clock_gettime", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "gettimeofday", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "nanosleep", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec SysWait = HeaderSpec< - "sys/wait.h", - [], // Macros - [PidT, StructRUsage, SigInfoType], - [], // Enumerations - [ - FunctionSpec< - "wait", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "waitpid", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - > - ] - >; - - HeaderSpec SysIOctl = HeaderSpec< - "sys/ioctl.h", - [ - Macro<"TIOCGETD">, - ], // Macros - [], // Types - [], // Enumerations - [] // Functions - >; - - HeaderSpec Spawn = HeaderSpec< - "spawn.h", - [], // Macros - [ModeTType, PosixSpawnAttrT, PidT, PosixSpawnFileActionsT], - [], // Enumerations - [ - FunctionSpec< - "posix_spawn_file_actions_addclose", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "posix_spawn_file_actions_adddup2", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "posix_spawn_file_actions_addopen", - RetValSpec, - [ArgSpec, ArgSpec, - ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "posix_spawn_file_actions_destroy", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "posix_spawn_file_actions_init", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "posix_spawn", - RetValSpec, - [ArgSpec, ArgSpec, - ArgSpec, ArgSpec, - ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Search = HeaderSpec< - "search.h", - [], // Macros - [ - ActionType, - EntryType, - LSearchCompareT, - ], // Types - [], // Enumerations - [ - FunctionSpec< - "hcreate", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "hdestroy", - RetValSpec, - [] // Args - >, - FunctionSpec< - "hsearch", - RetValSpec, - [ - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "insque", - RetValSpec, - [ - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "remque", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "lfind", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec - ] - > - ] - >; - - HeaderSpec Termios = HeaderSpec< - "termios.h", - [ - Macro<"NCCS">, - ], - [CcT, PidT, SpeedT, StructTermios, TcFlagT], // Types - [], // Enumerations - [ - FunctionSpec< - "cfgetispeed", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "cfgetospeed", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "cfsetispeed", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "cfsetospeed", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tcdrain", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "tcflow", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tcflush", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tcgetattr", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tcgetsid", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "tcsendbreak", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tcsetattr", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec SysSelect = HeaderSpec< - "sys/select.h", - [], // Macros - [FdSet, SigSetType, StructTimevalType, StructTimeSpec, SuSecondsT, TimeTType], - [], // Enumerations - [ - FunctionSpec< - "select", - RetValSpec, - [ - ArgSpec, ArgSpec, ArgSpec, - ArgSpec, ArgSpec - ] - > - ] - >; - - HeaderSpec SysSocket = HeaderSpec< - "sys/socket.h", - [ - Macro<"AF_UNSPEC">, - Macro<"AF_UNIX">, - Macro<"AF_LOCAL">, - Macro<"AF_INET">, - Macro<"AF_INET6">, - Macro<"SOCK_STREAM">, - Macro<"SOCK_DGRAM">, - Macro<"SOCK_RAW">, - Macro<"SOCK_RDM">, - Macro<"SOCK_SEQPACKET">, - Macro<"SOCK_PACKET">, - ], // Macros - [ - SizeTType, - SSizeTType, - SAFamilyType, - StructSockAddr, - StructSockAddrUn, - SocklenType, - StructIovec, - StructMsghdr, - ], // Types - [], // Enumerations - [ - FunctionSpec< - "socket", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "socketpair", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "bind", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "send", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "sendto", - RetValSpec, - [ - ArgSpec, ArgSpec, ArgSpec, - ArgSpec, ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "sendmsg", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "recv", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "recvfrom", - RetValSpec, - [ - ArgSpec, ArgSpec, ArgSpec, - ArgSpec, ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "recvmsg", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - ] // Functions - >; - - HeaderSpec SysTypes = HeaderSpec< - "sys/types.h", - [], // Macros - [ - BlkCntT, - BlkSizeT, - ClockIdT, - DevT, - GidT, - InoT, - ModeTType, - NLinkT, - OffTType, - PThreadAttrTType, - PThreadCondAttrTType, - PThreadKeyT, - PThreadMutexAttrTType, - PThreadMutexTType, - PThreadOnceT, - PThreadRWLockAttrTType, - PThreadRWLockTType, - PThreadTType, - PidT, - SSizeTType, - SizeTType, - SuSecondsT, - TimeTType, - UidT - ], // Types - [], // Enumerations - [] // Functions - >; - - let Headers = [ - ArpaInet, - CType, - Dirent, - DlFcn, - Errno, - FCntl, - PThread, - Sched, - Signal, - Spawn, - StdIO, - StdLib, - SysIOctl, - SysMMan, - SysResource, - SysSelect, - SysSocket, - SysStat, - SysStatvfs, - SysTypes, - SysUtsName, - SysWait, - Time, - Termios, - UniStd, - String, - Search, - ]; -} diff --git a/libc/spec/spec.td b/libc/spec/spec.td deleted file mode 100644 index ad9ca76846c280..00000000000000 --- a/libc/spec/spec.td +++ /dev/null @@ -1,253 +0,0 @@ -class Type {} - -class NamedType : Type { - string Name = name; -} - -class Field { - string Name = name; - Type FieldType = type; -} - -// Class to describe concrete structs specified by a standard. -class Struct : NamedType { - list Fields; -} - -class EnumNameValue { - string Name = name; - string Value = value; -} - -class Enum enumerations> : NamedType { - list Enumerations = enumerations; -} - -class PtrType : Type { - Type PointeeType = type; -} - -class ConstType : Type { - Type UnqualifiedType = type; -} - -class RestrictedPtrType : Type { - Type PointeeType = type; -} - -// Builtin types. -def VarArgType : NamedType<"...">; -def VaListType : NamedType<"va_list">; -def VoidType : NamedType<"void">; -def IntType : NamedType<"int">; -def UnsignedIntType : NamedType<"unsigned int">; -def LongType : NamedType<"long">; -def UnsignedLongType : NamedType<"unsigned long">; -def LongLongType : NamedType<"long long">; -def UnsignedLongLongType : NamedType<"unsigned long long">; -def FloatType : NamedType<"float">; -def DoubleType : NamedType<"double">; -def LongDoubleType : NamedType<"long double">; -def CharType : NamedType<"char">; -def UnsignedCharType : NamedType<"unsigned char">; -def UnsignedShortType : NamedType<"unsigned short">; -def BoolType : NamedType<"bool">; - -def Float16Type : NamedType<"_Float16">; -def Float128Type : NamedType<"float128">; - -// Common types -def VoidPtr : PtrType; -def VoidPtrPtr : PtrType; -def RestrictedVoidPtrPtr : RestrictedPtrType; -def ConstVoidPtr : ConstType; - -def SizeTType : NamedType<"size_t">; -def SizeTPtr : PtrType; -def RestrictedSizeTPtr : RestrictedPtrType; - -def Char8TType : NamedType<"char8_t">; -def Char16TType : NamedType<"char16_t">; -def Char32TType : NamedType<"char32_t">; -def WCharType : NamedType<"wchar_t">; -def WIntType : NamedType<"wint_t">; - -def LongDoublePtr : PtrType; - -def IntMaxTType : NamedType<"intmax_t">; -def UIntMaxTType : NamedType<"uintmax_t">; - -def UInt16Type : NamedType<"uint16_t">; -def UInt32Type : NamedType<"uint32_t">; - -def OffTType : NamedType<"off_t">; -def OffTPtr : PtrType; -def SSizeTType : NamedType<"ssize_t">; - -// _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; -def ConstVoidRestrictedPtr : ConstType; - -def CharPtr : PtrType; -def ConstCharPtr : ConstType; -def CharRestrictedPtr : RestrictedPtrType; -def CharRestrictedPtrPtr : RestrictedPtrType; -def ConstCharRestrictedPtr : ConstType; -def ConstCharRestrictedPtrPtr : PtrType; - -def OnceFlagType : NamedType<"once_flag">; -def OnceFlagTypePtr : PtrType; -// 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; -def CndTType : NamedType<"cnd_t">; -def CndTTypePtr : PtrType; -def ThrdStartTType : NamedType<"thrd_start_t">; -def ThrdTType : NamedType<"thrd_t">; -def ThrdTTypePtr : PtrType; - -def IntPtr : PtrType; -def RestrictedIntPtr : RestrictedPtrType; -def FloatPtr : PtrType; -def DoublePtr : PtrType; -def Float16Ptr : PtrType; -def Float128Ptr : PtrType; -def UnsignedCharPtr : PtrType; - -def ConstDoublePtr : ConstType; -def ConstFloatPtr : ConstType; -def ConstLongDoublePtr : ConstType; -def ConstFloat16Ptr : ConstType; -def ConstFloat128Ptr : ConstType; - -def SigHandlerT : NamedType<"__sighandler_t">; - -def TimeTType : NamedType<"time_t">; - -def StructTimeSpec : NamedType<"struct timespec">; -def StructTimeSpecPtr : PtrType; -def ConstStructTimeSpecPtr : ConstType; -def RestrictStructTimeSpecPtr : RestrictedPtrType; -def ConstRestrictStructTimeSpecPtr : ConstType; - -def BSearchCompareT : NamedType<"__bsearchcompare_t">; -def QSortCompareT : NamedType<"__qsortcompare_t">; - -def AtexitHandlerT : NamedType<"__atexithandler_t">; - -def FILE : NamedType<"FILE">; -def FILEPtr : PtrType; -def FILERestrictedPtr : RestrictedPtrType; - -def PThreadTType : NamedType<"pthread_t">; - -def PidT : NamedType<"pid_t">; -def RestrictedPidTPtr : RestrictedPtrType; - -def StructRUsage : NamedType<"struct rusage">; -def StructRUsagePtr : PtrType; - -def StructTimevalType : NamedType<"struct timeval">; -def StructTimevalPtr : PtrType; -def RestrictedStructTimevalPtr : RestrictedPtrType; - -def SuSecondsT : NamedType<"suseconds_t">; - -//added because __assert_fail needs it. -def UnsignedType : NamedType<"unsigned">; - -def ActionType : NamedType<"ACTION">; -def EntryType : NamedType<"ENTRY">; -def EntryTypePtr : PtrType; -def EntryTypePtrPtr : PtrType; - -def MBStateTType : NamedType<"mbstate_t">; - -class Macro { - string Name = name; -} - -class EnumeratedNameValue { - string Name = name; - string Value = value; -} - -class Annotation {} - -class RetValSpec annotations = []> { - Type ReturnType = type; - list Annotations = annotations; -} - -class ArgSpec annotations = [], string name = ""> { - Type ArgType = type; - list Annotations = annotations; - string Name = name; -} - -// The following classes are used to describe function attributes. -// In the future, we may consider supporting parameter attributes as well. -// https://clang.llvm.org/docs/AttributeReference.html -class FunctionAttr { - string Attr = attr; - // The style of the attribute, e.g. "gnu", "cxx11", "declspec". - // - "gnu" is for GNU-style attributes: __attribute__((...)) - // - "cxx11" is for C++11-style attributes: [[...]] - // - "declspec" is for Microsoft-style attributes: __declspec(...) - string Style = style; - - // For the time being, we are only interested in identifer-like attributes. - // We can extend this to support function-like attributes if needed. - // For example, in the future, we can #define __LIBC_ATTRIBUTE_NODISCARD(...) [[nodiscard(__VA_ARGS__)]] - // int FunctionLike = 0; -} -class GnuFunctionAttr : FunctionAttr<"gnu", attr> {} -class Cxx11FunctionAttr : FunctionAttr<"cxx11", attr> { - // The namespace of the attribute, e.g. "gnu" or "clang". Empty string means there is no namespace. - string Namespace = namespace; -} -class DeclspecFunctionAttr : FunctionAttr<"declspec", attr> {} -class FunctionAttrSpec instances> { - list Instances = instances; - string Macro = macro; -} - -class FunctionSpec args, list attrs = []> { - string Name = name; - RetValSpec Return = return; - list Args = args; - list Attributes = attrs; -} - -class GuardedFunctionSpec args, string guard_macro> : FunctionSpec { - string Guard = guard_macro; -} - -class ObjectSpec { - string Name = name; - string Type = type; -} - -class HeaderSpec macros = [], - list types = [], - list enumerations = [], - list functions = [], - list objects = []> { - string Name = name; - list Functions = functions; - list Types = types; - list Macros = macros; - list Enumerations = enumerations; - list Objects = objects; -} - -class StandardSpec { - string Name = name; - list Headers; -} diff --git a/libc/spec/stdc.td b/libc/spec/stdc.td deleted file mode 100644 index 4fa057da1cf133..00000000000000 --- a/libc/spec/stdc.td +++ /dev/null @@ -1,1819 +0,0 @@ -def StdC : StandardSpec<"stdc"> { - - NamedType StructTmType = NamedType<"struct tm">; - PtrType StructTmPtr = PtrType; - PtrType TimeTTypePtr = PtrType; - NamedType ClockT = NamedType<"clock_t">; - NamedType LocaleT = NamedType<"locale_t">; - - NamedType DivTType = NamedType<"div_t">; - NamedType LDivTType = NamedType<"ldiv_t">; - NamedType LLDivTType = NamedType<"lldiv_t">; - - NamedType JmpBuf = NamedType<"jmp_buf">; - - NamedType TssTType = NamedType<"tss_t">; - PtrType TssTPtr = PtrType; - NamedType TssDtorTType = NamedType<"tss_dtor_t">; - - HeaderSpec Assert = HeaderSpec< - "assert.h", - [ - Macro<"static_assert">, - Macro<"assert">, - ], - [], // Types - [], // Enumerations - [] - >; - - FunctionAttrSpec ConstAttr = FunctionAttrSpec<"__LIBC_CONST_ATTR", [ - Cxx11FunctionAttr<"const", "gnu">, - GnuFunctionAttr<"const">, - ]>; - - HeaderSpec CType = HeaderSpec< - "ctype.h", - [], // Macros - [ - LocaleT - ], // Types - [], // Enumerations - [ - FunctionSpec< - "isalnum", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isalpha", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isblank", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "iscntrl", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isdigit", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isgraph", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "islower", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isprint", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ispunct", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isspace", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isupper", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isxdigit", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "tolower", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "toupper", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "isalnum_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isalpha_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isblank_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "iscntrl_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isdigit_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isgraph_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "islower_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isprint_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "ispunct_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isspace_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isupper_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "isxdigit_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tolower_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "toupper_l", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - NamedType FEnvT = NamedType<"fenv_t">; - PtrType FEnvTPtr = PtrType; - ConstType ConstFEnvTPtr = ConstType; - NamedType FExceptT = NamedType<"fexcept_t">; - PtrType FExceptTPtr = PtrType; - ConstType ConstFExceptTPtr = ConstType; - HeaderSpec Fenv = HeaderSpec< - "fenv.h", - [ - Macro<"FE_DIVBYZERO">, - Macro<"FE_INEXACT">, - Macro<"FE_INVALID">, - Macro<"FE_OVERFLOW">, - Macro<"FE_UNDERFLOW">, - Macro<"FE_ALL_EXCEPT">, - - Macro<"FE_DOWNWARD">, - Macro<"FE_TONEAREST">, - Macro<"FE_TOWARDZERO">, - Macro<"FE_UPWARD">, - - Macro<"FE_DFL_ENV"> - ], - [ - FEnvT, - FExceptT, - ], // Types - [], // Enumerations - [ - FunctionSpec< - "feclearexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fetestexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fetestexceptflag", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "feraiseexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fesetround", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fegetround", - RetValSpec, - [] - >, - FunctionSpec< - "fegetenv", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fesetenv", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fegetexceptflag", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "fesetexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fesetexceptflag", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "feholdexcept", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "feupdateenv", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec String = HeaderSpec< - "string.h", - [ - Macro<"NULL">, - ], - [ - SizeTType, - ], - [], // Enumerations - [ - FunctionSpec< - "memcpy", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "memmove", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "memcmp", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "memchr", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "memset", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "memset_explicit", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strcpy", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strncpy", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "strcat", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strncat", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strcmp", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strcoll", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strcoll_l", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strncmp", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "strxfrm", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "strxfrm_l", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "strchr", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strcspn", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strdup", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "strndup", - RetValSpec, - [ArgSpec,ArgSpec] - >, - FunctionSpec< - "strpbrk", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strrchr", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strspn", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strstr", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strtok", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "strerror", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "strlen", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec Math = HeaderSpec< - "math.h", - [ - Macro<"MATH_ERRNO">, - Macro<"MATH_ERREXCEPT">, - Macro<"math_errhandling">, - - Macro<"HUGE_VAL">, - Macro<"INFINITY">, - Macro<"NAN">, - - Macro<"FP_INT_UPWARD">, - Macro<"FP_INT_DOWNWARD">, - Macro<"FP_INT_TOWARDZERO">, - Macro<"FP_INT_TONEARESTFROMZERO">, - Macro<"FP_INT_TONEAREST">, - - Macro<"FP_ILOGB0">, - Macro<"FP_ILOGBNAN">, - - Macro<"isfinite">, - Macro<"isinf">, - Macro<"isnan">, - ], - [ - NamedType<"float_t">, - NamedType<"double_t">, - NamedType<"float128">, - ], - [], // Enumerations - [ - FunctionSpec<"cbrt", RetValSpec, [ArgSpec]>, - FunctionSpec<"cbrtf", RetValSpec, [ArgSpec]>, - - FunctionSpec<"copysign", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"copysignf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"copysignl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"copysignf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"copysignf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"ceil", RetValSpec, [ArgSpec]>, - FunctionSpec<"ceilf", RetValSpec, [ArgSpec]>, - FunctionSpec<"ceill", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"ceilf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"ceilf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"daddl", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"ddivl", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"dfmal", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"dsubl", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"fabs", RetValSpec, [ArgSpec], [ConstAttr]>, - FunctionSpec<"fabsf", RetValSpec, [ArgSpec]>, - FunctionSpec<"fabsl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"fabsf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fabsf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fadd", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"faddl", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"fdim", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fdimf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fdiml", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fdimf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fdimf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fdiv", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fdivl", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"ffma", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"ffmal", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - - FunctionSpec<"floor", RetValSpec, [ArgSpec]>, - FunctionSpec<"floorf", RetValSpec, [ArgSpec]>, - FunctionSpec<"floorl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"floorf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"floorf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fmin", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fminf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"fminf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"fmax", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaxf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaxl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmaxf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - GuardedFunctionSpec<"fmaxf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"fmaximum", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximumf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximuml", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmaximumf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fmaximumf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fmaximum_num", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_numf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_numl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmaximum_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fmaximum_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fmaximum_mag", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_magf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_magl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmaximum_magf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fmaximum_magf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fmaximum_mag_num", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_mag_numf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_mag_numl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmaximum_mag_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fmaximum_mag_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fminimum", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimumf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimuml", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fminimumf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fminimumf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fminimum_num", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimum_numf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmaximum_numl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fminimum_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fminimum_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fminimum_mag", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimum_magf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimum_magl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fminimum_magf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fminimum_magf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fminimum_mag_num", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimum_mag_numf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fminimum_mag_numl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fminimum_mag_numf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fminimum_mag_numf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fma", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"fmaf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - - GuardedFunctionSpec<"f16fmaf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, - - FunctionSpec<"fmod", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmodf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmodl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fmodf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fmodf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"frexp", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"frexpf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"frexpl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"frexpf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"frexpf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fromfp", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"fromfpf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"fromfpl", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fromfpf16", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fromfpf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fromfpx", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"fromfpxf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"fromfpxl", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"fromfpxf16", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"fromfpxf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"fsub", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fsubl", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"ufromfp", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"ufromfpf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"ufromfpl", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"ufromfpf16", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"ufromfpf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"ufromfpx", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"ufromfpxf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"ufromfpxl", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"ufromfpxf16", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"ufromfpxf128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"hypot", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"hypotf", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"ilogb", RetValSpec, [ArgSpec]>, - FunctionSpec<"ilogbf", RetValSpec, [ArgSpec]>, - FunctionSpec<"ilogbl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"ilogbf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"ilogbf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"llogb", RetValSpec, [ArgSpec]>, - FunctionSpec<"llogbf", RetValSpec, [ArgSpec]>, - FunctionSpec<"llogbl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"llogbf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"llogbf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"ldexp", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"ldexpf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"ldexpl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"ldexpf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"ldexpf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"log10", RetValSpec, [ArgSpec]>, - FunctionSpec<"log10f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"log10f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"log1p", RetValSpec, [ArgSpec]>, - FunctionSpec<"log1pf", RetValSpec, [ArgSpec]>, - - FunctionSpec<"log2", RetValSpec, [ArgSpec]>, - FunctionSpec<"log2f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"log2f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"log", RetValSpec, [ArgSpec]>, - FunctionSpec<"logf", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"logf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"logb", RetValSpec, [ArgSpec]>, - FunctionSpec<"logbf", RetValSpec, [ArgSpec]>, - FunctionSpec<"logbl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"logbf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"logbf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"modf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"modff", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"modfl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"modff16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"modff128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"cos", RetValSpec, [ArgSpec]>, - FunctionSpec<"cosf", RetValSpec, [ArgSpec]>, - FunctionSpec<"sin", RetValSpec, [ArgSpec]>, - FunctionSpec<"sinf", RetValSpec, [ArgSpec]>, - FunctionSpec<"tan", RetValSpec, [ArgSpec]>, - FunctionSpec<"tanf", RetValSpec, [ArgSpec]>, - - FunctionSpec<"erff", RetValSpec, [ArgSpec]>, - - FunctionSpec<"exp", RetValSpec, [ArgSpec]>, - FunctionSpec<"expf", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"expf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"exp2", RetValSpec, [ArgSpec]>, - FunctionSpec<"exp2f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"exp2f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"exp2m1f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"exp2m1f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"expm1", RetValSpec, [ArgSpec]>, - FunctionSpec<"expm1f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"expm1f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"exp10", RetValSpec, [ArgSpec]>, - FunctionSpec<"exp10f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"exp10f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"exp10m1f", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"exp10m1f16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"remainder", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"remainderf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"remainderl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"remainderf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"remainderf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"remquo", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"remquof", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"remquol", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"remquof16", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"remquof128", RetValSpec, [ArgSpec, ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"round", RetValSpec, [ArgSpec]>, - FunctionSpec<"roundf", RetValSpec, [ArgSpec]>, - FunctionSpec<"roundl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"roundf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"roundf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"roundeven", RetValSpec, [ArgSpec]>, - FunctionSpec<"roundevenf", RetValSpec, [ArgSpec]>, - FunctionSpec<"roundevenl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"roundevenf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"roundevenf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"lround", RetValSpec, [ArgSpec]>, - FunctionSpec<"lroundf", RetValSpec, [ArgSpec]>, - FunctionSpec<"lroundl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"lroundf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"lroundf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"llround", RetValSpec, [ArgSpec]>, - FunctionSpec<"llroundf", RetValSpec, [ArgSpec]>, - FunctionSpec<"llroundl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"llroundf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"llroundf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"rint", RetValSpec, [ArgSpec]>, - FunctionSpec<"rintf", RetValSpec, [ArgSpec]>, - FunctionSpec<"rintl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"rintf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"rintf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"lrint", RetValSpec, [ArgSpec]>, - FunctionSpec<"lrintf", RetValSpec, [ArgSpec]>, - FunctionSpec<"lrintl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"lrintf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"lrintf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"llrint", RetValSpec, [ArgSpec]>, - FunctionSpec<"llrintf", RetValSpec, [ArgSpec]>, - FunctionSpec<"llrintl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"llrintf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"llrintf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"sqrt", RetValSpec, [ArgSpec]>, - FunctionSpec<"sqrtf", RetValSpec, [ArgSpec]>, - FunctionSpec<"sqrtl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"sqrtf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"sqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"trunc", RetValSpec, [ArgSpec]>, - FunctionSpec<"truncf", RetValSpec, [ArgSpec]>, - FunctionSpec<"truncl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"truncf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"truncf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"nearbyint", RetValSpec, [ArgSpec]>, - FunctionSpec<"nearbyintf", RetValSpec, [ArgSpec]>, - FunctionSpec<"nearbyintl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"nearbyintf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"nearbyintf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"nextafterf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"nextafter", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"nextafterl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"nextafterf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"nextafterf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"nexttowardf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"nexttoward", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"nexttowardl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"nexttowardf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"nextdown", RetValSpec, [ArgSpec]>, - FunctionSpec<"nextdownf", RetValSpec, [ArgSpec]>, - FunctionSpec<"nextdownl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"nextdownf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"nextdownf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"nextup", RetValSpec, [ArgSpec]>, - FunctionSpec<"nextupf", RetValSpec, [ArgSpec]>, - FunctionSpec<"nextupl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"nextupf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"nextupf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"powf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"pow", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"coshf", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"coshf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"sinhf", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"sinhf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"tanhf", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"tanhf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - - FunctionSpec<"acosf", RetValSpec, [ArgSpec]>, - - FunctionSpec<"asinf", RetValSpec, [ArgSpec]>, - FunctionSpec<"asin", RetValSpec, [ArgSpec]>, - - FunctionSpec<"atanf", RetValSpec, [ArgSpec]>, - - FunctionSpec<"atan2", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"atan2f", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"atan2l", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"acoshf", RetValSpec, [ArgSpec]>, - FunctionSpec<"asinhf", RetValSpec, [ArgSpec]>, - FunctionSpec<"atanhf", RetValSpec, [ArgSpec]>, - - FunctionSpec<"scalbln", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"scalblnf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"scalblnl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"scalblnf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"scalblnf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"scalbn", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"scalbnf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"scalbnl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"scalbnf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"scalbnf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"nanf", RetValSpec, [ArgSpec]>, - FunctionSpec<"nan", RetValSpec, [ArgSpec]>, - FunctionSpec<"nanl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"nanf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"nanf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"issignaling", RetValSpec, [ArgSpec]>, - FunctionSpec<"issignalingf", RetValSpec, [ArgSpec]>, - FunctionSpec<"issignalingl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"issignalingf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"issignalingf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"canonicalize", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"canonicalizef", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"canonicalizel", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"canonicalizef16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"canonicalizef128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"iscanonical", RetValSpec, [ArgSpec]>, - FunctionSpec<"iscanonicalf", RetValSpec, [ArgSpec]>, - FunctionSpec<"iscanonicall", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"iscanonicalf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"iscanonicalf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"dsqrtl", RetValSpec, [ArgSpec]>, - - FunctionSpec<"totalorder", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"totalorderf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"totalorderl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"totalorderf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"totalorderf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"totalordermag", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"totalordermagf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"totalordermagl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"totalordermagf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"totalordermagf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"getpayload", RetValSpec, [ArgSpec]>, - FunctionSpec<"getpayloadf", RetValSpec, [ArgSpec]>, - FunctionSpec<"getpayloadl", RetValSpec, [ArgSpec]>, - GuardedFunctionSpec<"getpayloadf16", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"getpayloadf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"setpayload", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"setpayloadf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"setpayloadl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"setpayloadf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"setpayloadf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - FunctionSpec<"setpayloadsig", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"setpayloadsigf", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"setpayloadsigl", RetValSpec, [ArgSpec, ArgSpec]>, - GuardedFunctionSpec<"setpayloadsigf16", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16">, - GuardedFunctionSpec<"setpayloadsigf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT128">, - - GuardedFunctionSpec<"f16addf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, - - GuardedFunctionSpec<"f16subf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, - - FunctionSpec<"fmul", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"fmull", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"dmull", RetValSpec, [ArgSpec, ArgSpec]>, - - GuardedFunctionSpec<"f16mulf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, - - FunctionSpec<"fsqrt", RetValSpec, [ArgSpec]>, - FunctionSpec<"fsqrtl", RetValSpec, [ArgSpec]>, - - GuardedFunctionSpec<"f16divf128", RetValSpec, [ArgSpec, ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, - - GuardedFunctionSpec<"f16sqrtf128", RetValSpec, [ArgSpec], "LIBC_TYPES_HAS_FLOAT16_AND_FLOAT128">, - - FunctionSpec<"lgamma", RetValSpec, [ArgSpec]>, - FunctionSpec<"lgammaf", RetValSpec, [ArgSpec]>, - FunctionSpec<"lgammal", RetValSpec, [ArgSpec]>, - ] - >; - - HeaderSpec StdIO = HeaderSpec< - "stdio.h", - [ - Macro<"stdin">, - Macro<"stderr">, - Macro<"stdout">, - Macro<"_IOFBF">, - Macro<"_IOLBF">, - Macro<"_IONBF">, - Macro<"EOF">, - ], // Macros - [ // Types - SizeTType, - FILE, - ], - [], // Enumerations - [ - FunctionSpec< - "clearerr", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fclose", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "feof", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ferror", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fgetc", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fgets", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "fflush", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fopen", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fputc", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "ftell", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getc", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "getchar", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "putc", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "putchar", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fputs", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "puts", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "fread", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fseek", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fwrite", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "remove", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "rename", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "setbuf", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "setvbuf", - RetValSpec, - [ArgSpec, ArgSpec, ArgSpec, ArgSpec] - >, - FunctionSpec< - "sscanf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vsscanf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "scanf", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vscanf", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fscanf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vfscanf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "sprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "snprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "printf", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "fprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "asprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vsprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vsnprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vprintf", - RetValSpec, - [ArgSpec, - ArgSpec] - >, - FunctionSpec< - "vfprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - FunctionSpec< - "ungetc", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "vasprintf", - RetValSpec, - [ArgSpec, - ArgSpec, - ArgSpec] - >, - ], - [ - ObjectSpec< - "stdin", - "FILE *" - >, - ObjectSpec< - "stdout", - "FILE *" - >, - ObjectSpec< - "stderr", - "FILE *" - >, - ] - >; - - HeaderSpec StdBit = HeaderSpec< - "stdbit.h", - [ - Macro<"__STDC_VERSION_STDBIT_H__">, - Macro<"__STDC_ENDIAN_LITTLE__">, - Macro<"__STDC_ENDIAN_BIG__">, - Macro<"__STDC_ENDIAN_NATIVE__">, - Macro<"stdc_leading_zeros">, - Macro<"stdc_leading_ones">, - Macro<"stdc_trailing_zeros">, - Macro<"stdc_trailing_ones">, - Macro<"stdc_first_leading_zero">, - Macro<"stdc_first_leading_one">, - Macro<"stdc_first_trailing_zero">, - Macro<"stdc_first_trailing_one">, - Macro<"stdc_count_zeros">, - Macro<"stdc_count_ones">, - Macro<"stdc_has_single_bit">, - Macro<"stdc_bit_width">, - Macro<"stdc_bit_floor">, - Macro<"stdc_bit_ceil"> - ], // Macros - [], // Types - [], // Enumerations - [ - FunctionSpec<"stdc_leading_zeros_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_zeros_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_zeros_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_zeros_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_zeros_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_ones_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_ones_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_ones_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_ones_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_leading_ones_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_zeros_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_zeros_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_zeros_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_zeros_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_zeros_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_ones_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_ones_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_ones_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_ones_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_trailing_ones_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_zero_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_zero_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_zero_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_zero_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_zero_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_one_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_one_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_one_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_one_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_leading_one_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_trailing_one_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_trailing_one_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_trailing_one_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_trailing_one_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_first_trailing_one_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_zeros_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_zeros_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_zeros_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_zeros_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_zeros_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_ones_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_ones_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_ones_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_ones_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_count_ones_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_has_single_bit_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_has_single_bit_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_has_single_bit_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_has_single_bit_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_has_single_bit_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_width_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_width_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_width_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_width_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_width_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_floor_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_floor_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_floor_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_floor_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_floor_ull", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_ceil_uc", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_ceil_us", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_ceil_ui", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_ceil_ul", RetValSpec, [ArgSpec]>, - FunctionSpec<"stdc_bit_ceil_ull", RetValSpec, [ArgSpec]> - ] // Functions - >; - - HeaderSpec StdCkdInt = HeaderSpec< - "stdckdint.h", - [ - Macro<"__STDC_VERSION_STDCKDINT_H__">, - Macro<"ckd_add">, - Macro<"ckd_sub">, - Macro<"ckd_mul"> - ], // Macros - [], // Types - [], // Enumerations - [] // Functions - >; - - HeaderSpec StdLib = HeaderSpec< - "stdlib.h", - [], // Macros - [ - DivTType, - LDivTType, - LLDivTType, - SizeTType, - BSearchCompareT, - QSortCompareT, - AtexitHandlerT, - ], // Types - [], // Enumerations - [ - FunctionSpec<"abort", RetValSpec, [ArgSpec]>, - - FunctionSpec<"bsearch", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - - FunctionSpec<"abs", RetValSpec, [ArgSpec]>, - FunctionSpec<"labs", RetValSpec, [ArgSpec]>, - FunctionSpec<"llabs", RetValSpec, [ArgSpec]>, - - FunctionSpec<"atof", RetValSpec, [ArgSpec]>, - FunctionSpec<"atoi", RetValSpec, [ArgSpec]>, - FunctionSpec<"atol", RetValSpec, [ArgSpec]>, - FunctionSpec<"atoll", RetValSpec, [ArgSpec]>, - - FunctionSpec<"div", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"ldiv", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"lldiv", RetValSpec, [ArgSpec, ArgSpec]>, - - FunctionSpec<"qsort", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - - FunctionSpec<"rand", RetValSpec, [ArgSpec]>, - FunctionSpec<"srand", RetValSpec, [ArgSpec]>, - - FunctionSpec<"strfromf", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strfromd", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strfroml", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - - FunctionSpec<"strtof", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"strtod", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"strtold", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"strtol", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoll", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoul", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoull", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - - FunctionSpec<"strtof_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtod_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtold_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtol_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoll_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoul_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoull_l", RetValSpec, [ArgSpec, ArgSpec, ArgSpec, ArgSpec]>, - - FunctionSpec<"malloc", RetValSpec, [ArgSpec]>, - FunctionSpec<"calloc", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"realloc", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"aligned_alloc", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"free", RetValSpec, [ArgSpec]>, - - FunctionSpec<"_Exit", RetValSpec, [ArgSpec]>, - FunctionSpec<"at_quick_exit", RetValSpec, [ArgSpec]>, - FunctionSpec<"atexit", RetValSpec, [ArgSpec]>, - FunctionSpec<"exit", RetValSpec, [ArgSpec]>, - FunctionSpec<"quick_exit", RetValSpec, [ArgSpec]>, - - FunctionSpec<"system", RetValSpec, [ArgSpec]>, - ] - >; - - NamedType IMaxDivTType = NamedType<"imaxdiv_t">; - - HeaderSpec IntTypes = HeaderSpec< - "inttypes.h", - [ - Macro<"__STDC_VERSION_INTTYPES_H__">, - ], // Macros - [ - IMaxDivTType, - ], // Types - [], // Enumerations - [ - FunctionSpec<"imaxabs", RetValSpec, [ArgSpec]>, - FunctionSpec<"imaxdiv", RetValSpec, [ArgSpec, ArgSpec]>, - FunctionSpec<"strtoimax", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - FunctionSpec<"strtoumax", RetValSpec, [ArgSpec, ArgSpec, ArgSpec]>, - ] - >; - - HeaderSpec Errno = HeaderSpec< - "errno.h", - [ - Macro<"errno">, - Macro<"EDOM">, - Macro<"EILSEQ">, - Macro<"ERANGE">, - ] - >; - - HeaderSpec Float = HeaderSpec< - "float.h", - [ - Macro<"FLT_MANT_DIG">, - Macro<"DBL_MANT_DIG">, - Macro<"LDBL_MANT_DIG">, - ] - >; - - HeaderSpec StdInt = HeaderSpec<"StdInt.h">; - - HeaderSpec Limits = HeaderSpec<"limits.h">; - - NamedType SigAtomicT = NamedType<"sig_atomic_t">; - HeaderSpec Signal = HeaderSpec< - "signal.h", - [ - Macro<"SIG_BLOCK">, - Macro<"SIG_UNBLOCK">, - Macro<"SIG_SETMASK">, - - Macro<"SIGABRT">, - Macro<"SIGFPE">, - Macro<"SIGILL">, - Macro<"SIGINT">, - Macro<"SIGSEGV">, - Macro<"SIGTERM"> - ], - [ - SizeTType, - SigAtomicT, - SigHandlerT, - ], - [], // Enumerations - [ - FunctionSpec<"raise", RetValSpec, [ArgSpec]>, - FunctionSpec< - "signal", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Threads = HeaderSpec< - "threads.h", - [ - Macro<"ONCE_FLAG_INIT">, - ], - [ - OnceFlagType, - CallOnceFuncType, - CndTType, - MtxTType, - ThrdStartTType, - ThrdTType, - TssTType, - TssDtorTType, - ], - [ - EnumeratedNameValue<"mtx_plain">, - EnumeratedNameValue<"mtx_recursive">, - EnumeratedNameValue<"mtx_timed">, - EnumeratedNameValue<"thrd_timedout">, - EnumeratedNameValue<"thrd_success">, - EnumeratedNameValue<"thrd_busy">, - EnumeratedNameValue<"thrd_error">, - EnumeratedNameValue<"thrd_nomem">, - ], - [ - FunctionSpec< - "call_once", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "cnd_broadcast", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "cnd_destroy", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "cnd_init", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "cnd_signal", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "cnd_wait", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "mtx_init", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "mtx_destroy", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "mtx_lock", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "mtx_unlock", - RetValSpec, - [ - ArgSpec, - ] - >, - FunctionSpec< - "thrd_create", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "thrd_join", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "thrd_detach", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "thrd_current", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "thrd_equal", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "thrd_exit", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "tss_create", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "tss_delete", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "tss_get", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "tss_set", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec Time = HeaderSpec< - "time.h", - [], // Macros - [ // Types - ClockT, - StructTmType, - StructTimeSpec, - TimeTType, - SizeTType, - ], - [], // Enumerations - [ - FunctionSpec< - "asctime", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "asctime_r", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "ctime", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "ctime_r", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "clock", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "difftime", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "gmtime", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "gmtime_r", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ] - >, - FunctionSpec< - "mktime", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "time", - RetValSpec, - [ArgSpec] - >, - ] - >; - - HeaderSpec SetJmp = HeaderSpec< - "setjmp.h", - [], // Macros - [JmpBuf], - [], // Enumerations - [ - FunctionSpec< - "longjmp", - RetValSpec, - [ArgSpec, ArgSpec] - >, - FunctionSpec< - "setjmp", - RetValSpec, - [ArgSpec] - >, - FunctionSpec< - "longjmp", - RetValSpec, - [ArgSpec, ArgSpec] - >, - ] - >; - - HeaderSpec UChar = HeaderSpec< - "uchar.h", - [], // Macros - [ //Types - MBStateTType, - Char8TType, - Char16TType, - Char32TType, - SizeTType, - ], - [], // Enumerations - [] - >; - - HeaderSpec WChar = HeaderSpec< - "wchar.h", - [ // Macros - Macro<"WEOF">, - ], - [ //Types - MBStateTType, - SizeTType, - WIntType, - WCharType, - ], - [], // Enumerations - [ - FunctionSpec< - "wctob", - RetValSpec, - [ArgSpec] - >, - ] - >; - - NamedType StructLconv = NamedType<"struct lconv">; - PtrType StructLconvPtr = PtrType; - - HeaderSpec Locale = HeaderSpec< - "locale.h", - [], // Macros - [LocaleT, StructLconv], // Types - [], // Enumerations - [ - FunctionSpec< - "duplocale", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "freelocale", - RetValSpec, - [ - ArgSpec - ] - >, - FunctionSpec< - "localeconv", - RetValSpec, - [] - >, - FunctionSpec< - "newlocale", - RetValSpec, - [ - ArgSpec, - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "setlocale", - RetValSpec, - [ - ArgSpec, - ArgSpec - ] - >, - FunctionSpec< - "uselocale", - RetValSpec, - [ - ArgSpec - ] - > - ] // Functions - >; - - let Headers = [ - Assert, - CType, - Errno, - Fenv, - Float, - StdInt, - Limits, - Math, - String, - StdBit, - StdCkdInt, - StdIO, - StdLib, - IntTypes, - SetJmp, - Signal, - Threads, - Time, - UChar, - WChar, - Locale, - ]; -} diff --git a/libc/spec/stdc_ext.td b/libc/spec/stdc_ext.td deleted file mode 100644 index dee3b8bdf6feeb..00000000000000 --- a/libc/spec/stdc_ext.td +++ /dev/null @@ -1,82 +0,0 @@ -// Fixed point types. -// From ISO/IEC TR 18037:2008 standard: -// https://standards.iso.org/ittf/PubliclyAvailableStandards/c051126_ISO_IEC_TR_18037_2008.zip -def ShortFractType : NamedType<"short fract">; -def FractType : NamedType<"fract">; -def LongFractType : NamedType<"long fract">; -def UnsignedShortFractType : NamedType<"unsigned short fract">; -def UnsignedFractType : NamedType<"unsigned fract">; -def UnsignedLongFractType : NamedType<"unsigned long fract">; - -def ShortAccumType : NamedType<"short accum">; -def AccumType : NamedType<"accum">; -def LongAccumType : NamedType<"long accum">; -def UnsignedShortAccumType : NamedType<"unsigned short accum">; -def UnsignedAccumType : NamedType<"unsigned accum">; -def UnsignedLongAccumType : NamedType<"unsigned long accum">; - -def IntHrT : NamedType <"int_hr_t">; -def IntRT : NamedType<"int_r_t">; -def IntLrT : NamedType<"int_lr_t">; -def IntHkT : NamedType<"int_hk_t">; -def IntKT : NamedType<"int_k_t">; -def IntLkT : NamedType<"int_lk_t">; -def UIntUhrT : NamedType<"uint_uhr_t">; -def UIntUrT : NamedType<"uint_ur_t">; -def UIntUlrT : NamedType<"uint_ulr_t">; -def UIntUhkT : NamedType<"uint_uhk_t">; -def UIntUkT : NamedType<"uint_uk_t">; -def UIntUlkT : NamedType<"uint_ulk_t">; - -def StdcExt : StandardSpec<"stdc_ext"> { - // From ISO/IEC TR 18037:2008 standard: - // https://standards.iso.org/ittf/PubliclyAvailableStandards/c051126_ISO_IEC_TR_18037_2008.zip - HeaderSpec StdFix = HeaderSpec< - "stdfix.h", - [], // macros - [IntHrT,IntRT, IntLrT, IntHkT, IntKT, IntLkT, UIntUhrT, UIntUrT, UIntUlrT, UIntUhkT, UIntUkT, UIntUlkT], // types - [], // enums - [ // functions - GuardedFunctionSpec<"abshr", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"absr", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"abslr", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"abshk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"absk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"abslk", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"roundhr", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundr", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundlr", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"roundhk", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundk", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundlk", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"rounduhr", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundur", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundulr", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"rounduhk", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"rounduk", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"roundulk", RetValSpec, [ArgSpec, ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - - GuardedFunctionSpec<"hrbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"rbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"lrbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"hkbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"kbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"lkbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"uhrbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"urbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"ukbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"ulrbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"uhkbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - GuardedFunctionSpec<"ulkbits", RetValSpec, [ArgSpec], "LIBC_COMPILER_HAS_FIXED_POINT">, - ] - >; - - let Headers = [ - StdFix, - ]; -} diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt index e121555bd60a9f..8ac8f91e98d4cc 100644 --- a/libc/test/src/CMakeLists.txt +++ b/libc/test/src/CMakeLists.txt @@ -88,81 +88,3 @@ add_subdirectory(locale) if(${LIBC_TARGET_OS} STREQUAL "linux") add_subdirectory(pthread) endif() - -if(LLVM_RUNTIMES_BUILD OR LIBC_HDRGEN_EXE) - # The public API test below uses tablegen to generate the test - # source file. Since tablegen is not available during a runtimes - # build, we will skip the test. - # If a different libc-hdrgen binary is being used, then also we - # skip the api-test as we cannot generate the test source file. - return() -endif() - -set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_api_test.cpp) - -set(entrypoints_name_list "") -foreach(entry IN LISTS TARGET_LLVMLIBC_ENTRYPOINTS) - get_target_property(entry_name ${entry} "ENTRYPOINT_NAME") - list(APPEND entrypoints_name_list ${entry_name}) -endforeach() - -# TODO: Remove these when they are added to the TableGen. -list(REMOVE_ITEM entrypoints_name_list "__assert_fail" "__errno_location") -list(TRANSFORM entrypoints_name_list PREPEND "-e=") - -file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td) - -# Generate api test souce code. -add_custom_command( - OUTPUT ${public_test} - COMMAND $ -o ${public_test} - ${entrypoints_name_list} - -I ${LIBC_SOURCE_DIR} - ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td - - DEPENDS ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td ${spec_files} - libc-prototype-testgen ${TARGET_PUBLIC_HEADERS} - ${LIBC_TARGET} -) - -add_custom_target(libc-api-test) -add_dependencies(check-libc libc-api-test) - -set( - allocator_entrypoints - libc.src.stdlib.malloc - libc.src.stdlib.calloc - libc.src.stdlib.realloc - libc.src.stdlib.aligned_alloc - libc.src.stdlib.free -) -set(api-test-entrypoints ${TARGET_LLVMLIBC_ENTRYPOINTS}) -list(REMOVE_ITEM api-test-entrypoints ${allocator_entrypoints}) -add_integration_test( - api-test - SUITE - libc-api-test - SRCS - ${public_test} - DEPENDS - ${api-test-entrypoints} -) - -if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING) - add_custom_target( - libc-api-test-tidy - VERBATIM - COMMAND ${LLVM_LIBC_CLANG_TIDY} --system-headers - --checks=-*,llvmlibc-restrict-system-libc-headers - "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}" - --header-filter=.* - --warnings-as-errors=llvmlibc-* - "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}" - --quiet - -p ${PROJECT_BINARY_DIR} - ${public_test} - DEPENDS - clang-tidy ${public_test} - ) - add_dependencies(libc-api-test libc-api-test-tidy) -endif() diff --git a/libc/utils/HdrGen/CMakeLists.txt b/libc/utils/HdrGen/CMakeLists.txt deleted file mode 100644 index 47f845b9f9a5bb..00000000000000 --- a/libc/utils/HdrGen/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -include(TableGen) - -if (NOT LLVM_LINK_LLVM_DYLIB) - set(LLVM_LINK_COMPONENTS Support) -endif() - -add_tablegen(libc-hdrgen LIBC - Command.h - Command.cpp - Generator.cpp - Generator.h - IncludeFileCommand.cpp - IncludeFileCommand.h - Main.cpp - PublicAPICommand.cpp - PublicAPICommand.h -) - -target_include_directories(libc-hdrgen PRIVATE ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) -target_link_libraries(libc-hdrgen PRIVATE LibcTableGenUtil) - -add_subdirectory(PrototypeTestGen) diff --git a/libc/utils/HdrGen/Command.cpp b/libc/utils/HdrGen/Command.cpp deleted file mode 100644 index 04462c18aac3f0..00000000000000 --- a/libc/utils/HdrGen/Command.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//===-- Base class for header generation commands -------------------------===// -// -// 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 "Command.h" - -namespace llvm_libc { - -Command::~Command() {} - -} // namespace llvm_libc diff --git a/libc/utils/HdrGen/Command.h b/libc/utils/HdrGen/Command.h deleted file mode 100644 index 42516798ffaec0..00000000000000 --- a/libc/utils/HdrGen/Command.h +++ /dev/null @@ -1,54 +0,0 @@ -//===-- Base class for header generation commands ---------------*- 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_UTILS_HDRGEN_COMMAND_H -#define LLVM_LIBC_UTILS_HDRGEN_COMMAND_H - -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/Twine.h" -#include "llvm/Support/SourceMgr.h" - -#include - -namespace llvm { - -class raw_ostream; -class RecordKeeper; - -} // namespace llvm - -namespace llvm_libc { - -typedef llvm::SmallVector ArgVector; - -class Command { -public: - class ErrorReporter { - llvm::SMLoc Loc; - const llvm::SourceMgr &SrcMgr; - - public: - ErrorReporter(llvm::SMLoc L, llvm::SourceMgr &SM) : Loc(L), SrcMgr(SM) {} - - [[noreturn]] void printFatalError(llvm::Twine Msg) const { - SrcMgr.PrintMessage(Loc, llvm::SourceMgr::DK_Error, Msg); - std::exit(1); - } - }; - - virtual ~Command(); - - virtual void run(llvm::raw_ostream &OS, const ArgVector &Args, - llvm::StringRef StdHeader, const llvm::RecordKeeper &Records, - const ErrorReporter &Reporter) const = 0; -}; - -} // namespace llvm_libc - -#endif // LLVM_LIBC_UTILS_HDRGEN_COMMAND_H diff --git a/libc/utils/HdrGen/Generator.cpp b/libc/utils/HdrGen/Generator.cpp deleted file mode 100644 index b4e1166b1a37b2..00000000000000 --- a/libc/utils/HdrGen/Generator.cpp +++ /dev/null @@ -1,203 +0,0 @@ -//===-- Implementation of the main header generation class ----------------===// -// -// 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 "Generator.h" - -#include "IncludeFileCommand.h" -#include "PublicAPICommand.h" -#include "utils/LibcTableGenUtil/APIIndexer.h" - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/Support/raw_ostream.h" - -#include -#include - -static const char CommandPrefix[] = "%%"; -static const size_t CommandPrefixSize = llvm::StringRef(CommandPrefix).size(); - -static const char CommentPrefix[] = ""; - -static const char ParamNamePrefix[] = "${"; -static const size_t ParamNamePrefixSize = - llvm::StringRef(ParamNamePrefix).size(); -static const char ParamNameSuffix[] = "}"; -static const size_t ParamNameSuffixSize = - llvm::StringRef(ParamNameSuffix).size(); - -namespace llvm_libc { - -Command *Generator::getCommandHandler(llvm::StringRef CommandName) { - if (CommandName == IncludeFileCommand::Name) { - if (!IncludeFileCmd) - IncludeFileCmd = std::make_unique(); - return IncludeFileCmd.get(); - } else if (CommandName == PublicAPICommand::Name) { - if (!PublicAPICmd) - PublicAPICmd = std::make_unique(EntrypointNameList); - return PublicAPICmd.get(); - } else { - return nullptr; - } -} - -void Generator::parseCommandArgs(llvm::StringRef ArgStr, ArgVector &Args) { - if (!ArgStr.contains(',') && ArgStr.trim(' ').trim('\t').size() == 0) { - // If it is just space between the parenthesis - return; - } - - ArgStr.split(Args, ","); - for (llvm::StringRef &A : Args) { - A = A.trim(' '); - if (A.starts_with(ParamNamePrefix) && A.ends_with(ParamNameSuffix)) { - A = A.drop_front(ParamNamePrefixSize).drop_back(ParamNameSuffixSize); - A = ArgMap[std::string(A)]; - } - } -} - -void Generator::generate(llvm::raw_ostream &OS, - const llvm::RecordKeeper &Records) { - auto DefFileBuffer = llvm::MemoryBuffer::getFile(HeaderDefFile); - if (!DefFileBuffer) { - llvm::errs() << "Unable to open " << HeaderDefFile << ".\n"; - std::exit(1); - } - llvm::SourceMgr SrcMgr; - unsigned DefFileID = SrcMgr.AddNewSourceBuffer( - std::move(DefFileBuffer.get()), llvm::SMLoc::getFromPointer(nullptr)); - - llvm::StringRef Content = SrcMgr.getMemoryBuffer(DefFileID)->getBuffer(); - while (true) { - std::pair P = Content.split('\n'); - Content = P.second; - - llvm::StringRef Line = P.first.trim(' '); - if (Line.starts_with(CommandPrefix)) { - Line = Line.drop_front(CommandPrefixSize); - - P = Line.split("("); - // It's possible that we have windows line endings, so strip off the extra - // CR. - P.second = P.second.trim(); - if (P.second.empty() || P.second[P.second.size() - 1] != ')') { - SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()), - llvm::SourceMgr::DK_Error, - "Command argument list should begin with '(' " - "and end with ')'."); - SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()), - llvm::SourceMgr::DK_Error, P.second.data()); - SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()), - llvm::SourceMgr::DK_Error, - std::to_string(P.second.size())); - std::exit(1); - } - llvm::StringRef CommandName = P.first; - Command *Cmd = getCommandHandler(CommandName); - if (Cmd == nullptr) { - SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(CommandName.data()), - llvm::SourceMgr::DK_Error, - "Unknown command '%%" + CommandName + "'."); - std::exit(1); - } - - llvm::StringRef ArgStr = P.second.drop_back(1); - ArgVector Args; - parseCommandArgs(ArgStr, Args); - - Command::ErrorReporter Reporter( - llvm::SMLoc::getFromPointer(CommandName.data()), SrcMgr); - Cmd->run(OS, Args, StdHeader, Records, Reporter); - } else if (!Line.starts_with(CommentPrefix)) { - // There is no comment or command on this line so we just write it as is. - OS << P.first << "\n"; - } - - if (P.second.empty()) - break; - } -} - -void Generator::generateDecls(llvm::raw_ostream &OS, - const llvm::RecordKeeper &Records) { - - OS << "//===-- C standard declarations for " << StdHeader << " " - << std::string(80 - (42 + StdHeader.size()), '-') << "===//\n" - << "//\n" - << "// Part of the LLVM Project, under the Apache License v2.0 with LLVM " - "Exceptions.\n" - << "// See https://llvm.org/LICENSE.txt for license information.\n" - << "// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n" - << "//\n" - << "//" - "===-------------------------------------------------------------------" - "---===//\n\n"; - - std::string HeaderGuard(StdHeader.size(), '\0'); - llvm::transform(StdHeader, HeaderGuard.begin(), [](const char C) -> char { - return !isalnum(C) ? '_' : llvm::toUpper(C); - }); - OS << "#ifndef __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n" - << "#define __LLVM_LIBC_DECLARATIONS_" << HeaderGuard << "\n\n"; - - OS << "#ifndef __LIBC_ATTRS\n" - << "#define __LIBC_ATTRS\n" - << "#endif\n\n"; - - OS << "#ifdef __cplusplus\n" - << "extern \"C\" {\n" - << "#endif\n\n"; - - APIIndexer G(StdHeader, Records); - for (auto &Name : EntrypointNameList) { - // Filter out functions not exported by this header. - if (G.FunctionSpecMap.find(Name) == G.FunctionSpecMap.end()) - continue; - - const llvm::Record *FunctionSpec = G.FunctionSpecMap[Name]; - const llvm::Record *RetValSpec = FunctionSpec->getValueAsDef("Return"); - const llvm::Record *ReturnType = RetValSpec->getValueAsDef("ReturnType"); - - OS << G.getTypeAsString(ReturnType) << " " << Name << "("; - - auto ArgsList = FunctionSpec->getValueAsListOfDefs("Args"); - for (size_t i = 0; i < ArgsList.size(); ++i) { - const llvm::Record *ArgType = ArgsList[i]->getValueAsDef("ArgType"); - OS << G.getTypeAsString(ArgType); - if (i < ArgsList.size() - 1) - OS << ", "; - } - - OS << ") __LIBC_ATTRS;\n\n"; - } - - // Make another pass over entrypoints to emit object declarations. - for (const auto &Name : EntrypointNameList) { - if (G.ObjectSpecMap.find(Name) == G.ObjectSpecMap.end()) - continue; - const llvm::Record *ObjectSpec = G.ObjectSpecMap[Name]; - auto Type = ObjectSpec->getValueAsString("Type"); - OS << "extern " << Type << " " << Name << " __LIBC_ATTRS;\n"; - } - - // Emit a final newline if we emitted any object declarations. - if (llvm::any_of(EntrypointNameList, [&](const std::string &Name) { - return G.ObjectSpecMap.find(Name) != G.ObjectSpecMap.end(); - })) - OS << "\n"; - - OS << "#ifdef __cplusplus\n" - << "}\n" - << "#endif\n\n"; - OS << "#endif\n"; -} - -} // namespace llvm_libc diff --git a/libc/utils/HdrGen/Generator.h b/libc/utils/HdrGen/Generator.h deleted file mode 100644 index 1c149d21156407..00000000000000 --- a/libc/utils/HdrGen/Generator.h +++ /dev/null @@ -1,60 +0,0 @@ -//===-- The main header generation class ------------------------*- 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H -#define LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H - -#include "Command.h" - -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" - -#include -#include -#include - -namespace llvm { - -class raw_ostream; -class RecordKeeper; - -} // namespace llvm - -namespace llvm_libc { - -class Command; - -class Generator { - llvm::StringRef HeaderDefFile; - const std::vector &EntrypointNameList; - llvm::StringRef StdHeader; - std::unordered_map &ArgMap; - - std::unique_ptr IncludeFileCmd; - std::unique_ptr PublicAPICmd; - - Command *getCommandHandler(llvm::StringRef CommandName); - - void parseCommandArgs(llvm::StringRef ArgStr, ArgVector &Args); - - void printError(llvm::StringRef Msg); - -public: - Generator(const std::string &DefFile, const std::vector &EN, - const std::string &Header, - std::unordered_map &Map) - : HeaderDefFile(DefFile), EntrypointNameList(EN), StdHeader(Header), - ArgMap(Map) {} - - void generate(llvm::raw_ostream &OS, const llvm::RecordKeeper &Records); - void generateDecls(llvm::raw_ostream &OS, const llvm::RecordKeeper &Records); -}; - -} // namespace llvm_libc - -#endif // LLVM_LIBC_UTILS_HDRGEN_GENERATOR_H diff --git a/libc/utils/HdrGen/IncludeFileCommand.cpp b/libc/utils/HdrGen/IncludeFileCommand.cpp deleted file mode 100644 index 43efe43585eb20..00000000000000 --- a/libc/utils/HdrGen/IncludeFileCommand.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===-- Implementation of IncludeFileCommand ------------------------------===// -// -// 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 "IncludeFileCommand.h" - -#include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SourceMgr.h" - -#include - -namespace llvm_libc { - -const char IncludeFileCommand::Name[] = "include_file"; - -void IncludeFileCommand::run(llvm::raw_ostream &OS, const ArgVector &Args, - llvm::StringRef StdHeader, - const llvm::RecordKeeper &Records, - const Command::ErrorReporter &Reporter) const { - if (Args.size() != 1) { - Reporter.printFatalError( - "%%include_file command takes exactly 1 argument."); - } - - llvm::StringRef IncludeFile = Args[0]; - auto Buffer = llvm::MemoryBuffer::getFileAsStream(IncludeFile); - if (!Buffer) - Reporter.printFatalError(llvm::StringRef("Unable to open ") + IncludeFile); - - llvm::StringRef Content = Buffer.get()->getBuffer(); - - // If the included file has %%begin() command listed, then we want to write - // only the content after the begin command. - // TODO: The way the content is split below does not allow space within the - // the parentheses and, before and after the command. This probably is too - // strict and should be relaxed. - auto P = Content.split("\n%%begin()\n"); - if (P.second.empty()) { - // There was no %%begin in the content. - OS << P.first; - } else { - OS << P.second; - } -} - -} // namespace llvm_libc diff --git a/libc/utils/HdrGen/IncludeFileCommand.h b/libc/utils/HdrGen/IncludeFileCommand.h deleted file mode 100644 index b3a6ff5462ded0..00000000000000 --- a/libc/utils/HdrGen/IncludeFileCommand.h +++ /dev/null @@ -1,32 +0,0 @@ -//===-- Class which implements the %%include_file command -------*- 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_UTILS_HDRGEN_INCLUDE_COMMAND_H -#define LLVM_LIBC_UTILS_HDRGEN_INCLUDE_COMMAND_H - -#include "Command.h" - -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" - -#include - -namespace llvm_libc { - -class IncludeFileCommand : public Command { -public: - static const char Name[]; - - void run(llvm::raw_ostream &OS, const ArgVector &Args, - llvm::StringRef StdHeader, const llvm::RecordKeeper &Records, - const Command::ErrorReporter &Reporter) const override; -}; - -} // namespace llvm_libc - -#endif // LLVM_LIBC_UTILS_HDRGEN_INCLUDE_COMMAND_H diff --git a/libc/utils/HdrGen/Main.cpp b/libc/utils/HdrGen/Main.cpp deleted file mode 100644 index f795e96e45c57a..00000000000000 --- a/libc/utils/HdrGen/Main.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===-- "main" function of libc-hdrgen ------------------------------------===// -// -// 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 "Generator.h" - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/TableGen/Main.h" - -#include -#include - -static llvm::cl::opt - HeaderDefFile("def", llvm::cl::desc("Path to the .h.def file."), - llvm::cl::value_desc(""), llvm::cl::Required); -static llvm::cl::opt StandardHeader( - "header", - llvm::cl::desc("The standard header file which is to be generated."), - llvm::cl::value_desc("
")); -static llvm::cl::list EntrypointNamesOption( - "e", llvm::cl::value_desc(""), - llvm::cl::desc( - "Each --e is one entrypoint (generated from entrypoints.txt)"), - llvm::cl::OneOrMore); -static llvm::cl::list ReplacementValues( - "args", llvm::cl::desc("Command separated = pairs."), - llvm::cl::value_desc("[,name=value]")); -static llvm::cl::opt ExportDecls( - "export-decls", - llvm::cl::desc("Output a new header containing only the entrypoints.")); - -static void -ParseArgValuePairs(std::unordered_map &Map) { - for (std::string &R : ReplacementValues) { - auto Pair = llvm::StringRef(R).split('='); - Map[std::string(Pair.first)] = std::string(Pair.second); - } -} - -static bool HeaderGeneratorMain(llvm::raw_ostream &OS, - const llvm::RecordKeeper &Records) { - std::unordered_map ArgMap; - ParseArgValuePairs(ArgMap); - llvm_libc::Generator G(HeaderDefFile, EntrypointNamesOption, StandardHeader, - ArgMap); - if (ExportDecls) - G.generateDecls(OS, Records); - else - G.generate(OS, Records); - - return false; -} - -int main(int argc, char *argv[]) { - llvm::cl::ParseCommandLineOptions(argc, argv); - return TableGenMain(argv[0], &HeaderGeneratorMain); -} diff --git a/libc/utils/HdrGen/PrototypeTestGen/CMakeLists.txt b/libc/utils/HdrGen/PrototypeTestGen/CMakeLists.txt deleted file mode 100644 index 9e25c21c6b3593..00000000000000 --- a/libc/utils/HdrGen/PrototypeTestGen/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_tablegen(libc-prototype-testgen LLVM_LIBC - PrototypeTestGen.cpp -) -target_link_libraries(libc-prototype-testgen PRIVATE LibcTableGenUtil) -target_include_directories(libc-prototype-testgen PRIVATE ${LIBC_SOURCE_DIR}) diff --git a/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp b/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp deleted file mode 100644 index 7acaf75c4c1c8b..00000000000000 --- a/libc/utils/HdrGen/PrototypeTestGen/PrototypeTestGen.cpp +++ /dev/null @@ -1,106 +0,0 @@ -//===-- PrototypeTestGen.cpp ----------------------------------------------===// -// -// 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 "utils/LibcTableGenUtil/APIIndexer.h" - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/TableGen/Main.h" -#include "llvm/TableGen/Record.h" - -namespace { - -llvm::cl::list - EntrypointNamesOption("e", llvm::cl::desc(""), - llvm::cl::OneOrMore); - -} // anonymous namespace - -bool TestGeneratorMain(llvm::raw_ostream &OS, - const llvm::RecordKeeper &records) { - OS << "#include \"src/__support/CPP/type_traits.h\"\n"; - llvm_libc::APIIndexer G(records); - std::unordered_set headerFileSet; - for (const auto &entrypoint : EntrypointNamesOption) { - if (entrypoint == "errno") - continue; - auto match = G.FunctionToHeaderMap.find(entrypoint); - if (match == G.FunctionToHeaderMap.end()) { - auto objectMatch = G.ObjectToHeaderMap.find(entrypoint); - if (objectMatch != G.ObjectToHeaderMap.end()) { - headerFileSet.insert(objectMatch->second); - continue; - } - - llvm::errs() << "ERROR: entrypoint '" << entrypoint - << "' could not be found in spec in any public header\n"; - return true; - } - headerFileSet.insert(match->second); - } - for (const auto &header : headerFileSet) - OS << "#include <" << header << ">\n"; - - OS << '\n'; - - OS << "extern \"C\" int main() {\n"; - for (const auto &entrypoint : EntrypointNamesOption) { - if (entrypoint == "errno") - continue; - auto match = G.FunctionSpecMap.find(entrypoint); - if (match == G.FunctionSpecMap.end()) { - auto objectMatch = G.ObjectSpecMap.find(entrypoint); - if (objectMatch != G.ObjectSpecMap.end()) { - auto entrypointPtr = entrypoint + "_ptr"; - llvm::Record *objectSpec = G.ObjectSpecMap[entrypoint]; - auto objectType = objectSpec->getValueAsString("Type"); - // We just make sure that the global object is present. - OS << " " << objectType << " *" << entrypointPtr << " = &" - << entrypoint << ";\n"; - OS << " ++" << entrypointPtr << ";\n"; // To avoid unused var warning. - continue; - } - llvm::errs() << "ERROR: entrypoint '" << entrypoint - << "' could not be found in spec in any public header\n"; - return true; - } - llvm::Record *functionSpec = match->second; - llvm::Record *retValSpec = functionSpec->getValueAsDef("Return"); - std::string returnType = - G.getTypeAsString(retValSpec->getValueAsDef("ReturnType")); - // _Noreturn is an indication for the compiler that a function - // doesn't return, and isn't a type understood by c++ templates. - if (llvm::StringRef(returnType).contains("_Noreturn")) - returnType = "void"; - - OS << " static_assert(LIBC_NAMESPACE::cpp::is_same_v<" << returnType - << '('; - auto args = functionSpec->getValueAsListOfDefs("Args"); - for (size_t i = 0, size = args.size(); i < size; ++i) { - llvm::Record *argType = args[i]->getValueAsDef("ArgType"); - OS << G.getTypeAsString(argType); - if (i < size - 1) - OS << ", "; - } - OS << ") __NOEXCEPT, decltype(" << entrypoint << ")>, "; - OS << '"' << entrypoint - << " prototype in TableGen does not match public header" << '"'; - OS << ");\n"; - } - - OS << '\n'; - OS << " return 0;\n"; - OS << "}\n\n"; - - return false; -} - -int main(int argc, char *argv[]) { - llvm::cl::ParseCommandLineOptions(argc, argv); - return TableGenMain(argv[0], TestGeneratorMain); -} diff --git a/libc/utils/HdrGen/PublicAPICommand.cpp b/libc/utils/HdrGen/PublicAPICommand.cpp deleted file mode 100644 index 5c46c82a238534..00000000000000 --- a/libc/utils/HdrGen/PublicAPICommand.cpp +++ /dev/null @@ -1,331 +0,0 @@ -//===-- Implementation of PublicAPICommand --------------------------------===// -// -// 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 "PublicAPICommand.h" - -#include "utils/LibcTableGenUtil/APIIndexer.h" - -#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/StringSwitch.h" -#include "llvm/Support/SourceMgr.h" -#include "llvm/TableGen/Record.h" -#include -#include - -// Text blocks for macro definitions and type decls can be indented to -// suit the surrounding tablegen listing. We need to dedent such blocks -// before writing them out. -static void dedentAndWrite(llvm::StringRef Text, llvm::raw_ostream &OS) { - llvm::SmallVector Lines; - llvm::SplitString(Text, Lines, "\n"); - size_t shortest_indent = 1024; - for (llvm::StringRef L : Lines) { - llvm::StringRef Indent = L.take_while([](char c) { return c == ' '; }); - size_t IndentSize = Indent.size(); - if (Indent.size() == L.size()) { - // Line is all spaces so no point noting the indent. - continue; - } - if (IndentSize < shortest_indent) - shortest_indent = IndentSize; - } - for (llvm::StringRef L : Lines) { - if (L.size() >= shortest_indent) - OS << L.drop_front(shortest_indent) << '\n'; - } -} - -static std::string getTypeHdrName(const std::string &Name) { - llvm::SmallVector Parts; - llvm::SplitString(llvm::StringRef(Name), Parts); - return llvm::join(Parts.begin(), Parts.end(), "_"); -} - -namespace llvm_libc { - -static bool isAsciiStart(char C) { - return (C >= 'A' && C <= 'Z') || (C >= 'a' && C <= 'z') || C == '_'; -} - -static bool isAsciiContinue(char C) { - return isAsciiStart(C) || (C >= '0' && C <= '9'); -} - -static bool isAsciiIdentifier(llvm::StringRef S) { - if (S.empty()) - return false; - if (!isAsciiStart(S[0])) - return false; - for (char C : S.drop_front()) - if (!isAsciiContinue(C)) - return false; - return true; -} - -static AttributeStyle getAttributeStyle(const llvm::Record *Instance) { - llvm::StringRef Style = Instance->getValueAsString("Style"); - return llvm::StringSwitch(Style) - .Case("cxx11", AttributeStyle::Cxx11) - .Case("gnu", AttributeStyle::Gnu) - .Case("declspec", AttributeStyle::Declspec) - .Default(AttributeStyle::Gnu); -} - -static AttributeNamespace getAttributeNamespace(const llvm::Record *Instance) { - llvm::StringRef Namespace = Instance->getValueAsString("Namespace"); - return llvm::StringSwitch(Namespace) - .Case("clang", AttributeNamespace::Clang) - .Case("gnu", AttributeNamespace::Gnu) - .Default(AttributeNamespace::None); -} - -using AttributeMap = llvm::DenseMap; - -template -static AttributeMap collectAttributeMacros(const SpecMap &Spec, - const FuncList &Funcs) { - llvm::DenseMap MacroAttr; - for (const auto &Name : Funcs) { - auto Iter = Spec.find(Name); - if (Iter == Spec.end()) - continue; - - const llvm::Record *FunctionSpec = Iter->second; - for (const llvm::Record *Attr : - FunctionSpec->getValueAsListOfDefs("Attributes")) - MacroAttr[Attr->getValueAsString("Macro")] = Attr; - } - return MacroAttr; -} - -static void emitAttributeMacroDecls(const AttributeMap &MacroAttr, - llvm::raw_ostream &OS) { - for (auto &[Macro, Attr] : MacroAttr) { - std::vector Instances = - Attr->getValueAsListOfDefs("Instances"); - llvm::SmallVector> Styles; - std::transform(Instances.begin(), Instances.end(), - std::back_inserter(Styles), - [&](const llvm::Record *Instance) - -> std::pair { - auto Style = getAttributeStyle(Instance); - return {Style, Instance}; - }); - // 1. If __cplusplus is defined and cxx11 style is provided, define the - // macro using cxx11 version with the following priority: - // 1a. If there is no namespace (so the macro is supposed to be - // compiler-independent), use this version first. This macro will be - // tested via __has_cpp_attribute. - // 1b. If the attribute is a clang attribute, check for __clang__. - // 1c. If the attribute is a gnu attribute, check for __GNUC__. - // 2. Otherwise, if __GNUC__ is defined and gnu style is provided, - // define the macro using gnu version; - // 3. Otherwise, if _MSC_VER is defined and __declspec is provided, define - // the macro using __declspec version; - // 4. Fallback to empty macro. - std::sort(Styles.begin(), Styles.end(), [&](auto &a, auto &b) { - if (a.first == AttributeStyle::Cxx11 && b.first == AttributeStyle::Cxx11) - return getAttributeNamespace(a.second) < - getAttributeNamespace(b.second); - return a.first < b.first; - }); - for (auto &[Style, Instance] : Styles) { - llvm::StringRef Attr = Instance->getValueAsString("Attr"); - if (Style == AttributeStyle::Cxx11) { - OS << "#if !defined(" << Macro << ") && defined(__cplusplus)"; - AttributeNamespace Namespace = getAttributeNamespace(Instance); - if (Namespace == AttributeNamespace::Clang) - OS << " && defined(__clang__)\n"; - else if (Namespace == AttributeNamespace::Gnu) - OS << " && defined(__GNUC__)\n"; - else - OS << '\n'; - if (isAsciiIdentifier(Attr) && Namespace != AttributeNamespace::None) - OS << "#if __has_attribute(" << Attr << ")\n"; - else - OS << "#if __has_cpp_attribute(" << Attr << ")\n"; - OS << "#define " << Macro << " [["; - if (Namespace == AttributeNamespace::Clang) - OS << "clang::"; - else if (Namespace == AttributeNamespace::Gnu) - OS << "gnu::"; - OS << Attr << "]]\n"; - if (isAsciiIdentifier(Attr)) - OS << "#endif\n"; - OS << "#endif\n"; - } - if (Style == AttributeStyle::Gnu) { - OS << "#if !defined(" << Macro << ") && defined(__GNUC__)\n"; - if (isAsciiIdentifier(Attr)) - OS << "#if __has_attribute(" << Attr << ")\n"; - OS << "#define " << Macro << " __attribute__(("; - OS << Attr << "))\n"; - if (isAsciiIdentifier(Attr)) - OS << "#endif\n"; - OS << "#endif\n"; - } - if (Style == AttributeStyle::Declspec) { - OS << "#if !defined(" << Macro << ") && defined(_MSC_VER)\n"; - OS << "#define " << Macro << " __declspec("; - OS << Attr << ")\n"; - OS << "#endif\n"; - } - } - OS << "#if !defined(" << Macro << ")\n"; - OS << "#define " << Macro << '\n'; - OS << "#endif\n"; - } - - if (!MacroAttr.empty()) - OS << '\n'; -} - -static void emitAttributeMacroForFunction(const llvm::Record *FunctionSpec, - llvm::raw_ostream &OS) { - std::vector Attributes = - FunctionSpec->getValueAsListOfDefs("Attributes"); - llvm::interleave( - Attributes.begin(), Attributes.end(), - [&](const llvm::Record *Attr) { OS << Attr->getValueAsString("Macro"); }, - [&]() { OS << ' '; }); - if (!Attributes.empty()) - OS << ' '; -} - -static void emitUndefsForAttributeMacros(const AttributeMap &MacroAttr, - llvm::raw_ostream &OS) { - if (!MacroAttr.empty()) - OS << '\n'; - for (auto &[Macro, Attr] : MacroAttr) - OS << "#undef " << Macro << '\n'; -} - -static void writeAPIFromIndex(APIIndexer &G, - std::vector EntrypointNameList, - llvm::raw_ostream &OS) { - for (auto &Pair : G.MacroDefsMap) { - const std::string &Name = Pair.first; - if (!G.MacroSpecMap.count(Name)) - llvm::PrintFatalError(Name + " not found in any standard spec.\n"); - - const llvm::Record *MacroDef = Pair.second; - dedentAndWrite(MacroDef->getValueAsString("Defn"), OS); - - OS << '\n'; - } - - for (auto &TypeName : G.RequiredTypes) { - if (!G.TypeSpecMap.count(TypeName)) - llvm::PrintFatalError(TypeName + " not found in any standard spec.\n"); - OS << "#include \n"; - } - OS << '\n'; - - if (G.Enumerations.size() != 0) - OS << "enum {" << '\n'; - for (const auto &Name : G.Enumerations) { - if (!G.EnumerationSpecMap.count(Name)) - llvm::PrintFatalError( - Name + " is not listed as an enumeration in any standard spec.\n"); - - const llvm::Record *EnumerationSpec = G.EnumerationSpecMap[Name]; - OS << " " << EnumerationSpec->getValueAsString("Name"); - auto Value = EnumerationSpec->getValueAsString("Value"); - if (Value == "__default__") { - OS << ",\n"; - } else { - OS << " = " << Value << ",\n"; - } - } - if (G.Enumerations.size() != 0) - OS << "};\n\n"; - - // Collect and declare macros for attributes - AttributeMap MacroAttr = - collectAttributeMacros(G.FunctionSpecMap, EntrypointNameList); - emitAttributeMacroDecls(MacroAttr, OS); - - OS << "__BEGIN_C_DECLS\n\n"; - for (auto &Name : EntrypointNameList) { - auto Iter = G.FunctionSpecMap.find(Name); - - // Functions that aren't in this header file are skipped as - // opposed to erroring out because the list of functions being - // iterated over is the complete list of functions with - // entrypoints. Thus this is filtering out the functions that - // don't go to this header file, whereas the other, similar - // conditionals above are more of a sanity check. - if (Iter == G.FunctionSpecMap.end()) - continue; - - const llvm::Record *FunctionSpec = Iter->second; - const llvm::Record *RetValSpec = FunctionSpec->getValueAsDef("Return"); - const llvm::Record *ReturnType = RetValSpec->getValueAsDef("ReturnType"); - - // TODO: https://github.com/llvm/llvm-project/issues/81208 - // Ideally, we should group functions based on their guarding macros. - bool Guarded = - (FunctionSpec->getType()->getAsString() == "GuardedFunctionSpec"); - - if (Guarded) - OS << "#ifdef " << FunctionSpec->getValueAsString("Guard") << "\n"; - - // Emit attribute macros for the function. Space is automatically added. - emitAttributeMacroForFunction(FunctionSpec, OS); - OS << G.getTypeAsString(ReturnType) << " " << Name << "("; - - auto ArgsList = FunctionSpec->getValueAsListOfDefs("Args"); - for (size_t i = 0; i < ArgsList.size(); ++i) { - const llvm::Record *ArgType = ArgsList[i]->getValueAsDef("ArgType"); - OS << G.getTypeAsString(ArgType); - if (i < ArgsList.size() - 1) - OS << ", "; - } - - OS << ") __NOEXCEPT;\n"; - - if (Guarded) - OS << "#endif // " << FunctionSpec->getValueAsString("Guard") << "\n"; - - OS << "\n"; - } - - // Make another pass over entrypoints to emit object declarations. - for (const auto &Name : EntrypointNameList) { - auto Iter = G.ObjectSpecMap.find(Name); - if (Iter == G.ObjectSpecMap.end()) - continue; - const llvm::Record *ObjectSpec = Iter->second; - auto Type = ObjectSpec->getValueAsString("Type"); - OS << "extern " << Type << " " << Name << ";\n"; - } - OS << "__END_C_DECLS\n"; - - // Undef file-level attribute macros. - emitUndefsForAttributeMacros(MacroAttr, OS); -} - -void writePublicAPI(llvm::raw_ostream &OS, const llvm::RecordKeeper &Records) {} - -const char PublicAPICommand::Name[] = "public_api"; - -void PublicAPICommand::run(llvm::raw_ostream &OS, const ArgVector &Args, - llvm::StringRef StdHeader, - const llvm::RecordKeeper &Records, - const Command::ErrorReporter &Reporter) const { - if (Args.size() != 0) - Reporter.printFatalError("public_api command does not take any arguments."); - - APIIndexer G(StdHeader, Records); - writeAPIFromIndex(G, EntrypointNameList, OS); -} - -} // namespace llvm_libc diff --git a/libc/utils/HdrGen/PublicAPICommand.h b/libc/utils/HdrGen/PublicAPICommand.h deleted file mode 100644 index 49078f4857f900..00000000000000 --- a/libc/utils/HdrGen/PublicAPICommand.h +++ /dev/null @@ -1,48 +0,0 @@ -//===-- Implementation of PublicAPICommand ----------------------*- 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_UTILS_HDRGEN_PUBLICAPICOMMAND_H -#define LLVM_LIBC_UTILS_HDRGEN_PUBLICAPICOMMAND_H - -#include "Command.h" - -#include "llvm/ADT/StringRef.h" -#include "llvm/TableGen/Error.h" -#include "llvm/TableGen/Record.h" - -namespace llvm { - -class raw_ostream; -class Record; -class RecordKeeper; - -} // namespace llvm - -namespace llvm_libc { - -enum class AttributeStyle { Cxx11 = 0, Gnu = 1, Declspec = 2 }; -enum class AttributeNamespace { None = 0, Clang = 1, Gnu = 2 }; - -class PublicAPICommand : public Command { -private: - const std::vector &EntrypointNameList; - -public: - static const char Name[]; - - PublicAPICommand(const std::vector &EntrypointNames) - : EntrypointNameList(EntrypointNames) {} - - void run(llvm::raw_ostream &OS, const ArgVector &Args, - llvm::StringRef StdHeader, const llvm::RecordKeeper &Records, - const Command::ErrorReporter &Reporter) const override; -}; - -} // namespace llvm_libc - -#endif // LLVM_LIBC_UTILS_HDRGEN_PUBLICAPICOMMAND_H diff --git a/libc/utils/HdrGen/README.md b/libc/utils/HdrGen/README.md deleted file mode 100644 index a61cf3bacbb0ee..00000000000000 --- a/libc/utils/HdrGen/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# The LLVM libc header generation system - -LLVM libc uses a header generation scheme to generate public as well as internal -header files. This directory contains the implementation of the header generator -which drives this header generation scheme. diff --git a/libc/utils/LibcTableGenUtil/APIIndexer.cpp b/libc/utils/LibcTableGenUtil/APIIndexer.cpp deleted file mode 100644 index cf66d0a7aef6e9..00000000000000 --- a/libc/utils/LibcTableGenUtil/APIIndexer.cpp +++ /dev/null @@ -1,173 +0,0 @@ -//===-- Implementation of APIIndexer class --------------------------------===// -// -// 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 "APIIndexer.h" - -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/TableGen/Error.h" -#include "llvm/TableGen/Record.h" - -namespace llvm_libc { - -static const char NamedTypeClassName[] = "NamedType"; -static const char PtrTypeClassName[] = "PtrType"; -static const char RestrictedPtrTypeClassName[] = "RestrictedPtrType"; -static const char ConstTypeClassName[] = "ConstType"; -static const char StructTypeClassName[] = "Struct"; - -static const char StandardSpecClassName[] = "StandardSpec"; -static const char PublicAPIClassName[] = "PublicAPI"; - -static bool isa(const llvm::Record *Def, const llvm::Record *TypeClass) { - const llvm::RecordRecTy *RecordType = Def->getType(); - llvm::ArrayRef Classes = RecordType->getClasses(); - // We want exact types. That is, we don't want the classes listed in - // spec.td to be subclassed. Hence, we do not want the record |Def| - // to be of more than one class type.. - if (Classes.size() != 1) - return false; - return Classes[0] == TypeClass; -} - -bool APIIndexer::isaNamedType(const llvm::Record *Def) { - return isa(Def, NamedTypeClass); -} - -bool APIIndexer::isaStructType(const llvm::Record *Def) { - return isa(Def, StructClass); -} - -bool APIIndexer::isaPtrType(const llvm::Record *Def) { - return isa(Def, PtrTypeClass); -} - -bool APIIndexer::isaConstType(const llvm::Record *Def) { - return isa(Def, ConstTypeClass); -} - -bool APIIndexer::isaRestrictedPtrType(const llvm::Record *Def) { - return isa(Def, RestrictedPtrTypeClass); -} - -bool APIIndexer::isaStandardSpec(const llvm::Record *Def) { - return isa(Def, StandardSpecClass); -} - -bool APIIndexer::isaPublicAPI(const llvm::Record *Def) { - return isa(Def, PublicAPIClass); -} - -std::string APIIndexer::getTypeAsString(const llvm::Record *TypeRecord) { - if (isaNamedType(TypeRecord) || isaStructType(TypeRecord)) { - return std::string(TypeRecord->getValueAsString("Name")); - } else if (isaPtrType(TypeRecord)) { - return getTypeAsString(TypeRecord->getValueAsDef("PointeeType")) + " *"; - } else if (isaConstType(TypeRecord)) { - return std::string("const ") + - getTypeAsString(TypeRecord->getValueAsDef("UnqualifiedType")); - } else if (isaRestrictedPtrType(TypeRecord)) { - return getTypeAsString(TypeRecord->getValueAsDef("PointeeType")) + - " *__restrict"; - } else { - llvm::PrintFatalError(TypeRecord->getLoc(), "Invalid type.\n"); - } -} - -void APIIndexer::indexStandardSpecDef(const llvm::Record *StandardSpec) { - auto HeaderSpecList = StandardSpec->getValueAsListOfDefs("Headers"); - for (const llvm::Record *HeaderSpec : HeaderSpecList) { - llvm::StringRef Header = HeaderSpec->getValueAsString("Name"); - if (!StdHeader.has_value() || Header == StdHeader) { - PublicHeaders.emplace(Header); - auto MacroSpecList = HeaderSpec->getValueAsListOfDefs("Macros"); - // TODO: Trigger a fatal error on duplicate specs. - for (const llvm::Record *MacroSpec : MacroSpecList) - MacroSpecMap[std::string(MacroSpec->getValueAsString("Name"))] = - MacroSpec; - - auto TypeSpecList = HeaderSpec->getValueAsListOfDefs("Types"); - for (const llvm::Record *TypeSpec : TypeSpecList) - TypeSpecMap[std::string(TypeSpec->getValueAsString("Name"))] = TypeSpec; - - auto FunctionSpecList = HeaderSpec->getValueAsListOfDefs("Functions"); - for (const llvm::Record *FunctionSpec : FunctionSpecList) { - auto FunctionName = std::string(FunctionSpec->getValueAsString("Name")); - FunctionSpecMap[FunctionName] = FunctionSpec; - FunctionToHeaderMap[FunctionName] = std::string(Header); - } - - auto EnumerationSpecList = - HeaderSpec->getValueAsListOfDefs("Enumerations"); - for (const llvm::Record *EnumerationSpec : EnumerationSpecList) { - EnumerationSpecMap[std::string( - EnumerationSpec->getValueAsString("Name"))] = EnumerationSpec; - } - - auto ObjectSpecList = HeaderSpec->getValueAsListOfDefs("Objects"); - for (const llvm::Record *ObjectSpec : ObjectSpecList) { - auto ObjectName = std::string(ObjectSpec->getValueAsString("Name")); - ObjectSpecMap[ObjectName] = ObjectSpec; - ObjectToHeaderMap[ObjectName] = std::string(Header); - } - } - } -} - -void APIIndexer::indexPublicAPIDef(const llvm::Record *PublicAPI) { - // While indexing the public API, we do not check if any of the entities - // requested is from an included standard. Such a check is done while - // generating the API. - auto MacroDefList = PublicAPI->getValueAsListOfDefs("Macros"); - for (const llvm::Record *MacroDef : MacroDefList) - MacroDefsMap[std::string(MacroDef->getValueAsString("Name"))] = MacroDef; - - auto TypeList = PublicAPI->getValueAsListOfStrings("Types"); - for (llvm::StringRef TypeName : TypeList) - RequiredTypes.insert(std::string(TypeName)); - - auto StructList = PublicAPI->getValueAsListOfStrings("Structs"); - for (llvm::StringRef StructName : StructList) - Structs.insert(std::string(StructName)); - - auto FunctionList = PublicAPI->getValueAsListOfStrings("Functions"); - for (llvm::StringRef FunctionName : FunctionList) - Functions.insert(std::string(FunctionName)); - - auto EnumerationList = PublicAPI->getValueAsListOfStrings("Enumerations"); - for (llvm::StringRef EnumerationName : EnumerationList) - Enumerations.insert(std::string(EnumerationName)); - - auto ObjectList = PublicAPI->getValueAsListOfStrings("Objects"); - for (llvm::StringRef ObjectName : ObjectList) - Objects.insert(std::string(ObjectName)); -} - -void APIIndexer::index(const llvm::RecordKeeper &Records) { - NamedTypeClass = Records.getClass(NamedTypeClassName); - PtrTypeClass = Records.getClass(PtrTypeClassName); - RestrictedPtrTypeClass = Records.getClass(RestrictedPtrTypeClassName); - StructClass = Records.getClass(StructTypeClassName); - ConstTypeClass = Records.getClass(ConstTypeClassName); - StandardSpecClass = Records.getClass(StandardSpecClassName); - PublicAPIClass = Records.getClass(PublicAPIClassName); - - const auto &DefsMap = Records.getDefs(); - for (auto &Pair : DefsMap) { - const llvm::Record *Def = Pair.second.get(); - if (isaStandardSpec(Def)) - indexStandardSpecDef(Def); - if (isaPublicAPI(Def)) { - if (!StdHeader.has_value() || - Def->getValueAsString("HeaderName") == StdHeader) - indexPublicAPIDef(Def); - } - } -} - -} // namespace llvm_libc diff --git a/libc/utils/LibcTableGenUtil/APIIndexer.h b/libc/utils/LibcTableGenUtil/APIIndexer.h deleted file mode 100644 index b8bca15ba131c1..00000000000000 --- a/libc/utils/LibcTableGenUtil/APIIndexer.h +++ /dev/null @@ -1,86 +0,0 @@ -//===-- A class to index libc API listed in tablegen files ------*- 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 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_UTILS_LIBC_TABLE_GEN_UTILS_API_INDEXER_H -#define LLVM_LIBC_UTILS_LIBC_TABLE_GEN_UTILS_API_INDEXER_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/TableGen/Record.h" - -#include -#include -#include -#include - -namespace llvm_libc { - -class APIIndexer { -private: - std::optional StdHeader; - - // TableGen classes in spec.td. - const llvm::Record *NamedTypeClass; - const llvm::Record *PtrTypeClass; - const llvm::Record *RestrictedPtrTypeClass; - const llvm::Record *ConstTypeClass; - const llvm::Record *StructClass; - const llvm::Record *StandardSpecClass; - const llvm::Record *PublicAPIClass; - - bool isaNamedType(const llvm::Record *Def); - bool isaStructType(const llvm::Record *Def); - bool isaPtrType(const llvm::Record *Def); - bool isaConstType(const llvm::Record *Def); - bool isaRestrictedPtrType(const llvm::Record *Def); - bool isaStandardSpec(const llvm::Record *Def); - bool isaPublicAPI(const llvm::Record *Def); - - void indexStandardSpecDef(const llvm::Record *StandardSpec); - void indexPublicAPIDef(const llvm::Record *PublicAPI); - void index(const llvm::RecordKeeper &Records); - -public: - using NameToRecordMapping = - std::unordered_map; - using NameSet = std::unordered_set; - - // This indexes all headers, not just a specified one. - explicit APIIndexer(const llvm::RecordKeeper &Records) - : StdHeader(std::nullopt) { - index(Records); - } - - APIIndexer(llvm::StringRef Header, const llvm::RecordKeeper &Records) - : StdHeader(Header) { - index(Records); - } - - // Mapping from names to records defining them. - NameToRecordMapping MacroSpecMap; - NameToRecordMapping TypeSpecMap; - NameToRecordMapping EnumerationSpecMap; - NameToRecordMapping FunctionSpecMap; - NameToRecordMapping MacroDefsMap; - NameToRecordMapping ObjectSpecMap; - - std::unordered_map FunctionToHeaderMap; - std::unordered_map ObjectToHeaderMap; - - NameSet RequiredTypes; - NameSet Structs; - NameSet Enumerations; - NameSet Functions; - NameSet Objects; - NameSet PublicHeaders; - - std::string getTypeAsString(const llvm::Record *TypeRecord); -}; - -} // namespace llvm_libc - -#endif // LLVM_LIBC_UTILS_LIBC_TABLE_GEN_UTILS_API_INDEXER_H diff --git a/libc/utils/LibcTableGenUtil/CMakeLists.txt b/libc/utils/LibcTableGenUtil/CMakeLists.txt deleted file mode 100644 index 9421383394a359..00000000000000 --- a/libc/utils/LibcTableGenUtil/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -if (NOT LLVM_LINK_LLVM_DYLIB) - set(flags "DISABLE_LLVM_LINK_LLVM_DYLIB;LINK_COMPONENTS;Support;TableGen") -else() - set(flags "LINK_COMPONENTS;TableGen") -endif() -add_llvm_library( - LibcTableGenUtil - APIIndexer.cpp - APIIndexer.h - ${flags} -) -target_include_directories(LibcTableGenUtil PUBLIC ${LIBC_SOURCE_DIR}) -target_include_directories(LibcTableGenUtil PRIVATE ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}) From 46251c628e4e4aee38f15419fcc67cc8b6c4d827 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Thu, 21 Nov 2024 13:07:27 -0800 Subject: [PATCH 2/5] clean up llvm/runtimes/CMakeList.txt --- llvm/runtimes/CMakeLists.txt | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index 57a56c6a604153..40fdb14e813332 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -520,24 +520,6 @@ if(build_runtimes) endif() endforeach() endif() - if("libc" IN_LIST LLVM_ENABLE_PROJECTS AND - (LLVM_LIBC_FULL_BUILD OR LLVM_LIBC_GPU_BUILD)) - if(LIBC_HDRGEN_EXE) - set(hdrgen_exe ${LIBC_HDRGEN_EXE}) - else() - if(TARGET ${LIBC_TABLEGEN_EXE}) - set(hdrgen_exe $) - else() - set(hdrgen_exe ${LIBC_TABLEGEN_EXE}) - endif() - set(hdrgen_deps ${LIBC_TABLEGEN_TARGET}) - endif() - if(NOT hdrgen_exe) - message(FATAL_ERROR "libc-hdrgen executable missing") - endif() - list(APPEND extra_cmake_args "-DLIBC_HDRGEN_EXE=${hdrgen_exe}") - list(APPEND extra_deps ${hdrgen_deps}) - endif() if(LLVM_LIBC_GPU_BUILD) list(APPEND extra_cmake_args "-DLLVM_LIBC_GPU_BUILD=ON") if("libc" IN_LIST RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES) From a649bf044a2a2c2cea571ab3271530e2a6f44fe8 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Thu, 21 Nov 2024 13:15:06 -0800 Subject: [PATCH 3/5] clean up more of llvm/runtimes/CMakeList.txt --- llvm/CMakeLists.txt | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index cfcf1404d82b7c..03c1486c45eebc 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -179,13 +179,8 @@ if(LIBC_GPU_BUILD) list(APPEND RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "libc") endif() -set(NEED_LIBC_HDRGEN FALSE) -if("libc" IN_LIST LLVM_ENABLE_RUNTIMES) - set(NEED_LIBC_HDRGEN TRUE) -endif() foreach(_name ${LLVM_RUNTIME_TARGETS}) if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES) - set(NEED_LIBC_HDRGEN TRUE) if("${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda") set(LLVM_LIBC_GPU_BUILD ON) endif() @@ -195,26 +190,6 @@ if("${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR "${LIBC_TARGET_TRIPLE}" STREQUAL "nvptx64-nvidia-cuda") set(LLVM_LIBC_GPU_BUILD ON) endif() -if(NEED_LIBC_HDRGEN) - # To build the libc runtime, we need to be able to build few libc build - # tools from the "libc" project. So, we add it to the list of enabled - # projects. - if (NOT "libc" IN_LIST LLVM_ENABLE_PROJECTS) - message(STATUS "Enabling libc project to build libc build tools") - list(APPEND LLVM_ENABLE_PROJECTS "libc") - endif() -endif() - -foreach(proj IN LISTS LLVM_ENABLE_RUNTIMES) - if("${proj}" IN_LIST LLVM_ENABLE_PROJECTS) - # The 'libc' project bootstraps a few executables via the project build and - # should not emit an error currently. - if(NOT (NEED_LIBC_HDRGEN AND "${proj}" STREQUAL "libc")) - message(FATAL_ERROR "Runtime project \"${proj}\" found in LLVM_ENABLE_PROJECTS and LLVM_ENABLE_RUNTIMES. It must only appear in one of them and that one should almost always be LLVM_ENABLE_RUNTIMES.") - endif() - endif() -endforeach() -unset(NEED_LIBC_HDRGEN) # LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the # `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for From 1c11706f118143d12b85608d07ce8e83db8511e7 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Thu, 21 Nov 2024 13:20:06 -0800 Subject: [PATCH 4/5] remove NEED_LIBC_HDRGEN from libc/CMakeLists.txt --- libc/CMakeLists.txt | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index d00888b8801dc5..834d5719ce4de4 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -60,27 +60,6 @@ if(LIBC_BUILD_GPU_LOADER OR (LLVM_LIBC_GPU_BUILD AND NOT LLVM_RUNTIMES_BUILD)) add_subdirectory(utils/gpu) endif() -set(NEED_LIBC_HDRGEN FALSE) -if(NOT LLVM_RUNTIMES_BUILD) - if("libc" IN_LIST LLVM_ENABLE_RUNTIMES) - set(NEED_LIBC_HDRGEN TRUE) - else() - foreach(_name ${LLVM_RUNTIME_TARGETS}) - if("libc" IN_LIST RUNTIMES_${_name}_LLVM_ENABLE_RUNTIMES) - set(NEED_LIBC_HDRGEN TRUE) - break() - endif() - endforeach() - endif() -endif() -if(NEED_LIBC_HDRGEN) - # When libc is build as part of the runtimes/bootstrap build's CMake run, we - # only need to build the host tools to build the libc. So, we just do enough - # to build libc-hdrgen and return. - return() -endif() -unset(NEED_LIBC_HDRGEN) - option(LIBC_CMAKE_VERBOSE_LOGGING "Log details warnings and notifications during CMake configuration." OFF) From ae75b6b1c9b90bdc1335cfdd96b38accc47f248e Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Thu, 21 Nov 2024 15:01:55 -0800 Subject: [PATCH 5/5] remove now unused add_gen_header, rename add_gen_header2 to add_gen_header --- libc/cmake/modules/LLVMLibCHeaderRules.cmake | 126 +++---------------- libc/include/CMakeLists.txt | 4 +- 2 files changed, 19 insertions(+), 111 deletions(-) diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake index 766225cbeab404..8f24cd4b3023bd 100644 --- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake +++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake @@ -71,9 +71,9 @@ function(add_header target_name) ) endfunction(add_header) -function(add_gen_header2 target_name) +function(add_gen_header target_name) cmake_parse_arguments( - "ADD_GEN_HDR2" + "ADD_GEN_HDR" "PUBLIC" # No optional arguments "YAML_FILE;DEF_FILE;GEN_HDR" # Single value arguments "DEPENDS" # Multi value arguments @@ -84,25 +84,25 @@ function(add_gen_header2 target_name) add_library(${fq_target_name} INTERFACE) return() endif() - if(NOT ADD_GEN_HDR2_DEF_FILE) - message(FATAL_ERROR "`add_gen_hdr2` rule requires DEF_FILE to be specified.") + if(NOT ADD_GEN_HDR_DEF_FILE) + message(FATAL_ERROR "`add_gen_hdr` rule requires DEF_FILE to be specified.") endif() - if(NOT ADD_GEN_HDR2_GEN_HDR) - message(FATAL_ERROR "`add_gen_hdr2` rule requires GEN_HDR to be specified.") + if(NOT ADD_GEN_HDR_GEN_HDR) + message(FATAL_ERROR "`add_gen_hdr` rule requires GEN_HDR to be specified.") endif() - if(NOT ADD_GEN_HDR2_YAML_FILE) - message(FATAL_ERROR "`add_gen_hdr2` rule requires YAML_FILE to be specified.") + if(NOT ADD_GEN_HDR_YAML_FILE) + message(FATAL_ERROR "`add_gen_hdr` rule requires YAML_FILE to be specified.") endif() - set(absolute_path ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR2_GEN_HDR}) + set(absolute_path ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR_GEN_HDR}) file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_SOURCE_DIR} ${absolute_path}) set(out_file ${LIBC_INCLUDE_DIR}/${relative_path}) - set(yaml_file ${CMAKE_SOURCE_DIR}/${ADD_GEN_HDR2_YAML_FILE}) - set(def_file ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR2_DEF_FILE}) + set(yaml_file ${CMAKE_SOURCE_DIR}/${ADD_GEN_HDR_YAML_FILE}) + set(def_file ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR_DEF_FILE}) set(fq_data_files "") - if(ADD_GEN_HDR2_DATA_FILES) - foreach(data_file IN LISTS ADD_GEN_HDR2_DATA_FILES) + if(ADD_GEN_HDR_DATA_FILES) + foreach(data_file IN LISTS ADD_GEN_HDR_DATA_FILES) list(APPEND fq_data_files "${CMAKE_CURRENT_SOURCE_DIR}/${data_file}") endforeach(data_file) endif() @@ -118,7 +118,7 @@ function(add_gen_header2 target_name) ${entry_points} --output_dir ${out_file} DEPENDS ${yaml_file} ${def_file} ${fq_data_files} - COMMENT "Generating header ${ADD_GEN_HDR2_GEN_HDR} from ${yaml_file} and ${def_file}" + COMMENT "Generating header ${ADD_GEN_HDR_GEN_HDR} from ${yaml_file} and ${def_file}" ) if(LIBC_TARGET_OS_IS_GPU) file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls) @@ -136,99 +136,6 @@ function(add_gen_header2 target_name) ) endif() - if(ADD_GEN_HDR2_DEPENDS) - get_fq_deps_list(fq_deps_list ${ADD_GEN_HDR2_DEPENDS}) - # Dependencies of a add_header target can only be another add_gen_header target - # or an add_header target. - foreach(dep IN LISTS fq_deps_list) - get_target_property(header_file ${dep} HEADER_FILE_PATH) - if(NOT header_file) - message(FATAL_ERROR "Invalid dependency '${dep}' for '${fq_target_name}'.") - endif() - endforeach() - endif() - set(generated_hdr_target ${fq_target_name}.__generated_hdr__) - add_custom_target( - ${generated_hdr_target} - DEPENDS ${out_file} ${fq_deps_list} ${decl_out_file} - ) - - add_header_library( - ${target_name} - HDRS - ${out_file} - ) - - add_dependencies(${fq_target_name} ${generated_hdr_target}) - - set_target_properties( - ${fq_target_name} - PROPERTIES - HEADER_FILE_PATH ${out_file} - DECLS_FILE_PATH "${decl_out_file}" - DEPS "${fq_deps_list}" - ) - - -endfunction(add_gen_header2) - -# Usage: -# add_gen_header( -# -# DEF_FILE <.h.def file> -# GEN_HDR -# PARAMS -# DATA_FILES -# ) -function(add_gen_header target_name) - cmake_parse_arguments( - "ADD_GEN_HDR" - "PUBLIC" # No optional arguments - "DEF_FILE;GEN_HDR" # Single value arguments - "PARAMS;DATA_FILES;DEPENDS" # Multi value arguments - ${ARGN} - ) - get_fq_target_name(${target_name} fq_target_name) - if(NOT LLVM_LIBC_FULL_BUILD) - # We don't want to use generated headers if we are doing a non-full-build. - add_library(${fq_target_name} INTERFACE) - return() - endif() - if(NOT ADD_GEN_HDR_DEF_FILE) - message(FATAL_ERROR "`add_gen_hdr` rule requires DEF_FILE to be specified.") - endif() - if(NOT ADD_GEN_HDR_GEN_HDR) - message(FATAL_ERROR "`add_gen_hdr` rule requires GEN_HDR to be specified.") - endif() - - set(absolute_path ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR_GEN_HDR}) - file(RELATIVE_PATH relative_path ${LIBC_INCLUDE_SOURCE_DIR} ${absolute_path}) - set(out_file ${LIBC_INCLUDE_DIR}/${relative_path}) - set(in_file ${CMAKE_CURRENT_SOURCE_DIR}/${ADD_GEN_HDR_DEF_FILE}) - - set(fq_data_files "") - if(ADD_GEN_HDR_DATA_FILES) - foreach(data_file IN LISTS ADD_GEN_HDR_DATA_FILES) - list(APPEND fq_data_files "${CMAKE_CURRENT_SOURCE_DIR}/${data_file}") - endforeach(data_file) - endif() - - set(replacement_params "") - if(ADD_GEN_HDR_PARAMS) - list(APPEND replacement_params "--args" ${ADD_GEN_HDR_PARAMS}) - endif() - - set(gen_hdr_script "${LIBC_BUILD_SCRIPTS_DIR}/gen_hdr.py") - - set(ENTRYPOINT_NAME_LIST_ARG ${TARGET_ENTRYPOINT_NAME_LIST}) - list(TRANSFORM ENTRYPOINT_NAME_LIST_ARG PREPEND "--e=") - - if(LIBC_TARGET_OS_IS_GPU) - file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls) - file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/llvm-libc-decls/gpu) - set(decl_out_file ${LIBC_INCLUDE_DIR}/llvm-libc-decls/${relative_path}) - endif() - if(ADD_GEN_HDR_DEPENDS) get_fq_deps_list(fq_deps_list ${ADD_GEN_HDR_DEPENDS}) # Dependencies of a add_header target can only be another add_gen_header target @@ -252,9 +159,6 @@ function(add_gen_header target_name) ${out_file} ) - # We add the dependencies separately and not list under add_header_library's - # DEPENDS option above. This is because, deps of add_header_library are - # used with target_link_libraries. add_dependencies(${fq_target_name} ${generated_hdr_target}) set_target_properties( @@ -264,4 +168,6 @@ function(add_gen_header target_name) DECLS_FILE_PATH "${decl_out_file}" DEPS "${fq_deps_list}" ) + + endfunction(add_gen_header) diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 483e63da48deae..2fad29450990ff 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -17,8 +17,10 @@ add_header( __llvm-libc-common.h ) +# TODO: Can we simplify this macro expansion? +# https://github.com/llvm/llvm-project/issues/117254 macro(add_header_macro TARGET_NAME YAML_FILE DEF_FILE GEN_HDR DEPENDS) - add_gen_header2( + add_gen_header( ${TARGET_NAME} YAML_FILE ${YAML_FILE} DEF_FILE ${DEF_FILE}