[cfe-commits] r74583 - in /cfe/trunk: include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/Basic/Targets.cpp lib/Frontend/InitPreprocessor.cpp

Eli Friedman eli.friedman at gmail.com
Tue Jun 30 20:36:11 PDT 2009


Author: efriedma
Date: Tue Jun 30 22:36:11 2009
New Revision: 74583

URL: http://llvm.org/viewvc/llvm-project?rev=74583&view=rev
Log:
Fix for PR4192: fix the definition of int64_t on x86_64 Linux.

Note that I'm guessing that *BSD and Solaris do the same thing as Linux 
here, but it's quite possible I'm wrong; if the following testcase 
gives an error on x86-64 with gcc for any of those operating systems, please
tell me:

#include <stdint.h>

int64_t x; long x;


Modified:
    cfe/trunk/include/clang/Basic/TargetInfo.h
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=74583&r1=74582&r2=74583&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jun 30 22:36:11 2009
@@ -76,7 +76,8 @@
     UnsignedLongLong
   };
 protected:
-  IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType;
+  IntType SizeType, IntMaxType, UIntMaxType, PtrDiffType, IntPtrType, WCharType,
+          Int64Type;
 public:
   IntType getSizeType() const { return SizeType; }
   IntType getIntMaxType() const { return IntMaxType; }
@@ -86,6 +87,7 @@
   }
   IntType getIntPtrType() const { return IntPtrType; }
   IntType getWCharType() const { return WCharType; }
+  IntType getInt64Type() const { return Int64Type; }
 
   /// getPointerWidth - Return the width of pointers on this target, for the
   /// specified address space.

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=74583&r1=74582&r2=74583&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue Jun 30 22:36:11 2009
@@ -41,6 +41,7 @@
   UIntMaxType = UnsignedLongLong;
   IntPtrType = SignedLong;
   WCharType = SignedInt;
+  Int64Type = SignedLongLong;
   FloatFormat = &llvm::APFloat::IEEEsingle;
   DoubleFormat = &llvm::APFloat::IEEEdouble;
   LongDoubleFormat = &llvm::APFloat::IEEEdouble;

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=74583&r1=74582&r2=74583&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jun 30 22:36:11 2009
@@ -549,6 +549,9 @@
 public:
   PPC64TargetInfo(const std::string& triple) : PPCTargetInfo(triple) {
     LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
+    IntMaxType = SignedLong;
+    UIntMaxType = UnsignedLong;
+    Int64Type = SignedLong;
     DescriptionString = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
                         "i64:64:64-f32:32:32-f64:64:64-v128:128:128";
   }
@@ -940,11 +943,11 @@
 public:
   X86_64TargetInfo(const std::string &triple) : X86TargetInfo(triple) {
     LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
-    DoubleAlign = LongLongAlign = 64;
     LongDoubleWidth = 128;
     LongDoubleAlign = 128;
     IntMaxType = SignedLong;
     UIntMaxType = UnsignedLong;
+    Int64Type = SignedLong;
     RegParmMax = 6;
 
     DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
@@ -963,6 +966,16 @@
 } // end anonymous namespace
 
 namespace {
+class DarwinX86_64TargetInfo : public DarwinTargetInfo<X86_64TargetInfo> {
+public:
+  DarwinX86_64TargetInfo(const std::string& triple) 
+      : DarwinTargetInfo<X86_64TargetInfo>(triple) {
+    Int64Type = SignedLongLong;
+  }
+};
+} // end anonymous namespace
+
+namespace {
 class ARMTargetInfo : public TargetInfo {
   enum {
     Armv4t,
@@ -1363,7 +1376,7 @@
 
   if (T.find("x86_64-") == 0 || T.find("amd64-") == 0) {
     if (isDarwin)
-      return new DarwinTargetInfo<X86_64TargetInfo>(T);
+      return new DarwinX86_64TargetInfo(T);
     if (isLinux)
       return new LinuxTargetInfo<X86_64TargetInfo>(T);
     if (isOpenBSD)

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=74583&r1=74582&r2=74583&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Jun 30 22:36:11 2009
@@ -383,7 +383,7 @@
   
   // 16-bit targets doesn't necessarily have a 64-bit type.
   if (TI.getLongLongWidth() == 64)
-    DefineBuiltinMacro(Buf, "__INT64_TYPE__=long long");
+    DefineType("__INT64_TYPE__", TI.getInt64Type(), Buf);
   
   // Add __builtin_va_list typedef.
   {





More information about the cfe-commits mailing list