[LLVMdev] Big endian ARM?

Richard Pennington rich at pennware.com
Sat Jun 2 20:35:42 PDT 2012


On Saturday, June 02, 2012 10:20:03 AM Richard Pennington wrote:
> Hi,
> 
> I've been trying to set up clang/LLVM to compile for big endian ARM and I
> need a little help. The code generation works for the most part and most of
> my regression tests pass, but I noticed that code like this
> 
> extern void g(void);
> int *p;
> 
> int main()
> {
>     if (*p & 0x01000000) g();
> }
> 
> generates
> 
>         ldr     r0, [r0]
>         ldrb    r0, [r0, #3]
>         tst     r0, #1
> 
> i.e. the test of the value is optimized to use a byte load, but the ldrb is
> done assuming a little endian address space.
> 
> I've been snooping around, but can't seem to find where the conversion to a
> byte operation is done. Could someone point me in the right direction?
> 

I've figured out my problem. I didn't adjust the data layout description string 
in ARMTargetMachine.cpp for big endian targets.

This brings up another question. clang has its own set of description strings 
for varying ABIs, etc. Should those strings somehow override in the code 
generators?

-Rich



More information about the llvm-dev mailing list