mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #5586 from ethereum/refactorEVMAssembly
Refactor evm assembly
This commit is contained in:
commit
8b38cf3ed4
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -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(),
|
||||
|
@ -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;
|
||||
|
@ -1,7 +1,6 @@
|
||||
add_library(yul
|
||||
AsmAnalysis.cpp
|
||||
AsmAnalysisInfo.cpp
|
||||
AsmCodeGen.cpp
|
||||
AsmParser.cpp
|
||||
AsmPrinter.cpp
|
||||
AsmScope.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user