From ba1cff4450e22415bfcb960342e6d5a5918e530a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 23 Feb 2010 07:50:58 +0000 Subject: [PATCH] add some #if 0'd out code for checking that named values in input/output patterns have the same type. It turns out that this triggers all the time because we don't infer types between these boundaries. Until we do, don't turn this on. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96905 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenDAGPatterns.cpp | 60 ++++++++++++++++++--------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index 3c7c2edae8e..112a52d567b 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -568,33 +568,36 @@ bool TreePatternNode::UpdateNodeType(const std::vector &ExtVTs, return true; // unreachable } +static std::string GetTypeName(unsigned char TypeID) { + switch (TypeID) { + case MVT::Other: return "Other"; + case MVT::iAny: return "iAny"; + case MVT::fAny: return "fAny"; + case MVT::vAny: return "vAny"; + case EEVT::isUnknown: return "isUnknown"; + case MVT::iPTR: return "iPTR"; + case MVT::iPTRAny: return "iPTRAny"; + default: + std::string VTName = llvm::getName((MVT::SimpleValueType)TypeID); + // Strip off EVT:: prefix if present. + if (VTName.substr(0,5) == "MVT::") + VTName = VTName.substr(5); + return VTName; + } +} + void TreePatternNode::print(raw_ostream &OS) const { if (isLeaf()) { OS << *getLeafValue(); } else { - OS << "(" << getOperator()->getName(); + OS << '(' << getOperator()->getName(); } // FIXME: At some point we should handle printing all the value types for // nodes that are multiply typed. - switch (getExtTypeNum(0)) { - case MVT::Other: OS << ":Other"; break; - case MVT::iAny: OS << ":iAny"; break; - case MVT::fAny : OS << ":fAny"; break; - case MVT::vAny: OS << ":vAny"; break; - case EEVT::isUnknown: ; /*OS << ":?";*/ break; - case MVT::iPTR: OS << ":iPTR"; break; - case MVT::iPTRAny: OS << ":iPTRAny"; break; - default: { - std::string VTName = llvm::getName(getTypeNum(0)); - // Strip off EVT:: prefix if present. - if (VTName.substr(0,5) == "MVT::") - VTName = VTName.substr(5); - OS << ":" << VTName; - break; - } - } + if (getExtTypeNum(0) != EEVT::isUnknown) + OS << ':' << GetTypeName(getExtTypeNum(0)); if (!isLeaf()) { if (getNumChildren() != 0) { @@ -2125,10 +2128,29 @@ void CodeGenDAGPatterns::AddPatternToMatch(const TreePattern *Pattern, // Scan all of the named values in the destination pattern, rejecting them if // they don't exist in the input pattern. for (std::map::iterator - I = DstNames.begin(), E = DstNames.end(); I != E; ++I) + I = DstNames.begin(), E = DstNames.end(); I != E; ++I) { if (SrcNames[I->first].first == 0) Pattern->error("Pattern has input without matching name in output: $" + I->first); + +#if 0 + const std::vector &SrcTypeVec = + SrcNames[I->first].first->getExtTypes(); + const std::vector &DstTypeVec = + I->second.first->getExtTypes(); + if (SrcTypeVec == DstTypeVec) continue; + + std::string SrcType, DstType; + for (unsigned i = 0, e = SrcTypeVec.size(); i != e; ++i) + SrcType += ":" + GetTypeName(SrcTypeVec[i]); + for (unsigned i = 0, e = DstTypeVec.size(); i != e; ++i) + DstType += ":" + GetTypeName(DstTypeVec[i]); + + Pattern->error("Variable $" + I->first + + " has different types in source (" + SrcType + + ") and dest (" + DstType + ") pattern!"); +#endif + } // Scan all of the named values in the source pattern, rejecting them if the // name isn't used in the dest, and isn't used to tie two values together. -- 2.34.1