[LLVMdev] switching ARM modes and integrated-as

Jim Grosbach grosbach at apple.com
Mon Nov 18 18:33:27 PST 2013


On Nov 18, 2013, at 6:18 PM, Greg Fitzgerald <garious at gmail.com> wrote:

> Does the integrated assembler in the ARM backend support switching
> between ARM and Thumb modes in the same file?

Yes.

>  I'm having trouble with
> the following assembly:
> 
>  .thumb_func
>  @   Enter ARM mode
>  adr r3, 1f
>  bx  r3
>  .align 4

That .align is probably not what you want. ARM .align is a power of two, so you’re aligning at 16 bytes here, not 32-bits.

>  .code 32
> 1:  push {r7}
>  mov r7, r12
>  svc 0x0
>  pop {r7}
>  @   Enter thumb mode
>  adr r3, 2f+1
>  bx  r3
>  .code 16
> 2:
>  bx  lr
> 
> 
> As a standalone .s file, GNU-as can compile it but with "clang
> -integrated-as", I get errors.  If using inline assembly in a C file,
> no error is reported (when compiled targeting thumb 2), but the 32-bit
> ARM instructions are encoded wrongly.  The two 16-bit halves need to
> be swapped.  A bug, unsupported, or perhaps just user error?

I just tried the above code in a .s file and it worked fine for me. Can you show exactly what you’re seeing that looks wrong? Note that Thumb2 wide instructions have the two half-words swapped from what one would expect. Possibly the disassembly isn’t identifying arm vs. thumb code and that’s what’s making things look wrong?

> 
> Thanks,
> Greg
> _______________________________________________
> 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