code generation for ARM

Hello,

I am getting the following error while generating code for arm using llc for one of the specint2000 benchmark. Though same works for x86 target.

Command => llc -march=arm 186.crafty/186.crafty.rel.bc -o 186.crafty/186.crafty.m5arm.s

Error => LLVM ERROR: Couldn’t allocate output reg for constraint ‘{cx}’!

Have anyone seen this before? Is there a work around for this? I have tried different register allocator using option “-regalloc=<>” to llc. It happens with all the register allocators.

Thanks
Daya

Hi Daya,

I am getting the following error while generating code for arm using llc for one
of the specint2000 benchmark. Though same works for x86 target.

Command => llc -march=arm 186.crafty/186.crafty.rel.bc -o
186.crafty/186.crafty.m5arm.s
Error => LLVM ERROR: Couldn't allocate output reg for constraint '{cx}'!

Have anyone seen this before? Is there a work around for this? I have tried
different register allocator using option "-regalloc=<>" to llc. It happens with
all the register allocators.

where did the bitcode come from? If the bitcode contains x86 inline assembler
then it is normal that it won't work on arm.

Ciao, Duncan.

Hello

Command => llc -march=arm 186.crafty/186.crafty.rel.bc -o
186.crafty/186.crafty.m5arm.s
Error => LLVM ERROR: Couldn't allocate output reg for constraint '{cx}'!

Have anyone seen this before?

It seems you're feeding x86-specific LLVM IR to arm backend. Please
don't do that.

Thanks for your reply.

I have a normal (…/configure --enable-profiling --disable-optimized --enable-assertions) llvm debug+profile+assert build.

I am generating llvm-bitcode using following commands.

llvm-gcc -DLINUX_i386 -DSPEC_CPU2000 -O3 -emit-llvm 186.crafty/src/valid.c -c -o 186.crafty/src/valid.bc

I believe you indeed need to specify some ARM-related things when buliding LLVM and LLVM-gcc (if you are compiling it from source). Below are the configurations I used, I believe. I may have tweaked them a bit, but this was the general idea:

Configure llvm:
…/llvm-2.9/configure --target=arm-none-linux-gnueabi --prefix=/home/grwright1/Research/llvm/llvm-install --with-llvmgccdir=/home/grwright1/Research/llvm/llvm-gcc --disable-multilib --disable-bootstrap --disable-optimized --enable-shared --enable-assertions --enable-languages=c,c++

Configure llvm-gcc:
…/llvm-gcc-4.2-2.9.source/configure --target=arm-none-linux-gnueabi --program-prefix=llvm-arm- --prefix=/home/grwright1/Research/llvm/llvm-gcc/install -with-sysroot=/home/grwright1/Research/llvm/arm-2010q1/arm-none-linux-gnueabi/libc --with-gnu-ld=/home/grwright1/Research/llvm/arm-2010q1/bin/arm-none-linux-gnueabi-ld --with-gnu-as=/home/grwright1/Research/llvm/arm-2010q1/bin/arm-none-linux-gnueabi-as --with-gnu-ar=/home/grwright1/Research/llvm/arm-2010q1/bin/arm-none-linux-gnueabi-ar --enable-llvm=/home/grwright1/Research/llvm/llvm-obj --disable-optimized --disable-multilib --disable-bootstrap --disable-shared --enable-checking --enable-languages=c,c++

-Griffin

-DLINUX_i386 seems like it might be including x86-specific assembly or intrinsics.

Steve

Hi Daya,

And there is not inline assembly in my C code.

there may well be in header files you include.

     > Error => LLVM ERROR: Couldn't allocate output reg for constraint '{cx}'!

This error message is complaining about inline assembler.

Ciao, Duncan.

Thank you all for the inline assembly pointer.

I have some macros (FD_ZERO, FD_SET) in benchmark code which comes from C library select (synchronous I/O multiplexing) and it does contain inline assembly. Is there a way the code containing such macros can work for ARM if compiled through llvm?

Thanks
Daya

Hi,

If you want your program to work, you will have to link against a library built for ARM. Linking against library headers built for x86 will not work, as you are finding out.

You should also give llvm-gcc the –march=arm option as well as llc, because bitcode is not target independent.

Cheers,

James