diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-04-30 02:43:43 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-04-30 02:43:43 +0000 |
| commit | f122cef4df04d017c1e43b9c6444c4e8e1a5b3ed (patch) | |
| tree | b0662fcfbbec40cd88ee5ed2c1e5914663a68c97 /clang/lib/AST | |
| parent | 7216b9da5f20226dd11bdf109bd9fb84463852ee (diff) | |
| download | bcm5719-llvm-f122cef4df04d017c1e43b9c6444c4e8e1a5b3ed.tar.gz bcm5719-llvm-f122cef4df04d017c1e43b9c6444c4e8e1a5b3ed.zip | |
initial support for __[u]int128_t, which should be basically
compatible with VC++ and GCC. The codegen/mangling angle hasn't
been fully ironed out yet. Note that we accept int128_t even in
32-bit mode, unlike gcc.
llvm-svn: 70464
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 18 | ||||
| -rw-r--r-- | clang/lib/AST/Type.cpp | 4 |
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 58fc42b036b..6cd016cab81 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -251,6 +251,10 @@ void ASTContext::InitBuiltinTypes() { InitBuiltinType(DoubleTy, BuiltinType::Double); InitBuiltinType(LongDoubleTy, BuiltinType::LongDouble); + // GNU extension, 128-bit integers. + InitBuiltinType(Int128Ty, BuiltinType::Int128); + InitBuiltinType(UnsignedInt128Ty, BuiltinType::UInt128); + if (LangOpts.CPlusPlus) // C++ 3.9.1p5 InitBuiltinType(WCharTy, BuiltinType::WChar); else // C99 @@ -421,6 +425,13 @@ ASTContext::getTypeInfo(const Type *T) { Width = Target.getLongDoubleWidth(); Align = Target.getLongDoubleAlign(); break; + case BuiltinType::Int128: + case BuiltinType::UInt128: + Width = 128; + + // FIXME: Is this correct for all targets? + Align = 128; + break; } break; case Type::FixedWidthInt: @@ -1923,6 +1934,9 @@ unsigned ASTContext::getIntegerRank(Type *T) { case BuiltinType::LongLong: case BuiltinType::ULongLong: return 6 + (getIntWidth(LongLongTy) << 3); + case BuiltinType::Int128: + case BuiltinType::UInt128: + return 7 + (getIntWidth(Int128Ty) << 3); } } @@ -2291,6 +2305,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, encoding = (const_cast<ASTContext *>(this))->getIntWidth(T) == 32 ? 'L' : 'Q'; break; + case BuiltinType::UInt128: encoding = 'T'; break; case BuiltinType::ULongLong: encoding = 'Q'; break; case BuiltinType::Char_S: case BuiltinType::SChar: encoding = 'c'; break; @@ -2301,6 +2316,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, (const_cast<ASTContext *>(this))->getIntWidth(T) == 32 ? 'l' : 'q'; break; case BuiltinType::LongLong: encoding = 'q'; break; + case BuiltinType::Int128: encoding = 't'; break; case BuiltinType::Float: encoding = 'f'; break; case BuiltinType::Double: encoding = 'd'; break; case BuiltinType::LongDouble: encoding = 'd'; break; @@ -3244,6 +3260,8 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) { return UnsignedLongTy; case BuiltinType::LongLong: return UnsignedLongLongTy; + case BuiltinType::Int128: + return UnsignedInt128Ty; default: assert(0 && "Unexpected signed integer type"); return QualType(); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 0331bbf40dd..d6cf4bd0c35 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -584,7 +584,7 @@ Type::getAsTemplateSpecializationType() const { bool Type::isIntegerType() const { if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) return BT->getKind() >= BuiltinType::Bool && - BT->getKind() <= BuiltinType::LongLong; + BT->getKind() <= BuiltinType::Int128; if (const TagType *TT = dyn_cast<TagType>(CanonicalType)) // Incomplete enum types are not treated as integer types. // FIXME: In C++, enum types are never integer types. @@ -901,11 +901,13 @@ const char *BuiltinType::getName() const { case Int: return "int"; case Long: return "long"; case LongLong: return "long long"; + case Int128: return "__int128_t"; case UChar: return "unsigned char"; case UShort: return "unsigned short"; case UInt: return "unsigned int"; case ULong: return "unsigned long"; case ULongLong: return "unsigned long long"; + case UInt128: return "__uint128_t"; case Float: return "float"; case Double: return "double"; case LongDouble: return "long double"; |

