[llvm-commits] [llvm] r78631 - in /llvm/trunk: include/llvm/CodeGen/ValueTypes.h include/llvm/CodeGen/ValueTypes.td include/llvm/Intrinsics.h include/llvm/Intrinsics.td lib/VMCore/Verifier.cpp utils/TableGen/CodeGenDAGPatterns.cpp utils/TableGen/CodeGenTarget.cpp utils/TableGen/IntrinsicEmitter.cpp

Bob Wilson bob.wilson at apple.com
Mon Aug 10 18:14:02 PDT 2009


Author: bwilson
Date: Mon Aug 10 20:14:02 2009
New Revision: 78631

URL: http://llvm.org/viewvc/llvm-project?rev=78631&view=rev
Log:
Add a new overloaded EVT::vAny type for use in TableGen to allow intrinsic
arguments that are vectors of any size and element type.

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

Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.h?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/ValueTypes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/ValueTypes.h Mon Aug 10 20:14:02 2009
@@ -83,26 +83,31 @@
       MAX_ALLOWED_VALUETYPE = 64,
 
       // Metadata - This is MDNode or MDString.
-      Metadata       = 251,
+      Metadata       = 250,
 
       // iPTRAny - An int value the size of the pointer of the current
       // target to any address space. This must only be used internal to
       // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
-      iPTRAny        =  252,
+      iPTRAny        = 251,
+
+      // vAny - A vector with any length and element size. This is used
+      // for intrinsics that have overloadings based on vector types.
+      // This is only for tblgen's consumption!
+      vAny           = 252,
 
       // 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,
+      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!
-      iAny           =  254,
+      iAny           = 254,
 
       // iPTR - An int value the size of the pointer of the current
       // target.  This should only be used internal to tblgen!
-      iPTR           =  255,
+      iPTR           = 255,
 
       // LastSimpleValueType - The greatest valid SimpleValueType value.
       LastSimpleValueType = 255
@@ -284,6 +289,11 @@
               V==v4i64) : isExtended256BitVector();
     }
 
+    /// isOverloaded - Return true if this is an overloaded type for TableGen.
+    bool isOverloaded() const {
+      return (V==iAny || V==fAny || V==vAny || V==iPTRAny);
+    }
+
     /// isByteSized - Return true if the bit size is a multiple of 8.
     bool isByteSized() const {
       return (getSizeInBits() & 7) == 0;
@@ -396,6 +406,7 @@
       case iPTRAny:
       case iAny:
       case fAny:
+      case vAny:
         assert(0 && "Value type is overloaded.");
       default:
         return getExtendedSizeInBits();

Modified: llvm/trunk/include/llvm/CodeGen/ValueTypes.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ValueTypes.td?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/ValueTypes.td (original)
+++ llvm/trunk/include/llvm/CodeGen/ValueTypes.td Mon Aug 10 20:14:02 2009
@@ -56,11 +56,14 @@
 def v2f64  : ValueType<128, 32>;   //  2 x f64 vector value
 def v4f64  : ValueType<256, 33>;   //  4 x f64 vector value
 
-def MetadataVT: ValueType<0, 251>; // Metadata
+def MetadataVT: ValueType<0, 250>; // Metadata
 
 // Pseudo valuetype mapped to the current pointer size to any address space.
 // Should only be used in TableGen.
-def iPTRAny   : ValueType<0, 252>;
+def iPTRAny   : ValueType<0, 251>;
+
+// Pseudo valuetype to represent "vector of any size"
+def vAny   : ValueType<0  , 252>;
 
 // Pseudo valuetype to represent "float of any format"
 def fAny   : ValueType<0  , 253>;

Modified: llvm/trunk/include/llvm/Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Intrinsics.h (original)
+++ llvm/trunk/include/llvm/Intrinsics.h Mon Aug 10 20:14:02 2009
@@ -63,7 +63,7 @@
   /// declaration for an intrinsic, and return it.
   ///
   /// The Tys and numTys parameters are for intrinsics with overloaded types
-  /// (i.e., those using iAny or fAny). For a declaration for an overloaded
+  /// (e.g., those using iAny or fAny). For a declaration for an overloaded
   /// intrinsic, Tys should point to an array of numTys pointers to Type,
   /// and must provide exactly one type for each overloaded type in the
   /// intrinsic.

Modified: llvm/trunk/include/llvm/Intrinsics.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Intrinsics.td (original)
+++ llvm/trunk/include/llvm/Intrinsics.td Mon Aug 10 20:14:02 2009
@@ -94,6 +94,7 @@
 def llvm_void_ty       : LLVMType<isVoid>;
 def llvm_anyint_ty     : LLVMType<iAny>;
 def llvm_anyfloat_ty   : LLVMType<fAny>;
+def llvm_anyvector_ty  : LLVMType<vAny>;
 def llvm_i1_ty         : LLVMType<i1>;
 def llvm_i8_ty         : LLVMType<i8>;
 def llvm_i16_ty        : LLVMType<i16>;

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Mon Aug 10 20:14:02 2009
@@ -1597,6 +1597,12 @@
       Suffix += "v" + utostr(NumElts);
 
     Suffix += EVT::getEVT(EltTy).getEVTString();
+  } else if (VT == EVT::vAny) {
+    if (!VTy) {
+      CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not a vector type.", F);
+      return false;
+    }
+    Suffix += ".v" + utostr(NumElts) + EVT::getEVT(EltTy).getEVTString();
   } else if (VT == EVT::iPTR) {
     if (!isa<PointerType>(Ty)) {
       CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is not a "

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Mon Aug 10 20:14:02 2009
@@ -87,9 +87,16 @@
 /// isExtFloatingPointInVTs - Return true if the specified extended value type
 /// vector contains isFP or a FP value type.
 bool isExtFloatingPointInVTs(const std::vector<unsigned char> &EVTs) {
-  assert(!EVTs.empty() && "Cannot check for integer in empty ExtVT list!");
+  assert(!EVTs.empty() && "Cannot check for FP in empty ExtVT list!");
   return EVTs[0] == isFP || !(FilterEVTs(EVTs, isFloatingPoint).empty());
 }
+
+/// isExtVectorInVTs - Return true if the specified extended value type
+/// vector contains a vector value type.
+bool isExtVectorInVTs(const std::vector<unsigned char> &EVTs) {
+  assert(!EVTs.empty() && "Cannot check for vector in empty ExtVT list!");
+  return !(FilterEVTs(EVTs, isVector).empty());
+}
 } // end namespace EEVT.
 } // end namespace llvm.
 
@@ -495,6 +502,14 @@
     setTypes(FVTs);
     return true;
   }
+  if (ExtVTs[0] == EVT::vAny && EEVT::isExtVectorInVTs(getExtTypes())) {
+    assert(hasTypeSet() && "should be handled above!");
+    std::vector<unsigned char> FVTs = FilterEVTs(getExtTypes(), isVector);
+    if (getExtTypes() == FVTs)
+      return false;
+    setTypes(FVTs);
+    return true;
+  }
       
   // If we know this is an int or fp type, and we are told it is a specific one,
   // take the advice.
@@ -504,7 +519,9 @@
   if (((getExtTypeNum(0) == EEVT::isInt || getExtTypeNum(0) == EVT::iAny) &&
        EEVT::isExtIntegerInVTs(ExtVTs)) ||
       ((getExtTypeNum(0) == EEVT::isFP || getExtTypeNum(0) == EVT::fAny) &&
-       EEVT::isExtFloatingPointInVTs(ExtVTs))) {
+       EEVT::isExtFloatingPointInVTs(ExtVTs)) ||
+      (getExtTypeNum(0) == EVT::vAny &&
+       EEVT::isExtVectorInVTs(ExtVTs))) {
     setTypes(ExtVTs);
     return true;
   }

Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Mon Aug 10 20:14:02 2009
@@ -56,6 +56,7 @@
   case EVT::i128:  return "EVT::i128";
   case EVT::iAny:  return "EVT::iAny";
   case EVT::fAny:  return "EVT::fAny";
+  case EVT::vAny:  return "EVT::vAny";
   case EVT::f32:   return "EVT::f32";
   case EVT::f64:   return "EVT::f64";
   case EVT::f80:   return "EVT::f80";
@@ -496,7 +497,7 @@
     } else {
       VT = getValueType(TyEl->getValueAsDef("VT"));
     }
-    if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny) {
+    if (EVT(VT).isOverloaded()) {
       OverloadedVTs.push_back(VT);
       isOverloaded |= true;
     }
@@ -526,7 +527,7 @@
               VT == EVT::iAny) && "Expected iAny type");
     } else
       VT = getValueType(TyEl->getValueAsDef("VT"));
-    if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny) {
+    if (EVT(VT).isOverloaded()) {
       OverloadedVTs.push_back(VT);
       isOverloaded |= true;
     }

Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=78631&r1=78630&r2=78631&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Mon Aug 10 20:14:02 2009
@@ -203,7 +203,7 @@
          << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
     else
       OS << "Tys[" << Number << "]";
-  } else if (VT == EVT::iAny || VT == EVT::fAny) {
+  } else if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::vAny) {
     // 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
@@ -329,7 +329,7 @@
         EVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
         OS << getEnumName(VT);
 
-        if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny)
+        if (EVT(VT).isOverloaded())
           OverloadedTypeIndices.push_back(j);
 
         if (VT == EVT::isVoid && j != 0 && j != je - 1)
@@ -357,7 +357,7 @@
         EVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
         OS << getEnumName(VT);
 
-        if (VT == EVT::iAny || VT == EVT::fAny || VT == EVT::iPTRAny)
+        if (EVT(VT).isOverloaded())
           OverloadedTypeIndices.push_back(j + RetTys.size());
 
         if (VT == EVT::isVoid && j != 0 && j != je - 1)





More information about the llvm-commits mailing list