-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.cpp
48 lines (39 loc) · 2.25 KB
/
cli.cpp
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
#include "cli.h"
#include "llvm/Support/CommandLine.h"
Options Options::parseOptions(int argc, char** argv) {
Options ret;
llvm::cl::OptionCategory CompilerCategory("Compiler Options",
"Options for controlling the compilation process.");
static llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
llvm::cl::desc("<input file>"),
llvm::cl::init("-"),
llvm::cl::cat(CompilerCategory));
static llvm::cl::opt<std::string> outputFilename("o",
llvm::cl::desc("Output filename"),
llvm::cl::value_desc("filename"),
llvm::cl::cat(CompilerCategory));
static llvm::cl::opt<std::string> mainFunctionName("mainFunctionName",
llvm::cl::desc("Main function name"),
llvm::cl::value_desc("name"),
llvm::cl::cat(CompilerCategory),
llvm::cl::init("main"));
static llvm::cl::opt<OutputType> outputType(
llvm::cl::desc("Output file type"),
llvm::cl::values(clEnumValN(LLVMIR, "E", "Emit LLVM IR as text"),
clEnumValN(Assembly, "S", "Emit assembly as text"),
clEnumValN(ObjectCode, "c", "Emit binary object code")),
llvm::cl::cat(CompilerCategory),
llvm::cl::init(ObjectCode));
static llvm::cl::opt<bool> verifyModule(
"verify",
llvm::cl::desc("Run verification on module before writing output"),
llvm::cl::cat(CompilerCategory),
llvm::cl::init(true));
llvm::cl::HideUnrelatedOptions(CompilerCategory);
llvm::cl::ParseCommandLineOptions(argc, argv);
return Options{inputFilename.getValue(),
outputFilename.getValue(),
mainFunctionName.getValue(),
outputType.getValue(),
verifyModule.getValue()};
}