[LLVMdev] llvm-mc and endianess. (original) (raw)

Richard Sandiford rsandifo at linux.vnet.ibm.com
Thu Mar 6 07:31:14 PST 2014


Dominique Torette <Dominique.Torette at spacebel.be> writes:

Hi,

As a first step to port the LLVM chain on an in-house big-endian processor, I'm integrating the native assembler as a new '-assemble -arch=' in llvm-mc. All work quite well, I have a correct output ELF format except that generated code is little-endian. I've understood that the endianess of the LLVM chain is controlled by the DataLayout class, but it appear to me that llvm-mc does not make use of such class. I've seen a backend (CPU0, http://jonathan2251.github.io/lbd/genobj.html) that defines two different targets and performs the byte swapping as part of the EmitInstruction'. Is it the right way? Could somebody confirm my understanding and give me some tips about endianess in llvm-mc?

At the MC level you need to make your *AsmInfo constructor set:

IsLittleEndian = false;

Also make sure you pass false to the third argument to createELFObjectWriter().

FWIW there are several in-tree targets that support big-endian, such as ARM, MIPS and PowerPC. SystemZ is big-endian only. It might help to compare with one of those.

Thanks, Richard



More information about the llvm-dev mailing list