[LLVMdev] Idea for Google Summer Code : C Compiler for EFI Byte Code implement in LLVM

Chris Lattner clattner at apple.com
Fri Mar 19 14:55:21 PDT 2010


On Mar 19, 2010, at 2:40 PM, Louis Gerbarg wrote:

> 
> What do you mean by "variable sized pointers"?  What does:
> 
> struct  S {void *X; };
> 
> return for sizeof(struct S); ?
> 
> It doesn't, at least not for Intel's EBC compiler. They error out on any sizeof that include a pointer.  A piece of EBC code can run in either a 32 bit or 64 bit environment, and everything in the compiler either needs to cope with it (by conditionally choosing the size of offsets into structs, for instance) or give up on it and abort. That also means that you cannot compile code that depends on knowing pointer sizes in the preprocessor, etc.

Ok, that makes sense.  It could be done by generalizing the notions of variably modified types (which are VLAs in C99) to include pointers. 

> I suspect getting something like this to work would require substantial changes to any existing C frontend, since as a language assumes knowledge of pointer size. On the other hand, it would allow for some neat tricks since it would allow one to compile a significant subset of C code to a pointer neutral intermediary form. Off the top of my head I can think of several potential uses for that, such as PNaCl <http://blog.chromium.org/2010/03/native-client-and-web-portability.html>.

PNaCL is already (planned to be) built with LLVM/Clang.  They just fix the pointer size at 32-bits, which also simplifies their SFI approach on 64-bit hosts.

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100319/504baa6e/attachment.html>


More information about the llvm-dev mailing list