[llvm-dev] Compile with both arm and thumb mode
Peter Smith via llvm-dev
llvm-dev at lists.llvm.org
Thu Nov 8 08:17:01 PST 2018
On Thu, 8 Nov 2018 at 15:26, Muhui Jiang via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi
>
> I would like to use clang to cross compile the ARM binary. I hope the target binary contains both arm and thumb instruction sets.
>
> I use the flag -mhwdiv=arm,thumb. I compiled several binaries. However, I found that the thumb mode instructions are few. Even for very big program like gcc. The number of thumb mode instruction is less than 100. I get the ground truth from the mapping table.
>
> Maybe the flag I use is not right? I think there should be many thumb mode instructions. How do clang select thumb or arm mode when compiling? Many Thanks
>
> Regards
> Muhui
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Hello Muhui,
clang with a target like armv7a-linux-gnueabihf will default to
compiling all the functions in the file in Arm state. If the option
-mthumb or a target like thumbv7a-linux-gnueabi is used then all of
the functions will be compiled in Thumb state. Depending on how the
flags vary across the program will determine the mix of Arm and Thumb
in the binary.
Off the top of my head I think that you can use the target attribute
to change the state of individual function
https://clang.llvm.org/docs/AttributeReference.html#target
Peter
More information about the llvm-dev
mailing list