Skip to content

Commit 4a49e6e

Browse files
authored
Merge pull request #12221 from ethereum/yulOptiNonInteractive
Non-interactive mode for yulopti.
2 parents 696964d + 95c973d commit 4a49e6e

File tree

3 files changed

+191
-128
lines changed

3 files changed

+191
-128
lines changed

libyul/optimiser/Suite.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ void OptimiserSuite::run(
111111
)(*_object.code));
112112
Block& ast = *_object.code;
113113

114-
OptimiserSuite suite(_dialect, reservedIdentifiers, Debug::None, ast, _expectedExecutionsPerDeployment);
114+
NameDispenser dispenser{_dialect, ast, reservedIdentifiers};
115+
OptimiserStepContext context{_dialect, dispenser, reservedIdentifiers, _expectedExecutionsPerDeployment};
116+
117+
OptimiserSuite suite(context, Debug::None);
115118

116119
// Some steps depend on properties ensured by FunctionHoister, BlockFlattener, FunctionGrouper and
117120
// ForLoopInitRewriter. Run them first to be able to run arbitrary sequences safely.
@@ -162,7 +165,7 @@ void OptimiserSuite::run(
162165
ast.statements.erase(ast.statements.begin());
163166
}
164167

165-
suite.m_dispenser.reset(ast);
168+
dispenser.reset(ast);
166169
NameSimplifier::run(suite.m_context, ast);
167170
VarNameCleaner::run(suite.m_context, ast);
168171

libyul/optimiser/Suite.h

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class OptimiserSuite
5959
PrintStep,
6060
PrintChanges
6161
};
62+
OptimiserSuite(OptimiserStepContext& _context, Debug _debug = Debug::None): m_context(_context), m_debug(_debug) {}
63+
6264
/// The value nullopt for `_expectedExecutionsPerDeployment` represents creation code.
6365
static void run(
6466
Dialect const& _dialect,
@@ -82,20 +84,7 @@ class OptimiserSuite
8284
static std::map<char, std::string> const& stepAbbreviationToNameMap();
8385

8486
private:
85-
OptimiserSuite(
86-
Dialect const& _dialect,
87-
std::set<YulString> const& _externallyUsedIdentifiers,
88-
Debug _debug,
89-
Block& _ast,
90-
std::optional<size_t> expectedExecutionsPerDeployment
91-
):
92-
m_dispenser{_dialect, _ast, _externallyUsedIdentifiers},
93-
m_context{_dialect, m_dispenser, _externallyUsedIdentifiers, expectedExecutionsPerDeployment},
94-
m_debug(_debug)
95-
{}
96-
97-
NameDispenser m_dispenser;
98-
OptimiserStepContext m_context;
87+
OptimiserStepContext& m_context;
9988
Debug m_debug;
10089
};
10190

0 commit comments

Comments
 (0)