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

dialect: (riscv) Throw parser error if immediate is not given #1371

Merged
merged 6 commits into from
Aug 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions xdsl/dialects/riscv.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,8 @@ def custom_parse_attributes(cls, parser: Parser) -> Mapping[str, Attribute]:
)
elif immediate := parser.parse_optional_str_literal():
attributes["immediate"] = LabelAttr(immediate)
else:
parser.raise_error("Expected immediate")
Copy link
Member

Choose a reason for hiding this comment

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

Can you please make it non-optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure if that is possible. Immediate is either integer or string literal.

Copy link
Member

Choose a reason for hiding this comment

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

I would recommend adding a parse_immediate and parse_optional_immediate helper pair that return either an int or a string literal (or None)

if parser.parse_optional_punctuation(","):
attributes["rd"] = parser.parse_attribute()
return attributes
Expand Down