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

[spirv] Add bare bone code for SPIR-V codegen #233

Merged
merged 3 commits into from
May 5, 2017

Conversation

antiagainst
Copy link
Contributor

  • Add libclangSPIRV and skeleton ASTFrontendAction for SPIR-V
  • Add -spirv into dxc for invoking EmitSPIRVAction
  • Build SPIR-V codegen conditionally using ENABLE_SPIRV_CODEGEN
    in CMake and -spirv in hctbuild.

For #216

cc @dneto0 @ehsannas

Added ENABLE_SPIRV_CODEGEN in CMake config to control the
building of SPIR-V component and wrap up SPIR-V code using it.
Also add -spirv to hctbuild to turn it on.
@msftclas
Copy link

@antiagainst,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@antiagainst antiagainst changed the title Add bare bone code for SPIR-V codegen [spirv] Add bare bone code for SPIR-V codegen Apr 19, 2017
@AppVeyorBot
Copy link

@thewilsonator
Copy link

thewilsonator commented Apr 19, 2017

@antiagainst What are your plans for generating the SPIR-V? I ask because I am in the process of redoing, for want of a better word, Khronos' SPIRV-LLVM for LLVM trunk utilising TableGen with the idea to more easily support SPIR-V graphics (as opposed to purely compute). Are you interested in collaborating ?

edit: Ah, I see you plan to do it straight for the AST.

@antiagainst
Copy link
Contributor Author

antiagainst commented Apr 19, 2017

@thewilsonator: This is the project repo right? That's super cool! Yep, we go from AST directly to SPIR-V. So we won't use LLVM IR or its derivatives. Our focus is translating HLSL. We've listed our thoughts in #216 with more details in docs/SPIR-V.rst.

@thewilsonator
Copy link

That's the one, although there is also some changes (build system related and intrinsics) that are in my fork of LLVM. Would you be interested in the TableGen files for specifying the SPIRV binary format? I have sections 3.1 through 3.31 complete and section 3.32.1 through 7 of the SPIRV spec done and am working on the rest of section 3.32 atm (though I can put the incomplete version up if you want to start asap). You would still need to do the ExtInsts for Vulkan, as my priority is the OpenCL ExtInsts.

@antiagainst
Copy link
Contributor Author

@thewilsonator: TableGen for SPIR-V binary format is definitely helpful to us. Would you mind to share a link? I only found one .td file in the repo which seems just a skeleton.

@dneto0
Copy link
Collaborator

dneto0 commented Apr 28, 2017

@thewilsonator : Are you using the JSON grammar files from SPIRV-Headers, for the core and extended instruction specs? That way updates for new revisions and standard extensions can be supported automatically.

(Actually, isn't this off topic for this PR?)

@thewilsonator
Copy link

thewilsonator commented Apr 28, 2017

@antiagainst sure
The enums are done as are the operands. The instructions are all done except for 3.32.10 Image instructions (PRs welcome!), and 3.32.22 Device-Side Enqueue Instructions.

The only major thing lacking is a tablegen backend for it, but I don't think it should be too difficult and you'll probably want different stuff printed out anyway.

Sorry for the late reply. If there's anything confusing just open an issue. The only major thing I think I will refactor soon is instruction taking a variable number of words (atm instruction with string literals are implicitly assumed to be "variadic").
(Also I have no idea about how tablegen is supposed to be used, I just fitted the specification to the .td format learning as i went. If I should be using dags instead of whatever or anything else please tell me!)

@thewilsonator
Copy link

@dneto0 No I'm going off of the .pdf of the spec. The json loses a lot of info w.r.t e.g. the types of the IdRef, IdResultType and IdResult operands. Perhaps it would be possible from the .xml but my past experience of trying to parse the Vulkan spec was not fun.

@antiagainst
Copy link
Contributor Author

@thewilsonator: Thanks for the links! I'll take a look.

@marcelolr marcelolr merged commit 2c7a3fc into microsoft:master May 5, 2017
@antiagainst antiagainst deleted the spirv-bare-bone branch May 7, 2017 20:21
ehsannas pushed a commit to ehsannas/DirectXShaderCompiler that referenced this pull request May 30, 2018
clang-spirv-tests uses a lot of external projects that keep
themselves clean with different standards of warnings flags.
This alters the appropriate cmake files to disable flags that
the DXC build enables.
Fixes 72 gcc and 166 clang warnings.

Additionally catch some sign mismatch comparisons in tests
built as part of clang-spirv-tests.
Fixes 2 gcc and 2 clang warnings, but one of them has multiple sources
So it's kind of a lot more.

Contributes to google#206
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.

None yet

6 participants