Muhui Jiang via llvm-dev
2018-Nov-08 15:25 UTC
[llvm-dev] Compile with both arm and thumb mode
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181108/5c73e4c2/attachment-0001.html>
Peter Smith via llvm-dev
2018-Nov-08 16:17 UTC
[llvm-dev] Compile with both arm and thumb mode
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-devHello 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
Muhui Jiang via llvm-dev
2018-Nov-09 02:49 UTC
[llvm-dev] Compile with both arm and thumb mode
Hi Peter Thanks for your reply. It seems that the mix of arm and thumb is determined by the target attribute inside the source code. Is it right? May I understand like this, I think the '-mthumb' is a compiling flag. If no target information is provided. Then instruction mode will be determined by the compiling flag. If I set -mthumb, all the instructions will be in thumb mode. If I set nothing, all the instructions will be compiled into arm mode by default. What if I set -mthumb, but there is a target information specifying arm mode? Besides, I looked at the link you provided, I don't know the valid value of target if I need the function to be compiled to thumb mode. Maybe something like __attribute__((target("thumbv7a-linux-gnueabi")))? Thank you very much. Regards Muhui Peter Smith <peter.smith at linaro.org> 于2018年11月9日周五 上午12:17写道:> 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181109/c57835f3/attachment.html>
Possibly Parallel Threads
- [RFC] Stop giving a default CPU to the LTO plugin?
- [RFC] Stop giving a default CPU to the LTO plugin?
- Distinguish between ARM and Thumb
- [LLVMdev] CPUStringIsValid() into MCSubtargetInfo and use it for ARM .cpu parsing
- [ARM/Thumb] Make a function in arm while in Thumb triple