[LLVMdev] Using llc to compile a .ll into a .s for ARM

Jim Grosbach grosbach at apple.com
Tue Jun 22 08:21:35 PDT 2010


On Jun 21, 2010, at 9:45 PM, Matthew Huck wrote:

> Hi,
>   I've battled with this now for a good many hours, and I was wondering if someone could point in the right direction. What I want to do is with the kaleidoscope tutorial code, take the IR from a run where I've just done
> 
> "
> def test(x) 42.0*x;
> "
> 
> resulting in the file test.ll
> 
> "
> ; ModuleID = 'my cool jit'
> 
> define double @test(double %x) {
> entry:
>   %multmp = fmul double %x, 4.200000e+01          ; <double> [#uses=1]
>   ret double %multmp
> }
> "
> 
> and the use llvm-ar to compile that test.ll to a test.bc and then compile that to a .S which I can pass to the Android NDK to compile.
> 
> I've tried (to cut a long day short!)
> Compiling llvm with the "--target=arm-eabi" and "--target=arm-elf-linux-gnu" options.

That bit's not necessary. llvm builds for all supported targets by default.

> Calling llc with -march=thumb and -march=arm (I'm trying to create a asm file for the android NDK gcc)

While that will give you ARM code, you may want -mtriple instead, to make sure you get the right calling convention and other such things.

> I'm able to get the NDK to get close (by using thumb, and manually editing the asm a bit, but it still complains about ___mulfp being undefined.

In that case, you're building ARM code just fine, but are missing some runtime libraries for floating point. If you have hardware floating point available, you can get that by specifying either -mcpu= or adding it directly via attributes. For example, if you're targetting a Cortex-A8, which it sounds like you are, try -mcpu=cortex-a8.


Regards,
  Jim

> 
> So questions:
> Do I have to somehow get LLVM to use the binutils in the NDK?
> Do I have to do a full Canadian Cross, and actually host the final thing on the android?
> 
> Oh, I'm currently doing all this on Snow Leopard (but did try Ubunutu), and have tried both LLVM1.6 and LLVM1.7, and I'm using NDKr4
> 
> Thoughts?
> 
> Cheers
> 
> Matthew
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list