Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[yul] Add support for EVM version-dependent rules. #8958
Conversation
This comment has been hidden.
This comment has been hidden.
5061893
to
0796771
54b85e5
to
590822c
114c81d
to
17cd482
This comment has been hidden.
This comment has been hidden.
|
This is still a little too complicated for my taste and only works for libyul and not the classic optimizer. Can you change the functions in RuleList.h to accept an EVMVersion parameter and then - in a regular
Please not that it should be |
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
db79174
to
2ba82cc
| /// @returns a list of generic simplification rules with additional rules that may apply for the given dialect. | ||
| template <class Pattern> | ||
| std::vector<SimplificationRule<Pattern>> simplificationRuleList( | ||
| yul::Dialect const& _dialect, |
chriseth
May 19, 2020
Contributor
Ah! Even better!
Ah! Even better!
| @@ -46,7 +46,7 @@ SimplificationRule<yul::Pattern> const* SimplificationRules::findFirstMatch( | |||
| if (!instruction) | |||
| return nullptr; | |||
|
|
|||
| static SimplificationRules rules; | |||
| static SimplificationRules rules(_dialect); | |||
chriseth
May 19, 2020
Contributor
This way, the rules list will always use the dialect it was first initialized with. You need a static (maybe LazyInit) variable of type std::map<EVMVersion, SimplificationRules>.
This way, the rules list will always use the dialect it was first initialized with. You need a static (maybe LazyInit) variable of type std::map<EVMVersion, SimplificationRules>.
aarlt
May 19, 2020
Author
Member
Ah ok.. I thought that the compiler will only be initialized with exactly one EVMVersion..
Ah ok.. I thought that the compiler will only be initialized with exactly one EVMVersion..
chriseth
May 19, 2020
Contributor
Never be sure about that :)
Never be sure about that :)
| Pattern Z | ||
| ) | ||
| { | ||
| std::vector<SimplificationRule<Pattern>> rules{simplificationRuleList(A, B, C, W, X, Y, Z)}; |
chriseth
May 19, 2020
Contributor
Why don't you change that function instead?
Why don't you change that function instead?
aarlt
May 19, 2020
Author
Member
I thought it may make sense to separate evm version specific rules from generic rules
I thought it may make sense to separate evm version specific rules from generic rules
chriseth
May 19, 2020
Contributor
In a way, we already have a lot of them mixed in, but they do not matter because they do not introduce a new opcode.
In a way, we already have a lot of them mixed in, but they do not matter because they do not introduce a new opcode.
aarlt
May 19, 2020
Author
Member
Ah oki, I will change the function.
Ah oki, I will change the function.
This comment has been hidden.
This comment has been hidden.
75982d0
to
b000af2
|
This is still missing the changes in the old optimizer. |
|
I'm working on this. |
|
It'd be fun to add a test like
Does the rule list work before or after the Yul optimizers in that case? |
| if (yul::EVMDialect const* evmDialect = dynamic_cast<yul::EVMDialect const*>(&_dialect)) | ||
| version = evmDialect->evmVersion(); | ||
|
|
||
| if (evmRules.find(version) == evmRules.end()) |
leonardoalt
May 26, 2020
Member
Suggested change
if (evmRules.find(version) == evmRules.end())
if (!evmRules.count(version))
| if (evmRules.find(version) == evmRules.end()) | |
| if (!evmRules.count(version)) |
|
Oh sorry, forgot to comment here: It turned out that this is not really worth it for the old optimizer, because the rules cannot be used with the old optimizer. The old optimizer can only have rules with instructions that are deterministic. Since |
|
Added the fun test. |
a06ac0f
into
develop
Fixes #7542, #8882