1# ===- GPU HeaderFile Class for --export-decls version --------*- python -*--==# 2# 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 6# 7# ==-------------------------------------------------------------------------==# 8 9from header import HeaderFile 10 11class GpuHeaderFile(HeaderFile): 12 def __str__(self): 13 content = [] 14 15 content.append( 16 f"//===-- C standard declarations for {self.name} ------------------------------===//" 17 ) 18 content.append("//") 19 content.append( 20 "// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions." 21 ) 22 content.append("// See https://llvm.org/LICENSE.txt for license information.") 23 content.append("// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception") 24 content.append("//") 25 content.append( 26 "//===----------------------------------------------------------------------===//\n" 27 ) 28 29 header_guard = f"__LLVM_LIBC_DECLARATIONS_{self.name.upper()[:-2]}_H" 30 content.append(f"#ifndef {header_guard}") 31 content.append(f"#define {header_guard}\n") 32 33 content.append("#ifndef __LIBC_ATTRS") 34 content.append("#define __LIBC_ATTRS") 35 content.append("#endif\n") 36 37 content.append("#ifdef __cplusplus") 38 content.append('extern "C" {') 39 content.append("#endif\n") 40 41 for function in self.functions: 42 content.append(f"{function} __LIBC_ATTRS;\n") 43 44 for object in self.objects: 45 content.append(f"{object} __LIBC_ATTRS;\n") 46 47 content.append("#ifdef __cplusplus") 48 content.append("}") 49 content.append("#endif\n") 50 51 content.append(f"#endif") 52 53 return "\n".join(content) 54