[libc++][Android] Allow testing libc++ with clang-r536225 (#116149)
[llvm-project.git] / libc / newhdrgen / gpu_headers.py
blobb26b3a88557b4a4334845177f10159ee383aca91
1 # ===- GPU HeaderFile Class for --export-decls version --------*- python -*--==#
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 # ==-------------------------------------------------------------------------==#
10 class GpuHeaderFile:
11 def __init__(self, name):
12 self.name = name
13 self.macros = []
14 self.types = []
15 self.enumerations = []
16 self.objects = []
17 self.functions = []
19 def add_macro(self, macro):
20 self.macros.append(macro)
22 def add_type(self, type_):
23 self.types.append(type_)
25 def add_enumeration(self, enumeration):
26 self.enumerations.append(enumeration)
28 def add_object(self, object):
29 self.objects.append(object)
31 def add_function(self, function):
32 self.functions.append(function)
34 def __str__(self):
35 content = []
37 content.append(
38 f"//===-- C standard declarations for {self.name} ------------------------------===//"
40 content.append("//")
41 content.append(
42 "// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions."
44 content.append("// See https://llvm.org/LICENSE.txt for license information.")
45 content.append("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception")
46 content.append("//")
47 content.append(
48 "//===----------------------------------------------------------------------===//\n"
51 header_guard = f"__LLVM_LIBC_DECLARATIONS_{self.name.upper()[:-2]}_H"
52 content.append(f"#ifndef {header_guard}")
53 content.append(f"#define {header_guard}\n")
55 content.append("#ifndef __LIBC_ATTRS")
56 content.append("#define __LIBC_ATTRS")
57 content.append("#endif\n")
59 content.append("#ifdef __cplusplus")
60 content.append('extern "C" {')
61 content.append("#endif\n")
63 for function in self.functions:
64 content.append(f"{function} __LIBC_ATTRS;\n")
66 for object in self.objects:
67 content.append(f"{object} __LIBC_ATTRS;\n")
69 content.append("#ifdef __cplusplus")
70 content.append("}")
71 content.append("#endif\n")
73 content.append(f"#endif")
75 return "\n".join(content)