Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Move hdrgen into utils/ subdirectory #121256

Merged
merged 3 commits into from
Dec 30, 2024

Conversation

frobtech
Copy link
Contributor

No description provided.

@frobtech frobtech requested review from fabio-d and Caslyn December 28, 2024 08:47
@frobtech frobtech marked this pull request as ready for review December 28, 2024 10:33
@llvmbot llvmbot added the libc label Dec 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 28, 2024

@llvm/pr-subscribers-libc

Author: Roland McGrath (frobtech)

Changes

Patch is 35.85 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/121256.diff

78 Files Affected:

  • (modified) libc/CMakeLists.txt (-2)
  • (modified) libc/cmake/modules/LLVMLibCHeaderRules.cmake (+3-2)
  • (modified) libc/docs/dev/header_generation.rst (+14-13)
  • (modified) libc/docs/dev/source_tree_layout.rst (-10)
  • (modified) libc/docs/full_cross_build.rst (+7-7)
  • (modified) libc/include/CMakeLists.txt (+55-55)
  • (modified) libc/src/math/docs/add_math_function.md (+1-1)
  • (modified) libc/utils/CMakeLists.txt (+2)
  • (renamed) libc/utils/hdrgen/CMakeLists.txt (+2-2)
  • (added) libc/utils/hdrgen/README.rst (+5)
  • (renamed) libc/utils/hdrgen/class_implementation/classes/enumeration.py ()
  • (renamed) libc/utils/hdrgen/class_implementation/classes/function.py ()
  • (renamed) libc/utils/hdrgen/class_implementation/classes/macro.py ()
  • (renamed) libc/utils/hdrgen/class_implementation/classes/object.py ()
  • (renamed) libc/utils/hdrgen/class_implementation/classes/type.py ()
  • (renamed) libc/utils/hdrgen/gpu_headers.py ()
  • (renamed) libc/utils/hdrgen/header.py ()
  • (renamed) libc/utils/hdrgen/tests/expected_output/test_header.h ()
  • (renamed) libc/utils/hdrgen/tests/input/test_small.h.def ()
  • (renamed) libc/utils/hdrgen/tests/input/test_small.yaml ()
  • (renamed) libc/utils/hdrgen/tests/test_integration.py (+6-6)
  • (renamed) libc/utils/hdrgen/yaml/arpa/inet.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/assert.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/complex.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/ctype.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/dirent.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/dlfcn.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/elf.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/errno.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/fcntl.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/features.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/fenv.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/float.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/inttypes.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/limits.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/link.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/locale.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/malloc.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/math.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/pthread.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sched.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/search.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/setjmp.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/signal.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/spawn.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/stdbit.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/stdckdint.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/stdfix.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/stdint.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/stdio.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/stdlib.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/string.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/strings.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/auxv.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/epoll.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/ioctl.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/mman.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/prctl.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/random.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/resource.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/select.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/sendfile.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/socket.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/stat.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/statvfs.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/syscall.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/time.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/types.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/utsname.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/sys/wait.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/termios.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/threads.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/time.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/uchar.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/unistd.yaml ()
  • (renamed) libc/utils/hdrgen/yaml/wchar.yaml ()
  • (renamed) libc/utils/hdrgen/yaml_functions_sorted.py ()
  • (renamed) libc/utils/hdrgen/yaml_to_classes.py ()
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 00a07ea3c8ac75..6f1c180a3f192e 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -64,8 +64,6 @@ if(LIBC_BUILD_GPU_LOADER OR ((NOT LLVM_RUNTIMES_BUILD) AND LLVM_LIBC_GPU_BUILD))
   return()
 endif()
 
-add_subdirectory(hdrgen)
-
 option(LIBC_CMAKE_VERBOSE_LOGGING
   "Log details warnings and notifications during CMake configuration." OFF)
 
diff --git a/libc/cmake/modules/LLVMLibCHeaderRules.cmake b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
index 31a88f0ef93be9..0de5e14359cfbb 100644
--- a/libc/cmake/modules/LLVMLibCHeaderRules.cmake
+++ b/libc/cmake/modules/LLVMLibCHeaderRules.cmake
@@ -110,9 +110,10 @@ function(add_gen_header target_name)
   set(entry_points "${TARGET_ENTRYPOINT_NAME_LIST}")
   list(TRANSFORM entry_points PREPEND "--e=")
 
+  set(LIBC_HDRGEN "${LIBC_SOURCE_DIR}/utils/hdrgen/yaml_to_classes.py")
   add_custom_command(
     OUTPUT ${out_file}
-    COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/hdrgen/yaml_to_classes.py
+    COMMAND ${Python3_EXECUTABLE} ${LIBC_HDRGEN}
             ${yaml_file}
             --h_def_file ${def_file}
             ${entry_points}
@@ -126,7 +127,7 @@ function(add_gen_header target_name)
     set(decl_out_file ${LIBC_INCLUDE_DIR}/llvm-libc-decls/${relative_path})
     add_custom_command(
       OUTPUT ${decl_out_file}
-      COMMAND ${Python3_EXECUTABLE} ${LIBC_SOURCE_DIR}/hdrgen/yaml_to_classes.py
+      COMMAND ${Python3_EXECUTABLE} ${LIBC_HDRGEN}
               ${yaml_file}
               --export-decls
               ${entry_points}
diff --git a/libc/docs/dev/header_generation.rst b/libc/docs/dev/header_generation.rst
index 2c586cc87b6990..17a8d7af3a2c8b 100644
--- a/libc/docs/dev/header_generation.rst
+++ b/libc/docs/dev/header_generation.rst
@@ -44,15 +44,15 @@ To add through the command line:
 
    .. code-block:: none
 
-     python3 libc/hdrgen/yaml_to_classes.py
-     libc/hdrgen/yaml/[yaml_file.yaml] --add_function "<return_type>" <function_name> "<function_arg1, function_arg2>" <standard> <guard> <attribute>
+     python3 libc/utils/hdrgen/yaml_to_classes.py
+     libc/utils/hdrgen/yaml/[yaml_file.yaml] --add_function "<return_type>" <function_name> "<function_arg1, function_arg2>" <standard> <guard> <attribute>
 
    Example:
 
    .. code-block:: none
 
-      python3 libc/hdrgen/yaml_to_classes.py
-      libc/hdrgen/yaml/ctype.yaml --add_function "char" example_function
+      python3 libc/utils/hdrgen/yaml_to_classes.py
+      libc/utils/hdrgen/yaml/ctype.yaml --add_function "char" example_function
       "int, void, const void" stdc example_float example_attribute
 
    Keep in mind only the return_type and arguments have quotes around them. If
@@ -62,7 +62,8 @@ To add through the command line:
    generated header file with the new addition in the hdrgen directory to
    examine.
 
-If you want to sort the functions alphabetically you can check out libc/hdrgen/yaml_functions_sorted.py.
+If you want to sort the functions alphabetically you can check out
+libc/utils/hdrgen/yaml_functions_sorted.py.
 
 
 Testing
@@ -75,10 +76,10 @@ ensures the process of YAML to classes to generate headers works properly. If
 there are any new additions on formatting headers, make sure the test is
 updated with the specific addition.
 
-Integration Test can be found in: ``libc/hdrgen/tests/test_integration.py``
+Integration Test can be found in: ``libc/utils/hdrgen/tests/test_integration.py``
 
 File to modify if adding something to formatting:
-``libc/hdrgen/tests/expected_output/test_header.h``
+``libc/utils/hdrgen/tests/expected_output/test_header.h``
 
 
 Common Errors
@@ -89,7 +90,7 @@ Common Errors
 
    .. code-block:: none
 
-      "/llvm-project/libc/hdrgen/yaml_to_classes.py", line 67, in yaml_to_classes function_data["return_type"]
+      "/llvm-project/libc/utils/hdrgen/yaml_to_classes.py", line 67, in yaml_to_classes function_data["return_type"]
 
    If you receive this error or any error pertaining to
    ``function_data[function_specific_component]`` while building the headers
@@ -117,7 +118,7 @@ Common Errors
    missing. Ensure the correct style and required files are present:
 
    | ``[header_name]``
-   | ``[../libc/hdrgen/yaml/[yaml_file.yaml]``
+   | ``[../libc/utils/hdrgen/yaml/[yaml_file.yaml]``
    | ``[header_name.h.def]``
    | ``[header_name.h]``
    | ``DEPENDS``
@@ -147,13 +148,13 @@ Common Errors
 
    .. code-block:: none
 
-     File "/llvm-project/libc/hdrgen/header.py", line 60, in __str__ for
+     File "/llvm-project/libc/utils/hdrgen/header.py", line 60, in __str__ for
      function in self.functions: AttributeError: 'HeaderFile' object has no
      attribute 'functions'
 
    When running ``ninja libc`` in the build directory to generate headers you
    may receive the error above. Essentially this means that in
-   ``libc/hdrgen/header.py`` there is a missing attribute named functions.
+   ``libc/utils/hdrgen/header.py`` there is a missing attribute named functions.
    Make sure all function components are defined within this file and there are
    no missing functions to add these components.
 
@@ -184,12 +185,12 @@ Common Errors
    Sometimes the integration test will fail but that
    still means the process is working unless the comparison between the output
    and expected_output is not showing. If that is the case make sure in
-   ``libc/hdrgen/tests/test_integration.py`` there are no missing arguments
+   ``libc/utils/hdrgen/tests/test_integration.py`` there are no missing arguments
    that run through the script.
 
    If the integration tests are failing due to mismatching of lines or small
    errors in spacing that is nothing to worry about. If this is happening while
    you are making a new change to the formatting of the headers, then
    ensure the expected output file
-   ``libc/hdrgen/tests/expected_output/test_header.h`` has the changes you
+   ``libc/utils/hdrgen/tests/expected_output/test_header.h`` has the changes you
    are applying.
diff --git a/libc/docs/dev/source_tree_layout.rst b/libc/docs/dev/source_tree_layout.rst
index bd9d6ca453e084..62c0434a0b2aa4 100644
--- a/libc/docs/dev/source_tree_layout.rst
+++ b/libc/docs/dev/source_tree_layout.rst
@@ -15,7 +15,6 @@ directories::
         - examples
         - fuzzing
         - hdr
-        - hdrgen
         - include
         - lib
         - src
@@ -88,15 +87,6 @@ The ``lib`` directory
 This directory contains a ``CMakeLists.txt`` file listing the targets for the
 public libraries ``libc.a``, ``libm.a`` etc.
 
-The ``hdrgen`` directory
----------------------------
-
-This directory contains the sources and specifications for the types, macros
-and entrypoint functions. These definitions are organized in the ``yaml``
-subdirectory and match the organization of the ``*.h.def`` files. This folder
-also contains the python sources for headergen, which is what generates the
-headers.
-
 The ``src`` directory
 ---------------------
 
diff --git a/libc/docs/full_cross_build.rst b/libc/docs/full_cross_build.rst
index 5f57169d228ef7..cd1ec89e5d5e90 100644
--- a/libc/docs/full_cross_build.rst
+++ b/libc/docs/full_cross_build.rst
@@ -8,7 +8,7 @@ Full Cross Build
    :depth: 1
    :local:
 
-.. note:: 
+.. note::
    Fullbuild requires running headergen, which is a python program that depends on
    pyyaml. The minimum versions are listed on the :ref:`header_generation`
    page, as well as additional information.
@@ -95,8 +95,8 @@ configure step.
 Bootstrap cross build
 =====================
 
-In this recipe, the clang compiler and the ``libc-hdrgen`` binary, both are
-built automatically before building the libc for the target.
+In this recipe, the clang compiler is built automatically before building
+the libc for the target.
 
 CMake configure step
 --------------------
@@ -151,8 +151,8 @@ built using any of the three recipes described above.
 Building for the GPU
 ====================
 
-To build for a GPU architecture, it should only be necessary to specify the 
-target triple as one of the supported GPU targets. Currently, this is either 
-``nvptx64-nvidia-cuda`` for NVIDIA GPUs or ``amdgcn-amd-amdhsa`` for AMD GPUs. 
-More detailed information is provided in the :ref:`GPU 
+To build for a GPU architecture, it should only be necessary to specify the
+target triple as one of the supported GPU targets. Currently, this is either
+``nvptx64-nvidia-cuda`` for NVIDIA GPUs or ``amdgcn-amd-amdhsa`` for AMD GPUs.
+More detailed information is provided in the :ref:`GPU
 documentation<libc_gpu_building>`.
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 3a05c01abba5a4..e490840cafedbb 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -32,7 +32,7 @@ endmacro()
 
 add_header_macro(
   ctype
-  ../libc/hdrgen/yaml/ctype.yaml
+  ../libc/utils/hdrgen/yaml/ctype.yaml
   ctype.h.def
   ctype.h
   DEPENDS
@@ -42,7 +42,7 @@ add_header_macro(
 
 add_header_macro(
   dirent
-  ../libc/hdrgen/yaml/dirent.yaml
+  ../libc/utils/hdrgen/yaml/dirent.yaml
   dirent.h.def
   dirent.h
   DEPENDS
@@ -54,7 +54,7 @@ add_header_macro(
 
 add_header_macro(
   fcntl
-  ../libc/hdrgen/yaml/fcntl.yaml
+  ../libc/utils/hdrgen/yaml/fcntl.yaml
   fcntl.h.def
   fcntl.h
   DEPENDS
@@ -70,7 +70,7 @@ add_header_macro(
 
 add_header_macro(
   dlfcn
-  ../libc/hdrgen/yaml/dlfcn.yaml
+  ../libc/utils/hdrgen/yaml/dlfcn.yaml
   dlfcn.h.def
   dlfcn.h
   DEPENDS
@@ -80,7 +80,7 @@ add_header_macro(
 
 add_header_macro(
   features
-  ../libc/hdrgen/yaml/features.yaml
+  ../libc/utils/hdrgen/yaml/features.yaml
   features.h.def
   features.h
   DEPENDS
@@ -90,7 +90,7 @@ add_header_macro(
 
 add_header_macro(
   fenv
-  ../libc/hdrgen/yaml/fenv.yaml
+  ../libc/utils/hdrgen/yaml/fenv.yaml
   fenv.h.def
   fenv.h
   DEPENDS
@@ -102,7 +102,7 @@ add_header_macro(
 
 add_header_macro(
   inttypes
-  ../libc/hdrgen/yaml/inttypes.yaml
+  ../libc/utils/hdrgen/yaml/inttypes.yaml
   inttypes.h.def
   inttypes.h
   DEPENDS
@@ -113,7 +113,7 @@ add_header_macro(
 
 add_header_macro(
   float
-  ../libc/hdrgen/yaml/float.yaml
+  ../libc/utils/hdrgen/yaml/float.yaml
   float.h.def
   float.h
   DEPENDS
@@ -122,7 +122,7 @@ add_header_macro(
 
 add_header_macro(
   stdint
-  ../libc/hdrgen/yaml/stdint.yaml
+  ../libc/utils/hdrgen/yaml/stdint.yaml
   stdint.h.def
   stdint.h
   DEPENDS
@@ -131,7 +131,7 @@ add_header_macro(
 
 add_header_macro(
   limits
-  ../libc/hdrgen/yaml/limits.yaml
+  ../libc/utils/hdrgen/yaml/limits.yaml
   limits.h.def
   limits.h
   DEPENDS
@@ -140,7 +140,7 @@ add_header_macro(
 
 add_header_macro(
   malloc
-  ../libc/hdrgen/yaml/malloc.yaml
+  ../libc/utils/hdrgen/yaml/malloc.yaml
   malloc.h.def
   malloc.h
   DEPENDS
@@ -150,7 +150,7 @@ add_header_macro(
 
 add_header_macro(
   math
-  ../libc/hdrgen/yaml/math.yaml
+  ../libc/utils/hdrgen/yaml/math.yaml
   math.h.def
   math.h
   DEPENDS
@@ -165,7 +165,7 @@ add_header_macro(
 
 add_header_macro(
   stdfix
-  ../libc/hdrgen/yaml/stdfix.yaml
+  ../libc/utils/hdrgen/yaml/stdfix.yaml
   stdfix.h.def
   stdfix.h
   DEPENDS
@@ -178,7 +178,7 @@ file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa)
 
 add_header_macro(
   arpa_inet
-  ../libc/hdrgen/yaml/arpa/inet.yaml
+  ../libc/utils/hdrgen/yaml/arpa/inet.yaml
   arpa/inet.h.def
   arpa/inet.h
   DEPENDS
@@ -187,7 +187,7 @@ add_header_macro(
 
 add_header_macro(
   assert
-  ../libc/hdrgen/yaml/assert.yaml
+  ../libc/utils/hdrgen/yaml/assert.yaml
   assert.h.def
   assert.h
   DEPENDS
@@ -197,7 +197,7 @@ add_header_macro(
 
 add_header_macro(
   complex
-  ../libc/hdrgen/yaml/complex.yaml
+  ../libc/utils/hdrgen/yaml/complex.yaml
   complex.h.def
   complex.h
   DEPENDS
@@ -207,7 +207,7 @@ add_header_macro(
 
 add_header_macro(
   setjmp
-  ../libc/hdrgen/yaml/setjmp.yaml
+  ../libc/utils/hdrgen/yaml/setjmp.yaml
   setjmp.h.def
   setjmp.h
   DEPENDS
@@ -217,7 +217,7 @@ add_header_macro(
 
 add_header_macro(
   string
-  ../libc/hdrgen/yaml/string.yaml
+  ../libc/utils/hdrgen/yaml/string.yaml
   string.h.def
   string.h
   DEPENDS
@@ -228,7 +228,7 @@ add_header_macro(
 
 add_header_macro(
   strings
-  ../libc/hdrgen/yaml/strings.yaml
+  ../libc/utils/hdrgen/yaml/strings.yaml
   strings.h.def
   strings.h
   DEPENDS
@@ -238,7 +238,7 @@ add_header_macro(
 
 add_header_macro(
   search
-  ../libc/hdrgen/yaml/search.yaml
+  ../libc/utils/hdrgen/yaml/search.yaml
   search.h.def
   search.h
   DEPENDS
@@ -252,7 +252,7 @@ add_header_macro(
 
 add_header_macro(
   time
-  ../libc/hdrgen/yaml/time.yaml
+  ../libc/utils/hdrgen/yaml/time.yaml
   time.h.def
   time.h
   DEPENDS
@@ -268,7 +268,7 @@ add_header_macro(
 
 add_header_macro(
   threads
-  ../libc/hdrgen/yaml/threads.yaml
+  ../libc/utils/hdrgen/yaml/threads.yaml
   threads.h.def
   threads.h
   DEPENDS
@@ -285,7 +285,7 @@ add_header_macro(
 
 add_header_macro(
   errno
-  ../libc/hdrgen/yaml/errno.yaml
+  ../libc/utils/hdrgen/yaml/errno.yaml
   errno.h.def
   errno.h
   DEPENDS
@@ -295,7 +295,7 @@ add_header_macro(
 
 add_header_macro(
   signal
-  ../libc/hdrgen/yaml/signal.yaml
+  ../libc/utils/hdrgen/yaml/signal.yaml
   signal.h.def
   signal.h
   DEPENDS
@@ -311,7 +311,7 @@ add_header_macro(
 
 add_header_macro(
   stdbit
-  ../libc/hdrgen/yaml/stdbit.yaml
+  ../libc/utils/hdrgen/yaml/stdbit.yaml
   stdbit.h.def
   stdbit.h
   DEPENDS
@@ -321,7 +321,7 @@ add_header_macro(
 
 add_header_macro(
   stdckdint
-  ../libc/hdrgen/yaml/stdckdint.yaml
+  ../libc/utils/hdrgen/yaml/stdckdint.yaml
   stdckdint.h.def
   stdckdint.h
   DEPENDS
@@ -331,7 +331,7 @@ add_header_macro(
 
 add_header_macro(
   stdio
-  ../libc/hdrgen/yaml/stdio.yaml
+  ../libc/utils/hdrgen/yaml/stdio.yaml
   stdio.h.def
   stdio.h
   DEPENDS
@@ -347,7 +347,7 @@ add_header_macro(
 
 add_header_macro(
   stdlib
-  ../libc/hdrgen/yaml/stdlib.yaml
+  ../libc/utils/hdrgen/yaml/stdlib.yaml
   stdlib.h.def
   stdlib.h
   DEPENDS
@@ -366,7 +366,7 @@ add_header_macro(
 
 add_header_macro(
   unistd
-  ../libc/hdrgen/yaml/unistd.yaml
+  ../libc/utils/hdrgen/yaml/unistd.yaml
   unistd.h.def
   unistd.h
   DEPENDS
@@ -385,7 +385,7 @@ add_header_macro(
 
 add_header_macro(
   pthread
-  ../libc/hdrgen/yaml/pthread.yaml
+  ../libc/utils/hdrgen/yaml/pthread.yaml
   pthread.h.def
   pthread.h
   DEPENDS
@@ -409,7 +409,7 @@ add_header_macro(
 
 add_header_macro(
   sched
-  ../libc/hdrgen/yaml/sched.yaml
+  ../libc/utils/hdrgen/yaml/sched.yaml
   sched.h.def
   sched.h
   DEPENDS
@@ -426,7 +426,7 @@ add_header_macro(
 
 add_header_macro(
   spawn
-  ../libc/hdrgen/yaml/spawn.yaml
+  ../libc/utils/hdrgen/yaml/spawn.yaml
   spawn.h.def
   spawn.h
   DEPENDS
@@ -439,7 +439,7 @@ add_header_macro(
 
 add_header_macro(
   link
-  ../libc/hdrgen/yaml/link.yaml
+  ../libc/utils/hdrgen/yaml/link.yaml
   link.h.def
   link.h
   DEPENDS
@@ -449,7 +449,7 @@ add_header_macro(
 
 add_header_macro(
   elf
-  ../libc/hdrgen/yaml/elf.yaml
+  ../libc/utils/hdrgen/yaml/elf.yaml
   elf.h.def
   elf.h
   DEPENDS
@@ -463,7 +463,7 @@ file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/sys)
 
 add_header_macro(
   sys_auxv
-  ../libc/hdrgen/yaml/sys/auxv.yaml
+  ../libc/utils/hdrgen/yaml/sys/auxv.yaml
   sys/auxv.h.def
   sys/auxv.h
   DEPENDS
@@ -473,7 +473,7 @@ add_header_macro(
 
 add_header_macro(
   sys_epoll
-  ../libc/hdrgen/yaml/sys/epoll.yaml
+  ../libc/utils/hdrgen/yaml/sys/epoll.yaml
   sys/epoll.h.def
   sys/epoll.h
   DEPENDS
@@ -486,7 +486,7 @@ add_header_macro(
 
 add_header_macro(
   sys_ioctl
-  ../libc/hdrgen/yaml/sys/ioctl.yaml
+  ../libc/utils/hdrgen/yaml/sys/ioctl.yaml
   sys/ioctl.h.def
   sys/ioctl.h
   DEPENDS
@@ -496,7 +496,7 @@ add_header_macro(
 
 add_header_macro(
   sys_mman
-  ../libc/hdrgen/yaml/sys/mman.yaml
+  ../libc/utils/hdrgen/yaml/sys/mman.yaml
   sys/mman.h.def
   sys/mman.h
   DEPENDS
@@ -509,7 +509,7 @@ add_header_macro(
 
 add_header_macro(
   sys_prctl
-  ../libc/hdrgen/yaml/sys/prctl.yaml
+  ../libc/utils/hdrgen/yaml/sys/prctl.yaml
   sys/prctl.h.def
   sys/prctl.h
   DEPENDS
@@ -526,7 +526,7 @@ add_header(
 
 add_header_macro(
   sys_random
-  ../libc/hdrgen/yaml/sys/random.yaml
+  ../libc/utils/hdrgen/yaml/sys/random.yaml
   sys/random.h.def
   sys/random.h
   DEPENDS
@@ -538,7 +538,7 @@ add_header_macro(
 
 add_header_macro(
   sys_resource
-  ../libc/hdrgen/yaml/sys/resource.yaml
+  ../libc/utils/hdrgen/yaml/sys/resource.yaml
   sys/resource.h.def
   sys/resource.h
   DEPENDS
@@ -550,7 +550,7 @@ add_header_macro(
 
 add_header_macro(
   sys_stat
-  ../libc/hdrgen/yaml/sys/stat.yaml
+  ../libc/utils/hdrgen/yaml/sys/stat.yaml
   sys/stat.h.def
   sys/stat.h
   DEPENDS
@@ -572,7 +572,7 @@ add_header_macro(
 
 add_header_macro(
   sys_select
-  ../libc/hdrgen/yaml/sys/select.yaml
+  ../libc/utils/hdrgen/yaml/sys/select.yaml
   sys/select.h.def
   sys/select.h
   DEPENDS
@@ -588,7 +588,7 @@ add_header_macro(
 
 add_header_macro(
   sys_sendfile
-  ../libc/hdrgen/yaml/sys/sendfile.yaml
+  ../libc/utils/hdrgen/yaml/sys/sendfile.yaml
   sys/sendfile.h.def
   sys/sendfile.h
   DEPENDS
@@ -600,7 +600,7 @@ add_header_macro(
 
 add_header_macro(
   sys_socket
-  ../libc/hdrgen/yaml/sys/socket.yaml
+  ../libc/utils/hdrgen/yaml/sys/socket.yaml
   sys/socket.h.def
   sys/socket.h
   DEPENDS
@@ -616,7 +616,7 @@ add_header_macro(
 
 add_header_macro(
   sys_statvfs
-  ../libc/hdrgen/yaml/sys/statvfs.yaml
+  ../libc/utils/hdrgen/yaml/sys/statvfs.yaml
   sys/statvfs.h.def
   sys/statvfs.h
   DEPENDS
@@ -626,7 +626,7 @@ add_header_macro(
 
 add_header_macro(
   sys_syscall
-  ../libc/hdrgen/yaml/sys/syscall.yaml
+  ../libc/utils/hdrgen/yaml/sys/syscall.yaml
   sys/syscall.h.def
   sys/syscall.h
   DEPENDS
@@ -634,7 +634,7 @@ add_header_macro(
 
 add_header_macro(
   sys_time
-  ../libc/hdrgen/yaml/sys/time.yaml
+  ../libc/utils/hdrgen/yaml/sys/time.yaml
   sys/time.h.def
   sys/time.h
   DEPENDS
@@ -645,7 +645,7 @@ add_header_macro(
 
 add_header_macro(
   sys_types
-  ../libc/hdrgen/yaml/sys/types.yaml
+  ../libc/utils/hdrgen/yaml/sys/types.yaml
   sys/types.h.def
   sys/types.h
   DEPENDS
@@ -675,7 +675,7 @@ add_header_macro(
 
 add_header_macro(
   sys_utsname
-  ../libc/hdrgen/yaml/sys/utsname.yaml
+  ../libc/utils/hdrgen/yaml/sys/utsname.yaml
   sys/utsname.h.def
   sys/utsname.h
   DEPENDS
@@ -685,7 +685,7 @@ add_header_macro(
 
 add_header_macro(
   sys_wait
-  ../libc/hdrgen/yaml/sys/wait.yaml
+  ../libc/utils/hdrgen/yaml/sys/wait.yaml
   sys/wait.h.def
   sys/wait.h
   DEPENDS
@@ -698,7 +698,7 @@ add_header_macro(
 
 add_header_macro(
   termios
-  ../libc/hdrgen/yaml/termios.yaml
+  ../libc/utils/hdrgen/yaml/termios.yaml
   termios.h.def
   termios.h
   DEPENDS
@@ -713,7 +713,7 @@ add_header_macro(
 
 add_header_macro(
   uchar
-  ../libc/hdrgen/yaml/uchar.yaml
+  ../libc/utils/hdrgen/yaml/uchar.yaml
   uchar.h.def
   uchar.h
   DEPENDS
@@ -726,7 +726,7 @@ add_header_macro(
 
 add_header_macro(
   wchar
-  ../libc/hdrgen/yaml/wchar.yaml
+  ../libc/utils/hdrgen/yaml/wchar.yaml
   wchar.h.def
   wchar.h
   DEPENDS
@@ -740,7 +740,7 @@ add_header_macro(
 
 add_header_macro(
   locale
-  ../libc/hdrgen/yaml/locale.yaml
+  ../libc/utils/hdrgen/yaml/locale.yaml
   locale.h.def
   locale.h
   DEPENDS
diff --git a/libc/src/math/docs/add_math_function.md b/libc/src/math/docs/add_math_function.md
index f02d502399e2b1..7d45bd02c4ff25 100644
--- a/libc/src/math/docs/add_math_function.md
+++ b/libc/src/math/docs/add_math_function.md
@@ -18,7 +18,7 @@ together with its specifications:
 ```
 - Add function specs to the file:
 ```
-  libc/hdrgen/yaml/math.yaml
+  libc/utils/hdrgen/yaml/math.yaml
 ```
 
 ## Implementation
diff --git a/libc/utils/CMakeLists.txt b/libc/utils/CMakeLists.txt
index 11f25503cc13e2..a33c13a045a8af 100644
--- a/libc/utils/CMakeLists.txt
+++ b/libc/utils/CMakeLists.txt
@@ -1,3 +1,5 @@
+add_subdirectory(hdrgen)
+
 if(LLVM_INCLUDE_TESTS)
   add_subdirectory(MPFRWrapper)
 endif()
diff --git a/libc/hdrgen/CMakeLists.txt b/libc/utils/hdrgen/CMakeLists.txt
similarity index 68%
rename from libc/hdrgen/CMakeLists.txt
rename to libc/utils/hdrgen/CMakeLists.txt
index 8ebde4e3e45882..c6827da215055a 100644
--- a/libc/hdrgen/CMakeLists.txt
+++ b/libc/utils/hdrgen/CMakeLists.txt
@@ -1,12 +1,12 @@
 if(LLVM_LIBC_FULL_BUILD)
   enable_testing()
 
-  set(NEWHDGEN_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
+  set(HDRGEN_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
   set(TEST_OUTPUT_DIR ${CMAKE_BINARY_DIR}/hdrgen/output)
 
   add_test(
     NAME hdrgen_integ...
[truncated]

@frobtech frobtech merged commit 9abcca5 into llvm:main Dec 30, 2024
12 checks passed
@frobtech frobtech deleted the p/libc-hdrgen-utils branch December 30, 2024 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants