[llvm-commits] [llvm] r77467 - /llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp

Bob Wilson bob.wilson at apple.com
Wed Jul 29 09:36:02 PDT 2009


Author: bwilson
Date: Wed Jul 29 11:35:59 2009
New Revision: 77467

URL: http://llvm.org/viewvc/llvm-project?rev=77467&view=rev
Log:
Fix the verifier to handle intrinsics with LLVMMatchType parameters, where
the return type of the intrinsic is not overloaded, i.e., where the type
being matched is some other parameter.  The argument to LLVMMatchType is
an index into the list of overloaded types (ignoring the fixed types),
but VerifyIntrinsicPrototype is expecting its arguments for LLVMMatchType
parameters to be indices into the combined list of _all_ return values and
parameters, not just the overloaded ones.

This patch changes TableGen to keep track for each overloaded type of the
corresponding index into the list of return values and parameters.  It
then generates the values expected by VerifyIntrinsicPrototype.

Modified:
    llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp

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

==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Wed Jul 29 11:35:59 2009
@@ -304,6 +304,7 @@
     const RecPair &ArgTypes = I->first;
     const std::vector<Record*> &RetTys = ArgTypes.first;
     const std::vector<Record*> &ParamTys = ArgTypes.second;
+    std::vector<unsigned> OverloadedTypeIndices;
 
     OS << "    VerifyIntrinsicPrototype(ID, IF, " << RetTys.size() << ", "
        << ParamTys.size();
@@ -315,6 +316,9 @@
 
       if (ArgType->isSubClassOf("LLVMMatchType")) {
         unsigned Number = ArgType->getValueAsInt("Number");
+        assert(Number < OverloadedTypeIndices.size() &&
+               "Invalid matching number!");
+        Number = OverloadedTypeIndices[Number];
         if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
           OS << "~(ExtendedElementVectorType | " << Number << ")";
         else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
@@ -325,6 +329,9 @@
         MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
         OS << getEnumName(VT);
 
+        if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny)
+          OverloadedTypeIndices.push_back(j);
+
         if (VT == MVT::isVoid && j != 0 && j != je - 1)
           throw "Var arg type not last argument";
       }
@@ -337,6 +344,9 @@
 
       if (ArgType->isSubClassOf("LLVMMatchType")) {
         unsigned Number = ArgType->getValueAsInt("Number");
+        assert(Number < OverloadedTypeIndices.size() &&
+               "Invalid matching number!");
+        Number = OverloadedTypeIndices[Number];
         if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
           OS << "~(ExtendedElementVectorType | " << Number << ")";
         else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
@@ -347,6 +357,9 @@
         MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
         OS << getEnumName(VT);
 
+        if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::iPTRAny)
+          OverloadedTypeIndices.push_back(j + RetTys.size());
+
         if (VT == MVT::isVoid && j != 0 && j != je - 1)
           throw "Var arg type not last argument";
       }





More information about the llvm-commits mailing list