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

SPIR-V: More codegen #8852

Merged
merged 12 commits into from
May 22, 2021
Merged

SPIR-V: More codegen #8852

merged 12 commits into from
May 22, 2021

Conversation

Snektron
Copy link
Collaborator

This PR adds again some more SPIR-V codegen stuff:

  • Reworked generation of float constants a bit, now uses Value.toFloat instead of the raw tag type.
  • Some general restructuring.
  • Integer encoding: This turned out to be harder than i anticipated, mostly because there is no decent way yet to obtain a 2s complement value for an int. For now, i handled it through toUnsignedInt and toSignedInt and then did some bit operations on that. I'm not yet sure how to encode "strange" integer types, so for now they're just inserted as an equivalent constant of the backing type.
  • Split out genCmp and genBinOp as Andrew suggested, though i have not yet removed the extra switch in genCmp, genBinOp and genUnOp.
  • A preliminary version of generating alloc, store and load.
    • They only work for local variables (with storage class Function) as of now. As these operations require pointers, and so more advanced stuff depends on more pointer metadata: address spaces #653. This is next on the agenda.
    • Local variables need to be declared in the first SPIR-V block, and so i made an additional arraylist in DeclGen to temporarily hold code generated by the current function, which OpVariable bypasses as it is inserted directly into spv.binary.fn_decls.
  • In order to get more useful error messages during developing i pass the instruction's source location to genType and genConstant, though i'm not actually sure whether this is the right source location (it points to the instruction instead of the type). Furthermore, how do i pass the proper source of stuff like types of function parameters?
  • With Stage2 whole file astgen #8554 merged, dbg_stmt now contains the actual source offset and so we can nicely generate that in SPIR-V debug info. Both OpLine and OpSource are emitted now.

@andrewrk andrewrk merged commit 63aabbb into ziglang:master May 22, 2021
@andrewrk
Copy link
Member

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants