1 //===- offload-tblgen/GenCommon.cpp - Common defs for Offload generators --===// 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 9 #pragma once 10 11 #include "RecordTypes.hpp" 12 #include "llvm/Support/FormatVariadic.h" 13 14 // Having inline bits of tabbed code is hard to read, provide some definitions 15 // so we can keep things tidier 16 #define TAB_1 " " 17 #define TAB_2 " " 18 #define TAB_3 " " 19 #define TAB_4 " " 20 #define TAB_5 " " 21 22 constexpr auto GenericHeader = 23 R"(//===- Auto-generated file, part of the LLVM/Offload project --------------===// 24 // 25 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 26 // See https://llvm.org/LICENSE.txt for license information. 27 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 28 // 29 //===----------------------------------------------------------------------===// 30 )"; 31 32 constexpr auto FileHeader = R"( 33 // Auto-generated file, do not manually edit. 34 35 #pragma once 36 37 #include <stddef.h> 38 #include <stdint.h> 39 40 #if defined(__cplusplus) 41 extern "C" { 42 #endif 43 44 )"; 45 46 constexpr auto FileFooter = R"( 47 #if defined(__cplusplus) 48 } // extern "C" 49 #endif 50 51 )"; 52 53 constexpr auto CommentsHeader = R"( 54 /////////////////////////////////////////////////////////////////////////////// 55 )"; 56 57 constexpr auto CommentsBreak = "///\n"; 58 59 constexpr auto PrefixLower = "ol"; 60 constexpr auto PrefixUpper = "OL"; 61 62 inline std::string 63 MakeParamComment(const llvm::offload::tblgen::ParamRec &Param) { 64 return llvm::formatv("// {0}{1}{2} {3}", (Param.isIn() ? "[in]" : ""), 65 (Param.isOut() ? "[out]" : ""), 66 (Param.isOpt() ? "[optional]" : ""), Param.getDesc()); 67 } 68