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] Make GpuHeaderFile a subclass #121445

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

frobtech
Copy link
Contributor

@frobtech frobtech commented Jan 2, 2025

Replace copy&paste from HeaderFile to GpuHeaderFile with
subclassing. Only the str method differs.

Replace copy&paste from HeaderFile to GpuHeaderFile with
subclassing.  Only the __str__ method differs.
@frobtech frobtech requested a review from jhuber6 January 2, 2025 01:06
@frobtech frobtech marked this pull request as ready for review January 2, 2025 01:06
@llvmbot llvmbot added the libc label Jan 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2025

@llvm/pr-subscribers-libc

Author: Roland McGrath (frobtech)

Changes

Replace copy&paste from HeaderFile to GpuHeaderFile with
subclassing. Only the str method differs.


Full diff: https://github.com/llvm/llvm-project/pull/121445.diff

1 Files Affected:

  • (modified) libc/utils/hdrgen/gpu_headers.py (+2-24)
diff --git a/libc/utils/hdrgen/gpu_headers.py b/libc/utils/hdrgen/gpu_headers.py
index b26b3a88557b4a..8c4ff6e08b1126 100644
--- a/libc/utils/hdrgen/gpu_headers.py
+++ b/libc/utils/hdrgen/gpu_headers.py
@@ -6,31 +6,9 @@
 #
 # ==-------------------------------------------------------------------------==#
 
+from header import HeaderFile
 
-class GpuHeaderFile:
-    def __init__(self, name):
-        self.name = name
-        self.macros = []
-        self.types = []
-        self.enumerations = []
-        self.objects = []
-        self.functions = []
-
-    def add_macro(self, macro):
-        self.macros.append(macro)
-
-    def add_type(self, type_):
-        self.types.append(type_)
-
-    def add_enumeration(self, enumeration):
-        self.enumerations.append(enumeration)
-
-    def add_object(self, object):
-        self.objects.append(object)
-
-    def add_function(self, function):
-        self.functions.append(function)
-
+class GpuHeaderFile(HeaderFile):
     def __str__(self):
         content = []
 

@frobtech frobtech requested review from fabio-d and Caslyn January 2, 2025 01:07
@frobtech frobtech merged commit 508929d into llvm:main Jan 2, 2025
15 checks passed
@frobtech frobtech deleted the p/libc-hdrgen-gpuheader-subclass branch January 2, 2025 02:16
meltq pushed a commit to meltq/llvm-project that referenced this pull request Jan 2, 2025
Replace copy&paste from HeaderFile to GpuHeaderFile with
subclassing.  Only the __str__ method differs.
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