Skip to content
  • Eli Friedman's avatar
    Initial implementation of arbitrary fixed-width integer types. · 1efaaeaa
    Eli Friedman authored
    Currently only used for 128-bit integers.
    
    Note that we can't use the fixed-width integer types for other integer 
    modes without other changes because glibc headers redefines (u)int*_t 
    and friends using the mode attribute.  For example, this means that uint64_t
    has to be compatible with unsigned __attribute((mode(DI))), and 
    uint64_t is currently defined to long long.  And I have a feeling we'll 
    run into issues if we try to define uint64_t as something which isn't 
    either long or long long.
    
    This doesn't get the alignment right in most cases, including 
    the 128-bit integer case; I'll file a PR shortly.  The gist of the issue 
    is that the targets don't really expose the information necessary to 
    figure out the alignment outside of the target description, so there's a 
    non-trivial amount of work involved in getting it working right.  That 
    said, the alignment used is conservative, so the only issue with the 
    current implementation is ABI compatibility.
    
    This makes it trivial to add some sort of "bitwidth" attribute to make 
    arbitrary-width integers; I'll do that in a followup.
    
    We could also use this for stuff like the following for compatibility 
    with gcc, but I have a feeling it would be a better idea for clang to be 
    consistent between C and C++ modes rather than follow gcc's example for 
    C mode.
    struct {unsigned long long x : 33;} x;
    unsigned long long a(void) {return x.x+1;}
    
    llvm-svn: 64434
    1efaaeaa
Loading