[LLVMdev] LLVM bytecode portability

Chris Lattner sabre at nondot.org
Thu Feb 24 21:26:53 PST 2005


On Thu, 24 Feb 2005, xavier wrote:

> Hi,
>
> I have some questions about LLVM
>
> Since it is available in several and different platforms like Intel x86, 
> PowerPc and Sparc, how do you handle the differences between these 
> platforms in your bytecode? For example, Can a bytecode generated under 
> MacOS run in the LLVM version under Linux x86? How do you handle things 
> like little endian / big endian? How do you handle the difference in 
> pointer sizes: Sparcs' 64 bit pointers and Intel x86 32 bits pointers?

There are two ways to do this.  A front-end (e.g. our Java front-end in 
development) that generates portable LLVM code (code that does not depend 
on the target) can just do so and things will magically work.  LLVM 
bytecode like this is portable.

For front-ends that compile non-type-safe languages (e.g. our C/C++ 
front-ends), we explicitly encode the target, and some additional 
information (including pointersize and endianness) in the bytecode file. 
These files MAY be portable, or they may not be, but there is no 
guarantee.  In the case of C/C++, basically anything that includes a 
standard header will not be portable, at least not across systems with 
different implementations of libc.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list