Philipp Klaus Krause
2006-Nov-24 20:13 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
Reid Spencer schrieb:> Hi Philipp, > > On Fri, 2006-11-24 at 20:09 +0100, Philipp Klaus Krause wrote: >> Reid Spencer schrieb: >> >>> Note that C and LLVM types are *not* the same things (despite the >>> similar names). We are in the process of making this abundantly clear. >>> The LLVM IR will soon use names like i8, i16, i32, and i64 (signless >>> integer quantities of specific sizes, regardless of platform). >> I had explicitly specified the size in the input code using a uint32_t >> type, the resulting C code used short, which is smaller on my target >> platform. > > One would think that it should result in a 32-bit unsigned type but its > hard to say without something concrete. Can you supply a small, > pre-processed example of some code that results in a CBE short for an > input C/C++ uint32_t ?Hmm the problem was a bit different. I just reproduced it. I used this input file: #include <stdint.h> uint32_t test(uint32_t t) { return(t + 42); } and got the following code: unsigned test(unsigned ltmp_0_1) { return (ltmp_0_1 + 42u); } unsigned is 16 bit on my target platform. Philipp
Reid Spencer
2006-Nov-24 21:02 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
On Fri, 2006-11-24 at 21:13 +0100, Philipp Klaus Krause wrote:> Reid Spencer schrieb:> Hmm the problem was a bit different. I just reproduced it. > > I used this input file: > > #include <stdint.h> > > uint32_t test(uint32_t t) > { > return(t + 42); > } > > and got the following code: > > unsigned test(unsigned ltmp_0_1) { > return (ltmp_0_1 + 42u); > } > > unsigned is 16 bit on my target platform.Sure, but what is it on the target that llvm-gcc is configured for? If you're running llvm-gcc on a 32-bit platform without configuring it as a cross-compiler then the above is correct. 32-bit unsigned is what is expected on the target you're compiling for. This is exactly why its important to configure llvm-gcc as a cross-compiler for your target. If you do, I'm sure that you'll find it will generate: unsigned long test (unsigned long ltmp_0_1) { return (ltmp_0_1 + 42ul); } assuming that "unsigned long" is a 32-bit unsigned long on your target. Reid.> > Philipp > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Chris Lattner
2006-Nov-25 05:11 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
On Fri, 24 Nov 2006, Reid Spencer wrote:>> return (ltmp_0_1 + 42u); >> } >> >> unsigned is 16 bit on my target platform. > > Sure, but what is it on the target that llvm-gcc is configured for? If > you're running llvm-gcc on a 32-bit platform without configuring it as aThis has nothing to do with cross compiling. The CBE always assumes that unsigned is 32-bits. This is obviously false. It should emit uint32_t references instead, but this requires pulling in <inttypes.h>, which it can't do. -Chris -- http://nondot.org/sabre/ http://llvm.org/
Maybe Matching Threads
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
- [LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)