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.
SPIR/SPIR64 are IR triples, but not backend targets, which is why enabling them as targets failed. SPIR binaries can be loaded into the llvm infrastructure as of LLVM 3.2, though I'm not sure about compatibility with later versions. The loaded module still needs to be lowered to their target specific version before anything is done in order to produce valid code. Micah> -----Original Message----- > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On Behalf Of Rahul Garg > Sent: Friday, September 05, 2014 12:50 PM > To: llvmdev at cs.uiuc.edu > Subject: Re: [LLVMdev] Enabling SPIR target in LLVM 3.3 > > 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. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Thanks Micah! I have switched to LLVM 3.2 instead of using 3.3 and now attempting to generate SPIR. On Tue, Sep 9, 2014 at 2:30 PM, Micah Villmow <micah.villmow at smachines.com> wrote:> SPIR/SPIR64 are IR triples, but not backend targets, which is why enabling them as targets failed. SPIR binaries can be loaded into the llvm infrastructure as of LLVM 3.2, though I'm not sure about compatibility with later versions. The loaded module still needs to be lowered to their target specific version before anything is done in order to produce valid code. > > Micah > >> -----Original Message----- >> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] >> On Behalf Of Rahul Garg >> Sent: Friday, September 05, 2014 12:50 PM >> To: llvmdev at cs.uiuc.edu >> Subject: Re: [LLVMdev] Enabling SPIR target in LLVM 3.3 >> >> 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. >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev