[LLVMdev] A problem with inline assembly in llvmc for ARM

Jim Grosbach grosbach at apple.com
Wed Jul 11 09:12:49 PDT 2012


Looks like a problem with llvmc. Your example works fine with clang.

~/tmp $ cat foo.c
void foo() {
   __asm__ volatile ("push   {r4}\n\t");
}
gilgamesh: ~/tmp $ clang -target arm-linux-eabi -S -Os foo.c -o -
	.syntax unified
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.file	"foo.c"
	.text
	.globl	foo
	.align	2
	.type	foo,%function
foo:
	@APP
	push   {r4}
	
	@NO_APP
	bx	lr
.Ltmp0:
	.size	foo, .Ltmp0-foo

On Jul 11, 2012, at 1:44 AM, Moshe Kravchik wrote:

> Hi,
> 
> I encountered an issue with inline assembly in my c files compiled with llvmc.
> 
> When I have a push instruction in the inline assembly like:
> 
>  __asm__ volatile (
>                                 "push   {r4}\n\t"
>                           );
> 
> the compiler will drop the curly braces and leave it in the generated assembly file as:
>         push    r4
> 
> And this is non-conformant with the ARM assembly synta! x for push and pop.
> 
> Is there any ways to resolve or overcome that? I need to keep the assembly inline, and not move it to the .s files.
> 
> I used the following llvmc:
>   llvm version 2.9
>   Optimized build.
>   Built Sep  8 2011 (11:43:28).
>   Host: i386-pc-linux-gnu
>   Host CPU: core2
> 
> Using the following flags:
> -Wllc,="-mtriple=arm-linux-eabi" -fmessage-length=0  -std=c99 -Wno-trigraphs -O3 -fpic -Wreturn-type -Wunused-variable -fvisibility=hidden -D__ARM_EABI__ -DANDROID -isysroot/usr/local/android/android-ndk-r6b/platforms/android-8/arch-arm 
> 
> Thanks a lot,
> Moshe
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120711/0a9e5de8/attachment.html>


More information about the llvm-dev mailing list