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
22constexpr 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
32constexpr 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)
41extern "C" {
42#endif
43
44)";
45
46constexpr auto FileFooter = R"(
47#if defined(__cplusplus)
48} // extern "C"
49#endif
50
51)";
52
53constexpr auto CommentsHeader = R"(
54///////////////////////////////////////////////////////////////////////////////
55)";
56
57constexpr auto CommentsBreak = "///\n";
58
59constexpr auto PrefixLower = "ol";
60constexpr auto PrefixUpper = "OL";
61
62inline std::string
63MakeParamComment(const llvm::offload::tblgen::ParamRec &Param) {
64 return llvm::formatv(Fmt: "// {0}{1}{2} {3}", Vals: (Param.isIn() ? "[in]" : ""),
65 Vals: (Param.isOut() ? "[out]" : ""),
66 Vals: (Param.isOpt() ? "[optional]" : ""), Vals: Param.getDesc());
67}
68

source code of offload/tools/offload-tblgen/GenCommon.hpp