• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===- subzero/src/IceClFlags.def - Cl Flags for translation ----*- C++ -*-===//
2//
3//                        The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief Declares the command line flags used by Subzero.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef SUBZERO_SRC_ICECLFLAGS_DEF
16#define SUBZERO_SRC_ICECLFLAGS_DEF
17
18namespace Ice {
19// cl_detail defines tags (i.e., structs) for specifying the type of a flag
20// (either single-, or multi-value), and whether or not the flag is available in
21// non-LLVM_CL build.
22namespace cl_detail {
23
24// Single-value flag, available in a non-LLVM_CL build.
25struct release_opt_flag {};
26// Single-value flag, not available in a non-LLVM_CL build.
27struct dev_opt_flag {};
28// Multi-value flag, not available in a non-LLVM_CL build.
29struct dev_list_flag {};
30
31} // end of namespace detail
32
33#define COMMAND_LINE_FLAGS                                                     \
34  /* Name, Type, ClType, <<flag declaration ctor arguments>> */                \
35  X(IRFilename, std::string, release_opt_flag, cl::Positional,                 \
36    cl::desc("IR File"), cl::init("-"))                                        \
37                                                                               \
38  X(NumTranslationThreads, uint32_t, release_opt_flag, "num_threads",          \
39    cl::desc("Number of translation threads (0 for purely sequential)"),       \
40    cl::init(2))                                                               \
41                                                                               \
42  X(OptLevel, Ice::OptLevel, release_opt_flag, cl::desc("Optimization level"), \
43    cl::init(Ice::Opt_m1), cl::value_desc("level"),                            \
44    cl::values(clEnumValN(Ice::Opt_m1, "Om1", "-1"),                           \
45               clEnumValN(Ice::Opt_m1, "O-1", "-1"),                           \
46               clEnumValN(Ice::Opt_0, "O0", "0"),                              \
47               clEnumValN(Ice::Opt_1, "O1", "1"),                              \
48               clEnumValN(Ice::Opt_2, "O2", "2") CLENUMVALEND))                \
49                                                                               \
50  X(OutputFilename, std::string, release_opt_flag, "o",                        \
51    cl::desc("Override output filename"), cl::init("-"),                       \
52    cl::value_desc("filename"))                                                \
53                                                                               \
54  X(TargetArch, Ice::TargetArch, release_opt_flag, "target",                   \
55    cl::desc("Target architecture:"), cl::init(Ice::Target_X8632),             \
56    cl::values(                                                                \
57        clEnumValN(Ice::Target_X8632, "x8632", "x86-32"),                      \
58        clEnumValN(Ice::Target_X8632, "x86-32", "x86-32 (same as x8632)"),     \
59        clEnumValN(Ice::Target_X8632, "x86_32", "x86-32 (same as x8632)"),     \
60        clEnumValN(Ice::Target_X8664, "x8664", "x86-64"),                      \
61        clEnumValN(Ice::Target_X8664, "x86-64", "x86-64 (same as x8664)"),     \
62        clEnumValN(Ice::Target_X8664, "x86_64", "x86-64 (same as x8664)"),     \
63        clEnumValN(Ice::Target_ARM32, "arm", "arm32"),                         \
64        clEnumValN(Ice::Target_ARM32, "arm32", "arm32 (same as arm)"),         \
65        clEnumValN(Ice::Target_ARM64, "arm64", "arm64"),                       \
66        clEnumValN(Ice::Target_MIPS32, "mips", "mips32"),                      \
67        clEnumValN(Ice::Target_MIPS32, "mips32", "mips32 (same as mips)")      \
68        CLENUMVALEND))                                                         \
69                                                                               \
70  /* The following are development flags, and ideally should not appear in a   \
71   * release build. */                                                         \
72                                                                               \
73  X(AllowErrorRecovery, bool, dev_opt_flag,                                    \
74    "allow-pnacl-reader-error-recovery",                                       \
75    cl::desc("Allow error recovery when reading PNaCl bitcode."),              \
76    cl::init(false))                                                           \
77                                                                               \
78  X(AllowExternDefinedSymbols, bool, dev_opt_flag,                             \
79    "allow-externally-defined-symbols",                                        \
80    cl::desc(                                                                  \
81        "Allow global symbols to be externally defined (other than _start "    \
82        "and __pnacl_pso_root)."),                                             \
83    cl::init(false))                                                           \
84                                                                               \
85  X(AllowIacaMarks, bool, dev_opt_flag, "allow-iaca-marks",                    \
86    cl::desc("Allow IACA (Intel Architecture Code Analyzer) marks to be "      \
87             "inserted. These binaries are not executable."),                  \
88    cl::init(false))                                                           \
89                                                                               \
90  X(AllowUninitializedGlobals, bool, dev_opt_flag,                             \
91    "allow-uninitialized-globals",                                             \
92    cl::desc("Allow global variables to be uninitialized"))                    \
93                                                                               \
94  X(AlwaysExitSuccess, bool, dev_opt_flag, "exit-success",                     \
95    cl::desc("Exit with success status, even if errors found"),                \
96    cl::init(false))                                                           \
97                                                                               \
98  X(AggressiveLea, bool, dev_opt_flag, "aggressive-lea",                       \
99    cl::desc("Convert additions to lea when it reduces code size"),            \
100    cl::init(false))                                                           \
101                                                                               \
102  X(BitcodeAsText, bool, dev_opt_flag, "bitcode-as-text",                      \
103    cl::desc("Accept textual form of PNaCl bitcode "                           \
104             "records (i.e. not .ll assembly)"),                               \
105    cl::init(false))                                                           \
106                                                                               \
107  X(BuildOnRead, bool, dev_opt_flag, "build-on-read",                          \
108    cl::desc("Build ICE instructions when reading bitcode"), cl::init(true))   \
109                                                                               \
110  X(DataSections, bool, dev_opt_flag, "fdata-sections",                        \
111    cl::desc("Emit (global) data into separate sections"))                     \
112                                                                               \
113  X(DecorateAsm, bool, dev_opt_flag, "asm-verbose",                            \
114    cl::desc("Decorate textual asm output with register liveness info"))       \
115                                                                               \
116  X(DefaultFunctionPrefix, std::string, dev_opt_flag,                          \
117    "default-function-prefix",                                                 \
118    cl::desc("Define default function prefix for naming unnamed functions"),   \
119    cl::init("Function"))                                                      \
120                                                                               \
121  X(DefaultGlobalPrefix, std::string, dev_opt_flag, "default-global-prefix",   \
122    cl::desc("Define default global prefix for naming unnamed globals"),       \
123    cl::init("Global"))                                                        \
124                                                                               \
125  X(DisableHybridAssembly, bool, dev_opt_flag, "no-hybrid-asm",                \
126    cl::desc("Disable hybrid assembly when -filetype=iasm"), cl::init(false))  \
127                                                                               \
128  X(DisableInternal, bool, dev_opt_flag, "externalize",                        \
129    cl::desc("Externalize all symbols"))                                       \
130                                                                               \
131  X(DisableTranslation, bool, dev_opt_flag, "notranslate",                     \
132    cl::desc("Disable Subzero translation"))                                   \
133                                                                               \
134  X(DumpStats, bool, dev_opt_flag, "szstats",                                  \
135    cl::desc("Print statistics after translating each function"))              \
136                                                                               \
137  X(DumpStrings, bool, dev_opt_flag,                                           \
138    "dump-strings",                                                            \
139    cl::desc("Dump string pools during compilation"),                          \
140    cl::init(false))                                                           \
141                                                                               \
142  X(EnableBlockProfile, bool, dev_opt_flag, "enable-block-profile",            \
143    cl::desc("Instrument basic blocks, and output profiling "                  \
144             "information to stdout at the end of program execution."),        \
145    cl::init(false))                                                           \
146                                                                               \
147  X(LocalCSE, Ice::LCSEOptions, dev_opt_flag, "lcse",                          \
148    cl::desc("Local common subexpression elimination"),                        \
149    cl::init(Ice::LCSE_EnabledSSA),                                            \
150    cl::values(                                                                \
151      clEnumValN(Ice::LCSE_Disabled, "0", "disabled"),                         \
152      clEnumValN(Ice::LCSE_EnabledSSA, "enabled", "assume-ssa"),               \
153      clEnumValN(Ice::LCSE_EnabledNoSSA, "no-ssa", "no-assume-ssa")            \
154      CLENUMVALEND))                                                           \
155                                                                               \
156  X(EmitRevision, bool, dev_opt_flag, "emit-revision",                         \
157    cl::desc("Emit Subzero revision string into the output"), cl::init(true))  \
158                                                                               \
159  X(EnablePhiEdgeSplit, bool, dev_opt_flag, "phi-edge-split",                  \
160    cl::desc("Enable edge splitting for Phi lowering"), cl::init(true))        \
161                                                                               \
162  X(EnableShortCircuit, bool, dev_opt_flag, "enable-sc",                       \
163    cl::desc("Split Nodes for short circuit evaluation"), cl::init(false))     \
164                                                                               \
165  X(ExcludedRegisters, std::string, dev_list_flag, "reg-exclude",              \
166    cl::CommaSeparated, cl::desc("Don't use specified registers"))             \
167                                                                               \
168  X(ForceMemIntrinOpt, bool, dev_opt_flag, "fmem-intrin-opt",                  \
169    cl::desc("Force optimization of memory intrinsics."))                      \
170                                                                               \
171  X(ForceO2String, std::string, dev_opt_flag, "force-O2",                      \
172    cl::desc("Force -O2 for certain functions (assumes -Om1)"), cl::init(""))  \
173                                                                               \
174  X(SplitInstString, std::string, dev_opt_flag, "split-inst",                  \
175    cl::desc("Restrict local var splitting to specific insts"), cl::init(":")) \
176                                                                               \
177  X(FunctionSections, bool, dev_opt_flag, "ffunction-sections",                \
178    cl::desc("Emit functions into separate sections"))                         \
179                                                                               \
180  X(GenerateBuildAtts, bool, release_opt_flag, "build-atts",                   \
181    cl::desc("Generate list of build attributes associated with "              \
182             "this executable."),                                              \
183    cl::init(false))                                                           \
184                                                                               \
185  X(SplitGlobalVars, bool, dev_opt_flag, "split-global-vars",                  \
186    cl::desc("Global live range splitting"),                                   \
187    cl::init(false))                                                           \
188                                                                               \
189  X(InputFileFormat, llvm::NaClFileFormat, dev_opt_flag, "bitcode-format",     \
190    cl::desc("Define format of input file:"),                                  \
191    cl::values(clEnumValN(llvm::LLVMFormat, "llvm", "LLVM file (default)"),    \
192               clEnumValN(llvm::PNaClFormat, "pnacl", "PNaCl bitcode file")    \
193               CLENUMVALEND),                                                  \
194    cl::init(llvm::LLVMFormat))                                                \
195                                                                               \
196  X(KeepDeletedInsts, bool, dev_opt_flag, "keep-deleted-insts",                \
197    cl::desc("Retain deleted instructions in the Cfg"),                        \
198    cl::init(Ice::BuildDefs::dump()))                                          \
199                                                                               \
200  X(LLVMVerboseErrors, bool, dev_opt_flag, "verbose-llvm-parse-errors",        \
201    cl::desc("Print out more descriptive PNaCl bitcode parse errors when "     \
202             "building LLVM IR first"),                                        \
203    cl::init(false))                                                           \
204                                                                               \
205   X(LocalCseMaxIterations, uint32_t, dev_opt_flag, "lcse-max-iters",          \
206    cl::desc("Number of times local-cse is run on a block"), cl::init(1))      \
207                                                                               \
208  X(LoopInvariantCodeMotion, bool, dev_opt_flag, "licm",                       \
209    cl::desc("Hoist loop invariant arithmetic operations"), cl::init(false))   \
210                                                                               \
211  X(LogFilename, std::string, dev_opt_flag, "log",                             \
212    cl::desc("Set log filename"), cl::init("-"), cl::value_desc("filename"))   \
213                                                                               \
214  X(MaxNopsPerInstruction, int, dev_opt_flag, "max-nops-per-instruction",      \
215    cl::desc("Max number of nops to insert per instruction"), cl::init(1))     \
216                                                                               \
217  X(MockBoundsCheck, bool, dev_opt_flag, "mock-bounds-check",                  \
218    cl::desc("Mock bounds checking on loads/stores"))                          \
219                                                                               \
220  X(NopProbabilityAsPercentage, int, dev_opt_flag, "nop-insertion-percentage", \
221    cl::desc("Nop insertion probability as percentage"), cl::init(10))         \
222                                                                               \
223  X(OutFileType, Ice::FileType, dev_opt_flag, "filetype",                      \
224    cl::desc("Output file type"), cl::init(Ice::FT_Iasm),                      \
225    cl::values(                                                                \
226        clEnumValN(Ice::FT_Elf, "obj", "Native ELF object ('.o') file"),       \
227        clEnumValN(Ice::FT_Asm, "asm", "Assembly ('.s') file"),                \
228        clEnumValN(Ice::FT_Iasm, "iasm",                                       \
229                   "Low-level integrated assembly ('.s') file")                \
230        CLENUMVALEND))                                                         \
231                                                                               \
232  X(ApplicationBinaryInterface, Ice::ABI, dev_opt_flag, "abi",                 \
233    cl::desc("ABI type"), cl::init(Ice::ABI_PNaCl),                            \
234    cl::values(                                                                \
235        clEnumValN(Ice::ABI_PNaCl, "pnacl", "x32 for unsandboxed 64-bit x86"), \
236        clEnumValN(Ice::ABI_Platform, "platform", "Native executable ABI")     \
237        CLENUMVALEND))                                                         \
238                                                                               \
239  X(ParseParallel, bool, dev_opt_flag, "parse-parallel",                       \
240    cl::desc("Parse function blocks in parallel"), cl::init(true))             \
241                                                                               \
242  X(SplitLocalVars, bool, dev_opt_flag, "split-local-vars", cl::init(true),    \
243    cl::desc("Block-local variable splitting (O2 only)"))                      \
244                                                                               \
245  X(RegAllocReserve, bool, dev_opt_flag, "reg-reserve",                        \
246    cl::desc("Let register allocation use reserve registers"),                 \
247    cl::init(false))                                                           \
248                                                                               \
249  X(RepeatRegAlloc, bool, dev_opt_flag, "regalloc-repeat",                     \
250    cl::desc("Repeat register allocation until convergence"), cl::init(true))  \
251                                                                               \
252  /* TODO(tlively): Generalize this to handle more sanitizers */               \
253  X(SanitizeAddresses, bool, dev_opt_flag, "fsanitize-address",                \
254    cl::desc("Instrument compiled code with Address Sanitizer"),               \
255    cl::init(false))                                                           \
256                                                                               \
257  X(SkipUnimplemented, bool, dev_opt_flag, "skip-unimplemented",               \
258    cl::desc("Skip through unimplemented lowering code instead of aborting."), \
259    cl::init(false))                                                           \
260                                                                               \
261  X(SubzeroTimingEnabled, bool, dev_opt_flag, "timing",                        \
262    cl::desc("Enable breakdown timing of Subzero translation"))                \
263                                                                               \
264  X(TargetInstructionSet, Ice::TargetInstructionSet, dev_opt_flag, "mattr",    \
265    cl::desc("Target architecture attributes"),                                \
266    cl::init(Ice::BaseInstructionSet),                                         \
267    cl::values(                                                                \
268        clEnumValN(Ice::BaseInstructionSet, "base",                            \
269                   "Target chooses baseline instruction set (default)"),       \
270        clEnumValN(Ice::X86InstructionSet_SSE2, "sse2",                        \
271                   "Enable X86 SSE2 instructions"),                            \
272        clEnumValN(Ice::X86InstructionSet_SSE4_1, "sse4.1",                    \
273                   "Enable X86 SSE 4.1 instructions"),                         \
274        clEnumValN(Ice::ARM32InstructionSet_Neon, "neon",                      \
275                   "Enable ARM Neon instructions"),                            \
276        clEnumValN(Ice::ARM32InstructionSet_HWDivArm, "hwdiv-arm",             \
277                   "Enable ARM integer divide instructions in ARM mode")       \
278        CLENUMVALEND))                                                         \
279                                                                               \
280  X(TestPrefix, std::string, dev_opt_flag, "prefix",                           \
281    cl::desc("Prepend a prefix to symbol names for testing"), cl::init(""),    \
282    cl::value_desc("prefix"))                                                  \
283                                                                               \
284  X(TestStackExtra, uint32_t, dev_opt_flag, "test-stack-extra",                \
285    cl::desc("Extra amount of stack to add to the "                            \
286             "frame in bytes (for testing)."),                                 \
287    cl::init(0))                                                               \
288                                                                               \
289  X(TestStatusString, std::string, dev_opt_flag, "test-status",                \
290    cl::desc("Testing flag for -verbose=status"), cl::init(":"))               \
291                                                                               \
292  X(TimeEachFunction, bool, dev_opt_flag, "timing-funcs",                      \
293    cl::desc("Print total translation time for each function"))                \
294                                                                               \
295  X(TimingFocusOnString, std::string, dev_opt_flag, "timing-focus",            \
296    cl::desc("Break down timing for specific functions (use ':' for all)"),    \
297    cl::init(""))                                                              \
298                                                                               \
299  X(TranslateOnlyString, std::string, dev_opt_flag, "translate-only",          \
300    cl::desc("Translate only the given functions"), cl::init(":"))             \
301                                                                               \
302  X(UseNonsfi, bool, dev_opt_flag, "nonsfi", cl::desc("Enable Non-SFI mode"))  \
303                                                                               \
304  X(UseRestrictedRegisters, std::string, dev_list_flag, "reg-use",             \
305    cl::CommaSeparated,                                                        \
306    cl::desc("Only use specified registers for corresponding register "        \
307             "classes"))                                                       \
308                                                                               \
309  X(UseSandboxing, bool, dev_opt_flag, "sandbox", cl::desc("Use sandboxing"))  \
310                                                                               \
311  X(Verbose, Ice::VerboseItem, dev_list_flag, "verbose", cl::CommaSeparated,   \
312    cl::desc("Verbose options (can be comma-separated):"),                     \
313    cl::values(                                                                \
314        clEnumValN(Ice::IceV_Instructions, "inst",                             \
315                   "Print basic instructions"),                                \
316        clEnumValN(Ice::IceV_Deleted, "del", "Include deleted instructions"),  \
317        clEnumValN(Ice::IceV_InstNumbers, "instnum",                           \
318                   "Print instruction numbers"),                               \
319        clEnumValN(Ice::IceV_Preds, "pred", "Show predecessors"),              \
320        clEnumValN(Ice::IceV_Succs, "succ", "Show successors"),                \
321        clEnumValN(Ice::IceV_Liveness, "live", "Liveness information"),        \
322        clEnumValN(Ice::IceV_RegOrigins, "orig", "Physical register origins"), \
323        clEnumValN(Ice::IceV_LinearScan, "regalloc", "Linear scan details"),   \
324        clEnumValN(Ice::IceV_Frame, "frame", "Stack frame layout details"),    \
325        clEnumValN(Ice::IceV_AddrOpt, "addropt", "Address mode optimization"), \
326        clEnumValN(Ice::IceV_Folding, "fold", "Instruction folding details"),  \
327        clEnumValN(Ice::IceV_RMW, "rmw", "ReadModifyWrite optimization"),      \
328        clEnumValN(Ice::IceV_Loop, "loop", "Loop nest depth analysis"),        \
329        clEnumValN(Ice::IceV_Mem, "mem", "Memory usage details"),              \
330        clEnumValN(Ice::IceV_ShufMat, "shufvec",                               \
331                   "Shufflevector rematerialization"),                         \
332        clEnumValN(Ice::IceV_Status, "status",                                 \
333                   "Print the name of the function being translated"),         \
334        clEnumValN(Ice::IceV_AvailableRegs, "registers",                       \
335                   "Show available registers for register allocation"),        \
336        clEnumValN(Ice::IceV_GlobalInit, "global_init",                        \
337                   "Global initializers"),                                     \
338        clEnumValN(Ice::IceV_ConstPoolStats, "cpool",                          \
339                   "Constant pool counters"),                                  \
340        clEnumValN(Ice::IceV_Wasm, "wasm", "WebAssembly builder"),             \
341        clEnumValN(Ice::IceV_All, "all", "Use all verbose options"),           \
342        clEnumValN(Ice::IceV_Most, "most",                                     \
343                   "Use all verbose options except 'regalloc,global_init'"),   \
344        clEnumValN(Ice::IceV_None, "none", "No verbosity") CLENUMVALEND))      \
345                                                                               \
346  X(VerboseFocusOnString, std::string, dev_opt_flag, "verbose-focus",          \
347    cl::desc("Override with -verbose=none except for specified functions"),    \
348    cl::init(":"))                                                             \
349                                                                               \
350  X(WasmBoundsCheck, bool, dev_opt_flag, "wasm-bounds-check",                  \
351    cl::desc("Add bounds checking code in WASM frontend"),                     \
352    cl::init(true))
353
354//#define X(Name, Type, ClType, ...)
355
356} // end of namespace Ice
357
358#endif // SUBZERO_SRC_ICECLFLAGS_DEF
359