OpenASIP 2.2
Loading...
Searching...
No Matches
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
35
36#include "AddressSpace.hh"
37#include "Environment.hh"
38
39const std::string LLVMTCECmdLineOptions::SWL_EMULATION_LIB = "emulation";
40const std::string LLVMTCECmdLineOptions::SWS_EMULATION_LIB = "e";
41const std::string LLVMTCECmdLineOptions::SWL_DEBUG_FLAG = "debug";
42const std::string LLVMTCECmdLineOptions::SWL_OPT_LEVEL = "optimize";
43const std::string LLVMTCECmdLineOptions::SWS_OPT_LEVEL = "O";
45 "primary-functions";
47const std::string LLVMTCECmdLineOptions::VERBOSE_SWITCH = "verbose";
48const std::string LLVMTCECmdLineOptions::DISABLE_LLVMAA = "disable-llvmaa";
49const std::string LLVMTCECmdLineOptions::DISABLE_ADDRESS_SPACE_AA = "disable-as-aa";
50const std::string LLVMTCECmdLineOptions::DISABLE_DSF = "disable-dsf";
52 "conservative-pre-ra-scheduler";
53const std::string LLVMTCECmdLineOptions::LLVM_USER_ARGS = "llvm-args";
54
55const std::string LLVMTCECmdLineOptions::SWL_DUMP_DDGS_DOT = "dump-ddgs-dot";
56const std::string LLVMTCECmdLineOptions::SWL_DUMP_DDGS_XML = "dump-ddgs-xml";
58 "save-backend-plugin";
60 "bottom-up-scheduler";
62 "bubblefish2-scheduler";
63const std::string LLVMTCECmdLineOptions::SWL_TD_SCHEDULER = "td-scheduler";
65 "use-old-backend-src";
67 "analyze-instruction-patterns";
68const std::string LLVMTCECmdLineOptions::SWL_TEMP_DIR = "temp-dir";
70 "vector-backend";
72 "wi-aa-filename";
74 "backend-cache-dir";
75
77 "print-inline-asm-warnings";
78
79const std::string LLVMTCECmdLineOptions::SWL_INIT_SP = "init-sp";
80
81const std::string LLVMTCECmdLineOptions::SWL_DATA_START = "data-start";
82
83const std::string LLVMTCECmdLineOptions::USAGE =
84 "Usage: llvm-tce [OPTION]... BYTECODE\n"
85 "Compile LLVM bytecode for target TCE architecture.\n";
86
88 "gen-plugin-only";
89
91 "disable-hwloops";
92
94 "assume-adf-stackalignment";
95/**
96 * Constructor.
97 */
99
100 addOption(
102 SWL_EMULATION_LIB, "Emulation library bitcode file.",
104
105 addOption(
107 SWL_OPT_LEVEL, "Optimization level (0-2)",
109
110 addOption(
112 SWL_DEBUG_FLAG, "Print LLVM debug data."));
113
114 addOption(
117 "List of function names that should be scheduled with "
118 "the primary scheduler config (-c). Other functions are scheduled "
119 "with the secondary config (-s).",
121
122 addOption(
124 VERBOSE_SWITCH, "The verbose switch", "v"));
125
126 addOption(
128 DISABLE_LLVMAA, "Disable use of LLVM Alias Analysis", DISABLE_LLVMAA));
129
130 addOption(
133 "Disable use of Address Space Alias Analysis",
135
136 addOption(
138 DISABLE_DSF, "Disable post-pass delay slot filler optimizer.",
139 DISABLE_DSF));
140
141 addOption(
144 "Conservative pre-ra-scheduler. May decrease register usage but "
145 "limit ILP. good for machines with low amount of registers."));
146
148 LLVM_USER_ARGS, "Parameters to pass to LLVM"));
149
150 addOption(
153 "Dump DDGs in dot format before and after scheduling."));
154
155 addOption(
158 "Dump DDGs in XML format before and after scheduling."));
159
160 addOption(
163 "Save the generated backend plugin for the architecture. "
164 "This avoid the regeneration of the backend plugin when calling "
165 "tcecc for the same architecture."));
166 addOption(
169 "Use an experiment Bottom Up scheduler."));
170
171 addOption(
174 "Use an experimental Bubblefish instructionscheduler v2."));
175
176 addOption(
179 "Use the old top-down instruction scheduler(previous default)."));
180
181 addOption(
184 "Use the existing backend sources from the given temporary directory."));
185
186 addOption(
189 "The temporary directory to use for files needed during the code generation."));
190
191 addOption(
194 "The filename with Work Item Alias Analysis - this is filled automatically "
195 "if tcecc finds path to installed pocl."));
196
197 addOption(
200 "Enable backend support for vector registers split between multiple RF's"));
201
202 addOption(
205 "Analyze the instruction patterns after instruction selection."));
206
207 addOption(
210 "The directory to use for caching LLVM backend plugins."));
211
212 addOption(
215 "Initialize the stack pointer of the program to the given value."));
217 SWL_DATA_START, "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 */
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
265std::string
269
270bool
274
275/**
276 * Returns true if optimization level switch was given.
277 *
278 * @return True, if optimization level was given on command line.
279 */
280bool
284
285
286/**
287 * Returns optimization level defined with the -O switch.
288 *
289 * @return Optimization level.
290 */
291int
295
296
297/**
298 * Returns true if the debug flag option was given.
299 *
300 * @return True, if debug mode switch was given.
301 */
302bool
304
305 if (findOption(SWL_DEBUG_FLAG)->isDefined() &&
306 findOption(SWL_DEBUG_FLAG)->isFlagOn()) {
307
308 return true;
309 }
310 return false;
311}
312
313bool
317
318bool
322
323bool
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 */
333bool
337
338bool
340 if (findOption(CONSERVATIVE_PRE_RA_SCHEDULER)->isDefined() &&
342 return true;
343 }
344 return false;
345}
346
347std::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
358bool
362
363bool
367
368bool
373bool
377
378bool
382
383bool
387
388bool
392
397
398bool
402
403bool
407
408std::string
412
413bool
417
418std::string
424
425bool
429
430uint64_t
434
435bool
437 TTAMachine::AddressSpace& aSpace) const {
439 if (opts->isDefined()) {
440 int size = opts->listSize();
441 if (size == 1) {
442 return true;
443 }
444 if (size % 2 != 0) {
446 "ERROR: Data-start option must be either just the start"
447 " of the default address space (unsigned integer),"
448 " or a list consisting of pairs:"
449 " <Address-Space Name>,<Address-Space Start>")
450 }
451 for (int i = 1; i <= size; i += 2) {
452 TCEString as_name = opts->String(i);
453 if (as_name == aSpace.name()) {
454 return true;
455 }
456 }
457 }
458 return false;
459}
460
461uint64_t
463 TTAMachine::AddressSpace& aSpace) const {
465 if (opts->isDefined()) {
466 int size = opts->listSize();
467 if (size == 1) {
468 uint64_t tmp = Conversion::toUnsignedLong(opts->String(1));
469 return tmp;
470 }
471 if (size % 2 != 0) {
473 "ERROR: Data-start option must be either just the start"
474 " of the default address space (unsigned integer),"
475 " or a list consisting of pairs:"
476 " <Address-Space Name>,<Address-Space Start>")
477 }
478 for (int i = 1; i <= size; i += 2) {
479 TCEString as_name = opts->String(i);
480 if (as_name == aSpace.name()) {
481 return Conversion::toUnsignedLong(opts->String(i + 1));
482 }
483 }
484 }
486 "ERROR: Failed parsing the data-start-option."
487 " Data-start option must be either just the start"
488 " of the default address space (unsigned integer),"
489 " or a list consisting of pairs:"
490 " <Address-Space Name>,<Address-Space Start>")
491}
492
493bool
498
499bool
504
505bool
509
510bool
#define abortWithError(message)
SimpleInterPassDatum< std::set< std::string > > FunctionNameList
This datum is set in case the pass should only process (or ignore) certain functions....
virtual int integer(int index=0) const
virtual int listSize() const
virtual bool isFlagOn() const
virtual std::string String(int index=0) const
virtual unsigned unsignedInteger(int index=0) const
CmdLineOptionParser * findOption(std::string name) const
void addOption(CmdLineOptionParser *opt)
static ULongWord toUnsignedLong(const T &source)
static std::string llvmtceCachePath()
static const std::string DISABLE_ADDRESS_SPACE_AA
static const std::string SWL_INIT_SP
static const std::string SWL_PRIMARY_FUNCTIONS
virtual bool disableLLVMAA() const
static const std::string DISABLE_DSF
static const std::string SWL_ENABLE_VECTOR_BACKEND
std::string standardEmulationLib() const
static const std::string SWL_GEN_PLUGIN_ONLY
static const std::string SWL_USE_OLD_BACKEND_SOURCES
uint64_t initialStackPointerValue() const
static const std::string SWL_ASSUME_ADF_STACKALIGNMENT
static const std::string CONSERVATIVE_PRE_RA_SCHEDULER
virtual bool dumpDDGsDot() const
static const std::string SWL_DEBUG_FLAG
static const std::string SWL_BACKEND_CACHE_DIR
static const std::string DISABLE_LLVMAA
static const std::string SWL_EMULATION_LIB
virtual bool dumpDDGsXML() const
static const std::string SWS_PRIMARY_FUNCTIONS
static const std::string SWS_EMULATION_LIB
static const std::string SWL_DUMP_DDGS_XML
static const std::string SWL_SAVE_BACKEND_PLUGIN
std::string workItemAAFile() const
static const std::string SWL_PRINT_INLINE_ASM_WARNINGS
static const std::string VERBOSE_SWITCH
Switch for verbose output listing scheduler modules.
static const std::string SWL_BU_SCHEDULER
static const std::string SWL_DATA_START
static const std::string SWL_TEMP_DIR
static const std::string SWL_WORK_ITEM_AA_FILE
static const std::string SWL_DISABLE_HWLOOPS
static const std::string SWL_BUBBLEFISH2_SCHEDULER
static const std::string SWL_OPT_LEVEL
virtual std::string getLLVMargv() const
static const std::string LLVM_USER_ARGS
virtual FunctionNameList * primaryFunctions() const
std::string backendCacheDir() const
uint64_t dataStartAddress(TTAMachine::AddressSpace &aSpace) const
static const std::string SWS_OPT_LEVEL
static const std::string SWL_TD_SCHEDULER
static const std::string SWL_ANALYZE_INSTRUCTION_PATTERNS
static const std::string SWL_DUMP_DDGS_DOT
bool isDataStartAddressSet(TTAMachine::AddressSpace &aSpace) const
static const std::string USAGE
virtual TCEString name() const