diff options
Diffstat (limited to 'test/tools/yulopti.cpp')
-rw-r--r-- | test/tools/yulopti.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/test/tools/yulopti.cpp b/test/tools/yulopti.cpp index fcbe308f..7203ef54 100644 --- a/test/tools/yulopti.cpp +++ b/test/tools/yulopti.cpp @@ -33,6 +33,7 @@ #include <libyul/optimiser/Disambiguator.h> #include <libyul/optimiser/CommonSubexpressionEliminator.h> #include <libyul/optimiser/NameCollector.h> +#include <libyul/optimiser/EquivalentFunctionCombiner.h> #include <libyul/optimiser/ExpressionSplitter.h> #include <libyul/optimiser/FunctionGrouper.h> #include <libyul/optimiser/FunctionHoister.h> @@ -45,6 +46,7 @@ #include <libyul/optimiser/UnusedPruner.h> #include <libyul/optimiser/ExpressionJoiner.h> #include <libyul/optimiser/RedundantAssignEliminator.h> +#include <libyul/optimiser/SSAReverser.h> #include <libyul/optimiser/SSATransform.h> #include <libyul/optimiser/StructuralSimplifier.h> #include <libyul/optimiser/VarDeclInitializer.h> @@ -85,7 +87,7 @@ public: { ErrorReporter errorReporter(m_errors); shared_ptr<Scanner> scanner = make_shared<Scanner>(CharStream(_input, "")); - m_ast = yul::Parser(errorReporter, yul::EVMDialect::strictAssemblyForEVM()).parse(scanner, false); + m_ast = yul::Parser(errorReporter, m_dialect).parse(scanner, false); if (!m_ast || !errorReporter.errors().empty()) { cout << "Error parsing source." << endl; @@ -98,7 +100,7 @@ public: errorReporter, EVMVersion::byzantium(), langutil::Error::Type::SyntaxError, - EVMDialect::strictAssemblyForEVM() + m_dialect ); if (!analyzer.analyze(*m_ast) || !errorReporter.errors().empty()) { @@ -120,15 +122,15 @@ public: return; if (!disambiguated) { - *m_ast = boost::get<yul::Block>(Disambiguator(*m_analysisInfo)(*m_ast)); + *m_ast = boost::get<yul::Block>(Disambiguator(*m_dialect, *m_analysisInfo)(*m_ast)); m_analysisInfo.reset(); - m_nameDispenser = make_shared<NameDispenser>(*m_ast); + m_nameDispenser = make_shared<NameDispenser>(*m_dialect, *m_ast); disambiguated = true; } cout << "(q)quit/(f)flatten/(c)se/initialize var(d)ecls/(x)plit/(j)oin/(g)rouper/(h)oister/" << endl; cout << " (e)xpr inline/(i)nline/(s)implify/(u)nusedprune/ss(a) transform/" << endl; cout << " (r)edundant assign elim./re(m)aterializer/f(o)r-loop-pre-rewriter/" << endl; - cout << " s(t)ructural simplifier? " << endl; + cout << " s(t)ructural simplifier/equi(v)alent function combiner/ssa re(V)erser? " << endl; cout.flush(); int option = readStandardInputChar(); cout << ' ' << char(option) << endl; @@ -143,13 +145,13 @@ public: ForLoopInitRewriter{}(*m_ast); break; case 'c': - (CommonSubexpressionEliminator{})(*m_ast); + (CommonSubexpressionEliminator{*m_dialect})(*m_ast); break; case 'd': (VarDeclInitializer{})(*m_ast); break; case 'x': - ExpressionSplitter{*m_nameDispenser}(*m_ast); + ExpressionSplitter{*m_dialect, *m_nameDispenser}(*m_ast); break; case 'j': ExpressionJoiner::run(*m_ast); @@ -161,28 +163,34 @@ public: (FunctionHoister{})(*m_ast); break; case 'e': - ExpressionInliner{*m_ast}.run(); + ExpressionInliner{*m_dialect, *m_ast}.run(); break; case 'i': FullInliner(*m_ast, *m_nameDispenser).run(); break; case 's': - ExpressionSimplifier::run(*m_ast); + ExpressionSimplifier::run(*m_dialect, *m_ast); break; case 't': - (StructuralSimplifier{})(*m_ast); + (StructuralSimplifier{*m_dialect})(*m_ast); break; case 'u': - UnusedPruner::runUntilStabilised(*m_ast); + UnusedPruner::runUntilStabilised(*m_dialect, *m_ast); break; case 'a': SSATransform::run(*m_ast, *m_nameDispenser); break; case 'r': - RedundantAssignEliminator::run(*m_ast); + RedundantAssignEliminator::run(*m_dialect, *m_ast); break; case 'm': - Rematerialiser{}(*m_ast); + Rematerialiser::run(*m_dialect, *m_ast); + break; + case 'v': + EquivalentFunctionCombiner::run(*m_ast); + break; + case 'V': + SSAReverser::run(*m_ast); break; default: cout << "Unknown option." << endl; @@ -194,6 +202,7 @@ public: private: ErrorList m_errors; shared_ptr<yul::Block> m_ast; + shared_ptr<Dialect> m_dialect{EVMDialect::strictAssemblyForEVMObjects()}; shared_ptr<AsmAnalysisInfo> m_analysisInfo; shared_ptr<NameDispenser> m_nameDispenser; }; |