OpenASIP  2.0
SchedulerCmdLineOptions.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 SchedulerCmdLineOptions.cc
26  *
27  * Implementation of SchedulerCmdLineOptions class.
28  *
29  * @author Ari Mets�halme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2010
31  * @note rating: red
32  */
33 
34 #include <iostream>
36 #include "tce_config.h"
37 
38 using std::cout;
39 using std::endl;
40 
41 const std::string SchedulerCmdLineOptions::USAGE =
42  "Usage: schedule [OPTION]... SOURCE\n"
43  "Schedule SOURCE binary with the given options\n"
44  "Example: schedule -a mach.adf hello.tpef";
45 
46 const std::string SchedulerCmdLineOptions::SWL_TARGET_MACHINE = "adf";
47 const std::string SchedulerCmdLineOptions::SWS_TARGET_MACHINE = "a";
48 const std::string SchedulerCmdLineOptions::SWL_OUTPUT_FILE = "output";
49 const std::string SchedulerCmdLineOptions::SWS_OUTPUT_FILE = "o";
50 const std::string SchedulerCmdLineOptions::SWL_LOOP_FLAG = "loop";
52  "scheduling-window-size";
54  "if-conversion-threshold";
56  "lowmem-mode-threshold";
57 const std::string SchedulerCmdLineOptions::SWL_RESTRICTED_AA = "restricted-aa";
58 const std::string SchedulerCmdLineOptions::SWL_STACK_AA = "stack-aa";
59 const std::string SchedulerCmdLineOptions::SWL_OFFSET_AA = "offset-aa";
60 const std::string SchedulerCmdLineOptions::SWL_RENAME_REGISTERS = "rename-registers";
62  "print-resource-constraints";
63 
65  "dump-ifconversion-cfgs";
66 
67 const std::string SchedulerCmdLineOptions::SWL_KILL_DEAD_RESULTS = "kill-dead-results";
68 const std::string SchedulerCmdLineOptions::SWL_BYPASS_DISTANCE = "bypass-distance";
69 const std::string SchedulerCmdLineOptions::SWL_NO_DRE_BYPASS_DISTANCE = "bypass-distance-nodre";
70 const std::string SchedulerCmdLineOptions::SWL_OPERAND_SHARE_DISTANCE = "operand-share-distance";
71 const std::string SchedulerCmdLineOptions::SWL_NOALIAS_FUNCTIONS = "noalias-functions";
72 
73 /**
74  * Constructor.
75  */
77 
78  addOption(
80  SWL_TARGET_MACHINE, "Target machine (.adf file)",
82 
83  addOption(
85  SWL_OUTPUT_FILE, "Output file name.",
87 
88  addOption(
90  SWL_LOOP_FLAG, "Use loop optimizations."));
91 
92  addOption(
95  "The scheduling window size in TTA instructions."));
96 
97  addOption(
100  "Use restricted C language keyword in alias analyzis."));
101 
102  addOption(
104  SWL_STACK_AA, "Enable stack alias analyzer. On by default."));
105 
106 
107  addOption(
110  "Rename already allocated registers during scheduler"));
111 
112  addOption(
115  "The maximum number of moves in an if-structure to predicate "
116  "when if-converting."));
117 
118  addOption(
121  "Move count of procedure which activates low-mem mode"
122  "which saves memory from scheduler but "
123  "disables some optimizations."));
124 
125  addOption(
127  SWL_OFFSET_AA, "Enable constant offset alias analyzer. On by default."));
128 
129  addOption(
132  "Rename already allocated registers during scheduler. "
133  "On by default."));
134 
135  addOption(
138  "Print out the resource constraints that potentially limit the "
139  "basic block's schedule."));
140 
141  addOption(
144  "Dumps the control flow graphs before and after if-conversion."));
145 
146  addOption(
149  "Kill dead results after bypass. On by default."));
150 
151  addOption(
154  "Bypass distance when dead result elimination can be used"));
155 
156  addOption(
159  "Bypass distance when dead result elimination cannot be used"));
160 
161  addOption(
164  "Operand sharing max distance"));
165 
166  addOption(
169  "List of functions which are scheduled with assumptions "
170  "that there are no aliased memory accesses in these function "
171  "This allows much more aggressive instruction scheduling, "
172  "but will cause broken code if the code contains memory "
173  "aliasing. Use with extreme caution!"));
174 }
175 
176 /**
177  * Destructor.
178  */
180 }
181 
182 /**
183  * Print the version of the user interface.
184  */
185 void
187  cout << "schedule - OpenASIP TTA Scheduler command line interface "
188  << Application::TCEVersionString() << endl;
189 }
190 
191 /**
192  * Returns path to the target .adf file defined with the -a switch.
193  *
194  * @return Target adf file defined in the command line.
195  */
196 std::string
199 }
200 
201 /**
202  * Returns true if the target machine file is defined, false otherwise.
203  *
204  * @return True if the target machine file is defined.
205  */
206 bool
209 }
210 
211 /**
212  * Returns path to the output file defined with the -o switch.
213  *
214  * @return Output file name defined in the command line.
215  */
216 std::string
218  return findOption(SWS_OUTPUT_FILE)->String();
219 }
220 
221 /**
222  * Returns true if the output file name is defined, false otherwise.
223  *
224  * @return True if the output file name is defined.
225  */
226 bool
229 }
230 
231 /**
232  * Return true if the loop opt switch was defined in the command line.
233  *
234  * @return True if the loop opt switch was defined in the command line.
235  */
236 bool
239 }
240 
241 bool
244 }
245 
246 bool
248  if (!optionGiven(SWL_STACK_AA)) {
249  return true;
250  }
251  return findOption(SWL_STACK_AA)->isFlagOn();
252 }
253 
254 bool
256  if (!optionGiven(SWL_OFFSET_AA)) {
257  return true;
258  }
259  return findOption(SWL_OFFSET_AA)->isFlagOn();
260 }
261 
262 bool
265  return true;
266  }
268 }
269 
270 bool
273  return false;
274  }
276 }
277 
278 bool
281  return false;
282  }
284 }
285 
286 /**
287  * Returns the maximum number of moves in an if-structure which is still
288  * if-converted.
289  *
290  * By default returns -1 which results in using heuristics to define the
291  * maximum values.
292  */
293 int
295  if (!findOption(SWL_IF_CONVERSION_THRESHOLD)->isDefined()) {
296  return -1;
297  } else {
299  }
300 }
301 
302 /**
303  * Returns the maximum number of moves in an if-structure which is still
304  * if-converted.
305  *
306  * By default returns -1 which results in using heuristics to define the
307  * maximum values.
308  */
309 int
311  if (!findOption(SWL_LOWMEM_MODE_THRESHOLD)->isDefined()) {
312  return -1;
313  } else {
315  }
316 }
317 
318 
319 
320 /**
321  * Returns the bypass limit when dead result elimination can be used.
322  *
323  * By default returns -1 which results in using heuristics to define the
324  * maximum values.
325  */
326 int
328  if (!findOption(SWL_BYPASS_DISTANCE)->isDefined()) {
329  return -1;
330  } else {
332  }
333 }
334 
335 int
337  if (!findOption(SWL_OPERAND_SHARE_DISTANCE)->isDefined()) {
338  return -1;
339  } else {
341  }
342 }
343 
344 
345 /**
346  * Returns the bypass limit when dead result elimination cannot be used.
347  *
348  * By default returns -1 which results in using heuristics to define the
349  * maximum values.
350  */
351 int
353  if (!findOption(SWL_NO_DRE_BYPASS_DISTANCE)->isDefined()) {
354  return -1;
355  } else {
357  }
358 }
359 
360 bool
363  return true;
364  }
366 }
367 
368 /**
369  * Returns the list of "noalias functions" that are scheduled
370  * with assumption of no aliasing memory accesses.
371  */
374  FunctionNameList* funcs = new FunctionNameList();
376  if (opt == NULL)
377  return funcs;
378  for (int i = 1; i <= opt->listSize(); ++i) {
379  funcs->insert(opt->String(i));
380  }
381  return funcs;
382 }
SimpleInterPassDatum
Definition: InterPassDatum.hh:64
SchedulerCmdLineOptions::SWL_RENAME_REGISTERS
static const std::string SWL_RENAME_REGISTERS
Definition: SchedulerCmdLineOptions.hh:102
SchedulerCmdLineOptions::enableOffsetAA
bool enableOffsetAA() const
Definition: SchedulerCmdLineOptions.cc:255
SchedulerCmdLineOptions::SWL_DUMP_IFCONVERSION_CFGS
static const std::string SWL_DUMP_IFCONVERSION_CFGS
Definition: SchedulerCmdLineOptions.hh:110
SchedulerCmdLineOptions::SWL_TARGET_MACHINE
static const std::string SWL_TARGET_MACHINE
Definition: SchedulerCmdLineOptions.hh:94
SchedulerCmdLineOptions::SWL_LOWMEM_MODE_THRESHOLD
static const std::string SWL_LOWMEM_MODE_THRESHOLD
Definition: SchedulerCmdLineOptions.hh:105
SchedulerCmdLineOptions::SWL_RESTRICTED_AA
static const std::string SWL_RESTRICTED_AA
Definition: SchedulerCmdLineOptions.hh:103
SchedulerCmdLineOptions::isLoopOptDefined
virtual bool isLoopOptDefined() const
Definition: SchedulerCmdLineOptions.cc:237
CmdLineOptionParser::isDefined
bool isDefined()
Definition: CmdLineOptionParser.cc:169
SchedulerCmdLineOptions::SchedulerCmdLineOptions
SchedulerCmdLineOptions()
Definition: SchedulerCmdLineOptions.cc:76
SchedulerCmdLineOptions::SWL_RESOURCE_CONSTRAINT_PRINTING
static const std::string SWL_RESOURCE_CONSTRAINT_PRINTING
Definition: SchedulerCmdLineOptions.hh:106
SchedulerCmdLineOptions::USAGE
static const std::string USAGE
Description of the command line usage of the Scheduler.
Definition: SchedulerCmdLineOptions.hh:93
SchedulerCmdLineOptions::killDeadResults
virtual bool killDeadResults() const
Definition: SchedulerCmdLineOptions.cc:361
SchedulerCmdLineOptions::SWL_NOALIAS_FUNCTIONS
static const std::string SWL_NOALIAS_FUNCTIONS
Definition: SchedulerCmdLineOptions.hh:112
SchedulerCmdLineOptions::printVersion
virtual void printVersion() const
Definition: SchedulerCmdLineOptions.cc:186
CmdLineOptionParser::isFlagOn
virtual bool isFlagOn() const
Definition: CmdLineOptionParser.cc:126
SchedulerCmdLineOptions.hh
CmdLineOptions::optionGiven
bool optionGiven(std::string key) const
Definition: CmdLineOptions.cc:320
SchedulerCmdLineOptions::noaliasFunctions
virtual FunctionNameList * noaliasFunctions() const
Definition: SchedulerCmdLineOptions.cc:373
SchedulerCmdLineOptions::enableStackAA
bool enableStackAA() const
Definition: SchedulerCmdLineOptions.cc:247
SchedulerCmdLineOptions::SWL_BYPASS_DISTANCE
static const std::string SWL_BYPASS_DISTANCE
Definition: SchedulerCmdLineOptions.hh:109
SchedulerCmdLineOptions::lowMemModeThreshold
virtual int lowMemModeThreshold() const
Definition: SchedulerCmdLineOptions.cc:310
CmdLineParser::addOption
void addOption(CmdLineOptionParser *opt)
SchedulerCmdLineOptions::machineFile
virtual std::string machineFile() const
Definition: SchedulerCmdLineOptions.cc:197
SchedulerCmdLineOptions::SWL_LOOP_FLAG
static const std::string SWL_LOOP_FLAG
Definition: SchedulerCmdLineOptions.hh:98
CmdLineOptionParser::listSize
virtual int listSize() const
Definition: CmdLineOptionParser.cc:150
CmdLineOptionParser
Definition: CmdLineOptionParser.hh:56
SchedulerCmdLineOptions::SWL_OPERAND_SHARE_DISTANCE
static const std::string SWL_OPERAND_SHARE_DISTANCE
Definition: SchedulerCmdLineOptions.hh:111
CmdLineOptions
Definition: CmdLineOptions.hh:54
BoolCmdLineOptionParser
Definition: CmdLineOptionParser.hh:278
SchedulerCmdLineOptions::~SchedulerCmdLineOptions
virtual ~SchedulerCmdLineOptions()
Definition: SchedulerCmdLineOptions.cc:179
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
SchedulerCmdLineOptions::SWS_TARGET_MACHINE
static const std::string SWS_TARGET_MACHINE
Definition: SchedulerCmdLineOptions.hh:95
SchedulerCmdLineOptions::outputFile
virtual std::string outputFile() const
Definition: SchedulerCmdLineOptions.cc:217
SchedulerCmdLineOptions::isMachineFileDefined
virtual bool isMachineFileDefined() const
Definition: SchedulerCmdLineOptions.cc:207
SchedulerCmdLineOptions::SWL_OUTPUT_FILE
static const std::string SWL_OUTPUT_FILE
Definition: SchedulerCmdLineOptions.hh:96
SchedulerCmdLineOptions::isOutputFileDefined
virtual bool isOutputFileDefined() const
Definition: SchedulerCmdLineOptions.cc:227
SchedulerCmdLineOptions::SWL_KILL_DEAD_RESULTS
static const std::string SWL_KILL_DEAD_RESULTS
Definition: SchedulerCmdLineOptions.hh:107
SchedulerCmdLineOptions::SWL_SCHEDULING_WINDOW
static const std::string SWL_SCHEDULING_WINDOW
Definition: SchedulerCmdLineOptions.hh:99
CmdLineOptionParser::String
virtual std::string String(int index=0) const
Definition: CmdLineOptionParser.cc:102
SchedulerCmdLineOptions::SWL_NO_DRE_BYPASS_DISTANCE
static const std::string SWL_NO_DRE_BYPASS_DISTANCE
Definition: SchedulerCmdLineOptions.hh:108
StringListCmdLineOptionParser
Definition: CmdLineOptionParser.hh:344
SchedulerCmdLineOptions::renameRegisters
virtual bool renameRegisters() const
Definition: SchedulerCmdLineOptions.cc:263
SchedulerCmdLineOptions::SWL_STACK_AA
static const std::string SWL_STACK_AA
Definition: SchedulerCmdLineOptions.hh:100
SchedulerCmdLineOptions::printResourceConstraints
bool printResourceConstraints() const
Definition: SchedulerCmdLineOptions.cc:271
SchedulerCmdLineOptions::SWL_IF_CONVERSION_THRESHOLD
static const std::string SWL_IF_CONVERSION_THRESHOLD
Definition: SchedulerCmdLineOptions.hh:104
SchedulerCmdLineOptions::useRestrictedAliasAnalyzer
virtual bool useRestrictedAliasAnalyzer() const
Definition: SchedulerCmdLineOptions.cc:242
SchedulerCmdLineOptions::noDreBypassDistance
virtual int noDreBypassDistance() const
Definition: SchedulerCmdLineOptions.cc:352
SchedulerCmdLineOptions::bypassDistance
virtual int bypassDistance() const
Definition: SchedulerCmdLineOptions.cc:327
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
Application::TCEVersionString
static std::string TCEVersionString()
Definition: Application.cc:510
SchedulerCmdLineOptions::dumpIfConversionCFGs
virtual bool dumpIfConversionCFGs() const
Definition: SchedulerCmdLineOptions.cc:279
SchedulerCmdLineOptions::SWS_OUTPUT_FILE
static const std::string SWS_OUTPUT_FILE
Definition: SchedulerCmdLineOptions.hh:97
SchedulerCmdLineOptions::operandShareDistance
virtual int operandShareDistance() const
Definition: SchedulerCmdLineOptions.cc:336
StringCmdLineOptionParser
Definition: CmdLineOptionParser.hh:180
SchedulerCmdLineOptions::ifConversionThreshold
virtual int ifConversionThreshold() const
Definition: SchedulerCmdLineOptions.cc:294
SchedulerCmdLineOptions::SWL_OFFSET_AA
static const std::string SWL_OFFSET_AA
Definition: SchedulerCmdLineOptions.hh:101
IntegerCmdLineOptionParser
Definition: CmdLineOptionParser.hh:117