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 # ==-------------------------------------------------------------------------==#
11 def __init__(self
, name
):
15 self
.enumerations
= []
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
)
38 f
"//===-- C standard declarations for {self.name} ------------------------------===//"
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")
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")
71 content
.append("#endif\n")
73 content
.append(f
"#endif")
75 return "\n".join(content
)