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

dialects: (riscv) label region is multi block #1172

Merged
merged 4 commits into from Jul 19, 2023

Conversation

superlopuh
Copy link
Member

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

@superlopuh superlopuh added the dialects Changes on the dialects label Jun 21, 2023
@superlopuh superlopuh self-assigned this Jun 21, 2023
@compor
Copy link
Collaborator

compor commented Jun 21, 2023

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.

@superlopuh
Copy link
Member Author

What for?

@compor
Copy link
Collaborator

compor commented Jun 21, 2023

What for?

Because I don't think it will pass the terminator tests in the middle of a module.
They need to be surrounded by a placeholder dummy region+block, no?
If for example we make the unconditional jumps terminators.

Nevermind me, I missed the block added in the diff :)

@superlopuh superlopuh force-pushed the sasha/riscv/label-multi-block branch from 8a72b03 to 9a62634 Compare June 21, 2023 15:58
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.01 ⚠️

Comparison is base (e781c09) 89.34% compared to head (ec35c17) 89.34%.

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              
Impacted Files Coverage Δ
xdsl/dialects/riscv.py 83.75% <100.00%> (-0.02%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@JosseVanDelm
Copy link
Collaborator

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.

I'm sorry I can not follow anymore, what did this PR change?

a lot more instructions are about to become terminators

Because we are going to match the behaviour of CF dialect? With risc-v jmp instruction becoming some type of terminator for example?

@superlopuh
Copy link
Member Author

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

Copy link
Collaborator

@AntonLydike AntonLydike left a 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>} : () -> ()
Copy link
Collaborator

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?

Copy link
Member Author

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

Comment on lines +91 to +102
"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
Copy link
Collaborator

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?

Copy link
Member Author

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

Comment on lines +86 to +97
"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<>) -> ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thing here

Copy link
Collaborator

@JosseVanDelm JosseVanDelm left a 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<>):
Copy link
Collaborator

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>
Copy link
Collaborator

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?

Copy link
Member Author

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<>):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be indented --?

Copy link
Member Author

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<>):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be indented --?

@superlopuh
Copy link
Member Author

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.

@superlopuh superlopuh marked this pull request as draft June 26, 2023 12:43
@superlopuh superlopuh force-pushed the sasha/riscv/label-multi-block branch from 03a8d1c to 4c7335c Compare June 27, 2023 20:36
@superlopuh superlopuh marked this pull request as ready for review June 27, 2023 20:36
@superlopuh
Copy link
Member Author

Closing this for now, will probably reopen later

@superlopuh superlopuh closed this Jul 2, 2023
@superlopuh superlopuh reopened this Jul 17, 2023
@superlopuh
Copy link
Member Author

@compor @AntonLydike can you please re-review?

@compor compor self-requested a review July 17, 2023 15:26
@compor
Copy link
Collaborator

compor commented Jul 18, 2023

Considering that using both our paths to lower required this I'm happy to accept it.
There are a few things to explore, but AFAIC this is now desirable.

@superlopuh superlopuh merged commit 7b597fc into main Jul 19, 2023
10 checks passed
@superlopuh superlopuh deleted the sasha/riscv/label-multi-block branch July 19, 2023 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialects Changes on the dialects
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants