aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-22 22:30:37 +0000
committerChris Lattner <sabre@nondot.org>2010-02-22 22:30:37 +0000
commit12a667c1e8fa57a13ae751164b6dd4412a62dc5d (patch)
treea98a6a6557659a50699254f925e083f95fb1e6fb
parent1f2ed5fe7ed9327f79dc7128fc109e4d6c864907 (diff)
downloadexternal_llvm-12a667c1e8fa57a13ae751164b6dd4412a62dc5d.zip
external_llvm-12a667c1e8fa57a13ae751164b6dd4412a62dc5d.tar.gz
external_llvm-12a667c1e8fa57a13ae751164b6dd4412a62dc5d.tar.bz2
add a new CheckMultiOpcode opcode for checking that a node
has one of the list of acceptable opcodes for a complex pattern. This fixes 4 regtest failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96814 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/DAGISelHeader.h11
-rw-r--r--utils/TableGen/DAGISelMatcher.cpp5
-rw-r--r--utils/TableGen/DAGISelMatcher.h21
-rw-r--r--utils/TableGen/DAGISelMatcherEmitter.cpp9
-rw-r--r--utils/TableGen/DAGISelMatcherGen.cpp8
5 files changed, 51 insertions, 3 deletions
diff --git a/include/llvm/CodeGen/DAGISelHeader.h b/include/llvm/CodeGen/DAGISelHeader.h
index 63d15cd..d60940f 100644
--- a/include/llvm/CodeGen/DAGISelHeader.h
+++ b/include/llvm/CodeGen/DAGISelHeader.h
@@ -211,6 +211,7 @@ enum BuiltinOpcodes {
OPC_CheckPatternPredicate,
OPC_CheckPredicate,
OPC_CheckOpcode,
+ OPC_CheckMultiOpcode,
OPC_CheckType,
OPC_CheckInteger1, OPC_CheckInteger2, OPC_CheckInteger4, OPC_CheckInteger8,
OPC_CheckCondCode,
@@ -410,6 +411,16 @@ SDNode *SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
case OPC_CheckOpcode:
if (N->getOpcode() != MatcherTable[MatcherIndex++]) break;
continue;
+
+ case OPC_CheckMultiOpcode: {
+ unsigned NumOps = MatcherTable[MatcherIndex++];
+ bool OpcodeEquals = false;
+ for (unsigned i = 0; i != NumOps; ++i)
+ OpcodeEquals |= N->getOpcode() == MatcherTable[MatcherIndex++];
+ if (!OpcodeEquals) break;
+ continue;
+ }
+
case OPC_CheckType: {
MVT::SimpleValueType VT =
(MVT::SimpleValueType)MatcherTable[MatcherIndex++];
diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp
index b3c846c..102b0e9 100644
--- a/utils/TableGen/DAGISelMatcher.cpp
+++ b/utils/TableGen/DAGISelMatcher.cpp
@@ -76,6 +76,11 @@ void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
printNext(OS, indent);
}
+void CheckMultiOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
+ OS.indent(indent) << "CheckMultiOpcode <todo args>\n";
+ printNext(OS, indent);
+}
+
void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n';
printNext(OS, indent);
diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h
index c162a0c..2379a21 100644
--- a/utils/TableGen/DAGISelMatcher.h
+++ b/utils/TableGen/DAGISelMatcher.h
@@ -51,6 +51,7 @@ public:
CheckPatternPredicate,
CheckPredicate, // Fail if node predicate fails.
CheckOpcode, // Fail if not opcode.
+ CheckMultiOpcode, // Fail if not in opcode list.
CheckType, // Fail if not correct type.
CheckInteger, // Fail if wrong val.
CheckCondCode, // Fail if not condcode.
@@ -262,6 +263,26 @@ public:
virtual void print(raw_ostream &OS, unsigned indent = 0) const;
};
+/// CheckMultiOpcodeMatcherNode - This checks to see if the current node has one
+/// of the specified opcode, if not it fails to match.
+class CheckMultiOpcodeMatcherNode : public MatcherNode {
+ SmallVector<StringRef, 4> OpcodeNames;
+public:
+ CheckMultiOpcodeMatcherNode(const StringRef *opcodes, unsigned numops)
+ : MatcherNode(CheckMultiOpcode), OpcodeNames(opcodes, opcodes+numops) {}
+
+ unsigned getNumOpcodeNames() const { return OpcodeNames.size(); }
+ StringRef getOpcodeName(unsigned i) const { return OpcodeNames[i]; }
+
+ static inline bool classof(const MatcherNode *N) {
+ return N->getKind() == CheckMultiOpcode;
+ }
+
+ virtual void print(raw_ostream &OS, unsigned indent = 0) const;
+};
+
+
+
/// CheckTypeMatcherNode - This checks to see if the current node has the
/// specified type, if not it fails to match.
class CheckTypeMatcherNode : public MatcherNode {
diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp
index 2c835cc..82d852e 100644
--- a/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -181,6 +181,15 @@ EmitMatcher(const MatcherNode *N, unsigned Indent, formatted_raw_ostream &OS) {
<< cast<CheckOpcodeMatcherNode>(N)->getOpcodeName() << ",\n";
return 2;
+ case MatcherNode::CheckMultiOpcode: {
+ const CheckMultiOpcodeMatcherNode *CMO=cast<CheckMultiOpcodeMatcherNode>(N);
+ OS << "OPC_CheckMultiOpcode, " << CMO->getNumOpcodeNames() << ", ";
+ for (unsigned i = 0, e = CMO->getNumOpcodeNames(); i != e; ++i)
+ OS << CMO->getOpcodeName(i) << ", ";
+ OS << '\n';
+ return 2 + CMO->getNumOpcodeNames();
+ }
+
case MatcherNode::CheckType:
OS << "OPC_CheckType, "
<< getEnumName(cast<CheckTypeMatcherNode>(N)->getType()) << ",\n";
diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp
index c913853..0ea165c 100644
--- a/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/utils/TableGen/DAGISelMatcherGen.cpp
@@ -251,9 +251,11 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
StringRef OpName = CGP.getSDNodeInfo(OpNodes[0]).getEnumName();
AddMatcherNode(new CheckOpcodeMatcherNode(OpName));
} else if (!OpNodes.empty()) {
- for (unsigned j = 0, e = OpNodes.size(); j != e; j++) {
- // .getOpcodeName(OpNodes[j], CGP)
- }
+ SmallVector<StringRef, 4> OpNames;
+ for (unsigned i = 0, e = OpNodes.size(); i != e; i++)
+ OpNames.push_back(CGP.getSDNodeInfo(OpNodes[i]).getEnumName());
+ AddMatcherNode(new CheckMultiOpcodeMatcherNode(OpNames.data(),
+ OpNames.size()));
}
}