Philipp Klaus Krause
2006-Nov-23 20:09 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
Reid Spencer schrieb:> On Thu, 2006-11-23 at 19:10 +0100, Philipp Klaus Krause wrote: >> Pertti Kellomäki schrieb: >>> Chris Lattner wrote: >>>> Many aspects of the target compiler can leak through. >>> So if one wants to use the LLVM system as a cross compiler, one >>> has to configure llvm-gcc as a cross compiler? Fair enough, I guess. >> I hope the C backend is still meant to generate portable code though. > > It generates C99. Its portability is no better or worse than any other > backend.Does that mean that I will have to configure llvm as a cross-compiler even when using the C backend? I want to use LLVM to translate C++ into C and compile the resulting C code using sdcc. I already noticed some problems (resulting C code uses different data types than input). Philipp
Reid Spencer
2006-Nov-23 21:08 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
On Thu, 2006-11-23 at 21:09 +0100, Philipp Klaus Krause wrote:> Reid Spencer schrieb: > > It generates C99. Its portability is no better or worse than any other > > backend. > > Does that mean that I will have to configure llvm as a cross-compiler > even when using the C backend?LLVM doesn't need to be configured as a cross compiler. It can generate code for a variety of platforms on any platform. What you do need to do is configure your front end to be a cross compiler. Then it will generate the correct LLVM input for that platform (and consequently LLVM will generate code for that platform) regardless of the platform on which either LLVM or your front end are running.> I want to use LLVM to translate C++ into C and compile the resulting C > code using sdcc.I'm not familiar with that compiler, but it should be fine as long as it can handle C99. Simply target llvm-gcc for platform you want to compile for and the resulting code should be suitable for compilation by sdcc on that platform.> I already noticed some problems (resulting C code uses different data > types than input).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).> PhilippHope that helps, Phillip. Reid.> > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Philipp Klaus Krause
2006-Nov-24 19:09 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
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. Philipp
Philipp Klaus Krause
2006-Nov-24 19:13 UTC
[LLVMdev] Byte code portability (was Re: libstdc++ as bytecode, and compiling C++ to C)
Reid Spencer schrieb:> hat you do need to do > is configure your front end to be a cross compiler. Then it will > generate the correct LLVM input for that platform (and consequently LLVM > will generate code for that platform) regardless of the platform on > which either LLVM or your front end are running. >Is that needed for thing like sizeof() and size of native datatypes only or for other things, too? Philipp
Possibly Parallel 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)