Hi. I am looking into generating SPIR from within a JIT compiler for a high level language using LLVM C++ API. The first step is to of course build LLVM with SPIR backend support and I am currently using LLVM 3.3. For reference, the host system is a x86-64 Linux. I first tried building LLVM 3.3 without specifying any targets, and it built many targets including aarch64, arm, x86, x86_64, nvptx etc but no spir or spir64 targets. Next, I tried to explicitly configure targets as follows: --enable-targets=x86_64,spir,spir64 but I got "unrecognized target spir". Any idea how to proceed? Do I need to apply some patches to LLVM? (Note that Clang is not involved, this is purely a LLVM question). rahul
Hi Rahul, On 5 September 2014 19:21, Rahul Garg <rahulgarg44 at gmail.com> wrote:> I am looking into generating SPIR from within a JIT compiler for a > high level language using LLVM C++ API. The first step is to of course > build LLVM with SPIR backend support and I am currently using LLVM > 3.3.As far as I know, there's no such thing as a SPIR backend, or the ability to translate fully generic LLVM IR into SPIR. If you want to generate SPIR, you have to know the restrictions it imposes and follow them. Where LLVM gets involved is that OpenCL compilers which accept SPIR input will (probably) pass it on to the usual LLVM backends (x86, ARM, bizare-GPU-43712) to translate into the appropriate machine code. Also, be aware that LLVM changes quickly. SPIR still seems to be based on version 3.2 which was nearly 2 years ago. You'd certainly hit issues trying to mix it with modern LLVM IR, and I'd not want to risk it with 3.3 either. Cheers. Tim.
Thanks. I am not trying to modify convert generic LLVM IR and know the requirements (such as specifying address spaces etc.). I guess I just need to ensure that I am sticking to LLVM 3.2 and the SPIR specified subset+ metadata annotations etc. Anyway, I was confused partly because there are references to a SPIR backend in LLVM code (eg: include/llvm/ADT/Triple.h lists spir and spir64 as possible architectures) rahui On Fri, Sep 5, 2014 at 2:55 PM, Tim Northover <t.p.northover at gmail.com> wrote:> Hi Rahul, > > On 5 September 2014 19:21, Rahul Garg <rahulgarg44 at gmail.com> wrote: >> I am looking into generating SPIR from within a JIT compiler for a >> high level language using LLVM C++ API. The first step is to of course >> build LLVM with SPIR backend support and I am currently using LLVM >> 3.3. > > As far as I know, there's no such thing as a SPIR backend, or the > ability to translate fully generic LLVM IR into SPIR. If you want to > generate SPIR, you have to know the restrictions it imposes and follow > them. > > Where LLVM gets involved is that OpenCL compilers which accept SPIR > input will (probably) pass it on to the usual LLVM backends (x86, ARM, > bizare-GPU-43712) to translate into the appropriate machine code. > > Also, be aware that LLVM changes quickly. SPIR still seems to be based > on version 3.2 which was nearly 2 years ago. You'd certainly hit > issues trying to mix it with modern LLVM IR, and I'd not want to risk > it with 3.3 either. > > Cheers. > > Tim.