r202004 - [AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.

Kevin Qin Kevin.Qin at arm.com
Sun Feb 23 18:45:04 PST 2014


Author: kevinqin
Date: Sun Feb 23 20:45:03 2014
New Revision: 202004

URL: http://llvm.org/viewvc/llvm-project?rev=202004&view=rev
Log:
[AArch64] Change int64_t from 'long long int' to 'long int' for AArch64 target.

Most 64-bit targets define int64_t as long int, and AArch64 should
make same definition to follow LP64 model. In GNU tool chain, int64_t
is defined as long int for 64-bit target. So to get consistent with GNU,
it's better Changing int64_t from 'long long int' to 'long int',
otherwise clang will get different name mangling suffix compared with g++.

Added:
    cfe/trunk/test/CodeGenCXX/int64_uint64.cpp
Modified:
    cfe/trunk/include/clang/Basic/Builtins.def
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/AST/ItaniumMangle.cpp
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp
    cfe/trunk/test/Preprocessor/init.c
    cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sun Feb 23 20:45:03 2014
@@ -50,6 +50,7 @@
 //  L   -> long (e.g. Li for 'long int')
 //  LL  -> long long
 //  LLL -> __int128_t (e.g. LLLi)
+//  W   -> int64_t
 //  S   -> signed
 //  U   -> unsigned
 //  I   -> Required to constant fold to an integer constant expression.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Feb 23 20:45:03 2014
@@ -7526,6 +7526,19 @@ static QualType DecodeTypeFromStr(const
       assert(HowLong <= 2 && "Can't have LLLL modifier");
       ++HowLong;
       break;
+    case 'W':
+      // This modifier represents int64 type.
+      assert(HowLong == 0 && "Can't use both 'L' and 'W' modifiers!");
+      switch (Context.getTargetInfo().getInt64Type()) {
+      default:
+        llvm_unreachable("Unexpected integer type");
+      case TargetInfo::SignedLong:
+        HowLong = 1;
+        break;
+      case TargetInfo::SignedLongLong:
+        HowLong = 2;
+        break;
+      }
     }
   }
 

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Sun Feb 23 20:45:03 2014
@@ -2203,7 +2203,7 @@ static StringRef mangleAArch64VectorBase
     return "Int16";
   case BuiltinType::Int:
     return "Int32";
-  case BuiltinType::LongLong:
+  case BuiltinType::Long:
     return "Int64";
   case BuiltinType::UChar:
     return "Uint8";
@@ -2211,7 +2211,7 @@ static StringRef mangleAArch64VectorBase
     return "Uint16";
   case BuiltinType::UInt:
     return "Uint32";
-  case BuiltinType::ULongLong:
+  case BuiltinType::ULong:
     return "Uint64";
   case BuiltinType::Half:
     return "Float16";
@@ -2246,7 +2246,7 @@ void CXXNameMangler::mangleAArch64NeonVe
     case BuiltinType::UShort:
       EltName = "Poly16";
       break;
-    case BuiltinType::ULongLong:
+    case BuiltinType::ULong:
       EltName = "Poly64";
       break;
     default:

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sun Feb 23 20:45:03 2014
@@ -3367,6 +3367,9 @@ class AArch64TargetInfo : public TargetI
 
 public:
   AArch64TargetInfo(const llvm::Triple &Triple) : TargetInfo(Triple) {
+    IntMaxType = SignedLong;
+    UIntMaxType = UnsignedLong;
+    Int64Type = SignedLong;
     BigEndian = false;
     LongWidth = LongAlign = 64;
     LongDoubleWidth = LongDoubleAlign = 128;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Feb 23 20:45:03 2014
@@ -374,13 +374,17 @@ static QualType getNeonEltType(NeonTypeF
   case NeonTypeFlags::Int32:
     return Flags.isUnsigned() ? Context.UnsignedIntTy : Context.IntTy;
   case NeonTypeFlags::Int64:
-    return Flags.isUnsigned() ? Context.UnsignedLongLongTy : Context.LongLongTy;
+    if (IsAArch64)
+      return Flags.isUnsigned() ? Context.UnsignedLongTy : Context.LongTy;
+    else
+      return Flags.isUnsigned() ? Context.UnsignedLongLongTy
+                                : Context.LongLongTy;
   case NeonTypeFlags::Poly8:
     return IsAArch64 ? Context.UnsignedCharTy : Context.SignedCharTy;
   case NeonTypeFlags::Poly16:
     return IsAArch64 ? Context.UnsignedShortTy : Context.ShortTy;
   case NeonTypeFlags::Poly64:
-    return Context.UnsignedLongLongTy;
+    return Context.UnsignedLongTy;
   case NeonTypeFlags::Poly128:
     break;
   case NeonTypeFlags::Float16:

Modified: cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp Sun Feb 23 20:45:03 2014
@@ -5,8 +5,8 @@ typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
 typedef signed char int8_t;
 typedef signed short int16_t;
-typedef signed long long int64_t;
-typedef unsigned long long uint64_t;
+typedef signed long int64_t;
+typedef unsigned long uint64_t;
 typedef unsigned char poly8_t;
 typedef unsigned short poly16_t;
 typedef __fp16 float16_t;

Added: cfe/trunk/test/CodeGenCXX/int64_uint64.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/int64_uint64.cpp?rev=202004&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/int64_uint64.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/int64_uint64.cpp Sun Feb 23 20:45:03 2014
@@ -0,0 +1,25 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple arm-linux-guneabi \
+// RUN:   -target-cpu cortex-a8 \
+// RUN:   -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-ARM %s
+
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-linux-gnueabi \
+// RUN:   -target-feature +neon \
+// RUN:   -emit-llvm -w -O1 -o - %s | FileCheck --check-prefix=CHECK-AARCH64 %s
+
+// Test if int64_t and uint64_t can be correctly mangled.
+
+#include "arm_neon.h"
+// CHECK-ARM: f1x(
+// CHECK-AARCH64: f1l(
+void f1(int64_t a) {}
+// CHECK-ARM: f2y(
+// CHECK-AARCH64: f2m(
+void f2(uint64_t a) {}
+// CHECK-ARM: f3Px(
+// CHECK-AARCH64: f3Pl(
+void f3(int64_t *ptr) {}
+// CHECK-ARM: f4Py(
+// CHECK-AARCH64: f4Pm(
+void f4(uint64_t *ptr) {}

Modified: cfe/trunk/test/Preprocessor/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Sun Feb 23 20:45:03 2014
@@ -202,6 +202,106 @@
 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
 // SHORTWCHAR: #define __WCHAR_WIDTH__ 16
 //
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-none-none < /dev/null | FileCheck -check-prefix AARCH64 %s
+//
+// AARCH64:#define _LP64 1
+// AARCH64:#define __AARCH64EL__ 1
+// AARCH64:#define __ALIGNOF_MAX_ALIGN_T__ 16
+// AARCH64:#define __ARM_64BIT_STATE 1
+// AARCH64:#define __ARM_ARCH 8
+// AARCH64:#define __ARM_ARCH_ISA_A64 1
+// AARCH64:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// AARCH64:#define __CHAR16_TYPE__ unsigned short
+// AARCH64:#define __CHAR32_TYPE__ unsigned int
+// AARCH64:#define __CHAR_BIT__ 8
+// AARCH64:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// AARCH64:#define __DBL_DIG__ 15
+// AARCH64:#define __DBL_EPSILON__ 2.2204460492503131e-16
+// AARCH64:#define __DBL_HAS_DENORM__ 1
+// AARCH64:#define __DBL_HAS_INFINITY__ 1
+// AARCH64:#define __DBL_HAS_QUIET_NAN__ 1
+// AARCH64:#define __DBL_MANT_DIG__ 53
+// AARCH64:#define __DBL_MAX_10_EXP__ 308
+// AARCH64:#define __DBL_MAX_EXP__ 1024
+// AARCH64:#define __DBL_MAX__ 1.7976931348623157e+308
+// AARCH64:#define __DBL_MIN_10_EXP__ (-307)
+// AARCH64:#define __DBL_MIN_EXP__ (-1021)
+// AARCH64:#define __DBL_MIN__ 2.2250738585072014e-308
+// AARCH64:#define __DECIMAL_DIG__ 36
+// AARCH64:#define __FLT_DENORM_MIN__ 1.40129846e-45F
+// AARCH64:#define __FLT_DIG__ 6
+// AARCH64:#define __FLT_EPSILON__ 1.19209290e-7F
+// AARCH64:#define __FLT_EVAL_METHOD__ 0
+// AARCH64:#define __FLT_HAS_DENORM__ 1
+// AARCH64:#define __FLT_HAS_INFINITY__ 1
+// AARCH64:#define __FLT_HAS_QUIET_NAN__ 1
+// AARCH64:#define __FLT_MANT_DIG__ 24
+// AARCH64:#define __FLT_MAX_10_EXP__ 38
+// AARCH64:#define __FLT_MAX_EXP__ 128
+// AARCH64:#define __FLT_MAX__ 3.40282347e+38F
+// AARCH64:#define __FLT_MIN_10_EXP__ (-37)
+// AARCH64:#define __FLT_MIN_EXP__ (-125)
+// AARCH64:#define __FLT_MIN__ 1.17549435e-38F
+// AARCH64:#define __FLT_RADIX__ 2
+// AARCH64:#define __INT16_TYPE__ short
+// AARCH64:#define __INT32_TYPE__ int
+// AARCH64:#define __INT64_C_SUFFIX__ L
+// AARCH64:#define __INT64_TYPE__ long int
+// AARCH64:#define __INT8_TYPE__ char
+// AARCH64:#define __INTMAX_MAX__ 9223372036854775807L
+// AARCH64:#define __INTMAX_TYPE__ long int
+// AARCH64:#define __INTMAX_WIDTH__ 64
+// AARCH64:#define __INTPTR_TYPE__ long int
+// AARCH64:#define __INTPTR_WIDTH__ 64
+// AARCH64:#define __INT_MAX__ 2147483647
+// AARCH64:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L
+// AARCH64:#define __LDBL_DIG__ 33
+// AARCH64:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L
+// AARCH64:#define __LDBL_HAS_DENORM__ 1
+// AARCH64:#define __LDBL_HAS_INFINITY__ 1
+// AARCH64:#define __LDBL_HAS_QUIET_NAN__ 1
+// AARCH64:#define __LDBL_MANT_DIG__ 113
+// AARCH64:#define __LDBL_MAX_10_EXP__ 4932
+// AARCH64:#define __LDBL_MAX_EXP__ 16384
+// AARCH64:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L
+// AARCH64:#define __LDBL_MIN_10_EXP__ (-4931)
+// AARCH64:#define __LDBL_MIN_EXP__ (-16381)
+// AARCH64:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L
+// AARCH64:#define __LONG_LONG_MAX__ 9223372036854775807LL
+// AARCH64:#define __LONG_MAX__ 9223372036854775807L
+// AARCH64:#define __LP64__ 1
+// AARCH64:#define __POINTER_WIDTH__ 64
+// AARCH64:#define __PTRDIFF_TYPE__ long int
+// AARCH64:#define __PTRDIFF_WIDTH__ 64
+// AARCH64:#define __SCHAR_MAX__ 127
+// AARCH64:#define __SHRT_MAX__ 32767
+// AARCH64:#define __SIG_ATOMIC_WIDTH__ 32
+// AARCH64:#define __SIZEOF_DOUBLE__ 8
+// AARCH64:#define __SIZEOF_FLOAT__ 4
+// AARCH64:#define __SIZEOF_INT128__ 16
+// AARCH64:#define __SIZEOF_INT__ 4
+// AARCH64:#define __SIZEOF_LONG_DOUBLE__ 16
+// AARCH64:#define __SIZEOF_LONG_LONG__ 8
+// AARCH64:#define __SIZEOF_LONG__ 8
+// AARCH64:#define __SIZEOF_POINTER__ 8
+// AARCH64:#define __SIZEOF_PTRDIFF_T__ 8
+// AARCH64:#define __SIZEOF_SHORT__ 2
+// AARCH64:#define __SIZEOF_SIZE_T__ 8
+// AARCH64:#define __SIZEOF_WCHAR_T__ 4
+// AARCH64:#define __SIZEOF_WINT_T__ 4
+// AARCH64:#define __SIZE_MAX__ 18446744073709551615UL
+// AARCH64:#define __SIZE_TYPE__ long unsigned int
+// AARCH64:#define __SIZE_WIDTH__ 64
+// AARCH64:#define __UINTMAX_TYPE__ long unsigned int
+// AARCH64:#define __USER_LABEL_PREFIX__ _
+// AARCH64:#define __WCHAR_MAX__ 4294967295U
+// AARCH64:#define __WCHAR_TYPE__ unsigned int
+// AARCH64:#define __WCHAR_UNSIGNED__ 1
+// AARCH64:#define __WCHAR_WIDTH__ 32
+// AARCH64:#define __WINT_TYPE__ int
+// AARCH64:#define __WINT_WIDTH__ 32
+// AARCH64:#define __aarch64__ 1
+//
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-netbsd < /dev/null | FileCheck -check-prefix AARCH64-NETBSD %s
 //
 // AARCH64-NETBSD:#define _LP64 1
@@ -246,11 +346,11 @@
 // AARCH64-NETBSD:#define __FLT_RADIX__ 2
 // AARCH64-NETBSD:#define __INT16_TYPE__ short
 // AARCH64-NETBSD:#define __INT32_TYPE__ int
-// AARCH64-NETBSD:#define __INT64_C_SUFFIX__ LL
-// AARCH64-NETBSD:#define __INT64_TYPE__ long long int
+// AARCH64-NETBSD:#define __INT64_C_SUFFIX__ L
+// AARCH64-NETBSD:#define __INT64_TYPE__ long int
 // AARCH64-NETBSD:#define __INT8_TYPE__ char
-// AARCH64-NETBSD:#define __INTMAX_MAX__ 9223372036854775807LL
-// AARCH64-NETBSD:#define __INTMAX_TYPE__ long long int
+// AARCH64-NETBSD:#define __INTMAX_MAX__ 9223372036854775807L
+// AARCH64-NETBSD:#define __INTMAX_TYPE__ long int
 // AARCH64-NETBSD:#define __INTMAX_WIDTH__ 64
 // AARCH64-NETBSD:#define __INTPTR_TYPE__ long int
 // AARCH64-NETBSD:#define __INTPTR_WIDTH__ 64
@@ -294,7 +394,7 @@
 // AARCH64-NETBSD:#define __SIZE_MAX__ 18446744073709551615UL
 // AARCH64-NETBSD:#define __SIZE_TYPE__ long unsigned int
 // AARCH64-NETBSD:#define __SIZE_WIDTH__ 64
-// AARCH64-NETBSD:#define __UINTMAX_TYPE__ long long unsigned int
+// AARCH64-NETBSD:#define __UINTMAX_TYPE__ long unsigned int
 // AARCH64-NETBSD:#define __USER_LABEL_PREFIX__
 // AARCH64-NETBSD:#define __WCHAR_MAX__ 2147483647
 // AARCH64-NETBSD:#define __WCHAR_TYPE__ int

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=202004&r1=202003&r2=202004&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Sun Feb 23 20:45:03 2014
@@ -780,7 +780,7 @@ static std::string BuiltinTypeString(con
       s.push_back('S'); // make chars explicitly signed
 
     if (type == 'l') // 64-bit long
-      s += "LLi";
+      s += "Wi";
     else if (type == 'k') // 128-bit long
       s = "LLLi";
     else
@@ -809,7 +809,7 @@ static std::string BuiltinTypeString(con
     if (ck != ClassB && type == 'i')
       return quad ? "V4i" : "V2i";
     if (ck != ClassB && type == 'l')
-      return quad ? "V2LLi" : "V1LLi";
+      return quad ? "V2Wi" : "V1Wi";
 
     return quad ? "V16Sc" : "V8Sc";
   }
@@ -831,7 +831,7 @@ static std::string BuiltinTypeString(con
   if (ck != ClassB && type == 'i')
     return quad ? "V4i" : "V2i";
   if (ck != ClassB && type == 'l')
-    return quad ? "V2LLi" : "V1LLi";
+    return quad ? "V2Wi" : "V1Wi";
 
   return quad ? "V16Sc" : "V8Sc";
 }





More information about the cfe-commits mailing list