mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
OptimiserSuite: Add two maps for converting between step names and abbreviations
- Abbreviations match those used in yulopti. - I considered using boost::bimap but I think it would be an overkill. Two simple maps are good enough in a situation where data is constant and there isn't much of it. - I could also use InvertibleMap from libsolutil but I don't even need any of its methods since my map is a constant. I also don't need the inverted map to store sets because my values are unique. - The reverseMap() is generic enough to be moved to some global file with utilities but I don't sure if it's going to actually be useful to others in practice.
This commit is contained in:
parent
9c8187bd29
commit
4e7c1c7876
@ -370,6 +370,49 @@ map<string, unique_ptr<OptimiserStep>> const& OptimiserSuite::allSteps()
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map<string, char> const& OptimiserSuite::stepNameToAbbreviationMap()
|
||||||
|
{
|
||||||
|
static map<string, char> lookupTable{
|
||||||
|
{BlockFlattener::name, 'f'},
|
||||||
|
{CommonSubexpressionEliminator::name, 'c'},
|
||||||
|
{ConditionalSimplifier::name, 'C'},
|
||||||
|
{ConditionalUnsimplifier::name, 'U'},
|
||||||
|
{ControlFlowSimplifier::name, 'n'},
|
||||||
|
{DeadCodeEliminator::name, 'D'},
|
||||||
|
{EquivalentFunctionCombiner::name, 'v'},
|
||||||
|
{ExpressionInliner::name, 'e'},
|
||||||
|
{ExpressionJoiner::name, 'j'},
|
||||||
|
{ExpressionSimplifier::name, 's'},
|
||||||
|
{ExpressionSplitter::name, 'x'},
|
||||||
|
{ForLoopConditionIntoBody::name, 'I'},
|
||||||
|
{ForLoopConditionOutOfBody::name, 'O'},
|
||||||
|
{ForLoopInitRewriter::name, 'o'},
|
||||||
|
{FullInliner::name, 'i'},
|
||||||
|
{FunctionGrouper::name, 'g'},
|
||||||
|
{FunctionHoister::name, 'h'},
|
||||||
|
{LiteralRematerialiser::name, 'T'},
|
||||||
|
{LoadResolver::name, 'L'},
|
||||||
|
{LoopInvariantCodeMotion::name, 'M'},
|
||||||
|
{RedundantAssignEliminator::name, 'r'},
|
||||||
|
{Rematerialiser::name, 'm'},
|
||||||
|
{SSAReverser::name, 'V'},
|
||||||
|
{SSATransform::name, 'a'},
|
||||||
|
{StructuralSimplifier::name, 't'},
|
||||||
|
{UnusedPruner::name, 'u'},
|
||||||
|
{VarDeclInitializer::name, 'd'},
|
||||||
|
};
|
||||||
|
yulAssert(lookupTable.size() == allSteps().size(), "");
|
||||||
|
|
||||||
|
return lookupTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
map<char, string> const& OptimiserSuite::stepAbbreviationToNameMap()
|
||||||
|
{
|
||||||
|
static map<char, string> lookupTable = util::invertMap(stepNameToAbbreviationMap());
|
||||||
|
|
||||||
|
return lookupTable;
|
||||||
|
}
|
||||||
|
|
||||||
void OptimiserSuite::runSequence(std::vector<string> const& _steps, Block& _ast)
|
void OptimiserSuite::runSequence(std::vector<string> const& _steps, Block& _ast)
|
||||||
{
|
{
|
||||||
unique_ptr<Block> copy;
|
unique_ptr<Block> copy;
|
||||||
|
@ -62,6 +62,8 @@ public:
|
|||||||
void runSequence(std::vector<std::string> const& _steps, Block& _ast);
|
void runSequence(std::vector<std::string> const& _steps, Block& _ast);
|
||||||
|
|
||||||
static std::map<std::string, std::unique_ptr<OptimiserStep>> const& allSteps();
|
static std::map<std::string, std::unique_ptr<OptimiserStep>> const& allSteps();
|
||||||
|
static std::map<std::string, char> const& stepNameToAbbreviationMap();
|
||||||
|
static std::map<char, std::string> const& stepAbbreviationToNameMap();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OptimiserSuite(
|
OptimiserSuite(
|
||||||
|
Loading…
Reference in New Issue
Block a user