[cfe-dev] preserving type signatures

David Chisnall theraven at sucs.org
Wed Mar 24 15:05:17 PDT 2010


On 24 Mar 2010, at 21:54, Renato Golin wrote:

> So, that means the IR is not platform/ABI agnostic?

Correct.  See: http://llvm.org/docs/FAQ.html#platformindependent

> What if I want to
> mix IR generated from different platforms into one big virtual machine
> (RPE-style)?

Then you need to use something other than LLVM IR.  You also need to start with a source language other than C, because things like sizeof(int) change on different platforms, as do a lot of things defined in headers and a number of predefined macros.  Even preprocessing the same C source on FreeBSD/x86 and Solaris/SPARC64 will give very different output for all but the most trivial programs.  Compiling it to IR will add even more differences.

> I hope there's a way to disable all that ABI stuff and
> generate plain simple IR, is there?


No.  LLVM IR is less expressive than C.  There is no way of generating 'plain and simple IR' that can be turned into native code trivially.  Consider something simple like a function taking an argument that is a union of an int and a void*.  On any sane ABI, this argument will be passed in a register, so the IR will use an i32 or i64.  Linux/86, however, will pass it via a pointer.  How would you represent this in LLVM IR?

David

-- Sent from my brain





More information about the cfe-dev mailing list