-
Notifications
You must be signed in to change notification settings - Fork 472
Add new node pattern matching boilerplate & make use of it #5284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
asl
commented
May 18, 2025
- Add node pattern matching implementation similar to LLVM's IR pattern matching:
- More flexible & generic than present pattern matching, could be further extended if necessary
- Can optionally bind nodes in the pattern to local variables
- Can match types, can perform deferred matching (e.g. refine the match further on)
- Switch reassociation and strength reduction to this new implementation
- Extend reassociation (and document its limitations)
- Add couple more strength reduction patterns
Signed-off-by: Anton Korobeynikov <[email protected]>
…ation Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
const IR::Constant *c1, *c2; | ||
const IR::Expression *e; | ||
if (match(root, | ||
m_BinOp(m_AllOf(m_BinOp(lhs), m_BinOp(m_Expr(e), m_Constant(c1))), m_Constant(c2))) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems far inferior to the IR::Pattern matching, which is much simpler and clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you please be more specific? How I can e.g. match if operand has particular type in IR::Pattern
? Or check if two operands are the same? etc.