Skip to content
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

[HWToSMT] Proper error message for 0-bit constants #7727

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Conversion/HWToSMT/HWToSMT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ struct HWConstantOpConversion : OpConversionPattern<ConstantOp> {
LogicalResult
matchAndRewrite(ConstantOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const override {
if (adaptor.getValue().getBitWidth() < 1)
return rewriter.notifyMatchFailure(op.getLoc(),
"0-bit constants not supported");
rewriter.replaceOpWithNewOp<smt::BVConstantOp>(op, adaptor.getValue());
return success();
}
Expand Down
7 changes: 7 additions & 0 deletions test/Conversion/HWToSMT/hw-to-smt-errors.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: circt-opt --convert-hw-to-smt --split-input-file --verify-diagnostics %s

hw.module @zeroBitConstant() {
// expected-error @below {{failed to legalize operation 'hw.constant' that was explicitly marked illegal}}
%c0_i0 = hw.constant 0 : i0
hw.output
}
Loading