1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
//===- offload-tblgen/offload-tblgen.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This is a Tablegen tool that produces source files for the Offload project.
// See offload/API/README.md for more information.
//
//===----------------------------------------------------------------------===//
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/InitLLVM.h"
#include "llvm/TableGen/Main.h"
#include "llvm/TableGen/Record.h"
#include "Generators.hpp"
namespace llvm {
namespace offload {
namespace tblgen {
enum ActionType {
PrintRecords,
DumpJSON,
GenAPI,
GenDoc,
GenFuncNames,
GenImplFuncDecls,
GenEntryPoints,
GenPrintHeader,
GenExports,
GenErrcodes,
GenInfo,
};
namespace {
cl::opt<ActionType> Action(
cl::desc("Action to perform:"),
cl::values(
clEnumValN(PrintRecords, "print-records",
"Print all records to stdout (default)"),
clEnumValN(DumpJSON, "dump-json",
"Dump all records as machine-readable JSON"),
clEnumValN(GenAPI, "gen-api", "Generate Offload API header contents"),
clEnumValN(GenDoc, "gen-doc",
"Generate Offload API documentation contents"),
clEnumValN(GenFuncNames, "gen-func-names",
"Generate a list of all Offload API function names"),
clEnumValN(
GenImplFuncDecls, "gen-impl-func-decls",
"Generate declarations for Offload API implementation functions"),
clEnumValN(GenEntryPoints, "gen-entry-points",
"Generate Offload API wrapper function definitions"),
clEnumValN(GenPrintHeader, "gen-print-header",
"Generate Offload API print header"),
clEnumValN(GenExports, "gen-exports",
"Generate export file for the Offload library"),
clEnumValN(GenErrcodes, "gen-errcodes",
"Generate Offload Error Code enum"),
clEnumValN(GenInfo, "gen-info", "Generate Offload Info enum")));
}
static bool OffloadTableGenMain(raw_ostream &OS, const RecordKeeper &Records) {
switch (Action) {
case PrintRecords:
OS << Records;
break;
case DumpJSON:
EmitJSON(Records, OS);
break;
case GenAPI:
EmitOffloadAPI(Records, OS);
break;
case GenDoc:
EmitOffloadDoc(Records, OS);
break;
case GenFuncNames:
EmitOffloadFuncNames(Records, OS);
break;
case GenImplFuncDecls:
EmitOffloadImplFuncDecls(Records, OS);
break;
case GenEntryPoints:
EmitOffloadEntryPoints(Records, OS);
break;
case GenPrintHeader:
EmitOffloadPrintHeader(Records, OS);
break;
case GenExports:
EmitOffloadExports(Records, OS);
break;
case GenErrcodes:
EmitOffloadErrcodes(Records, OS);
break;
case GenInfo:
EmitOffloadInfo(Records, OS);
break;
}
return false;
}
int OffloadTblgenMain(int argc, char **argv) {
InitLLVM y(argc, argv);
cl::ParseCommandLineOptions(argc, argv);
return TableGenMain(argv[0], &OffloadTableGenMain);
}
} // namespace tblgen
} // namespace offload
} // namespace llvm
using namespace llvm;
using namespace offload::tblgen;
int main(int argc, char **argv) { return OffloadTblgenMain(argc, argv); }
|