[cfe-dev] Fwd: making the SPIR target work

Ronan KERYELL ronan at keryell.fr
Sat Nov 22 10:47:43 PST 2014


>>>>> On Sat, 22 Nov 2014 15:48:52 +0530, "Sahasrabuddhe, Sameer" <sameer.sahasrabuddhe at amd.com> said:

    Sameer> From the attachments, it seems like you have already done
    Sameer> some work to port the changes from the Khronos SPIR
    Sameer> generator to Clang. But it is not clear if you want to have
    Sameer> them reviewed and submitted. As far as I know, there is no
    Sameer> reason why they can't be submitted ... it's just that no one
    Sameer> has bothered to do it before. It would be useful if you
    Sameer> submit each patch as a separate review request.

+1

    Sameer> Like Pekka said, SPIR 1.2 is based on LLVM 3.2, and there is
    Sameer> no guarantee that the generated IR will be valid SPIR. But
    Sameer> there is no harm in making sure that the SPIR target is
    Sameer> maintained so that the generated IR is as close to SPIR 1.2
    Sameer> as possible.

+1
That would ease the work for people generating SPIR 1.2...

    Sameer>  One could write a side-project that translates
    Sameer> the LLVM IR to version 3.2 in order to produce perfect SPIR
    Sameer> 1.2 if necessary. On the other hand, SPIR 2.0 is still
    Sameer> provisional, so it's too early to say if those changes
    Sameer> should be submitted to Clang.

And anyway we would have the same issue since SPIR 2.0 is based on LLVM
IR 3.4, which is older than the ToT, by definition of the release
concept.

But there are some tools based on ToT that are able to generate SPIR
1.2, such as the OpenCL SYCL compiler from Codeplay. But I do not know
how they do this, since it is not open source. A post-processor that
downgrades the post-modern LLVM IR to SPIR 1.2 or a direct SPIR 1.2
generator inside ToT LLVM?

Since everybody will have the same issue, it would be nice to have an
Open Source translator ToT LLVM IR -> SPIR 1.2 -> ToT LLVM IR backed by
the Khronos Group and upstreamed in ToT. Since LLVM IR is expected to be
upward compatible, the last translation may be useless or just easy to
implement...
-- 
  Ronan KERYEL



More information about the cfe-dev mailing list