diff options
author | chriseth <chris@ethereum.org> | 2018-12-04 22:55:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 22:55:53 +0800 |
commit | 8b38cf3ed43d17a7d80a45237f1ec5b538af55b3 (patch) | |
tree | c6a34c4f194a088f749aec0e875f15f4cd05fc61 | |
parent | 126ed2e990280b7200a7872d8d6f5b8db14e4b0a (diff) | |
parent | 7ee1ddc172a29ed1ccdd545a996d19f4c2a145a3 (diff) | |
download | dexon-solidity-8b38cf3ed43d17a7d80a45237f1ec5b538af55b3.tar.gz dexon-solidity-8b38cf3ed43d17a7d80a45237f1ec5b538af55b3.tar.zst dexon-solidity-8b38cf3ed43d17a7d80a45237f1ec5b538af55b3.zip |
Merge pull request #5586 from ethereum/refactorEVMAssembly
Refactor evm assembly
-rw-r--r-- | libsolidity/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libsolidity/codegen/AsmCodeGen.cpp (renamed from libyul/AsmCodeGen.cpp) | 15 | ||||
-rw-r--r-- | libsolidity/codegen/AsmCodeGen.h (renamed from libyul/AsmCodeGen.h) | 18 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerContext.cpp | 4 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 4 | ||||
-rw-r--r-- | libsolidity/interface/AssemblyStack.cpp | 5 | ||||
-rw-r--r-- | libyul/CMakeLists.txt | 1 |
7 files changed, 20 insertions, 28 deletions
diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index dc4c6d15..43d61c86 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -23,6 +23,7 @@ set(sources ast/Types.cpp codegen/ABIFunctions.cpp codegen/ArrayUtils.cpp + codegen/AsmCodeGen.cpp codegen/Compiler.cpp codegen/CompilerContext.cpp codegen/CompilerUtils.cpp diff --git a/libyul/AsmCodeGen.cpp b/libsolidity/codegen/AsmCodeGen.cpp index 23bf395d..83dd08fb 100644 --- a/libyul/AsmCodeGen.cpp +++ b/libsolidity/codegen/AsmCodeGen.cpp @@ -15,17 +15,12 @@ along with solidity. If not, see <http://www.gnu.org/licenses/>. */ /** - * @author Christian <c@ethdev.com> - * @date 2016 - * Code-generating part of inline assembly. + * Adaptor between the abstract assembly and eth assembly. */ -#include <libyul/AsmCodeGen.h> +#include <libsolidity/codegen/AsmCodeGen.h> -#include <libyul/AsmParser.h> #include <libyul/AsmData.h> -#include <libyul/AsmScope.h> -#include <libyul/AsmAnalysis.h> #include <libyul/AsmAnalysisInfo.h> #include <libyul/backends/evm/AbstractAssembly.h> @@ -36,12 +31,6 @@ #include <liblangutil/SourceLocation.h> -#include <libdevcore/CommonIO.h> - -#include <boost/range/adaptor/reversed.hpp> -#include <boost/range/adaptor/map.hpp> -#include <boost/range/algorithm/count_if.hpp> - #include <memory> #include <functional> diff --git a/libyul/AsmCodeGen.h b/libsolidity/codegen/AsmCodeGen.h index fd5ac0a1..dc529e10 100644 --- a/libyul/AsmCodeGen.h +++ b/libsolidity/codegen/AsmCodeGen.h @@ -15,9 +15,7 @@ along with solidity. If not, see <http://www.gnu.org/licenses/>. */ /** - * @author Christian <c@ethdev.com> - * @date 2016 - * Code-generating part of inline assembly. + * Adaptor between the abstract assembly and eth assembly. */ #pragma once @@ -26,25 +24,28 @@ #include <functional> +namespace yul +{ +struct Block; +} + namespace dev { namespace eth { class Assembly; } -} -namespace yul +namespace solidity { -struct Block; class CodeGenerator { public: /// Performs code generation and appends generated to _assembly. static void assemble( - Block const& _parsedData, - AsmAnalysisInfo& _analysisInfo, + yul::Block const& _parsedData, + yul::AsmAnalysisInfo& _analysisInfo, dev::eth::Assembly& _assembly, yul::ExternalIdentifierAccess const& _identifierAccess = yul::ExternalIdentifierAccess(), bool _useNamedLabelsForFunctions = false @@ -52,3 +53,4 @@ public: }; } +} diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 039738a6..5ccdac37 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -24,10 +24,10 @@ #include <libsolidity/codegen/CompilerUtils.h> #include <libsolidity/ast/AST.h> #include <libsolidity/codegen/Compiler.h> +#include <libsolidity/codegen/AsmCodeGen.h> #include <libsolidity/interface/Version.h> #include <liblangutil/SourceReferenceFormatter.h> #include <libyul/AsmParser.h> -#include <libyul/AsmCodeGen.h> #include <libyul/AsmAnalysis.h> #include <libyul/AsmAnalysisInfo.h> #include <libyul/YulString.h> @@ -395,7 +395,7 @@ void CompilerContext::appendInlineAssembly( } solAssert(errorReporter.errors().empty(), "Failed to analyze inline assembly block."); - yul::CodeGenerator::assemble(*parserResult, analysisInfo, *m_asm, identifierAccess, _system); + CodeGenerator::assemble(*parserResult, analysisInfo, *m_asm, identifierAccess, _system); // Reset the source location to the one of the node (instead of the CODEGEN source location) updateSourceLocation(); diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index aabdbb79..ec55ae9b 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -23,8 +23,8 @@ #include <libsolidity/codegen/ContractCompiler.h> #include <libsolidity/codegen/ExpressionCompiler.h> #include <libsolidity/codegen/CompilerUtils.h> +#include <libsolidity/codegen/AsmCodeGen.h> #include <libsolidity/ast/AST.h> -#include <libyul/AsmCodeGen.h> #include <liblangutil/ErrorReporter.h> #include <libevmasm/Instruction.h> @@ -618,7 +618,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) } }; solAssert(_inlineAssembly.annotation().analysisInfo, ""); - yul::CodeGenerator::assemble( + CodeGenerator::assemble( _inlineAssembly.operations(), *_inlineAssembly.annotation().analysisInfo, m_context.nonConstAssembly(), diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index ff345089..c15a192a 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -22,12 +22,13 @@ #include <libsolidity/interface/AssemblyStack.h> +#include <libsolidity/codegen/AsmCodeGen.h> + #include <liblangutil/Scanner.h> #include <libyul/AsmPrinter.h> #include <libyul/AsmParser.h> #include <libyul/AsmAnalysis.h> #include <libyul/AsmAnalysisInfo.h> -#include <libyul/AsmCodeGen.h> #include <libyul/backends/evm/EVMCodeTransform.h> #include <libyul/backends/evm/EVMAssembly.h> #include <libyul/ObjectParser.h> @@ -111,7 +112,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const { MachineAssemblyObject object; eth::Assembly assembly; - yul::CodeGenerator::assemble(*m_parserResult->code, *m_parserResult->analysisInfo, assembly); + CodeGenerator::assemble(*m_parserResult->code, *m_parserResult->analysisInfo, assembly); object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble()); object.assembly = assembly.assemblyString(); return object; diff --git a/libyul/CMakeLists.txt b/libyul/CMakeLists.txt index 7ed84ff5..2dec0a44 100644 --- a/libyul/CMakeLists.txt +++ b/libyul/CMakeLists.txt @@ -1,7 +1,6 @@ add_library(yul AsmAnalysis.cpp AsmAnalysisInfo.cpp - AsmCodeGen.cpp AsmParser.cpp AsmPrinter.cpp AsmScope.cpp |