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
dialects: (riscv) label region is multi block #1172
Conversation
Maybe move each terminator to a separate module in the filecheck files? I wanted to do just that in the terminator PRs but I forgot. |
What for? |
Nevermind me, I missed the block added in the diff :) |
8a72b03
to
9a62634
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1172 +/- ##
==========================================
- Coverage 89.34% 89.34% -0.01%
==========================================
Files 181 181
Lines 24080 24079 -1
Branches 3663 3663
==========================================
- Hits 21515 21514 -1
Misses 1991 1991
Partials 574 574
☔ View full report in Codecov by Sentry. |
I'm sorry I can not follow anymore, what did this PR change?
Because we are going to match the behaviour of CF dialect? With risc-v jmp instruction becoming some type of terminator for example? |
This PR changes the label region to multi-block, and changes the tests to reflect this. Please take a look at my newer PR for more blocks due to branch instructions and j |
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.
Similarly to Josse, I'm having difficulty following what the intentions are here, but if this works for you sure!
|
||
"riscv.j"() {"immediate" = 1 : i32, "rd" = !riscv.reg<zero>} : () -> () | ||
// CHECK-NEXT: j 1 | ||
"riscv.j"() {"immediate" = #riscv.label<"label">, "rd" = !riscv.reg<zero>} : () -> () |
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.
Shouldn't this then be a block not a label?
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.
that's also in the next PR
"riscv.beq"(%2, %1) {"offset" = 1 : i32}: (!riscv.reg<j2>, !riscv.reg<j1>) -> () | ||
// CHECK-NEXT: beq j2, j1, 1 | ||
"riscv.bne"(%2, %1) {"offset" = 1 : i32}: (!riscv.reg<j2>, !riscv.reg<j1>) -> () | ||
// CHECK-NEXT: bne j2, j1, 1 | ||
"riscv.blt"(%2, %1) {"offset" = 1 : i32}: (!riscv.reg<j2>, !riscv.reg<j1>) -> () | ||
// CHECK-NEXT: blt j2, j1, 1 | ||
"riscv.bge"(%2, %1) {"offset" = 1 : i32}: (!riscv.reg<j2>, !riscv.reg<j1>) -> () | ||
// CHECK-NEXT: bge j2, j1, 1 | ||
"riscv.bltu"(%2, %1) {"offset" = 1 : i32}: (!riscv.reg<j2>, !riscv.reg<j1>) -> () | ||
// CHECK-NEXT: bltu j2, j1, 1 | ||
"riscv.bgeu"(%2, %1) {"offset" = 1 : i32}: (!riscv.reg<j2>, !riscv.reg<j1>) -> () | ||
// CHECK-NEXT: bgeu j2, j1, 1 |
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.
Similarly here, shouldn't these be jumping to other blocks?
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.
That's in the next PR, this PR just sets the scene for that change
"riscv.beq"(%0, %1) {"offset" = 1 : i32}: (!riscv.reg<>, !riscv.reg<>) -> () | ||
// CHECK-NEXT: "riscv.beq"(%{{.*}}, %{{.*}}) {"offset" = 1 : i32} : (!riscv.reg<>, !riscv.reg<>) -> () | ||
"riscv.bne"(%0, %1) {"offset" = 1 : i32}: (!riscv.reg<>, !riscv.reg<>) -> () | ||
// CHECK-NEXT: "riscv.bne"(%{{.*}}, %{{.*}}) {"offset" = 1 : i32} : (!riscv.reg<>, !riscv.reg<>) -> () | ||
"riscv.blt"(%0, %1) {"offset" = 1 : i32}: (!riscv.reg<>, !riscv.reg<>) -> () | ||
// CHECK-NEXT: "riscv.blt"(%{{.*}}, %{{.*}}) {"offset" = 1 : i32} : (!riscv.reg<>, !riscv.reg<>) -> () | ||
"riscv.bge"(%0, %1) {"offset" = 1 : i32}: (!riscv.reg<>, !riscv.reg<>) -> () | ||
// CHECK-NEXT: "riscv.bge"(%{{.*}}, %{{.*}}) {"offset" = 1 : i32} : (!riscv.reg<>, !riscv.reg<>) -> () | ||
"riscv.bltu"(%0, %1) {"offset" = 1 : i32}: (!riscv.reg<>, !riscv.reg<>) -> () | ||
// CHECK-NEXT: "riscv.bltu"(%{{.*}}, %{{.*}}) {"offset" = 1 : i32} : (!riscv.reg<>, !riscv.reg<>) -> () | ||
"riscv.bgeu"(%0, %1) {"offset" = 1 : i32}: (!riscv.reg<>, !riscv.reg<>) -> () | ||
// CHECK-NEXT: "riscv.bgeu"(%{{.*}}, %{{.*}}) {"offset" = 1 : i32} : (!riscv.reg<>, !riscv.reg<>) -> () |
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.
Same thing here
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.
Hi, after the zulip discussion it is now a lot more clear why we need this.
The syntax still looks a bit weird though. Is this me, or is this something that needs fixing?
// CHECK-NEXT: ebreak | ||
"riscv.ret"() : () -> () | ||
// CHECK-NEXT: ret | ||
^1(%b10 : !riscv.reg<>, %b11 : !riscv.reg<>): |
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.
Should this be indented --?
// Unconditional Branch Instructions | ||
"riscv.ret"() : () -> () // pseudo-instruction | ||
// CHECK-NEXT: ret | ||
%0 = "riscv.li"() {"immediate" = 6 : i32} : () -> !riscv.reg<zero> |
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.
Shouldn't this start with
^0
?
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.
The first block is not printed if it doesn't have arguments, and only block that are printed get labels. It's sort of annoying, I'd like to fix it in the future, but right now that's how it is. I took the labels that xdsl-opt printed and put them on the input so that it wouldn't be confusing.
|
||
"riscv.ret"() : () -> () | ||
// CHECK-NEXT: ret | ||
^0(%b00 : !riscv.reg<>, %b01 : !riscv.reg<>): |
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.
Should this be indented --?
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.
dedented all
|
||
"riscv.ret"() : () -> () | ||
// CHECK-NEXT: "riscv.ret"() : () -> () | ||
^0(%2 : !riscv.reg<>, %3 : !riscv.reg<>): |
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.
Should this be indented --?
We've decided against this direction for the riscv dialect, we'll separate the label in the riscv dialect from its use as a control flow structure, and add this multi-block label at a higher level of abstraction. |
03a8d1c
to
4c7335c
Compare
Closing this for now, will probably reopen later |
@compor @AntonLydike can you please re-review? |
Considering that using both our paths to lower required this I'm happy to accept it. |
I put the return back in the middle because a lot more instructions are about to become terminators so it makes sense for them to be in order again