[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
Reid Spencer
rspencer at reidspencer.com
Fri Nov 24 13:32:08 PST 2006
Hi Phillipp,
On Fri, 2006-11-24 at 22:06 +0100, Philipp Klaus Krause wrote:
> Anton Korobeynikov schrieb:
> > Hello, Philipp.
> >
> >> unsigned is 16 bit on my target platform.
> > Could you please show LLVM bytecode?
> >
>
> I've attached the .bc file and the .c source and output files.
The LLVM Assembly looks like:
; ModuleID = '/tmp/test.bc'
target datalayout = "e-p:32:32"
target endian = little
target pointersize = 32
target triple = "i686-pc-linux-gnu"
deplibs = [ "c", "crtend" ]
implementation ; Functions:
uint %test(uint %t) {
entry:
%tmp.1 = add uint %t, 42 ; <uint> [#uses=1]
ret uint %tmp.1
}
Note the "target pointersize = 32"
This is how LLVM says "the source compiler things the target is 32-bit"
> I compiled using llvm-gcc (not configured as cross-compiler though, so
> that might be the problem).
Yes. That is the problem.
>
> Nevertheless I don't really see why portable source shouldn't be
> translated into portable source.
The source isn't portable. Look at how uint32_t is defined. Undoubtedly
it is in an ifdef that defines it as "unsigned int" on your 32-bit
platform. The code generated is for a 32-bit platform so the "uint" type
in LLVM and the "unsigned" type in the CBE output are correct (for a
32-bit platform). However, you're compiling the CBE output on a 16-bit
platform!
You *must* configure llvm-gcc as a cross-compiler for your 16-bit
platform.
>
> Philipp
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list