Is there an API for generating SPIR-V assembly?

I’m writing a front-end to generate SPIR-V and I was hoping there was a C/C++ API for building SPIR-V (like the LLVM API). This would be nicer than generating raw text since I wouldn’t have to worry as much about syntax.

I know that SPIRV-Tools can assemble SPIR-V as a string, so is it my best bet to generate raw text and use this?


If you’re writing a front-end that generates SPIR-V, then it should generate SPIR-V, which is a binary format. For debugging purposes, you may need to generate text, but I would try to make that work through SPIRV-Tools (ie: generate binary and make the tool generate text).

I was able to find a Java tool for generating SPIR-V, but not a C++ one.