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
76f1416d61
commit
1286e4aae7
@ -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,28 +39,45 @@ 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;
|
||||||
CodeTransform transform(
|
if (_system && _optimizeStackAllocation && _evmVersion.canOverchargeGasForCall())
|
||||||
assemblyAdapter,
|
{
|
||||||
_analysisInfo,
|
int oldStackHeight = assemblyAdapter.stackHeight();
|
||||||
_parsedData,
|
assemblyAdapter.setStackHeight(0);
|
||||||
EVMDialect::strictAssemblyForEVM(_evmVersion),
|
auto stackErrors = OptimizedEVMCodeTransform::run(assemblyAdapter, _analysisInfo, _parsedData, EVMDialect::strictAssemblyForEVM(_evmVersion), builtinContext, _system);
|
||||||
builtinContext,
|
assemblyAdapter.setStackHeight(oldStackHeight);
|
||||||
_optimizeStackAllocation,
|
if (!stackErrors.empty())
|
||||||
_identifierAccessCodeGen,
|
assertThrow(
|
||||||
_useNamedLabelsForFunctions
|
false,
|
||||||
);
|
langutil::StackTooDeepError,
|
||||||
transform(_parsedData);
|
"Stack too deep when compiling inline assembly" +
|
||||||
if (!transform.stackErrors().empty())
|
(stackErrors.front().comment() ? ": " + *stackErrors.front().comment() : ".")
|
||||||
assertThrow(
|
);
|
||||||
false,
|
}
|
||||||
langutil::StackTooDeepError,
|
else
|
||||||
"Stack too deep when compiling inline assembly" +
|
{
|
||||||
(transform.stackErrors().front().comment() ? ": " + *transform.stackErrors().front().comment() : ".")
|
CodeTransform transform(
|
||||||
|
assemblyAdapter,
|
||||||
|
_analysisInfo,
|
||||||
|
_parsedData,
|
||||||
|
EVMDialect::strictAssemblyForEVM(_evmVersion),
|
||||||
|
builtinContext,
|
||||||
|
_optimizeStackAllocation,
|
||||||
|
_identifierAccessCodeGen,
|
||||||
|
_system
|
||||||
);
|
);
|
||||||
|
transform(_parsedData);
|
||||||
|
if (!transform.stackErrors().empty())
|
||||||
|
assertThrow(
|
||||||
|
false,
|
||||||
|
langutil::StackTooDeepError,
|
||||||
|
"Stack too deep when compiling inline assembly" +
|
||||||
|
(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