-
Notifications
You must be signed in to change notification settings - Fork 366
[Datapath] Conversion Pass Comb to Datapath #8664
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
Conversation
… builder and assemblyFormat
…explicit reduction factor
…ingle compressor tree and removing zeros
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.
Seems like you're missing a link target in https://github.com/llvm/circt/blob/main/lib/CAPI/Conversion/CMakeLists.txt
Otherwise LGTM!
target.addLegalDialect<datapath::DatapathDialect, comb::CombDialect, | ||
hw::HWDialect>(); | ||
|
||
target.addIllegalOp<comb::AddOp, comb::MulOp>(); |
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.
Isn't this redundant due to the below dynamic legality constraints?
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.
Thanks Martin - didn't realise that addDynamicallyLegalOp would mark the remainder as illegal - useful to know!
ConversionPatternRewriter &rewriter) const override { | ||
// Can only introduce compressor for three-inputs or more | ||
if (op.getNumOperands() <= 2) | ||
return failure(); |
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.
Nit: I think the preferred way to fail is to use rewriter.notifyMatchFailure
which will also notify the listener (also in the pattern below).
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.
I think operations with numOperands() <= 2
are legal so I believe patterns won't apply in the first place?
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.
Removed this check as suggested
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.
LGTM
|
||
// Permit 2-input adders (carry-propagate adders) | ||
target.addDynamicallyLegalOp<comb::AddOp>( | ||
[](comb::AddOp op) { return op.getNumOperands() == 2; }); |
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.
nit: Can we make unary add legal as well? They will be canonicalized anyway
[](comb::AddOp op) { return op.getNumOperands() == 2; }); | |
[](comb::AddOp op) { return op.getNumOperands() <= 2; }); |
ConversionPatternRewriter &rewriter) const override { | ||
// Can only introduce compressor for three-inputs or more | ||
if (op.getNumOperands() <= 2) | ||
return failure(); |
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.
I think operations with numOperands() <= 2
are legal so I believe patterns won't apply in the first place?
Thanks reviewers - suggestions implemented ready to merge once checks are completed - still awaiting commit access approval... |
Add support for lowering variadic adders and two-input multipliers to datapath operations. Now automiatng
Resulting from comb-to-datapath and canonicalize:
This will be integrated into circt-synth during a subsequent PR.