@@ -162,6 +162,36 @@ class YulOpti
162
162
}
163
163
}
164
164
165
+ int runSteps (string source, string steps)
166
+ {
167
+ if (!parse (source))
168
+ return 1 ;
169
+
170
+ set<YulString> reservedIdentifiers;
171
+ *m_ast = std::get<yul::Block>(Disambiguator (m_dialect, *m_analysisInfo)(*m_ast));
172
+ m_analysisInfo.reset ();
173
+ m_nameDispenser = make_shared<NameDispenser>(m_dialect, *m_ast, reservedIdentifiers);
174
+
175
+ OptimiserStepContext context{
176
+ m_dialect,
177
+ *m_nameDispenser,
178
+ reservedIdentifiers,
179
+ solidity::frontend::OptimiserSettings::standard ().expectedExecutionsPerDeployment
180
+ };
181
+
182
+ map<char , string> const & abbreviationMap = OptimiserSuite::stepAbbreviationToNameMap ();
183
+ for (char stepAbbreviation: steps)
184
+ if (auto abbreviationAndName = util::valueOrNullptr (abbreviationMap, stepAbbreviation))
185
+ OptimiserSuite::allSteps ().at (*abbreviationAndName)->run (context, *m_ast);
186
+ else
187
+ {
188
+ cerr << " Unknown optimizer step." << endl;
189
+ return 1 ;
190
+ }
191
+ cout << AsmPrinter{m_dialect}(*m_ast) << endl;
192
+ return 0 ;
193
+ }
194
+
165
195
void runInteractive (string source)
166
196
{
167
197
bool disambiguated = false ;
@@ -256,6 +286,11 @@ Allowed options)",
256
286
po::value<string>(),
257
287
" input file"
258
288
)
289
+ (
290
+ " steps" ,
291
+ po::value<string>(),
292
+ " steps to execute non-interactively"
293
+ )
259
294
(" help" , " Show this help screen." );
260
295
261
296
// All positional options should be interpreted as input files
@@ -292,7 +327,12 @@ Allowed options)",
292
327
}
293
328
294
329
if (arguments.count (" input-file" ))
295
- YulOpti{}.runInteractive (input);
330
+ {
331
+ if (arguments.count (" steps" ))
332
+ return YulOpti{}.runSteps (input, arguments[" steps" ].as <string>());
333
+ else
334
+ YulOpti{}.runInteractive (input);
335
+ }
296
336
else
297
337
cout << options;
298
338
0 commit comments