From 6c44c5f0c93d6ce623bec773cc151a73d4b12bff Mon Sep 17 00:00:00 2001 From: chriseth Date: Sat, 3 Nov 2018 16:05:08 +0100 Subject: Apply the optimize commandline parameter to assembly mode. --- libsolidity/interface/AssemblyStack.cpp | 9 +++++++++ libsolidity/interface/AssemblyStack.h | 3 +++ 2 files changed, 12 insertions(+) (limited to 'libsolidity/interface') diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index 24e190b3..f361c5da 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -34,6 +34,8 @@ #include +#include + using namespace std; using namespace dev; using namespace langutil; @@ -79,6 +81,13 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string return analyzeParsed(); } +void AssemblyStack::optimize() +{ + solAssert(m_language != Language::Assembly, "Optimization requested for loose assembly."); + yul::OptimiserSuite::run(*m_parserResult->code, *m_parserResult->analysisInfo); + solAssert(analyzeParsed(), "Invalid source code after optimization."); +} + bool AssemblyStack::analyzeParsed() { solAssert(m_parserResult, ""); diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h index 7ae0592e..0d04ffec 100644 --- a/libsolidity/interface/AssemblyStack.h +++ b/libsolidity/interface/AssemblyStack.h @@ -69,6 +69,9 @@ public: /// Multiple calls overwrite the previous state. bool parseAndAnalyze(std::string const& _sourceName, std::string const& _source); + /// Run the optimizer suite. Can only be used with Yul or strict assembly. + void optimize(); + /// Run the assembly step (should only be called after parseAndAnalyze). MachineAssemblyObject assemble(Machine _machine) const; -- cgit