Add MVT::fAny for overloading intrinsics on floating-point types.
authorDan Gohman <gohman@apple.com>
Thu, 16 Aug 2007 21:57:19 +0000 (21:57 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 16 Aug 2007 21:57:19 +0000 (21:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41128 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/ValueTypes.h
include/llvm/CodeGen/ValueTypes.td
include/llvm/Intrinsics.td
lib/VMCore/Verifier.cpp
utils/TableGen/CodeGenTarget.cpp
utils/TableGen/IntrinsicEmitter.cpp

index 4ddacba3191d4e296af9a6ae4081af50d3a8be40..965043a1093365e88b505f9cd22f04ce557aecbf 100644 (file)
@@ -67,6 +67,11 @@ namespace MVT {  // MVT = Machine Value Types
 
     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!
index 47678d1de9639a4dc5ae5b7a8686ff6c94aab43e..19ebf5df395bab1aaf7208bd54aa1f77deb75f23 100644 (file)
@@ -49,6 +49,9 @@ def v3f32  : ValueType<96 , 24>;   //  3 x f32 vector value
 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>;
 
index 91f12841f4b03ed60ac5eb24c3f54b527b5cde7f..6f21a1c7bd078a48aff76212615147c11f3a251a 100644 (file)
@@ -68,6 +68,7 @@ class LLVMMatchType<int num>
 
 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>;
index c01f0fe9cc18982507d9383b13a66ce8e8b45311..0c4ca642098e7926cc15ee3f01ab38b2440d8b12 100644 (file)
@@ -1157,6 +1157,20 @@ void Verifier::VerifyIntrinsicPrototype(Intrinsic::ID ID,
             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 "
index 78b850b43ca8647a51cbb3f7576697b7d1ce9d20..1fee306e9f832f5a9b2fc0d218301374ff1b3252 100644 (file)
@@ -44,6 +44,7 @@ std::string llvm::getName(MVT::ValueType T) {
   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 @@ std::string llvm::getEnumName(MVT::ValueType T) {
   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 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R, CodeGenTarget *CGT) {
     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);
   }
index f5df933f2ea2b0734bc6ab4c97c8f3441e126fb2..c3db273ce60706185edf1b25d1daa34e42e8757f 100644 (file)
@@ -146,7 +146,7 @@ static void EmitTypeGenerate(std::ostream &OS, Record *ArgType,
     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