mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make hardcoded parts of the optimizer sequence configurable
This commit is contained in:
@@ -209,6 +209,7 @@ void YulStack::optimize(Object& _object, bool _isCreation)
|
||||
_object,
|
||||
m_optimiserSettings.optimizeStackAllocation,
|
||||
m_optimiserSettings.yulOptimiserSteps,
|
||||
m_optimiserSettings.yulOptimiserCleanupSteps,
|
||||
_isCreation ? nullopt : make_optional(m_optimiserSettings.expectedExecutionsPerDeployment),
|
||||
{}
|
||||
);
|
||||
|
||||
@@ -93,6 +93,7 @@ void OptimiserSuite::run(
|
||||
Object& _object,
|
||||
bool _optimizeStackAllocation,
|
||||
string_view _optimisationSequence,
|
||||
string_view _optimisationCleanupSequence,
|
||||
optional<size_t> _expectedExecutionsPerDeployment,
|
||||
set<YulString> const& _externallyUsedIdentifiers
|
||||
)
|
||||
@@ -139,7 +140,10 @@ void OptimiserSuite::run(
|
||||
_optimizeStackAllocation,
|
||||
stackCompressorMaxIterations
|
||||
);
|
||||
suite.runSequence("fDnTOc g", ast);
|
||||
|
||||
// Run the user supplied (otherwise default) clean up sequence
|
||||
suite.runSequence(_optimisationCleanupSequence, ast);
|
||||
suite.runSequence("g", ast);
|
||||
|
||||
if (evmDialect)
|
||||
{
|
||||
@@ -296,6 +300,7 @@ map<char, string> const& OptimiserSuite::stepAbbreviationToNameMap()
|
||||
void OptimiserSuite::validateSequence(string_view _stepAbbreviations)
|
||||
{
|
||||
int8_t nestingLevel = 0;
|
||||
int8_t colonDelimiters = 0;
|
||||
for (char abbreviation: _stepAbbreviations)
|
||||
switch (abbreviation)
|
||||
{
|
||||
@@ -310,6 +315,10 @@ void OptimiserSuite::validateSequence(string_view _stepAbbreviations)
|
||||
nestingLevel--;
|
||||
assertThrow(nestingLevel >= 0, OptimizerException, "Unbalanced brackets");
|
||||
break;
|
||||
case ':':
|
||||
assertThrow(nestingLevel == 0, OptimizerException, "Cleanup delimiter may only be placed at nesting level zero");
|
||||
assertThrow(++colonDelimiters <=1, OptimizerException, "Too many colon delimiters");
|
||||
break;
|
||||
default:
|
||||
{
|
||||
yulAssert(
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
/// Special characters that do not represent optimiser steps but are allowed in abbreviation sequences.
|
||||
/// Some of them (like whitespace) are ignored, others (like brackets) are a part of the syntax.
|
||||
static constexpr char NonStepAbbreviations[] = " \n[]";
|
||||
static constexpr char NonStepAbbreviations[] = " \n[]:";
|
||||
|
||||
enum class Debug
|
||||
{
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
Object& _object,
|
||||
bool _optimizeStackAllocation,
|
||||
std::string_view _optimisationSequence,
|
||||
std::string_view _optimisationCleanupSequence,
|
||||
std::optional<size_t> _expectedExecutionsPerDeployment,
|
||||
std::set<YulString> const& _externallyUsedIdentifiers = {}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user