clspv icon indicating copy to clipboard operation
clspv copied to clipboard

Spirv as target

Open seanbaxter opened this issue 4 years ago • 1 comments

I wrote the Circle C++ compiler. I'm considering integrating graphics shaders as a single-source language extension, similar to how CUDA integrates as single source with the host compiler.

Andrew Richards directed me here. I'm not entirely understanding what clspv is, or if it could be used to help me generate SPIRV.

Currently I generate LLVM/x64 and LLVM/NVVM by descending my translation unit's AST. Ideally there'd be a SPIRV LLVM target, so that I could create a llvm::Module in the same context as the rest of the translation unit, and they'd share the same types, and I'd just re-use the same codegen code, descend down the AST, and use IRBuilder to produce function definitions for this SPIRV Module.

I don't know if this is part of clspv, or if it's part of SPIRV-Tools, or if it's part of the LLVM trunk. What should I be looking at to get this started?

sean

seanbaxter avatar May 22 '20 17:05 seanbaxter

From LLVM to SPIR-V there is clspv (OpenCL C to shader SPIR-V) and the SPIRV-LLVM-Translator (bidirectional translation between kernel SPIR-V and OpenCL C LLVM IR, but doesn't do shader SPIR-V). You'd have to generate IR that looks like OpenCL (e.g. right address spaces). You can play with such a flow by running clspv with -x ir on the command line to take LLVM IR as input.

alan-baker avatar May 28 '20 12:05 alan-baker