[llvm-dev] Generating SPIR

Nicholas Wilson via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 20 05:22:49 PST 2017


Well it’s better than nothing! Thanks I will see what I can do with that.

Also that code looks suspiciously like the stuff for clang and LDC SPIR-V 
frontend metadata emission. Looks like it shouldn’t be too much effort.

> On 20 Dec 2017, at 9:00 pm, Ronan KERYELL <ronan-list at keryell.fr> wrote:
> 
>>>>>> On Tue, 19 Dec 2017 14:03:01 +0000, Neil Henning via llvm-dev <llvm-dev at lists.llvm.org> said:
> 
>    Neil> For SPIR 1.2 you can use this repo + the instructions in it
>    Neil> https://github.com/KhronosGroup/SPIR
> 
>    Neil> I don't believe there is a way to generate SPIR from LLVM
>    Neil> trunk.
> 
> Well, I guess there are some companies like Codeplay with this in
> house, but it is not open-source...
> 
> If you use the current Clang/LLVM to generate SPIR from OpenCL, it will
> generate actualy a SPIR-ish output (what I call SPIR "de facto"),
> basically something that looks like SPIR but that is actually not
> compliant, since SPIR 1.2 standard states that it has to be based on LLVM
> 3.2 IR and SPIR 2.0 has to be based on LLVM 3.4 IR.
> 
> Interestingly, the LLVM metadata are generated by... Clang in
> tools/clang/lib/CodeGen/CodeGenFunction.cpp by
> clang::CodeGen::CodeGenFunction::EmitOpenCLKernelMetadata when compiling
> OpenCL.
> 
> 
> Inside triSYCL https://github.com/triSYCL/triSYCL (a prototype for SYCL,
> the single-source modern C++ standard from Khronos on top of OpenCL) I
> have a hack for LLVM 3.9 to generate some SPIR "de-facto" directly at
> the LLVM level, since I do not use the Clang OpenCL front-end.  Look at
> https://github.com/triSYCL/llvm/blob/ronan/sycl/lib/SYCL/inSPIRation.cpp
> 
> In my case, even if it is not compliant, it seems to work with PoCL or
> Xilinx SDx/xocc for FPGA.
> It should not be difficult to migrate this to ToT if it can help your
> use case.
> 
> Then remains the question about how to generate real compliant SPIR from
> both possible paths.
> There are some open-source LLVM IR downgrading writer around as already discussed on
> this mailing list
> http://lists.llvm.org/pipermail/llvm-dev/2016-August/103395.html
> 
> So to conclude, the big picture is a little bit messy for now... :-(
> -- 
>  Ronan KERYELL



More information about the llvm-dev mailing list