summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-23 07:22:28 +0000
committerChris Lattner <sabre@nondot.org>2010-02-23 07:22:28 +0000
commit5b0e24902bfa6435664b2f62fd63a7c8aceac015 (patch)
tree2db8fe733526701ad7e302995321ff93692eec24 /llvm/utils/TableGen/CodeGenDAGPatterns.cpp
parent89f6ec462d740c72a1988269ced1188ac18a00e8 (diff)
downloadbcm5719-llvm-5b0e24902bfa6435664b2f62fd63a7c8aceac015.tar.gz
bcm5719-llvm-5b0e24902bfa6435664b2f62fd63a7c8aceac015.zip
Reject patterns that use a name multiple times in the src or result
of a pattern and where the uses have different types. llvm-svn: 96904
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.cpp')
-rw-r--r--llvm/utils/TableGen/CodeGenDAGPatterns.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index e27b602a238..3c7c2edae8e 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2091,20 +2091,21 @@ void CodeGenDAGPatterns::ParseInstructions() {
typedef std::pair<const TreePatternNode*, unsigned> NameRecord;
static void FindNames(const TreePatternNode *P,
- std::map<std::string, NameRecord> &Names) {
+ std::map<std::string, NameRecord> &Names,
+ const TreePattern *PatternTop) {
if (!P->getName().empty()) {
NameRecord &Rec = Names[P->getName()];
// If this is the first instance of the name, remember the node.
if (Rec.second++ == 0)
Rec.first = P;
-// else
-// assert(Rec.first->getExtTypes() == P->getExtTypes() &&
-// "Type mismatch on name repetition");
+ else if (Rec.first->getExtTypes() != P->getExtTypes())
+ PatternTop->error("repetition of value: $" + P->getName() +
+ " where different uses have different types!");
}
if (!P->isLeaf()) {
for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i)
- FindNames(P->getChild(i), Names);
+ FindNames(P->getChild(i), Names, PatternTop);
}
}
@@ -2118,8 +2119,8 @@ void CodeGenDAGPatterns::AddPatternToMatch(const TreePattern *Pattern,
// Find all of the named values in the input and output, ensure they have the
// same type.
std::map<std::string, NameRecord> SrcNames, DstNames;
- FindNames(PTM.getSrcPattern(), SrcNames);
- FindNames(PTM.getDstPattern(), DstNames);
+ FindNames(PTM.getSrcPattern(), SrcNames, Pattern);
+ FindNames(PTM.getDstPattern(), DstNames, Pattern);
// Scan all of the named values in the destination pattern, rejecting them if
// they don't exist in the input pattern.
OpenPOWER on IntegriCloud