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

[calyx] fix calyx canonicalization. #7456

Merged
merged 7 commits into from
Aug 10, 2024

Conversation

linuxlonelyeagle
Copy link
Member

See issue.
Honestly, I saw this bug a few months ago and I think I fixed it, just like this PR did. But I don't think it was enough.

test.mlir:2:3: note: see current operation: 
"calyx.component"() ({
^bb0(%arg0: i1, %arg1: i1, %arg2: i1, %arg3: i1):
  %0:6 = "calyx.register"() {sym_name = "r"} : () -> (i1, i1, i1, i1, i1, i1)
  "calyx.wires"() ({
  ^bb0:
  }) : () -> ()
  "calyx.control"() ({
  ^bb0:
  }) : () -> ()
}) {function_type = (i1, i1, i1, i1) -> (), portAttributes = [{go}, {clk}, {reset}, {done}], portDirections = -8 : i4, portNames = ["go", "clk", "reset", "done"], sym_name = "main"} : () -> ()

The problem is as I said in the issue, solved he still reports an error because now calyx.control is empty after -canonicalize.
So a few months ago I tried to include stricter restrictions, but I didn't have too good an idea.
Now my idea, when checking calyx.control, that op must have calyx.enable,calyx.invoke alive fsm.machine present. but it also causes other problems.
On the one hand, I want to discuss it, and on the other hand, I think this PR makes sense.There is no test file because there are no examples of errors reported after -canonicalise in the existing test file.

@rachitnigam
Copy link
Contributor

Thanks for creating this @linuxlonelyeagle! I think we should add a text with the three cases you mentioned so that future PRs don't break it. I'm also wondering if we should start canonicalizing away empty control programs (if with empty bodies etc.) so passes can make stronger assumptions about the shape of programs.

Copy link
Member

@cgyurgyik cgyurgyik left a comment

Choose a reason for hiding this comment

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

A few smaller comments, but otherwise LGTM.

lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
test/Dialect/Calyx/errors.mlir Show resolved Hide resolved
@cgyurgyik
Copy link
Member

I'm also wondering if we should start canonicalizing away empty control programs (if with empty bodies etc.) so passes can make stronger assumptions about the shape of programs.

+1

linuxlonelyeagle and others added 3 commits August 9, 2024 16:17
Optimized code.

Co-authored-by: Chris Gyurgyik <[email protected]>
Optimize error reporting.

Co-authored-by: Chris Gyurgyik <[email protected]>
Copy link
Member

@cgyurgyik cgyurgyik left a comment

Choose a reason for hiding this comment

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

LGTM, I see this as an incremental improvement. Thanks!

lib/Dialect/Calyx/CalyxOps.cpp Outdated Show resolved Hide resolved
@linuxlonelyeagle
Copy link
Member Author

Can you help me merge codes? Thanks!

@rachitnigam rachitnigam merged commit 286e73e into llvm:main Aug 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants