--- Merging r89898 into '.':
U    gcc/config/i386/i386.h
U    gcc/config/i386/llvm-i386.cpp
U    gcc/config/i386/i386.c

llvm-svn: 89901
diff --git a/llvm-gcc-4.2/gcc/config/i386/i386.c b/llvm-gcc-4.2/gcc/config/i386/i386.c
index 0c006d6..ae48590 100644
--- a/llvm-gcc-4.2/gcc/config/i386/i386.c
+++ b/llvm-gcc-4.2/gcc/config/i386/i386.c
@@ -1294,13 +1294,15 @@
     X86_64_X87_CLASS,
     X86_64_X87UP_CLASS,
     X86_64_COMPLEX_X87_CLASS,
-    X86_64_MEMORY_CLASS
+    X86_64_MEMORY_CLASS,
+    X86_64_POINTER_CLASS
   };
 #endif /* !ENABLE_LLVM */
 /* LLVM LOCAL end */
 static const char * const x86_64_reg_class_name[] = {
   "no", "integer", "integerSI", "sse", "sseSF", "sseDF",
-  "sseup", "x87", "x87up", "cplx87", "no"
+  /* LLVM LOCAL */
+  "sseup", "x87", "x87up", "cplx87", "no", "ptr"
 };
 
 #define MAX_CLASSES 4
@@ -3303,8 +3305,12 @@
   if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS)
       || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS))
     return X86_64_INTEGERSI_CLASS;
+  /* LLVM LOCAL begin */
   if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS
-      || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS)
+      || class1 == X86_64_POINTER_CLASS
+      || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS
+      || class2 == X86_64_POINTER_CLASS)
+  /* LLVM LOCAL end */
     return X86_64_INTEGER_CLASS;
 
   /* Rule #5: If one of the classes is X87, X87UP, or COMPLEX_X87 class,
@@ -3551,6 +3557,14 @@
       classes[1] = X86_64_SSEUP_CLASS;
       return 2;
     case DImode:
+      /* LLVM LOCAL begin */
+      if (POINTER_TYPE_P(type))
+        {
+          classes[0] = X86_64_POINTER_CLASS;
+          return 1;
+        }
+      /* fall through */
+      /* LLVM LOCAL end */
     case SImode:
     case HImode:
     case QImode:
@@ -3651,6 +3665,8 @@
       {
       case X86_64_INTEGER_CLASS:
       case X86_64_INTEGERSI_CLASS:
+      /* LLVM LOCAL */
+      case X86_64_POINTER_CLASS:
 	(*int_nregs)++;
 	break;
       case X86_64_SSE_CLASS:
@@ -3764,6 +3780,8 @@
       {
       case X86_64_INTEGER_CLASS:
       case X86_64_INTEGERSI_CLASS:
+      /* LLVM LOCAL */
+      case X86_64_POINTER_CLASS:
 	return gen_rtx_REG (mode, intreg[0]);
       case X86_64_SSE_CLASS:
       case X86_64_SSESF_CLASS:
@@ -3799,6 +3817,8 @@
 	    break;
 	  case X86_64_INTEGER_CLASS:
 	  case X86_64_INTEGERSI_CLASS:
+          /* LLVM LOCAL */
+          case X86_64_POINTER_CLASS:
 	    /* Merge TImodes on aligned occasions here too.  */
 	    if (i * 8 + 8 > bytes)
 	      tmpmode = mode_for_size ((bytes - i * 8) * BITS_PER_UNIT, MODE_INT, 0);
diff --git a/llvm-gcc-4.2/gcc/config/i386/i386.h b/llvm-gcc-4.2/gcc/config/i386/i386.h
index 9ffa655..43b86e9 100644
--- a/llvm-gcc-4.2/gcc/config/i386/i386.h
+++ b/llvm-gcc-4.2/gcc/config/i386/i386.h
@@ -60,7 +60,8 @@
     X86_64_X87_CLASS,
     X86_64_X87UP_CLASS,
     X86_64_COMPLEX_X87_CLASS,
-    X86_64_MEMORY_CLASS
+    X86_64_MEMORY_CLASS,
+    X86_64_POINTER_CLASS
   };
 
 #endif /* ENABLE_LLVM */
diff --git a/llvm-gcc-4.2/gcc/config/i386/llvm-i386.cpp b/llvm-gcc-4.2/gcc/config/i386/llvm-i386.cpp
index dd8e2c3..9f737fd 100644
--- a/llvm-gcc-4.2/gcc/config/i386/llvm-i386.cpp
+++ b/llvm-gcc-4.2/gcc/config/i386/llvm-i386.cpp
@@ -838,6 +838,11 @@
       totallyEmpty = false;
       Bytes -= 8;
       break;
+    case X86_64_POINTER_CLASS:
+      Elts.push_back(Type::getInt8PtrTy(Context));
+      totallyEmpty = false;
+      Bytes -= 8;
+      break;
     case X86_64_SSE_CLASS:
       totallyEmpty = false;
       // If it's a SSE class argument, then one of the followings are possible:
@@ -902,6 +907,9 @@
         } else if (Class[i+1] == X86_64_INTEGER_CLASS) {
           Elts.push_back(VectorType::get(Type::getFloatTy(Context), 2));
           Elts.push_back(Type::getInt64Ty(Context));
+        } else if (Class[i+1] == X86_64_POINTER_CLASS) {
+          Elts.push_back(VectorType::get(Type::getFloatTy(Context), 2));
+          Elts.push_back(Type::getInt8PtrTy(Context));
         } else if (Class[i+1] == X86_64_NO_CLASS) {
           // padding bytes, don't pass
           Elts.push_back(Type::getDoubleTy(Context));
@@ -1069,7 +1077,8 @@
     return false;
 
   if (NumClasses == 1 && 
-      (Class[0] == X86_64_INTEGERSI_CLASS || Class[0] == X86_64_INTEGER_CLASS))
+      (Class[0] == X86_64_INTEGERSI_CLASS || Class[0] == X86_64_INTEGER_CLASS ||
+       Class[0] == X86_64_POINTER_CLASS))
     // This will fit in one i64 register.
     return false;
 
@@ -1113,11 +1122,14 @@
 
     if (NumClasses == 1) {
       if (Class[0] == X86_64_INTEGERSI_CLASS ||
-          Class[0] == X86_64_INTEGER_CLASS) {
+          Class[0] == X86_64_INTEGER_CLASS ||
+          Class[0] == X86_64_POINTER_CLASS) {
         // one int register
         HOST_WIDE_INT Bytes =
           (Mode == BLKmode) ? int_size_in_bytes(type) : 
                               (int) GET_MODE_SIZE(Mode);
+        if (Bytes==8 && Class[0] == X86_64_POINTER_CLASS)
+          return Type::getInt8PtrTy(Context);
         if (Bytes>4)
           return Type::getInt64Ty(Context);
         else if (Bytes>2)
@@ -1135,6 +1147,8 @@
             Class[0] == X86_64_NO_CLASS ||
             Class[0] == X86_64_INTEGERSI_CLASS)
           return Type::getInt64Ty(Context);
+        else if (Class[0] == X86_64_POINTER_CLASS)
+          return Type::getInt8PtrTy(Context);
         else if (Class[0] == X86_64_SSE_CLASS || Class[0] == X86_64_SSEDF_CLASS)
           return Type::getDoubleTy(Context);
         else if (Class[0] == X86_64_SSESF_CLASS)
@@ -1146,6 +1160,8 @@
         if (Class[1] == X86_64_INTEGERSI_CLASS ||
             Class[1] == X86_64_INTEGER_CLASS)
           return Type::getInt64Ty(Context);
+        else if (Class[1] == X86_64_POINTER_CLASS)
+          return Type::getInt8PtrTy(Context);
         else if (Class[1] == X86_64_SSE_CLASS || Class[1] == X86_64_SSEDF_CLASS)
           return Type::getDoubleTy(Context);
         else if (Class[1] == X86_64_SSESF_CLASS)
@@ -1189,6 +1205,9 @@
   if (NumClasses == 1 && Class[0] == X86_64_INTEGER_CLASS)
      assert(0 && "This type does not need multiple return registers!");
 
+  if (NumClasses == 1 && Class[0] == X86_64_POINTER_CLASS)
+     assert(0 && "This type does not need multiple return registers!");
+
   // classify_argument uses a single X86_64_NO_CLASS as a special case for
   // empty structs. Recognize it and don't add any return values in that
   // case.
@@ -1202,6 +1221,10 @@
       Elts.push_back(Type::getInt64Ty(Context));
       Bytes -= 8;
       break;
+    case X86_64_POINTER_CLASS:
+      Elts.push_back(Type::getInt8PtrTy(Context));
+      Bytes -= 8;
+      break;
     case X86_64_SSE_CLASS:
       // If it's a SSE class argument, then one of the followings are possible:
       // 1. 1 x SSE, size is 8: 1 x Double.
@@ -1264,6 +1287,9 @@
         } else if (Class[i+1] == X86_64_INTEGER_CLASS) {
           Elts.push_back(VectorType::get(Type::getFloatTy(Context), 2));
           Elts.push_back(Type::getInt64Ty(Context));
+        } else if (Class[i+1] == X86_64_POINTER_CLASS) {
+          Elts.push_back(VectorType::get(Type::getFloatTy(Context), 2));
+          Elts.push_back(Type::getInt8PtrTy(Context));
         } else if (Class[i+1] == X86_64_NO_CLASS) {
           Elts.push_back(Type::getDoubleTy(Context));
           Bytes -= 16;
@@ -1467,7 +1493,8 @@
     int NumClasses = ix86_ClassifyArgument(Mode, type, Class, 0);
     *DontCheckAlignment= true;
     if (NumClasses == 1 && (Class[0] == X86_64_INTEGER_CLASS ||
-                            Class[0] == X86_64_INTEGERSI_CLASS)) {
+                            Class[0] == X86_64_INTEGERSI_CLASS ||
+                            Class[0] == X86_64_POINTER_CLASS)) {
       // one int register
       HOST_WIDE_INT Bytes =
         (Mode == BLKmode) ? int_size_in_bytes(type) : (int) GET_MODE_SIZE(Mode);
@@ -1480,8 +1507,10 @@
       return true;
     }
     if (NumClasses == 2 && (Class[0] == X86_64_INTEGERSI_CLASS ||
-                            Class[0] == X86_64_INTEGER_CLASS)) {
-      if (Class[1] == X86_64_INTEGER_CLASS) {
+                            Class[0] == X86_64_INTEGER_CLASS ||
+                            Class[0] == X86_64_POINTER_CLASS)) {
+      if (Class[1] == X86_64_INTEGER_CLASS ||
+          Class[1] == X86_64_POINTER_CLASS) {
         // 16 byte object, 2 int registers
         *size = 16;
         return true;