Add new ABIArgInfo kind: Extend. This allows target to implement its own argument
zero/sign extension logic (consider, e.g. target has only 64 bit registers and thus
i32's should be extended as well).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72998 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp
index 573ffed..6f7bea2 100644
--- a/lib/CodeGen/TargetABIInfo.cpp
+++ b/lib/CodeGen/TargetABIInfo.cpp
@@ -28,6 +28,9 @@
   case Direct:
     fprintf(stderr, "Direct");
     break;
+  case Extend:
+    fprintf(stderr, "Extend");
+    break;
   case Ignore:
     fprintf(stderr, "Ignore");
     break;
@@ -342,7 +345,8 @@
 
     return ABIArgInfo::getIndirect(0);
   } else {
-    return ABIArgInfo::getDirect();
+    return (RetTy->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 }
 
@@ -371,7 +375,8 @@
 
     return ABIArgInfo::getIndirect(0);
   } else {
-    return ABIArgInfo::getDirect();
+    return (Ty->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 }
 
@@ -750,8 +755,8 @@
     // Integer and pointer types will end up in a general purpose
     // register.
     if (Ty->isIntegralType() || Ty->isPointerType())
-      return ABIArgInfo::getDirect();
-
+      return (Ty->isPromotableIntegerType() ?
+              ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   } else if (CoerceTo == llvm::Type::DoubleTy) {
     // FIXME: It would probably be better to make CGFunctionInfo only map using
     // canonical types than to canonize here.
@@ -771,7 +776,8 @@
   // If this is a scalar LLVM value then assume LLVM will pass it in the right
   // place naturally.
   if (!CodeGenFunction::hasAggregateLLVMType(Ty))
-    return ABIArgInfo::getDirect();
+    return (Ty->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
 
   // FIXME: Set alignment correctly.
   return ABIArgInfo::getIndirect(0);
@@ -1267,7 +1273,8 @@
 ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty,
                                             ASTContext &Context) const {
   if (!CodeGenFunction::hasAggregateLLVMType(Ty)) {
-    return ABIArgInfo::getDirect();
+    return (Ty->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
   // FIXME: This is kind of nasty... but there isn't much choice because the ARM
   // backend doesn't support byval.
@@ -1299,7 +1306,8 @@
       return ABIArgInfo::getCoerce(llvm::Type::Int32Ty);
     return ABIArgInfo::getIndirect(0);
   } else {
-    return ABIArgInfo::getDirect();
+    return (RetTy->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 }
 
@@ -1335,7 +1343,8 @@
   } else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
     return ABIArgInfo::getIndirect(0);
   } else {
-    return ABIArgInfo::getDirect();
+    return (RetTy->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 }
 
@@ -1344,7 +1353,8 @@
   if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
     return ABIArgInfo::getIndirect(0);
   } else {
-    return ABIArgInfo::getDirect();
+    return (Ty->isPromotableIntegerType() ?
+            ABIArgInfo::getExtend() : ABIArgInfo::getDirect());
   }
 }