]> granicus.if.org Git - clang/commit
Initial implementation of arbitrary fixed-width integer types.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 13 Feb 2009 02:31:07 +0000 (02:31 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 13 Feb 2009 02:31:07 +0000 (02:31 +0000)
commitf98aba35e6c3da5aae61843fc01334939e4e12ec
tree59b82ef65867dfc610ea4b5c79c3a64fbc60f8e3
parenta8538d902fce9cfec20f39b34492268b51643819
Initial implementation of arbitrary fixed-width integer types.
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;}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64434 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/ASTContext.h
include/clang/AST/Type.h
lib/AST/ASTContext.cpp
lib/AST/Type.cpp
lib/CodeGen/CodeGenTypes.cpp
lib/Sema/SemaDeclAttr.cpp
test/Sema/128bitint.c [new file with mode: 0644]