-
Notifications
You must be signed in to change notification settings - Fork 78
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
ir: use value.Value for operands of instructions? #50
Comments
I played with the official python API and everything being a value (including instructions that do not return a value) was bewildering. Don't know what's better in this case, though. |
I agree, you kind of feel like a compiler construction Wizard when everything can be used as an operand to everything else. I think we've struck a good balance atm with what instructions implement the Regarding this issue, we are trying to figure out if relaxing the type constraints on the concrete struct types of various instructions may allow for more powerful data flow analysis APIs in future releases of llir/llvm. There is an obvious trade-off. The more concrete of a type you have as members of the structs, the more knowledge is presented to the user, e.g. using However, if we relax this and use value.Value throughout, then we could have APIs that allow not only retrieval of information about value uses throughout the IR, but also makes it possible to have APIs that update the values through We will continue to collect information, and see what are the various benefits and drawbacks with different approaches. I think I'm starting to lean more and more to the side of using Wish you a great winter holidays and happy coding! Cheers, |
Hmm, I've been using the help wanted labels for indicating that we'd like to get more input and various views for the design discussions. Perhaps this label is more often interpreted to mean something along the lines of we need help to implement this rather than please join our discussion to nail the API. Should we add a new label (e.g. ongoing discussion, user input wanted, or something along those lines) instead? cc: @pwaller. |
Perhaps this label is more often interpreted to mean something along the lines of *we need help to implement this*
Yes, that's how I interpret it.
Should we add a new label (e.g. *ongoing discussion*, *user input wanted*, or something along those lines) instead?
SGTM.
|
Good. I've added the proposal label now, perhaps that is enough to indicate that this is a design decision that needs to be fleshed out and that welcome anyone to contribution to the discussion. |
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
Note: this commit is targetted for the v0.4 release. Updates llir#50.
* ir: use value.Value for Scope of InstCatchPad and InstCleanupPad Note: this commit is targetted for the v0.4 release. Updates #50. * ir: use value.Value for Pred of Incoming in InstPhi Note: this commit is targetted for the v0.4 release. Updates #50. * ir: use value.Value for basic block targets and operands of terminators Note: this commit is targetted for the v0.4 release. Updates #50. * ir: remove unused isUnwindTarget UnwindTarget is now essentially the value.Value interface. * ir: remove unused isUnwindTarget and isExceptionScope
Note, the v0.3.0 release had a few changes to the API. The most intrusive one may be to use value.Value in all places where operands of instructions are used. This has both pros and cons, where the cons include less exact types used for instruction and terminator operands. The benefit is that this change enable a unified and quite powerful use-tracking API, as further outlined in llir/llvm#50, llir/llvm#122 and llir/irutil#1.
This has come up in discussion and would enable APIs such as
Operands() []*value.Value
, which would allow not only use tracking, but also value replacement; as proposed by @pwaller. (ref: #42)Depending on how far we wish to take this API change, there are some benefits and drawbacks. The main drawback I can see is if we change instructions (and terminators) to take
value.Value
instead of*ir.BasicBlock
, since then users of the API cannot make use of the basic block directly, but would have to type assert to inspect the instructions of the basic block for instance. This is also true for thephi
instruction, for whichIncoming
may be redefined as follows:Another instruction that would change is
catchdad
, which would take avalue.Value
instead of the concrete type*TermCatchSwitch
:Besides the
phi
andcatchpad
instructions, quite a few terminators would be update to make use ofvalue.Value
instead of*ir.BasicBlock
.The
catchret
terminator would take avalue.Value
instead of*ir.InstCatchPad
It is also possible we'd have to update ir.Case to take a
value.Value
instead of aconstant.Constant
if we want to use this approach for also refining/updating/replacing values and not just for read-only access to operands.I'm currently on the fence whether this change is good or not. The data types become less exact with what values they may contain, and specifically for basic blocks, users of the API would have to type assert to access the fields specific to basic blocks (such as its instructions). On the other hand, it would enable a general and quite powerful API for operand tracking and replacement.
I'll label this for the v0.4.0 release for now, as it mostly targets data analysis and the use-def chains API.
Any input is warmly welcome.
Cheers,
/u
The text was updated successfully, but these errors were encountered: