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: Raise a parsing error in accfg.setup when result type is invalid #3990

Open
wants to merge 1 commit into
base: math-fehr/stack/4
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
7 changes: 7 additions & 0 deletions tests/filecheck/dialects/accfg/invalid.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: xdsl-opt --split-input-file --parsing-diagnostics %s | filecheck %s

%one = "test.op"() : () -> i32
%zero = arith.constant 0 : i32
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is %zero used? Am I missing something?

%state = accfg.setup "acc1" to ("A" = %one : i32) : !accfg.state<"acc2">

// CHECK: expected !accfg.state<"acc1">, but got !accfg.state<"acc2">
7 changes: 6 additions & 1 deletion xdsl/dialects/accfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,19 @@ def parse_itm() -> tuple[str, SSAValue]:
attributes = parser.parse_optional_attr_dict()

parser.parse_punctuation(":")
pos = parser.pos
res_typ = parser.parse_type()
if res_typ != StateType(accelerator):
parser.raise_error(
f"expected {StateType(accelerator)}, but got {res_typ}", pos
)

setup_op = cls(
[val for _, val in args],
[name for name, _ in args],
accelerator,
in_state,
)
setup_op.out_state.type = res_typ
setup_op.attributes.update(attributes)
return setup_op

Expand Down
Loading