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

Unstructured control flow #889

Closed
lifpan opened this issue Mar 11, 2019 · 9 comments
Closed

Unstructured control flow #889

lifpan opened this issue Mar 11, 2019 · 9 comments
Labels
question Further progress depends on answer from issue creator.

Comments

@lifpan
Copy link
Contributor

lifpan commented Mar 11, 2019

Will you support unstructured control flow which don't use "OpLoopMerge" and "OpSelectionMerge"?

I'd like to add a member variable for SPIRBlock struct:
uint32_t after_block = 0; // The block literally resides just after current block.

@HansKristian-Work HansKristian-Work added the question Further progress depends on answer from issue creator. label Mar 11, 2019
@HansKristian-Work
Copy link
Contributor

I don't really understand the question. SPIRV-Cross can only support the requirements of the Shader programming model, i.e. structured control flow. Please elaborate with a concrete SPIR-V example.

@lifpan
Copy link
Contributor Author

lifpan commented Mar 12, 2019

I'm processing some SPIR-V shader from Apple Metal, which is unstructured control flow. It converts unstructured llvm to unstructured SPIR-V. I want to analyze it's control flow, so I'd like to add new member variable "after_block" to SPIRBlock struct. In this way, I could traverse all blocks in its literal order easily.
I think SPIRV-Cross could add a module to transform unstructured control flow to structured.

@HansKristian-Work
Copy link
Contributor

I see. I does sound more like this is more suited for SPIRV-Tools though. SPIRV-Cross imo, is not the right place to deal with SPIR-V -> SPIR-V transforms. SPIRV-Cross does not support serializing out the structured SPIR-V after performing the transform, so it won't be useful for consuming MSL in Vulkan. Is there a reason why this work must be done in SPIRV-Cross in particular?

@lifpan
Copy link
Contributor Author

lifpan commented Mar 12, 2019

No particular reason. Right, it's more suited for SPIRV-Tools. Would you accept this small change if I push it to git depo? I'd like to make my version of SPIRV parser consistent with depo's.

@HansKristian-Work
Copy link
Contributor

I think you'll get the same effect if you loop over SPIRFunction::blocks. Those are in module declaration order.

@lifpan
Copy link
Contributor Author

lifpan commented Mar 12, 2019

I see. Thanks!

@HansKristian-Work
Copy link
Contributor

HansKristian-Work commented Mar 12, 2019

Cool. Don't there is anything that should change in SPIRV-Cross right now, so closing. Good luck with the MSL transform!

@billhollings
Copy link
Contributor

@lifpan Interesting workflow. What toolchain are you using to go from MSL to SPIR-V?

@lifpan
Copy link
Contributor Author

lifpan commented Mar 13, 2019

@billhollings I'm not responsible for the translation of MSL->LLVM->SPIR-V. I don't know the detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further progress depends on answer from issue creator.
Projects
None yet
Development

No branches or pull requests

3 participants