-
Notifications
You must be signed in to change notification settings - Fork 57
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
Move OpPhi into BasicBlock #58
Comments
This would allow us to have a class on this Op (say "FunctionStruct"), which would in turn make the structured implementation more straightforward. |
@antiagainst please see the draft implementation in 6541019 |
If we were to do this then it would probably make sense to also make the label non-optional and have another field that stores the termination instruction that must be the last instruction in the block (and maybe even an optional merge that must be the second to last). These define a block so the only way you could end up not being able to make a block is if a function isn't followed by an |
The data representation is currently written (consistently!) in a way that makes most of the things optional (that are otherwise not by the spec). Addressing this, if requested, should be a separate effort/issue. Saying that, the WIP structured representation (see #46) doesn't do it and instead makes required things be actually non-optional, so fixing the data representation isn't a huge priority to me at this point. |
I initially designed the DR as-is to also make it possible to have minimal verification in the parser itself and support invalid cases so that we can even import broken SPIR-V blobs and investigate what is wrong with it. Now I feel whether that's useful is up to debate. I'm not opposed to revisiting this if it become a burden to maintain. If to drop this guarantee, then mandating the leading But I don't quite see why we'd like to special case |
I don't mind DR going either way.
I would prefer (3) or (4). @antiagainst what choice do you suggest? |
Shouldn't SR have its own BasicBlock type that can store all the extra information? I feel like that would solve the problem, although I may have misunderstood how the DR and SR are seperated. |
Yes, SR will have it's own block struct. It doesn't require DR to respect |
Going more structured in SR makes sense for me (well that's the purpose)! So SGTM to have separate struct and place it at the beginning of BasicBlock SR. I'm still not sold on changing DR to specially treat phi though. It's strange for us to only specially handle phi but not other terminators etc; it feels in an inconsistent state. If we want to do it, better to also consider having the terminator separated out from the list of instructions. (Another annoying thing that I forgot to mention is OpLine. DR doesn't handle OpLine properly. IMO OpLine is a strange thing in the spec given it can appear almost everywhere, even at structural places, which breaks the module structure... Making the DR more "structured' we will also encounter this more too.) What do you mean by "fix the DR to handle it properly (without changing the way OpPhi is represented)" in 3? If it means still keeping OpPhi as an instruction in the main But if you'd really like to separate phi reprenstation out in DR, please also do it for terminators. |
I'll just proceed with only recognizing OpPhi at the SR level. Thank you for your thoughts! |
The spec says that
OpPhi
has to appear within a block before any other instruction (except for "OpLabel", which is already hard-wired to theBasicBlock
). Would it make sense to represent it as this?The text was updated successfully, but these errors were encountered: