-
Notifications
You must be signed in to change notification settings - Fork 485
[circt-bmc] Add dbg.trace for BMC counterexample value tracking #10747
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,23 @@ def VariableOp : DebugOp<"variable"> { | |
| }]; | ||
| } | ||
|
|
||
| def TraceOp : DebugOp<"trace"> { | ||
| let summary = "Record a named runtime value for counterexample tracing"; | ||
| let description = [{ | ||
| Records a named value at a specific step for later counterexample | ||
| materialization. This is intended as an internal bridge from the BMC flow | ||
| to the final runtime-backed text/VCD emission path. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure the motivation for this op is entirely clear to me; what's the aim for its eventual lowering? Would the aim be to lower this op to some call that reaches out to the BMCTrace runtime with a value and a cycle number? If that's the case then I'm not sure it's completely clear to me why we need a dedicated op for this instead of building this IR directly as we build the for loop that it sits in.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The intended lowering is a later counterexample-materialization step that consumes dbg.trace(step, name, value) and lowers it to the BMC runtime trace path. I introduced a dedicated op to keep VerifToSMT backend-neutral instead of constructing runtime-specific IR directly in the loop body. You’re right that this isn’t clear from the current patch. |
||
| }]; | ||
| let arguments = (ins | ||
| I32:$step, | ||
| StrAttr:$name, | ||
| AnyType:$value | ||
| ); | ||
| let assemblyFormat = [{ | ||
| $step `,` $name `,` $value attr-dict `:` type($step) `,` type($value) | ||
| }]; | ||
| } | ||
|
|
||
|
|
||
| def ValueOp : DebugOp<"value"> { | ||
| let summary = "Attach source-language metadata to a value"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,9 +5,11 @@ func.func @Foo(%arg0: i32, %arg1: index, %arg2: f64) { | |
| // CHECK-NEXT: dbg.variable "foo", %arg0 : i32 | ||
| // CHECK-NEXT: dbg.variable "bar", %arg1 : index | ||
| // CHECK-NEXT: dbg.variable "baz", %arg2 : f64 | ||
| // CHECK-NEXT: dbg.trace %arg0, "tracefoo", %arg2 : i32, f64 | ||
| dbg.variable "foo", %arg0 : i32 | ||
| dbg.variable "bar", %arg1 : index | ||
| dbg.variable "baz", %arg2 : f64 | ||
| dbg.trace %arg0, "tracefoo", %arg2 : i32, f64 | ||
|
|
||
| // CHECK-NEXT: [[TMP:%.+]] = dbg.struct {"foo": %arg0, "bar": %arg1, "baz": %arg2} : i32, index, f64 | ||
| // CHECK-NEXT: dbg.variable "megafoo", [[TMP]] : !dbg.struct | ||
|
|
@@ -28,4 +30,3 @@ func.func @Foo(%arg0: i32, %arg1: index, %arg2: f64) { | |
|
|
||
| return | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: unrelated change |
||
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'm not totally sure having this in the debug dialect is the right move when it's very specific to BMC. Maybe the verif dialect would make more sense?