brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · b57f96a Raw
73 lines · plain
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-exception6//7//===----------------------------------------------------------------------===//8 9#pragma once10 11#include "RecordTypes.hpp"12#include "llvm/Support/FormatVariadic.h"13 14// Having inline bits of tabbed code is hard to read, provide some definitions15// so we can keep things tidier16#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-exception28//29//===----------------------------------------------------------------------===//30)";31 32constexpr auto FileHeader = R"(33// Auto-generated file, do not manually edit.34 35#pragma once36 37#include <stddef.h>38#include <stdint.h>39 40#if defined(__cplusplus)41extern "C" {42#endif43 44)";45 46constexpr auto FileFooter = R"(47#if defined(__cplusplus)48} // extern "C"49#endif50 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::string63MakeParamComment(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 69inline std::string70getHandleImplName(const llvm::offload::tblgen::HandleRec &H) {71  return (H.getName().substr(0, H.getName().size() - 9) + "_impl_t").str();72}73