34 log(
" opt [options] [selection]\n");
36 log(
"This pass calls all the other opt_* passes in a useful order. This performs\n");
37 log(
"a series of trivial optimizations and cleanups. This pass executes the other\n");
38 log(
"passes in the following order:\n");
40 log(
" opt_const [-mux_undef] [-mux_bool] [-undriven] [-fine] [-full] [-keepdc]\n");
41 log(
" opt_share -nomux\n");
44 log(
" opt_muxtree\n");
45 log(
" opt_reduce [-fine] [-full]\n");
48 log(
" opt_clean [-purge]\n");
49 log(
" opt_const [-mux_undef] [-mux_bool] [-undriven] [-fine] [-full] [-keepdc]\n");
50 log(
" while <changed design>\n");
52 log(
"When called with -fast the following script is used instead:\n");
55 log(
" opt_const [-mux_undef] [-mux_bool] [-undriven] [-fine] [-full] [-keepdc]\n");
58 log(
" opt_clean [-purge]\n");
59 log(
" while <changed design in opt_rmdff>\n");
61 log(
"Note: Options in square brackets (such as [-keepdc]) are passed through to\n");
62 log(
"the opt_* commands when given to 'opt'.\n");
68 std::string opt_clean_args;
69 std::string opt_const_args;
70 std::string opt_reduce_args;
71 bool fast_mode =
false;
73 log_header(
"Executing OPT pass (performing simple optimizations).\n");
77 for (argidx = 1; argidx < args.size(); argidx++) {
78 if (args[argidx] ==
"-purge") {
79 opt_clean_args +=
" -purge";
82 if (args[argidx] ==
"-mux_undef") {
83 opt_const_args +=
" -mux_undef";
86 if (args[argidx] ==
"-mux_bool") {
87 opt_const_args +=
" -mux_bool";
90 if (args[argidx] ==
"-undriven") {
91 opt_const_args +=
" -undriven";
94 if (args[argidx] ==
"-fine") {
95 opt_const_args +=
" -fine";
96 opt_reduce_args +=
" -fine";
99 if (args[argidx] ==
"-full") {
100 opt_const_args +=
" -full";
101 opt_reduce_args +=
" -full";
104 if (args[argidx] ==
"-keepdc") {
105 opt_const_args +=
" -keepdc";
108 if (args[argidx] ==
"-fast") {
119 Pass::call(design,
"opt_const" + opt_const_args);
125 Pass::call(design,
"opt_clean" + opt_clean_args);
126 log_header(
"Rerunning OPT passes. (Removed registers in this run.)\n");
128 Pass::call(design,
"opt_clean" + opt_clean_args);
132 Pass::call(design,
"opt_const" + opt_const_args);
137 Pass::call(design,
"opt_reduce" + opt_reduce_args);
140 Pass::call(design,
"opt_clean" + opt_clean_args);
141 Pass::call(design,
"opt_const" + opt_const_args);
144 log_header(
"Rerunning OPT passes. (Maybe there is more to do..)\n");
148 log_header(fast_mode ?
"Finished fast OPT passes." :
"Finished OPT passes. (There is nothing left to do.)\n");
void log_header(const char *format,...)
void scratchpad_unset(std::string varname)
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
#define PRIVATE_NAMESPACE_BEGIN
bool scratchpad_get_bool(std::string varname, bool default_value=false) const
#define PRIVATE_NAMESPACE_END
#define USING_YOSYS_NAMESPACE
void log(const char *format,...)
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
static void call(RTLIL::Design *design, std::string command)