[cfe-commits] r64495 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp lib/Headers/stdint.h lib/Lex/Preprocessor.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 13 14:29:00 PST 2009
Author: lattner
Date: Fri Feb 13 16:28:55 2009
New Revision: 64495
URL: http://llvm.org/viewvc/llvm-project?rev=64495&view=rev
Log:
Give TargetInfo a new IntPtrType to hold the intptr_t type for
a target.
Make Preprocessor.cpp define a new __INTPTR_TYPE__ macro based on this.
On linux/32, set intptr_t to int, instead of long. This fixes PR3563.
Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/Headers/stdint.h
cfe/trunk/lib/Lex/Preprocessor.cpp
Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=64495&r1=64494&r2=64495&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Feb 13 16:28:55 2009
@@ -72,7 +72,7 @@
UnsignedLongLong
};
protected:
- IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, WCharType;
+ IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType;
public:
IntType getSizeType() const { return SizeType; }
IntType getIntMaxType() const { return IntMaxType; }
@@ -80,6 +80,7 @@
IntType getPtrDiffType(unsigned AddrSpace) const {
return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
}
+ IntType getIntPtrType() const { return IntPtrType; }
IntType getWCharType() const { return WCharType; }
/// isCharSigned - Return true if 'char' is 'signed char' or false if it is
Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=64495&r1=64494&r2=64495&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Fri Feb 13 16:28:55 2009
@@ -39,6 +39,7 @@
PtrDiffType = SignedLong;
IntMaxType = SignedLongLong;
UIntMaxType = UnsignedLongLong;
+ IntPtrType = SignedLong;
WCharType = SignedInt;
FloatFormat = &llvm::APFloat::IEEEsingle;
DoubleFormat = &llvm::APFloat::IEEEdouble;
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=64495&r1=64494&r2=64495&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Fri Feb 13 16:28:55 2009
@@ -629,6 +629,7 @@
UserLabelPrefix = "";
SizeType = UnsignedInt;
PtrDiffType = SignedInt;
+ IntPtrType = SignedInt;
}
virtual void getTargetDefines(std::vector<char> &Defines) const {
X86_32TargetInfo::getTargetDefines(Defines);
@@ -937,6 +938,7 @@
SizeType = UnsignedInt;
IntMaxType = SignedLong;
UIntMaxType = UnsignedLong;
+ IntPtrType = SignedShort;
PtrDiffType = SignedInt;
DescriptionString = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8";
}
Modified: cfe/trunk/lib/Headers/stdint.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/stdint.h?rev=64495&r1=64494&r2=64495&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/stdint.h (original)
+++ cfe/trunk/lib/Headers/stdint.h Fri Feb 13 16:28:55 2009
@@ -70,25 +70,8 @@
/* C99 7.18.1.4 Integer types capable of holding object pointers.
*/
-#if (1LL << (__POINTER_WIDTH__-1))-1 == __LONG_MAX__
-/* If the pointer size is equal to long, use long. This is for compatibility
- * with many systems which just use long and expect it to work in 32-bit and
- * 64-bit mode. If long is not suitable, we use a fixed size type below.
- */
-typedef long intptr_t;
-typedef unsigned long uintptr_t;
-#elif __POINTER_WIDTH__ == 64
-typedef int64_t intptr_t;
-typedef uint64_t uintptr_t;
-#elif __POINTER_WIDTH__ == 32
-typedef int32_t intptr_t;
-typedef uint32_t uintptr_t;
-#elif __POINTER_WIDTH__ == 16
-typedef int16_t intptr_t;
-typedef uint16_t uintptr_t;
-#else
-#error "unknown or unset pointer width!"
-#endif
+typedef __INTPTR_TYPE__ intptr_t;
+typedef unsigned __INTPTR_TYPE__ uintptr_t;
/* C99 7.18.1.5 Greatest-width integer types.
*/
Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=64495&r1=64494&r2=64495&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Feb 13 16:28:55 2009
@@ -557,6 +557,7 @@
DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Buf);
DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Buf);
DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Buf);
+ DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Buf);
DefineType("__SIZE_TYPE__", TI.getSizeType(), Buf);
DefineType("__WCHAR_TYPE__", TI.getWCharType(), Buf);
// FIXME: TargetInfo hookize __WINT_TYPE__.
More information about the cfe-commits
mailing list