diff options
author | chriseth <chris@ethereum.org> | 2018-12-10 23:14:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-10 23:14:33 +0800 |
commit | 871ea22bb9158e23254406d21673cfbeda2d7138 (patch) | |
tree | d2a3e88b0c22ee008a0bd480fdf78581d7f5eb67 /libsolidity | |
parent | 055c5fe173b90b7d07f1170de5d7018140296f89 (diff) | |
parent | b05d33d7714c5dbbb034d29b2eea8171807d093b (diff) | |
download | dexon-solidity-871ea22bb9158e23254406d21673cfbeda2d7138.tar.gz dexon-solidity-871ea22bb9158e23254406d21673cfbeda2d7138.tar.zst dexon-solidity-871ea22bb9158e23254406d21673cfbeda2d7138.zip |
Merge pull request #5008 from liangdzou/yul_stack_reuse
Reuse stack slots in Yul codegen
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/codegen/AsmCodeGen.cpp | 5 | ||||
-rw-r--r-- | libsolidity/codegen/AsmCodeGen.h | 3 | ||||
-rw-r--r-- | libsolidity/interface/AssemblyStack.cpp | 6 | ||||
-rw-r--r-- | libsolidity/interface/AssemblyStack.h | 3 |
4 files changed, 11 insertions, 6 deletions
diff --git a/libsolidity/codegen/AsmCodeGen.cpp b/libsolidity/codegen/AsmCodeGen.cpp index dfcc900b..3f770f62 100644 --- a/libsolidity/codegen/AsmCodeGen.cpp +++ b/libsolidity/codegen/AsmCodeGen.cpp @@ -179,13 +179,16 @@ void CodeGenerator::assemble( AsmAnalysisInfo& _analysisInfo, eth::Assembly& _assembly, ExternalIdentifierAccess const& _identifierAccess, - bool _useNamedLabelsForFunctions + bool _useNamedLabelsForFunctions, + bool _optimize ) { EthAssemblyAdapter assemblyAdapter(_assembly); CodeTransform( assemblyAdapter, _analysisInfo, + _parsedData, + _optimize, false, false, _identifierAccess, diff --git a/libsolidity/codegen/AsmCodeGen.h b/libsolidity/codegen/AsmCodeGen.h index 4c6d97f4..303d32ee 100644 --- a/libsolidity/codegen/AsmCodeGen.h +++ b/libsolidity/codegen/AsmCodeGen.h @@ -85,7 +85,8 @@ public: yul::AsmAnalysisInfo& _analysisInfo, dev::eth::Assembly& _assembly, yul::ExternalIdentifierAccess const& _identifierAccess = yul::ExternalIdentifierAccess(), - bool _useNamedLabelsForFunctions = false + bool _useNamedLabelsForFunctions = false, + bool _optimize = false ); }; diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index fbfb3472..5952d914 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -122,7 +122,7 @@ void AssemblyStack::optimize(yul::Object& _object) yul::OptimiserSuite::run(*_object.code, *_object.analysisInfo); } -MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const +MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize) const { solAssert(m_analysisSuccessful, ""); solAssert(m_parserResult, ""); @@ -136,7 +136,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const MachineAssemblyObject object; eth::Assembly assembly; EthAssemblyAdapter adapter(assembly); - yul::EVMObjectCompiler::compile(*m_parserResult, adapter, m_language == Language::Yul, false); + yul::EVMObjectCompiler::compile(*m_parserResult, adapter, m_language == Language::Yul, false, _optimize); object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble()); object.assembly = assembly.assemblyString(); return object; @@ -145,7 +145,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const { MachineAssemblyObject object; yul::EVMAssembly assembly(true); - yul::EVMObjectCompiler::compile(*m_parserResult, assembly, m_language == Language::Yul, true); + yul::EVMObjectCompiler::compile(*m_parserResult, assembly, m_language == Language::Yul, true, _optimize); object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize()); /// TODO: fill out text representation return object; diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h index 485ec1e7..6cfefcd8 100644 --- a/libsolidity/interface/AssemblyStack.h +++ b/libsolidity/interface/AssemblyStack.h @@ -73,7 +73,8 @@ public: void optimize(); /// Run the assembly step (should only be called after parseAndAnalyze). - MachineAssemblyObject assemble(Machine _machine) const; + /// @param _optimize does not run the optimizer but performs optimized code generation. + MachineAssemblyObject assemble(Machine _machine, bool _optimize = false) const; /// @returns the errors generated during parsing, analysis (and potentially assembly). langutil::ErrorList const& errors() const { return m_errors; } |