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

Stage 2: SPIR-V setup #7827

Merged
merged 8 commits into from
Feb 1, 2021
Merged

Stage 2: SPIR-V setup #7827

merged 8 commits into from
Feb 1, 2021

Conversation

Snektron
Copy link
Collaborator

@Snektron Snektron commented Jan 19, 2021

This pull request introduces the initial setup for a self-hosted stage 2 SPIR-V backend. It includes the following things:

  • I wrote a quick tool that can generate Zig-code from SPIR-V JSON specifications. A description of the schema of such a specification can be found on the Khronos website. Specification JSON files can be obtained from the SPIR-V headers project. The generator supports both core and extension grammars, and simply generates all enums and bit fields. This should help to make the code generation a bit more sane.
  • A generated spec for the SPIR-V core grammar was added.
  • 2 new architectures are added (spirv32 and spirv64), and 3 new operating systems are defined (OpenCL, GLSL450 and Vulkan).
    • SPIR-V requires a memory model to be specified for the final module. This operation takes an addressing mode (either Logical, Physical32 or Physical64, among others), and a memory model itself.
    • The GLSL450 and Vulkan memory models only support the logical addressing mode. In this mode, pointers are opaque. For these architectures, the difference between spirv32 and spirv64 will simply be the integer used for usize. Note that for Vulkan targets, 64-bit (as well as 8 and 16-bit) integers need to be explicitly enabled.
    • The OpenCL memory models support the Physical32 and Physical64 addressing models as well. spirv32 and spirv64 map to Physical32 and Physical64 respectively.
  • Finally, i made a setup for linker and codegen for the SPIR-V binary format. Currently, it is capable of generating a very basic binary containing the SPIR-V header and some initial capability and memory model instructions.

Related: #2683

@andrewrk andrewrk merged commit 102d954 into ziglang:master Feb 1, 2021
jayschwa added a commit to jayschwa/zig that referenced this pull request May 5, 2021
PR ziglang#7827 added some new `std.Target.Os.Tag` before `other`.
The corresponding enum in stage1.h was not updated, which caused a
mismatch in the underlying integer values. While attempting to target
`other`, I encountered crashes.

This PR updates the stage1.h enum to include the added OS tags.
The new tags also had to be added to various switch cases to fix
compiler warnings, but have not been tested in any way.
andrewrk pushed a commit that referenced this pull request May 5, 2021
PR #7827 added some new `std.Target.Os.Tag` before `other`.
The corresponding enum in stage1.h was not updated, which caused a
mismatch in the underlying integer values. While attempting to target
`other`, I encountered crashes.

This PR updates the stage1.h enum to include the added OS tags.
The new tags also had to be added to various switch cases to fix
compiler warnings, but have not been tested in any way.
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