1 | /** |
2 | * Copyright (c) Glow Contributors. See CONTRIBUTORS file. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | #include "glow/LLVMIRCodeGen/CommandLine.h" |
18 | |
19 | llvm::cl::OptionCategory &getLLVMBackendCat() { |
20 | static llvm::cl::OptionCategory cpuBackendCat("Glow CPU Backend Options" ); |
21 | return cpuBackendCat; |
22 | } |
23 | |
24 | llvm::cl::opt<std::string> |
25 | llvmTarget("target" , llvm::cl::desc("LLVM target triple to be used" )); |
26 | |
27 | llvm::cl::opt<std::string> |
28 | llvmArch("march" , llvm::cl::desc("LLVM architecture to be used" )); |
29 | |
30 | llvm::cl::opt<std::string> llvmCPU("mcpu" , |
31 | llvm::cl::desc("LLVM CPU to be used" )); |
32 | |
33 | llvm::cl::opt<std::string> llvmABI("mabi" , |
34 | llvm::cl::desc("Machine ABI to be used" )); |
35 | |
36 | llvm::cl::opt<llvm::CodeModel::Model> llvmCodeModel( |
37 | "code-model" , |
38 | llvm::cl::desc("Specify which code model to use on the target machine" ), |
39 | llvm::cl::values( |
40 | clEnumValN(llvm::CodeModel::Model::Small, "small" , "Small code model" ), |
41 | clEnumValN(llvm::CodeModel::Model::Medium, "medium" , |
42 | "Medium code model" ), |
43 | clEnumValN(llvm::CodeModel::Model::Large, "large" , "Large code model" )), |
44 | llvm::cl::init(llvm::CodeModel::Model::Large), |
45 | llvm::cl::cat(getLLVMBackendCat())); |
46 | |
47 | llvm::cl::opt<llvm::CodeModel::Model> llvmBundleCodeModel( |
48 | "bundle-code-model" , |
49 | llvm::cl::desc("Specify which code model to use for a bundle" ), |
50 | llvm::cl::values( |
51 | clEnumValN(llvm::CodeModel::Model::Small, "small" , "Small code model" ), |
52 | clEnumValN(llvm::CodeModel::Model::Medium, "medium" , |
53 | "Medium code model" ), |
54 | clEnumValN(llvm::CodeModel::Model::Large, "large" , "Large code model" )), |
55 | llvm::cl::init(llvm::CodeModel::Model::Small), |
56 | llvm::cl::cat(getLLVMBackendCat())); |
57 | |
58 | llvm::cl::opt<llvm::Reloc::Model> llvmRelocModel( |
59 | "relocation-model" , |
60 | llvm::cl::desc( |
61 | "Specify which relocation model to use on the target machine" ), |
62 | llvm::cl::values( |
63 | clEnumValN(llvm::Reloc::Static, "static" , "Non-relocatable code" ), |
64 | clEnumValN(llvm::Reloc::PIC_, "pic" , "Position independent code" )), |
65 | llvm::cl::init(llvm::Reloc::Static), llvm::cl::cat(getLLVMBackendCat())); |
66 | |
67 | llvm::cl::list<std::string> |
68 | llvmTargetFeatures("target-feature" , |
69 | llvm::cl::desc("LLVM target/CPU features to be used" ), |
70 | llvm::cl::CommaSeparated, llvm::cl::ZeroOrMore); |
71 | |
72 | llvm::cl::alias llvmMAttr("mattr" , llvm::cl::desc("Alias for -target-feature" ), |
73 | llvm::cl::aliasopt(llvmTargetFeatures)); |
74 | |
75 | llvm::cl::opt<std::string> |
76 | llvmCompiler("llvm-compiler" , |
77 | llvm::cl::desc("External LLVM compiler (e.g. llc) to use for " |
78 | "compiling LLVM bitcode into machine code" )); |
79 | |
80 | llvm::cl::opt<std::string> |
81 | llvmOpt("llvm-opt" , |
82 | llvm::cl::desc("External LLVM-Opt compiler (opt) to use for " |
83 | "optimizing LLVM bitcode." )); |
84 | |
85 | llvm::cl::list<std::string> llvmCompilerOptions( |
86 | "llvm-compiler-opt" , |
87 | llvm::cl::desc("Options to pass to the external LLVM compiler" ), |
88 | llvm::cl::ZeroOrMore); |
89 | |
90 | llvm::cl::opt<bool> llvmSaveAsm( |
91 | "llvm-save-asm" , |
92 | llvm::cl::desc("Create and save asm file along with Bundle object file." ), |
93 | llvm::cl::init(false), llvm::cl::cat(getLLVMBackendCat())); |
94 | |
95 | llvm::cl::opt<llvm::FloatABI::ABIType> |
96 | floatABI("float-abi" , llvm::cl::desc("Option to set float ABI type" ), |
97 | llvm::cl::values(clEnumValN(llvm::FloatABI::Default, "default" , |
98 | "Default float ABI type" ), |
99 | clEnumValN(llvm::FloatABI::Soft, "soft" , |
100 | "Soft float ABI (softfp)" ), |
101 | clEnumValN(llvm::FloatABI::Hard, "hard" , |
102 | "Hard float ABI (hardfp)" )), |
103 | llvm::cl::init(llvm::FloatABI::Default)); |
104 | |
105 | static llvm::cl::OptionCategory bundleSaverCat("Bundle Options" ); |
106 | |
107 | llvm::cl::opt<glow::BundleApiType> |
108 | bundleAPI("bundle-api" , llvm::cl::desc("Specify which bundle API to use." ), |
109 | llvm::cl::Optional, |
110 | llvm::cl::values(clEnumValN(glow::BundleApiType::Dynamic, |
111 | "dynamic" , "Dynamic API" ), |
112 | clEnumValN(glow::BundleApiType::Static, "static" , |
113 | "Static API" )), |
114 | llvm::cl::init(glow::BundleApiType::Static), |
115 | llvm::cl::cat(bundleSaverCat)); |
116 | |
117 | llvm::cl::opt<bool> bundleAPIVerbose( |
118 | "bundle-api-verbose" , |
119 | llvm::cl::desc("Print more details in the bundle API header file" ), |
120 | llvm::cl::init(false), llvm::cl::cat(bundleSaverCat)); |
121 | |
122 | llvm::cl::list<std::string> bundleObjectsOpt( |
123 | "bundle-objects" , |
124 | llvm::cl::desc("Comma separated list of names of other object files which " |
125 | "should be archived into the bundle. The object files are " |
126 | "pre registered during Glow build. " ), |
127 | llvm::cl::CommaSeparated, llvm::cl::ZeroOrMore); |
128 | |