Add MVT::fAny for overloading intrinsics on floating-point types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41128 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h
index 4ddacba..965043a 100644
--- a/include/llvm/CodeGen/ValueTypes.h
+++ b/include/llvm/CodeGen/ValueTypes.h
@@ -67,6 +67,11 @@
 
     LAST_VALUETYPE =  27,   // This always remains at the end of the list.
 
+    // fAny - Any floating-point or vector floating-point value. This is used
+    // for intrinsics that have overloadings based on floating-point types.
+    // This is only for tblgen's consumption!
+    fAny           =  253,   
+
     // iAny - An integer or vector integer value of any bit width. This is
     // used for intrinsics that have overloadings based on integer bit widths.
     // This is only for tblgen's consumption!
diff --git a/include/llvm/CodeGen/ValueTypes.td b/include/llvm/CodeGen/ValueTypes.td
index 47678d1..19ebf5d 100644
--- a/include/llvm/CodeGen/ValueTypes.td
+++ b/include/llvm/CodeGen/ValueTypes.td
@@ -49,6 +49,9 @@
 def v4f32  : ValueType<128, 25>;   //  4 x f32 vector value
 def v2f64  : ValueType<128, 26>;   //  2 x f64 vector value
 
+// Pseudo valuetype to represent "float of any format"
+def fAny   : ValueType<0  , 253>;
+
 // Pseudo valuetype to represent "integer of any bit width"
 def iAny   : ValueType<0  , 254>;
 
diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td
index 91f1284..6f21a1c 100644
--- a/include/llvm/Intrinsics.td
+++ b/include/llvm/Intrinsics.td
@@ -68,6 +68,7 @@
 
 def llvm_void_ty       : LLVMType<isVoid>;
 def llvm_anyint_ty     : LLVMType<iAny>;
+def llvm_anyfloat_ty   : LLVMType<fAny>;
 def llvm_i1_ty         : LLVMType<i1>;
 def llvm_i8_ty         : LLVMType<i8>;
 def llvm_i16_ty        : LLVMType<i16>;
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index c01f0fe..0c4ca64 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1157,6 +1157,20 @@
             CheckFailed("Intrinsic requires even byte width argument", F);
           break;
       }
+    } else if (VT == MVT::fAny) {
+      Suffix += ".";
+      if (EltTy != Ty)
+        Suffix += "v" + utostr(NumElts);
+      Suffix += MVT::getValueTypeString(MVT::getValueType(EltTy));
+      if (!EltTy->isFloatingPoint()) {
+        if (ArgNo == 0)
+          CheckFailed("Intrinsic result type is not "
+                      "a floating-point type.", F);
+        else
+          CheckFailed("Intrinsic parameter #" + utostr(ArgNo-1) + " is not "
+                      "a floating-point type.", F);
+        break;
+      }
     } else if (VT == MVT::iPTR) {
       if (!isa<PointerType>(Ty)) {
         CheckFailed("Intrinsic parameter #" + utostr(ArgNo-1) + " is not a "
diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp
index 78b850b..1fee306 100644
--- a/utils/TableGen/CodeGenTarget.cpp
+++ b/utils/TableGen/CodeGenTarget.cpp
@@ -44,6 +44,7 @@
   case MVT::i64:   return "MVT::i64";
   case MVT::i128:  return "MVT::i128";
   case MVT::iAny:  return "MVT::iAny";
+  case MVT::fAny:  return "MVT::fAny";
   case MVT::f32:   return "MVT::f32";
   case MVT::f64:   return "MVT::f64";
   case MVT::f80:   return "MVT::f80";
@@ -78,6 +79,7 @@
   case MVT::i64:   return "MVT::i64";
   case MVT::i128:  return "MVT::i128";
   case MVT::iAny:  return "MVT::iAny";
+  case MVT::fAny:  return "MVT::fAny";
   case MVT::f32:   return "MVT::f32";
   case MVT::f64:   return "MVT::f64";
   case MVT::f80:   return "MVT::f80";
@@ -652,7 +654,7 @@
     Record *TyEl = TypeList->getElementAsRecord(i);
     assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!");
     MVT::ValueType VT = getValueType(TyEl->getValueAsDef("VT"));
-    isOverloaded |= VT == MVT::iAny;
+    isOverloaded |= VT == MVT::iAny || VT == MVT::fAny;
     ArgVTs.push_back(VT);
     ArgTypeDefs.push_back(TyEl);
   }
diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp
index f5df933..c3db273 100644
--- a/utils/TableGen/IntrinsicEmitter.cpp
+++ b/utils/TableGen/IntrinsicEmitter.cpp
@@ -146,7 +146,7 @@
     unsigned Number = ArgType->getValueAsInt("Number");
     assert(Number < ArgNo && "Invalid matching number!");
     OS << "Tys[" << Number << "]";
-  } else if (VT == MVT::iAny) {
+  } else if (VT == MVT::iAny || VT == MVT::fAny) {
     // NOTE: The ArgNo variable here is not the absolute argument number, it is
     // the index of the "arbitrary" type in the Tys array passed to the
     // Intrinsic::getDeclaration function. Consequently, we only want to