[cfe-dev] Modify for a variation of C with "size of" problem

David Chisnall csdavec at swan.ac.uk
Tue Dec 14 14:58:41 PST 2010


On 14 Dec 2010, at 22:12, Lu Mitnick wrote:

> Because I want to support EFI C in clang. The main difference between ANSI C and EFI C(used in EFI Byte Code Virtual Machine) 
> 
> is that int size is determined at running time (4-byte on 32-bit processor and 8-byte on 64-bit processor).


This does not require sizeof to be a function (in fact, as I said in my previous mail, sizeof can't be implemented as a function).  It merely requires the result of sizeof not to be a constant expression.  This is the case with variable-length arrays in C99 already.  You could look at how these are implemented for an example.  

Note, however, that if the size of int is not constant, you will probably not be able to use clang's codegen library (which generates LLVM IR) without some serious and invasive modifications, because it assumes that int is a fixed size in a lot of places and lowers it to i16, i32, or i64 in LLVM IR.  

David

-- Sent from my Cray X1





More information about the cfe-dev mailing list