19abcca5eSRoland McGrath# ===- GPU HeaderFile Class for --export-decls version --------*- python -*--==# 29abcca5eSRoland McGrath# 39abcca5eSRoland McGrath# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 49abcca5eSRoland McGrath# See https://llvm.org/LICENSE.txt for license information. 59abcca5eSRoland McGrath# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 69abcca5eSRoland McGrath# 79abcca5eSRoland McGrath# ==-------------------------------------------------------------------------==# 89abcca5eSRoland McGrath 9*508929d4SRoland McGrathfrom header import HeaderFile 109abcca5eSRoland McGrath 11*508929d4SRoland McGrathclass GpuHeaderFile(HeaderFile): 129abcca5eSRoland McGrath def __str__(self): 139abcca5eSRoland McGrath content = [] 149abcca5eSRoland McGrath 159abcca5eSRoland McGrath content.append( 169abcca5eSRoland McGrath f"//===-- C standard declarations for {self.name} ------------------------------===//" 179abcca5eSRoland McGrath ) 189abcca5eSRoland McGrath content.append("//") 199abcca5eSRoland McGrath content.append( 209abcca5eSRoland McGrath "// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions." 219abcca5eSRoland McGrath ) 229abcca5eSRoland McGrath content.append("// See https://llvm.org/LICENSE.txt for license information.") 239abcca5eSRoland McGrath content.append("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception") 249abcca5eSRoland McGrath content.append("//") 259abcca5eSRoland McGrath content.append( 269abcca5eSRoland McGrath "//===----------------------------------------------------------------------===//\n" 279abcca5eSRoland McGrath ) 289abcca5eSRoland McGrath 299abcca5eSRoland McGrath header_guard = f"__LLVM_LIBC_DECLARATIONS_{self.name.upper()[:-2]}_H" 309abcca5eSRoland McGrath content.append(f"#ifndef {header_guard}") 319abcca5eSRoland McGrath content.append(f"#define {header_guard}\n") 329abcca5eSRoland McGrath 339abcca5eSRoland McGrath content.append("#ifndef __LIBC_ATTRS") 349abcca5eSRoland McGrath content.append("#define __LIBC_ATTRS") 359abcca5eSRoland McGrath content.append("#endif\n") 369abcca5eSRoland McGrath 379abcca5eSRoland McGrath content.append("#ifdef __cplusplus") 389abcca5eSRoland McGrath content.append('extern "C" {') 399abcca5eSRoland McGrath content.append("#endif\n") 409abcca5eSRoland McGrath 419abcca5eSRoland McGrath for function in self.functions: 429abcca5eSRoland McGrath content.append(f"{function} __LIBC_ATTRS;\n") 439abcca5eSRoland McGrath 449abcca5eSRoland McGrath for object in self.objects: 459abcca5eSRoland McGrath content.append(f"{object} __LIBC_ATTRS;\n") 469abcca5eSRoland McGrath 479abcca5eSRoland McGrath content.append("#ifdef __cplusplus") 489abcca5eSRoland McGrath content.append("}") 499abcca5eSRoland McGrath content.append("#endif\n") 509abcca5eSRoland McGrath 519abcca5eSRoland McGrath content.append(f"#endif") 529abcca5eSRoland McGrath 539abcca5eSRoland McGrath return "\n".join(content) 54