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

[SMT] Parse SMT bitvector width as signed #8042

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion include/circt/Dialect/SMT/SMTTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def BitVectorType : SMTTypeDef<"BitVector"> {
The bit-width must be strictly greater than zero.
}];

let parameters = (ins "uint64_t":$width);
let parameters = (ins "int64_t":$width);
let assemblyFormat = "`<` $width `>`";

let genVerifyDecl = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/Dialect/SMT/SMTTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool smt::isAnySMTValueType(Type type) {

LogicalResult
BitVectorType::verify(function_ref<InFlightDiagnostic()> emitError,
uint64_t width) {
int64_t width) {
if (width <= 0U)
return emitError() << "bit-vector must have at least a width of one";
return success();
Expand Down
13 changes: 10 additions & 3 deletions test/Dialect/SMT/bitvector-errors.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ func.func @at_least_size_one(%arg0: !smt.bv<0>) {

// -----

// expected-error @below {{bit-vector must have at least a width of one}}
func.func @positive_width(%arg0: !smt.bv<-1>) {
return
}

// -----

func.func @attr_type_and_return_type_match() {
// expected-error @below {{inferred type(s) '!smt.bv<1>' are incompatible with return type(s) of operation '!smt.bv<32>'}}
// expected-error @below {{failed to infer returned types}}
Expand Down Expand Up @@ -89,8 +96,8 @@ func.func @repeat_count_too_large(%arg0: !smt.bv<32>) {

// -----

func.func @repeat_result_type_bitwidth_too_large(%arg0: !smt.bv<18446744073709551612>) {
// expected-error @below {{result bit-width (provided integer times bit-width of the input type) must fit into 64 bits}}
smt.bv.repeat 2 times %arg0 : !smt.bv<18446744073709551612>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the repeat parser, 64 is hardcoded as the width of the unsigned integer used. We'd need to adjust this and keep this error test but with a smaller number.

// expected-error @below {{integer value too large}}
// expected-error @below {{failed to parse BitVectorType parameter 'width' which is to be a `int64_t`}}
func.func @bitwidth_too_large(%arg0: !smt.bv<18446744073709551612>) {
return
}
Loading