mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #5988 from ethereum/moveAsmCodeGen
[REF] Move asm code gen
This commit is contained in:
		
						commit
						bbeab9ffdf
					
				| @ -51,8 +51,6 @@ set(sources | ||||
| 	codegen/ABIFunctions.h | ||||
| 	codegen/ArrayUtils.cpp | ||||
| 	codegen/ArrayUtils.h | ||||
| 	codegen/AsmCodeGen.cpp | ||||
| 	codegen/AsmCodeGen.h | ||||
| 	codegen/Compiler.cpp | ||||
| 	codegen/Compiler.h | ||||
| 	codegen/CompilerContext.cpp | ||||
|  | ||||
| @ -23,7 +23,6 @@ | ||||
| #include <libsolidity/codegen/CompilerContext.h> | ||||
| 
 | ||||
| #include <libsolidity/ast/AST.h> | ||||
| #include <libsolidity/codegen/AsmCodeGen.h> | ||||
| #include <libsolidity/codegen/Compiler.h> | ||||
| #include <libsolidity/codegen/CompilerUtils.h> | ||||
| #include <libsolidity/interface/Version.h> | ||||
| @ -31,6 +30,7 @@ | ||||
| #include <libyul/AsmParser.h> | ||||
| #include <libyul/AsmAnalysis.h> | ||||
| #include <libyul/AsmAnalysisInfo.h> | ||||
| #include <libyul/backends/evm/AsmCodeGen.h> | ||||
| #include <libyul/backends/evm/EVMDialect.h> | ||||
| #include <libyul/YulString.h> | ||||
| 
 | ||||
| @ -407,7 +407,7 @@ void CompilerContext::appendInlineAssembly( | ||||
| 	} | ||||
| 
 | ||||
| 	solAssert(errorReporter.errors().empty(), "Failed to analyze inline assembly block."); | ||||
| 	CodeGenerator::assemble(*parserResult, analysisInfo, *m_asm, identifierAccess, _system); | ||||
| 	yul::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(); | ||||
|  | ||||
| @ -21,14 +21,16 @@ | ||||
|  */ | ||||
| 
 | ||||
| #include <libsolidity/ast/AST.h> | ||||
| #include <libsolidity/codegen/AsmCodeGen.h> | ||||
| #include <libsolidity/codegen/CompilerUtils.h> | ||||
| #include <libsolidity/codegen/ContractCompiler.h> | ||||
| #include <libsolidity/codegen/ExpressionCompiler.h> | ||||
| 
 | ||||
| #include <libyul/backends/evm/AsmCodeGen.h> | ||||
| 
 | ||||
| #include <libevmasm/Instruction.h> | ||||
| #include <libevmasm/Assembly.h> | ||||
| #include <libevmasm/GasMeter.h> | ||||
| 
 | ||||
| #include <liblangutil/ErrorReporter.h> | ||||
| 
 | ||||
| #include <boost/range/adaptor/reversed.hpp> | ||||
| @ -713,7 +715,7 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) | ||||
| 		} | ||||
| 	}; | ||||
| 	solAssert(_inlineAssembly.annotation().analysisInfo, ""); | ||||
| 	CodeGenerator::assemble( | ||||
| 	yul::CodeGenerator::assemble( | ||||
| 		_inlineAssembly.operations(), | ||||
| 		*_inlineAssembly.annotation().analysisInfo, | ||||
| 		*m_context.assemblyPtr(), | ||||
|  | ||||
| @ -22,7 +22,6 @@ | ||||
| 
 | ||||
| #include <libsolidity/interface/AssemblyStack.h> | ||||
| 
 | ||||
| #include <libsolidity/codegen/AsmCodeGen.h> | ||||
| #include <libevmasm/Assembly.h> | ||||
| #include <liblangutil/Scanner.h> | ||||
| 
 | ||||
| @ -30,6 +29,7 @@ | ||||
| #include <libyul/AsmAnalysisInfo.h> | ||||
| #include <libyul/AsmParser.h> | ||||
| #include <libyul/AsmPrinter.h> | ||||
| #include <libyul/backends/evm/AsmCodeGen.h> | ||||
| #include <libyul/backends/evm/EVMAssembly.h> | ||||
| #include <libyul/backends/evm/EVMCodeTransform.h> | ||||
| #include <libyul/backends/evm/EVMDialect.h> | ||||
| @ -151,7 +151,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize) | ||||
| 	{ | ||||
| 		MachineAssemblyObject object; | ||||
| 		eth::Assembly assembly; | ||||
| 		EthAssemblyAdapter adapter(assembly); | ||||
| 		yul::EthAssemblyAdapter adapter(assembly); | ||||
| 		compileEVM(adapter, false, _optimize); | ||||
| 		object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble()); | ||||
| 		object.assembly = assembly.assemblyString(); | ||||
|  | ||||
| @ -26,6 +26,8 @@ add_library(yul | ||||
| 	Utilities.h | ||||
| 	YulString.h | ||||
| 	backends/evm/AbstractAssembly.h | ||||
| 	backends/evm/AsmCodeGen.h | ||||
| 	backends/evm/AsmCodeGen.cpp | ||||
| 	backends/evm/EVMAssembly.cpp | ||||
| 	backends/evm/EVMAssembly.h | ||||
| 	backends/evm/EVMCodeTransform.cpp | ||||
|  | ||||
| @ -18,7 +18,7 @@ | ||||
|  * Adaptor between the abstract assembly and eth assembly. | ||||
|  */ | ||||
| 
 | ||||
| #include <libsolidity/codegen/AsmCodeGen.h> | ||||
| #include <libyul/backends/evm/AsmCodeGen.h> | ||||
| 
 | ||||
| #include <libyul/AsmData.h> | ||||
| #include <libyul/AsmAnalysisInfo.h> | ||||
| @ -41,7 +41,6 @@ using namespace std; | ||||
| using namespace dev; | ||||
| using namespace langutil; | ||||
| using namespace yul; | ||||
| using namespace dev::solidity; | ||||
| 
 | ||||
| EthAssemblyAdapter::EthAssemblyAdapter(eth::Assembly& _assembly): | ||||
| 	m_assembly(_assembly) | ||||
| @ -20,16 +20,11 @@ | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <libyul/AsmAnalysis.h> | ||||
| #include <libyul/backends/evm/AbstractAssembly.h> | ||||
| #include <libyul/AsmAnalysis.h> | ||||
| #include <liblangutil/SourceLocation.h> | ||||
| #include <functional> | ||||
| 
 | ||||
| namespace yul | ||||
| { | ||||
| struct Block; | ||||
| } | ||||
| 
 | ||||
| namespace dev | ||||
| { | ||||
| namespace eth | ||||
| @ -37,18 +32,20 @@ namespace eth | ||||
| class Assembly; | ||||
| class AssemblyItem; | ||||
| } | ||||
| } | ||||
| 
 | ||||
| namespace solidity | ||||
| namespace yul | ||||
| { | ||||
| struct Block; | ||||
| 
 | ||||
| class EthAssemblyAdapter: public yul::AbstractAssembly | ||||
| class EthAssemblyAdapter: public AbstractAssembly | ||||
| { | ||||
| public: | ||||
| 	explicit EthAssemblyAdapter(eth::Assembly& _assembly); | ||||
| 	explicit EthAssemblyAdapter(dev::eth::Assembly& _assembly); | ||||
| 	void setSourceLocation(langutil::SourceLocation const& _location) override; | ||||
| 	int stackHeight() const override; | ||||
| 	void appendInstruction(solidity::Instruction _instruction) override; | ||||
| 	void appendConstant(u256 const& _constant) override; | ||||
| 	void appendInstruction(dev::solidity::Instruction _instruction) override; | ||||
| 	void appendConstant(dev::u256 const& _constant) override; | ||||
| 	void appendLabel(LabelID _labelId) override; | ||||
| 	void appendLabelReference(LabelID _labelId) override; | ||||
| 	size_t newLabelId() override; | ||||
| @ -67,9 +64,9 @@ public: | ||||
| 	SubID appendData(dev::bytes const& _data) override; | ||||
| 
 | ||||
| private: | ||||
| 	static LabelID assemblyTagToIdentifier(eth::AssemblyItem const& _tag); | ||||
| 	static LabelID assemblyTagToIdentifier(dev::eth::AssemblyItem const& _tag); | ||||
| 
 | ||||
| 	eth::Assembly& m_assembly; | ||||
| 	dev::eth::Assembly& m_assembly; | ||||
| 	std::map<SubID, dev::u256> m_dataHashBySubId; | ||||
| 	size_t m_nextDataCounter = std::numeric_limits<size_t>::max() / 2; | ||||
| }; | ||||
| @ -79,14 +76,13 @@ class CodeGenerator | ||||
| public: | ||||
| 	/// Performs code generation and appends generated to _assembly.
 | ||||
| 	static void assemble( | ||||
| 		yul::Block const& _parsedData, | ||||
| 		yul::AsmAnalysisInfo& _analysisInfo, | ||||
| 		Block const& _parsedData, | ||||
| 		AsmAnalysisInfo& _analysisInfo, | ||||
| 		dev::eth::Assembly& _assembly, | ||||
| 		yul::ExternalIdentifierAccess const& _identifierAccess = yul::ExternalIdentifierAccess(), | ||||
| 		ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(), | ||||
| 		bool _useNamedLabelsForFunctions = false, | ||||
| 		bool _optimize = false | ||||
| 	); | ||||
| }; | ||||
| 
 | ||||
| } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user