OpenASIP  2.0
LLVMTCECmdLineOptions.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2020 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file LLVMTCECmdLineOptions.hh
26  *
27  * Implementation of LLVMTCECmdLineOptions class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2008 (vjaaskel-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2008-2020
31  * @note rating: red
32  */
33 
34 #include "LLVMTCECmdLineOptions.hh"
35 #include "Environment.hh"
36 
37 const std::string LLVMTCECmdLineOptions::SWL_EMULATION_LIB = "emulation";
38 const std::string LLVMTCECmdLineOptions::SWS_EMULATION_LIB = "e";
39 const std::string LLVMTCECmdLineOptions::SWL_DEBUG_FLAG = "debug";
40 const std::string LLVMTCECmdLineOptions::SWL_OPT_LEVEL = "optimize";
41 const std::string LLVMTCECmdLineOptions::SWS_OPT_LEVEL = "O";
43  "primary-functions";
44 const std::string LLVMTCECmdLineOptions::SWS_PRIMARY_FUNCTIONS = "p";
45 const std::string LLVMTCECmdLineOptions::VERBOSE_SWITCH = "verbose";
46 const std::string LLVMTCECmdLineOptions::DISABLE_LLVMAA = "disable-llvmaa";
47 const std::string LLVMTCECmdLineOptions::DISABLE_ADDRESS_SPACE_AA = "disable-as-aa";
48 const std::string LLVMTCECmdLineOptions::DISABLE_DSF = "disable-dsf";
50  "conservative-pre-ra-scheduler";
51 const std::string LLVMTCECmdLineOptions::LLVM_USER_ARGS = "llvm-args";
52 
53 const std::string LLVMTCECmdLineOptions::SWL_DUMP_DDGS_DOT = "dump-ddgs-dot";
54 const std::string LLVMTCECmdLineOptions::SWL_DUMP_DDGS_XML = "dump-ddgs-xml";
56  "save-backend-plugin";
58  "bottom-up-scheduler";
60  "bubblefish2-scheduler";
61 const std::string LLVMTCECmdLineOptions::SWL_TD_SCHEDULER = "td-scheduler";
63  "use-old-backend-src";
65  "analyze-instruction-patterns";
66 const std::string LLVMTCECmdLineOptions::SWL_TEMP_DIR = "temp-dir";
68  "vector-backend";
70  "wi-aa-filename";
72  "backend-cache-dir";
73 
75  "print-inline-asm-warnings";
76 
77 const std::string LLVMTCECmdLineOptions::SWL_INIT_SP = "init-sp";
78 
79 const std::string LLVMTCECmdLineOptions::SWL_DATA_START = "data-start";
80 
81 const std::string LLVMTCECmdLineOptions::USAGE =
82  "Usage: llvm-tce [OPTION]... BYTECODE\n"
83  "Compile LLVM bytecode for target TCE architecture.\n";
84 
86  "gen-plugin-only";
87 
89  "disable-hwloops";
90 
92  "assume-adf-stackalignment";
93 /**
94  * Constructor.
95  */
97 
98  addOption(
100  SWL_EMULATION_LIB, "Emulation library bitcode file.",
102 
103  addOption(
105  SWL_OPT_LEVEL, "Optimization level (0-2)",
106  SWS_OPT_LEVEL));
107 
108  addOption(
110  SWL_DEBUG_FLAG, "Print LLVM debug data."));
111 
112  addOption(
115  "List of function names that should be scheduled with "
116  "the primary scheduler config (-c). Other functions are scheduled "
117  "with the secondary config (-s).",
119 
120  addOption(
122  VERBOSE_SWITCH, "The verbose switch", "v"));
123 
124  addOption(
126  DISABLE_LLVMAA, "Disable use of LLVM Alias Analysis", DISABLE_LLVMAA));
127 
128  addOption(
131  "Disable use of Address Space Alias Analysis",
133 
134  addOption(
136  DISABLE_DSF, "Disable post-pass delay slot filler optimizer.",
137  DISABLE_DSF));
138 
139  addOption(
142  "Conservative pre-ra-scheduler. May decrease register usage but "
143  "limit ILP. good for machines with low amount of registers."));
144 
146  LLVM_USER_ARGS, "Parameters to pass to LLVM"));
147 
148  addOption(
151  "Dump DDGs in dot format before and after scheduling."));
152 
153  addOption(
156  "Dump DDGs in XML format before and after scheduling."));
157 
158  addOption(
161  "Save the generated backend plugin for the architecture. "
162  "This avoid the regeneration of the backend plugin when calling "
163  "tcecc for the same architecture."));
164  addOption(
167  "Use an experiment Bottom Up scheduler."));
168 
169  addOption(
172  "Use an experimental Bubblefish instructionscheduler v2."));
173 
174  addOption(
177  "Use the old top-down instruction scheduler(previous default)."));
178 
179  addOption(
182  "Use the existing backend sources from the given temporary directory."));
183 
184  addOption(
186  SWL_TEMP_DIR,
187  "The temporary directory to use for files needed during the code generation."));
188 
189  addOption(
192  "The filename with Work Item Alias Analysis - this is filled automatically "
193  "if tcecc finds path to installed pocl."));
194 
195  addOption(
198  "Enable backend support for vector registers split between multiple RF's"));
199 
200  addOption(
203  "Analyze the instruction patterns after instruction selection."));
204 
205  addOption(
208  "The directory to use for caching LLVM backend plugins."));
209 
210  addOption(
212  SWL_INIT_SP,
213  "Initialize the stack pointer of the program to the given value."));
214  addOption(
217  "Override the global data start address."));
218 
219  addOption(
222  "Prints warnings from inline assembly parsing. Default is off."));
223  addOption(
226  "Generates LLVM backend plugin for target machine without tpef "
227  "generation."));
228 
231  "Do not use hardware loops even though the processor supports them."));
232 
233  addOption(
236  "Assume size of stackalignment based on biggest memory operations in the adf."));
237 }
238 
239 /**
240  * Destructor.
241  */
243 }
244 
245 
246 /**
247  * Returns the list of "primary functions" that should be scheduled
248  * with the primary scheduling conf.
249  *
250  * Rest of the functions are scheduled with the scheduling config
251  * given with -s.
252  */
255  FunctionNameList* funcs = new FunctionNameList();
257  if (opt == NULL)
258  return funcs;
259  for (int i = 1; i <= opt->listSize(); ++i) {
260  funcs->insert(opt->String(i));
261  }
262  return funcs;
263 }
264 
265 std::string
268 }
269 
270 bool
273 }
274 
275 /**
276  * Returns true if optimization level switch was given.
277  *
278  * @return True, if optimization level was given on command line.
279  */
280 bool
283 }
284 
285 
286 /**
287  * Returns optimization level defined with the -O switch.
288  *
289  * @return Optimization level.
290  */
291 int
293  return findOption(SWS_OPT_LEVEL)->integer();
294 }
295 
296 
297 /**
298  * Returns true if the debug flag option was given.
299  *
300  * @return True, if debug mode switch was given.
301  */
302 bool
304 
305  if (findOption(SWL_DEBUG_FLAG)->isDefined() &&
306  findOption(SWL_DEBUG_FLAG)->isFlagOn()) {
307 
308  return true;
309  }
310  return false;
311 }
312 
313 bool
316 }
317 
318 bool
321 }
322 
323 bool
325  return findOption(DISABLE_DSF)->isDefined();
326 }
327 
328 /**
329  * Return true if the verbose switch was defined in the command line.
330  *
331  * @return True if the verbose switch was defined in the command line.
332  */
333 bool
336 }
337 
338 bool
340  if (findOption(CONSERVATIVE_PRE_RA_SCHEDULER)->isDefined() &&
342  return true;
343  }
344  return false;
345 }
346 
347 std::string
349  if (!findOption(LLVM_USER_ARGS)->isDefined()) {
350  return "llvm-tce --no-stack-coloring";
351  } else {
352  std::string argv = "llvm-tce --no-stack-coloring " +
354  return argv;
355  }
356 }
357 
358 bool
361 }
362 
363 bool
366 }
367 
368 bool
372 }
373 bool
376 }
377 
378 bool
381 }
382 
383 bool
386 }
387 
388 bool
391 }
392 
393 TCEString
395  return findOption(SWL_TEMP_DIR)->String();
396 }
397 
398 bool
401 }
402 
403 bool
406 }
407 
408 std::string
411 }
412 
413 bool
416 }
417 
418 std::string
420  if (findOption(SWL_BACKEND_CACHE_DIR)->isDefined())
423 }
424 
425 bool
427  return findOption(SWL_INIT_SP)->isDefined();
428 }
429 
430 uint64_t
433 }
434 
435 bool
438 }
439 
440 uint64_t
443 }
444 
445 bool
447  return (findOption(SWL_PRINT_INLINE_ASM_WARNINGS)->isDefined() &&
449 }
450 
451 bool
453  return (findOption(SWL_GEN_PLUGIN_ONLY)->isDefined() &&
454  findOption(SWL_GEN_PLUGIN_ONLY)->isFlagOn());
455 }
456 
457 bool
460 }
461 
462 bool
465 }
SimpleInterPassDatum
Definition: InterPassDatum.hh:64
LLVMTCECmdLineOptions::debugFlag
bool debugFlag() const
Definition: LLVMTCECmdLineOptions.cc:303
LLVMTCECmdLineOptions::SWL_DEBUG_FLAG
static const std::string SWL_DEBUG_FLAG
Definition: LLVMTCECmdLineOptions.hh:118
LLVMTCECmdLineOptions::SWL_TEMP_DIR
static const std::string SWL_TEMP_DIR
Definition: LLVMTCECmdLineOptions.hh:138
CmdLineOptionParser::unsignedInteger
virtual unsigned unsignedInteger(int index=0) const
Definition: CmdLineOptionParser.cc:90
LLVMTCECmdLineOptions::SWL_ENABLE_VECTOR_BACKEND
static const std::string SWL_ENABLE_VECTOR_BACKEND
Definition: LLVMTCECmdLineOptions.hh:139
LLVMTCECmdLineOptions::LLVM_USER_ARGS
static const std::string LLVM_USER_ARGS
Definition: LLVMTCECmdLineOptions.hh:128
LLVMTCECmdLineOptions::SWL_BU_SCHEDULER
static const std::string SWL_BU_SCHEDULER
Definition: LLVMTCECmdLineOptions.hh:134
CmdLineOptionParser::isDefined
bool isDefined()
Definition: CmdLineOptionParser.cc:169
LLVMTCECmdLineOptions::disableDelaySlotFiller
bool disableDelaySlotFiller() const
Definition: LLVMTCECmdLineOptions.cc:324
LLVMTCECmdLineOptions::saveBackendPlugin
bool saveBackendPlugin() const
Definition: LLVMTCECmdLineOptions.cc:369
LLVMTCECmdLineOptions::SWL_OPT_LEVEL
static const std::string SWL_OPT_LEVEL
Definition: LLVMTCECmdLineOptions.hh:119
LLVMTCECmdLineOptions::SWL_DATA_START
static const std::string SWL_DATA_START
Definition: LLVMTCECmdLineOptions.hh:144
LLVMTCECmdLineOptions::analyzeInstructionPatterns
bool analyzeInstructionPatterns() const
Definition: LLVMTCECmdLineOptions.cc:414
LLVMTCECmdLineOptions::DISABLE_DSF
static const std::string DISABLE_DSF
Definition: LLVMTCECmdLineOptions.hh:129
LLVMTCECmdLineOptions::tempDir
TCEString tempDir() const
Definition: LLVMTCECmdLineOptions.cc:394
LLVMTCECmdLineOptions::SWL_ASSUME_ADF_STACKALIGNMENT
static const std::string SWL_ASSUME_ADF_STACKALIGNMENT
Definition: LLVMTCECmdLineOptions.hh:149
LLVMTCECmdLineOptions::SWL_DUMP_DDGS_XML
static const std::string SWL_DUMP_DDGS_XML
Definition: LLVMTCECmdLineOptions.hh:132
LLVMTCECmdLineOptions::workItemAAFile
std::string workItemAAFile() const
Definition: LLVMTCECmdLineOptions.cc:409
LLVMTCECmdLineOptions::~LLVMTCECmdLineOptions
~LLVMTCECmdLineOptions()
Definition: LLVMTCECmdLineOptions.cc:242
LLVMTCECmdLineOptions::conservativePreRAScheduler
bool conservativePreRAScheduler() const
Definition: LLVMTCECmdLineOptions.cc:339
LLVMTCECmdLineOptions::optLevel
int optLevel() const
Definition: LLVMTCECmdLineOptions.cc:292
LLVMTCECmdLineOptions::disableLLVMAA
virtual bool disableLLVMAA() const
Definition: LLVMTCECmdLineOptions.cc:314
LLVMTCECmdLineOptions::isStandardEmulationLibDefined
bool isStandardEmulationLibDefined() const
Definition: LLVMTCECmdLineOptions.cc:271
LLVMTCECmdLineOptions::dumpDDGsDot
virtual bool dumpDDGsDot() const
Definition: LLVMTCECmdLineOptions.cc:359
LLVMTCECmdLineOptions::standardEmulationLib
std::string standardEmulationLib() const
Definition: LLVMTCECmdLineOptions.cc:266
CmdLineOptionParser::isFlagOn
virtual bool isFlagOn() const
Definition: CmdLineOptionParser.cc:126
LLVMTCECmdLineOptions::SWS_EMULATION_LIB
static const std::string SWS_EMULATION_LIB
Definition: LLVMTCECmdLineOptions.hh:117
LLVMTCECmdLineOptions::useBUScheduler
bool useBUScheduler() const
Definition: LLVMTCECmdLineOptions.cc:374
LLVMTCECmdLineOptions::DISABLE_ADDRESS_SPACE_AA
static const std::string DISABLE_ADDRESS_SPACE_AA
Definition: LLVMTCECmdLineOptions.hh:130
LLVMTCECmdLineOptions::dataStartAddress
uint64_t dataStartAddress() const
Definition: LLVMTCECmdLineOptions.cc:441
LLVMTCECmdLineOptions::LLVMTCECmdLineOptions
LLVMTCECmdLineOptions()
Definition: LLVMTCECmdLineOptions.cc:96
LLVMTCECmdLineOptions::SWS_PRIMARY_FUNCTIONS
static const std::string SWS_PRIMARY_FUNCTIONS
Definition: LLVMTCECmdLineOptions.hh:122
LLVMTCECmdLineOptions::useBubbleFish2Scheduler
bool useBubbleFish2Scheduler() const
Definition: LLVMTCECmdLineOptions.cc:379
LLVMTCECmdLineOptions::SWL_DISABLE_HWLOOPS
static const std::string SWL_DISABLE_HWLOOPS
Definition: LLVMTCECmdLineOptions.hh:148
CmdLineParser::addOption
void addOption(CmdLineOptionParser *opt)
LLVMTCECmdLineOptions::isVerboseSwitchDefined
bool isVerboseSwitchDefined() const
Definition: LLVMTCECmdLineOptions.cc:334
LLVMTCECmdLineOptions::isDataStartAddressSet
bool isDataStartAddressSet() const
Definition: LLVMTCECmdLineOptions.cc:436
CmdLineOptionParser::listSize
virtual int listSize() const
Definition: CmdLineOptionParser.cc:150
CmdLineOptionParser
Definition: CmdLineOptionParser.hh:56
LLVMTCECmdLineOptions.hh
LLVMTCECmdLineOptions::generatePluginOnly
bool generatePluginOnly() const
Definition: LLVMTCECmdLineOptions.cc:452
LLVMTCECmdLineOptions::disableAddressSpaceAA
bool disableAddressSpaceAA() const
Definition: LLVMTCECmdLineOptions.cc:319
LLVMTCECmdLineOptions::SWL_GEN_PLUGIN_ONLY
static const std::string SWL_GEN_PLUGIN_ONLY
Definition: LLVMTCECmdLineOptions.hh:147
LLVMTCECmdLineOptions::SWL_WORK_ITEM_AA_FILE
static const std::string SWL_WORK_ITEM_AA_FILE
Definition: LLVMTCECmdLineOptions.hh:140
LLVMTCECmdLineOptions::SWL_ANALYZE_INSTRUCTION_PATTERNS
static const std::string SWL_ANALYZE_INSTRUCTION_PATTERNS
Definition: LLVMTCECmdLineOptions.hh:141
LLVMTCECmdLineOptions::SWL_SAVE_BACKEND_PLUGIN
static const std::string SWL_SAVE_BACKEND_PLUGIN
Definition: LLVMTCECmdLineOptions.hh:133
BoolCmdLineOptionParser
Definition: CmdLineOptionParser.hh:278
LLVMTCECmdLineOptions::SWL_INIT_SP
static const std::string SWL_INIT_SP
Definition: LLVMTCECmdLineOptions.hh:143
LLVMTCECmdLineOptions::SWL_EMULATION_LIB
static const std::string SWL_EMULATION_LIB
Definition: LLVMTCECmdLineOptions.hh:116
LLVMTCECmdLineOptions::useVectorBackend
bool useVectorBackend() const
Definition: LLVMTCECmdLineOptions.cc:399
Environment.hh
FunctionNameList
SimpleInterPassDatum< std::set< std::string > > FunctionNameList
This datum is set in case the pass should only process (or ignore) certain functions....
Definition: InterPassDatum.hh:91
LLVMTCECmdLineOptions::SWL_PRINT_INLINE_ASM_WARNINGS
static const std::string SWL_PRINT_INLINE_ASM_WARNINGS
Definition: LLVMTCECmdLineOptions.hh:146
LLVMTCECmdLineOptions::getLLVMargv
virtual std::string getLLVMargv() const
Definition: LLVMTCECmdLineOptions.cc:348
LLVMTCECmdLineOptions::SWL_USE_OLD_BACKEND_SOURCES
static const std::string SWL_USE_OLD_BACKEND_SOURCES
Definition: LLVMTCECmdLineOptions.hh:137
LLVMTCECmdLineOptions::primaryFunctions
virtual FunctionNameList * primaryFunctions() const
Definition: LLVMTCECmdLineOptions.cc:254
LLVMTCECmdLineOptions::backendCacheDir
std::string backendCacheDir() const
Definition: LLVMTCECmdLineOptions.cc:419
LLVMTCECmdLineOptions::useOldBackendSources
bool useOldBackendSources() const
Definition: LLVMTCECmdLineOptions.cc:389
LLVMTCECmdLineOptions::DISABLE_LLVMAA
static const std::string DISABLE_LLVMAA
Definition: LLVMTCECmdLineOptions.hh:126
LLVMTCECmdLineOptions::assumeADFStackAlignment
bool assumeADFStackAlignment() const
Definition: LLVMTCECmdLineOptions.cc:463
LLVMTCECmdLineOptions::dumpDDGsXML
virtual bool dumpDDGsXML() const
Definition: LLVMTCECmdLineOptions.cc:364
LLVMTCECmdLineOptions::SWL_TD_SCHEDULER
static const std::string SWL_TD_SCHEDULER
Definition: LLVMTCECmdLineOptions.hh:136
LLVMTCECmdLineOptions::isInitialStackPointerValueSet
bool isInitialStackPointerValueSet() const
Definition: LLVMTCECmdLineOptions.cc:426
LLVMTCECmdLineOptions::SWL_BUBBLEFISH2_SCHEDULER
static const std::string SWL_BUBBLEFISH2_SCHEDULER
Definition: LLVMTCECmdLineOptions.hh:135
CmdLineOptionParser::String
virtual std::string String(int index=0) const
Definition: CmdLineOptionParser.cc:102
LLVMTCECmdLineOptions::CONSERVATIVE_PRE_RA_SCHEDULER
static const std::string CONSERVATIVE_PRE_RA_SCHEDULER
Definition: LLVMTCECmdLineOptions.hh:127
LLVMTCECmdLineOptions::USAGE
static const std::string USAGE
Definition: LLVMTCECmdLineOptions.hh:145
StringListCmdLineOptionParser
Definition: CmdLineOptionParser.hh:344
Environment::llvmtceCachePath
static std::string llvmtceCachePath()
Definition: Environment.cc:1087
LLVMTCECmdLineOptions::useTDScheduler
bool useTDScheduler() const
Definition: LLVMTCECmdLineOptions.cc:384
LLVMTCECmdLineOptions::disableHWLoops
bool disableHWLoops() const
Definition: LLVMTCECmdLineOptions.cc:458
TCEString
Definition: TCEString.hh:53
LLVMTCECmdLineOptions::printInlineAsmWarnings
bool printInlineAsmWarnings() const
Definition: LLVMTCECmdLineOptions.cc:446
LLVMTCECmdLineOptions::SWL_PRIMARY_FUNCTIONS
static const std::string SWL_PRIMARY_FUNCTIONS
Definition: LLVMTCECmdLineOptions.hh:121
LLVMTCECmdLineOptions::isWorkItemAAFileDefined
bool isWorkItemAAFileDefined() const
Definition: LLVMTCECmdLineOptions.cc:404
LLVMTCECmdLineOptions::VERBOSE_SWITCH
static const std::string VERBOSE_SWITCH
Switch for verbose output listing scheduler modules.
Definition: LLVMTCECmdLineOptions.hh:125
CmdLineOptionParser::integer
virtual int integer(int index=0) const
Definition: CmdLineOptionParser.cc:84
CmdLineParser::findOption
CmdLineOptionParser * findOption(std::string name) const
Definition: CmdLineParser.cc:160
UnsignedIntegerCmdLineOptionParser
Definition: CmdLineOptionParser.hh:147
LLVMTCECmdLineOptions::SWS_OPT_LEVEL
static const std::string SWS_OPT_LEVEL
Definition: LLVMTCECmdLineOptions.hh:120
StringCmdLineOptionParser
Definition: CmdLineOptionParser.hh:180
LLVMTCECmdLineOptions::isOptLevelDefined
bool isOptLevelDefined() const
Definition: LLVMTCECmdLineOptions.cc:281
LLVMTCECmdLineOptions::initialStackPointerValue
uint64_t initialStackPointerValue() const
Definition: LLVMTCECmdLineOptions.cc:431
LLVMTCECmdLineOptions::SWL_DUMP_DDGS_DOT
static const std::string SWL_DUMP_DDGS_DOT
Definition: LLVMTCECmdLineOptions.hh:131
IntegerCmdLineOptionParser
Definition: CmdLineOptionParser.hh:117
LLVMTCECmdLineOptions::SWL_BACKEND_CACHE_DIR
static const std::string SWL_BACKEND_CACHE_DIR
Definition: LLVMTCECmdLineOptions.hh:142