[libc-commits] [libc] [libc] reordered Function class parameters and moved yaml files (PR #97329)

via libc-commits libc-commits at lists.llvm.org
Tue Jul 2 10:46:31 PDT 2024


https://github.com/RoseZhang03 updated https://github.com/llvm/llvm-project/pull/97329

>From 870d58fe93597be358982a923e6634a8b153e4b0 Mon Sep 17 00:00:00 2001
From: Rose Zhang <rosezhang at google.com>
Date: Mon, 1 Jul 2024 17:31:21 +0000
Subject: [PATCH 1/3] [libc] reordered Function class parameters and moved yaml
 files

Reordered Function class parameter "standards" to make more logical
sense and to match the ordering in the add_function function.
Deleted the yaml_combined folder and moved contained files to the yaml
folder.
---
 libc/newhdrgen/class_implementation/classes/function.py | 4 ++--
 libc/newhdrgen/{yaml_combined => yaml}/ctype.yaml       | 0
 libc/newhdrgen/{yaml_combined => yaml}/fenv.yaml        | 0
 libc/newhdrgen/{yaml_combined => yaml}/math.yaml        | 0
 libc/newhdrgen/{yaml_combined => yaml}/pthread.yaml     | 0
 libc/newhdrgen/{yaml_combined => yaml}/sched.yaml       | 0
 libc/newhdrgen/{yaml_combined => yaml}/signal.yaml      | 0
 libc/newhdrgen/{yaml_combined => yaml}/stdfix.yaml      | 0
 libc/newhdrgen/{yaml_combined => yaml}/stdio.yaml       | 0
 libc/newhdrgen/{yaml_combined => yaml}/stdlib.yaml      | 0
 libc/newhdrgen/{yaml_combined => yaml}/string.yaml      | 0
 libc/newhdrgen/{yaml_combined => yaml}/strings.yaml     | 0
 libc/newhdrgen/{yaml_combined => yaml}/sys_mman.yaml    | 0
 libc/newhdrgen/{yaml_combined => yaml}/sys_wait.yaml    | 0
 libc/newhdrgen/{yaml_combined => yaml}/time.yaml        | 0
 libc/newhdrgen/yaml_to_classes.py                       | 2 +-
 16 files changed, 3 insertions(+), 3 deletions(-)
 rename libc/newhdrgen/{yaml_combined => yaml}/ctype.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/fenv.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/math.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/pthread.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/sched.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/signal.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/stdfix.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/stdio.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/stdlib.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/string.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/strings.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/sys_mman.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/sys_wait.yaml (100%)
 rename libc/newhdrgen/{yaml_combined => yaml}/time.yaml (100%)

diff --git a/libc/newhdrgen/class_implementation/classes/function.py b/libc/newhdrgen/class_implementation/classes/function.py
index 3c464e48b6e3b..27219bfd3f611 100644
--- a/libc/newhdrgen/class_implementation/classes/function.py
+++ b/libc/newhdrgen/class_implementation/classes/function.py
@@ -11,14 +11,14 @@
 
 class Function:
     def __init__(
-        self, standards, return_type, name, arguments, guard=None, attributes=[]
+        self, return_type, name, arguments, standards, guard=None, attributes=[]
     ):
-        self.standards = standards
         self.return_type = return_type
         self.name = name
         self.arguments = [
             arg if isinstance(arg, str) else arg["type"] for arg in arguments
         ]
+        self.standards = standards
         self.guard = guard
         self.attributes = attributes or []
 
diff --git a/libc/newhdrgen/yaml_combined/ctype.yaml b/libc/newhdrgen/yaml/ctype.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/ctype.yaml
rename to libc/newhdrgen/yaml/ctype.yaml
diff --git a/libc/newhdrgen/yaml_combined/fenv.yaml b/libc/newhdrgen/yaml/fenv.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/fenv.yaml
rename to libc/newhdrgen/yaml/fenv.yaml
diff --git a/libc/newhdrgen/yaml_combined/math.yaml b/libc/newhdrgen/yaml/math.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/math.yaml
rename to libc/newhdrgen/yaml/math.yaml
diff --git a/libc/newhdrgen/yaml_combined/pthread.yaml b/libc/newhdrgen/yaml/pthread.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/pthread.yaml
rename to libc/newhdrgen/yaml/pthread.yaml
diff --git a/libc/newhdrgen/yaml_combined/sched.yaml b/libc/newhdrgen/yaml/sched.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/sched.yaml
rename to libc/newhdrgen/yaml/sched.yaml
diff --git a/libc/newhdrgen/yaml_combined/signal.yaml b/libc/newhdrgen/yaml/signal.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/signal.yaml
rename to libc/newhdrgen/yaml/signal.yaml
diff --git a/libc/newhdrgen/yaml_combined/stdfix.yaml b/libc/newhdrgen/yaml/stdfix.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/stdfix.yaml
rename to libc/newhdrgen/yaml/stdfix.yaml
diff --git a/libc/newhdrgen/yaml_combined/stdio.yaml b/libc/newhdrgen/yaml/stdio.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/stdio.yaml
rename to libc/newhdrgen/yaml/stdio.yaml
diff --git a/libc/newhdrgen/yaml_combined/stdlib.yaml b/libc/newhdrgen/yaml/stdlib.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/stdlib.yaml
rename to libc/newhdrgen/yaml/stdlib.yaml
diff --git a/libc/newhdrgen/yaml_combined/string.yaml b/libc/newhdrgen/yaml/string.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/string.yaml
rename to libc/newhdrgen/yaml/string.yaml
diff --git a/libc/newhdrgen/yaml_combined/strings.yaml b/libc/newhdrgen/yaml/strings.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/strings.yaml
rename to libc/newhdrgen/yaml/strings.yaml
diff --git a/libc/newhdrgen/yaml_combined/sys_mman.yaml b/libc/newhdrgen/yaml/sys_mman.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/sys_mman.yaml
rename to libc/newhdrgen/yaml/sys_mman.yaml
diff --git a/libc/newhdrgen/yaml_combined/sys_wait.yaml b/libc/newhdrgen/yaml/sys_wait.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/sys_wait.yaml
rename to libc/newhdrgen/yaml/sys_wait.yaml
diff --git a/libc/newhdrgen/yaml_combined/time.yaml b/libc/newhdrgen/yaml/time.yaml
similarity index 100%
rename from libc/newhdrgen/yaml_combined/time.yaml
rename to libc/newhdrgen/yaml/time.yaml
diff --git a/libc/newhdrgen/yaml_to_classes.py b/libc/newhdrgen/yaml_to_classes.py
index 7159dd9cc8881..8ca09267dbb3d 100644
--- a/libc/newhdrgen/yaml_to_classes.py
+++ b/libc/newhdrgen/yaml_to_classes.py
@@ -54,10 +54,10 @@ def yaml_to_classes(yaml_data):
         standards = (function_data.get("standards", None),)
         header.add_function(
             Function(
-                standards,
                 function_data["return_type"],
                 function_data["name"],
                 arguments,
+                standards,
                 guard,
                 attributes,
             )

>From 92746619fc69c6f8e7205ad92c4e8cfb6a7e9a8b Mon Sep 17 00:00:00 2001
From: Rose Zhang <rosezhang at google.com>
Date: Mon, 1 Jul 2024 23:28:37 +0000
Subject: [PATCH 2/3] removed duplicate macros list and deleted unecessary
 comments

---
 libc/newhdrgen/yaml/sys_mman.yaml  | 2 --
 libc/newhdrgen/yaml/sys_types.yaml | 2 +-
 libc/newhdrgen/yaml/sys_wait.yaml  | 2 +-
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libc/newhdrgen/yaml/sys_mman.yaml b/libc/newhdrgen/yaml/sys_mman.yaml
index 7b858db2de11a..16a6463b0917d 100644
--- a/libc/newhdrgen/yaml/sys_mman.yaml
+++ b/libc/newhdrgen/yaml/sys_mman.yaml
@@ -1,8 +1,6 @@
-#known as sys/mman in POSIX 
 header: sys-mman.h
 standards: POSIX
 macros: []
-macros: []
 types:
   - type_name: mode_t
   - type_name: size_t
diff --git a/libc/newhdrgen/yaml/sys_types.yaml b/libc/newhdrgen/yaml/sys_types.yaml
index 6b08254a7fab1..20cf9bcd39da3 100644
--- a/libc/newhdrgen/yaml/sys_types.yaml
+++ b/libc/newhdrgen/yaml/sys_types.yaml
@@ -26,5 +26,5 @@ types:
   - type_name: pthread_key_t
   - type_name: pthread_condattr_t
 enums: []
-functions: []
 objects: []
+functions: []
diff --git a/libc/newhdrgen/yaml/sys_wait.yaml b/libc/newhdrgen/yaml/sys_wait.yaml
index 56a6066e925d6..2f2f70d0e9745 100644
--- a/libc/newhdrgen/yaml/sys_wait.yaml
+++ b/libc/newhdrgen/yaml/sys_wait.yaml
@@ -1,4 +1,4 @@
-header: sys-wait.h #sys/wait.h
+header: sys-wait.h
 macros: []
 types:
   - type_name: siginfo_t

>From 36a45b6acba9f6063e763aacefed291ac640be0a Mon Sep 17 00:00:00 2001
From: Rose Zhang <rosezhang at google.com>
Date: Tue, 2 Jul 2024 17:45:58 +0000
Subject: [PATCH 3/3] updated math.yaml with functions added to llvm_libc_ext
 standard

---
 libc/newhdrgen/yaml/math.yaml | 61 +++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/libc/newhdrgen/yaml/math.yaml b/libc/newhdrgen/yaml/math.yaml
index dbb1e6ec63030..5d2dbdaa2a907 100644
--- a/libc/newhdrgen/yaml/math.yaml
+++ b/libc/newhdrgen/yaml/math.yaml
@@ -1882,3 +1882,64 @@ functions:
     arguments:
       - type: float
     guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16addf
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: float
+      - type: float
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16subf
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: float
+      - type: float
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16div
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: double
+      - type: double
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16divf
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: float
+      - type: float
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16divl
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: long double
+      - type: long double
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16sqrt
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: double
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16sqrtf
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: float
+    guard: LIBC_TYPES_HAS_FLOAT16
+  - name: f16sqrtl
+    standards: 
+      - llvm_libc_ext
+    return_type: _Float16
+    arguments:
+      - type: long double
+    guard: LIBC_TYPES_HAS_FLOAT16



More information about the libc-commits mailing list