mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Enable the new code generator for "system" inline assembly routines.
This commit is contained in:
parent
7f50e58dbf
commit
b8bf8da514
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <libyul/backends/evm/EthAssemblyAdapter.h>
|
#include <libyul/backends/evm/EthAssemblyAdapter.h>
|
||||||
#include <libyul/backends/evm/EVMCodeTransform.h>
|
#include <libyul/backends/evm/EVMCodeTransform.h>
|
||||||
|
#include <libyul/backends/evm/OptimizedEVMCodeTransform.h>
|
||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/AsmAnalysisInfo.h>
|
#include <libyul/AsmAnalysisInfo.h>
|
||||||
|
|
||||||
@ -38,12 +39,28 @@ void CodeGenerator::assemble(
|
|||||||
evmasm::Assembly& _assembly,
|
evmasm::Assembly& _assembly,
|
||||||
langutil::EVMVersion _evmVersion,
|
langutil::EVMVersion _evmVersion,
|
||||||
ExternalIdentifierAccess::CodeGenerator _identifierAccessCodeGen,
|
ExternalIdentifierAccess::CodeGenerator _identifierAccessCodeGen,
|
||||||
bool _useNamedLabelsForFunctions,
|
bool _system,
|
||||||
bool _optimizeStackAllocation
|
bool _optimizeStackAllocation
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EthAssemblyAdapter assemblyAdapter(_assembly);
|
EthAssemblyAdapter assemblyAdapter(_assembly);
|
||||||
BuiltinContext builtinContext;
|
BuiltinContext builtinContext;
|
||||||
|
if (_system && _optimizeStackAllocation && _evmVersion > EVMVersion::homestead())
|
||||||
|
{
|
||||||
|
int oldStackHeight = assemblyAdapter.stackHeight();
|
||||||
|
assemblyAdapter.setStackHeight(0);
|
||||||
|
auto stackErrors = OptimizedEVMCodeTransform::run(assemblyAdapter, _analysisInfo, _parsedData, EVMDialect::strictAssemblyForEVM(_evmVersion), builtinContext, _system);
|
||||||
|
assemblyAdapter.setStackHeight(oldStackHeight);
|
||||||
|
if (!stackErrors.empty())
|
||||||
|
assertThrow(
|
||||||
|
false,
|
||||||
|
langutil::StackTooDeepError,
|
||||||
|
"Stack too deep when compiling inline assembly" +
|
||||||
|
(stackErrors.front().comment() ? ": " + *stackErrors.front().comment() : ".")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CodeTransform transform(
|
CodeTransform transform(
|
||||||
assemblyAdapter,
|
assemblyAdapter,
|
||||||
_analysisInfo,
|
_analysisInfo,
|
||||||
@ -52,7 +69,7 @@ void CodeGenerator::assemble(
|
|||||||
builtinContext,
|
builtinContext,
|
||||||
_optimizeStackAllocation,
|
_optimizeStackAllocation,
|
||||||
_identifierAccessCodeGen,
|
_identifierAccessCodeGen,
|
||||||
_useNamedLabelsForFunctions
|
_system
|
||||||
);
|
);
|
||||||
transform(_parsedData);
|
transform(_parsedData);
|
||||||
if (!transform.stackErrors().empty())
|
if (!transform.stackErrors().empty())
|
||||||
@ -62,4 +79,5 @@ void CodeGenerator::assemble(
|
|||||||
"Stack too deep when compiling inline assembly" +
|
"Stack too deep when compiling inline assembly" +
|
||||||
(transform.stackErrors().front().comment() ? ": " + *transform.stackErrors().front().comment() : ".")
|
(transform.stackErrors().front().comment() ? ": " + *transform.stackErrors().front().comment() : ".")
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
evmasm::Assembly& _assembly,
|
evmasm::Assembly& _assembly,
|
||||||
langutil::EVMVersion _evmVersion,
|
langutil::EVMVersion _evmVersion,
|
||||||
ExternalIdentifierAccess::CodeGenerator _identifierAccess = {},
|
ExternalIdentifierAccess::CodeGenerator _identifierAccess = {},
|
||||||
bool _useNamedLabelsForFunctions = false,
|
bool _system = false,
|
||||||
bool _optimizeStackAllocation = false
|
bool _optimizeStackAllocation = false
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user