-
Notifications
You must be signed in to change notification settings - Fork 66
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
Unit Attribute Handling #161
Conversation
Hmm, I'm not sure I really like this approach :/ But it's maybe because I don't understand what is the problem. If we defined a |
Yeah, you are right, I overlooked that problem. I will draft a version, that adds a |
src/xdsl/printer.py
Outdated
self.print("\"%s\" = " % attribute_list[0][0]) | ||
self.print_attribute(attribute_list[0][1]) | ||
self._print_attr_string(attribute_list[0][0], attribute_list[0][1], | ||
True) |
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.
If anyone sees a way to make this nicer, please tell me!
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.
There should be a print_list
method in Printer
that should do what you want ;)
That way, you can remove your if not first: self.print(", ")
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.
Wow, that is way better!
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.
Besides my comments, this looks good!
src/xdsl/printer.py
Outdated
self.print("\"%s\" = " % attribute_list[0][0]) | ||
self.print_attribute(attribute_list[0][1]) | ||
self._print_attr_string(attribute_list[0][0], attribute_list[0][1], | ||
True) |
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.
There should be a print_list
method in Printer
that should do what you want ;)
That way, you can remove your if not first: self.print(", ")
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.
LGTM, we can squash and merge it if you want!
This PR concerns UnitAttrs and how to handle them as I need it to add a
llvm.emit_c_interface
to a function operation.Currently, this is primarily a hack that I used to get UnitAttrs through the MLIRConverter, but I think this nicely opens the can of worms that is design decisions around UnitAttrs.
The approach of this PR is an implicit one. Anything that maps a str to
None
is just a UnitAttr with that name.Obviously, this does not add any functionality to
AttributeDef
and just hacks around in the attributes dictionary currently. However, I feel that this might not be too bad, at least not the spirit of it. In my understanding, UnitAttrs are not really something you want to define in an AttributeDef (unless it is as part of an OptAttr), but rather information you want to pass down by just adding some attribute.On the user-side I have this code: