summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-27 21:48:43 +0000
committerChris Lattner <sabre@nondot.org>2010-02-27 21:48:43 +0000
commita230f9623d864450d432bb76c397b0cb35a3437e (patch)
tree2be73812f216d3264745af0db51056fe19b32ce6
parent9fa200d2a2360412465bbd6cfb485af2e9d5b1b4 (diff)
downloadllvm-a230f9623d864450d432bb76c397b0cb35a3437e.tar.gz
llvm-a230f9623d864450d432bb76c397b0cb35a3437e.tar.bz2
llvm-a230f9623d864450d432bb76c397b0cb35a3437e.tar.xz
change CheckOpcodeMatcher to hold the SDNodeInfo instead of
the opcode name. This gives the optimizer more semantic info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97346 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/DAGISelMatcher.cpp14
-rw-r--r--utils/TableGen/DAGISelMatcher.h23
-rw-r--r--utils/TableGen/DAGISelMatcherEmitter.cpp10
-rw-r--r--utils/TableGen/DAGISelMatcherGen.cpp12
-rw-r--r--utils/TableGen/DAGISelMatcherOpt.cpp4
5 files changed, 32 insertions, 31 deletions
diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp
index d8aee08517..ade058ef5f 100644
--- a/utils/TableGen/DAGISelMatcher.cpp
+++ b/utils/TableGen/DAGISelMatcher.cpp
@@ -81,7 +81,7 @@ void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
}
void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
- OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n';
+ OS.indent(indent) << "CheckOpcode " << Opcode.getEnumName() << '\n';
}
void CheckMultiOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const{
@@ -202,13 +202,13 @@ unsigned CheckPredicateMatcher::getHashImpl() const {
}
unsigned CheckOpcodeMatcher::getHashImpl() const {
- return HashString(OpcodeName);
+ return HashString(Opcode.getEnumName());
}
unsigned CheckMultiOpcodeMatcher::getHashImpl() const {
unsigned Result = 0;
- for (unsigned i = 0, e = OpcodeNames.size(); i != e; ++i)
- Result |= HashString(OpcodeNames[i]);
+ for (unsigned i = 0, e = Opcodes.size(); i != e; ++i)
+ Result |= HashString(Opcodes[i]->getEnumName());
return Result;
}
@@ -263,7 +263,7 @@ unsigned CompleteMatchMatcher::getHashImpl() const {
bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const {
if (const CheckOpcodeMatcher *COM = dyn_cast<CheckOpcodeMatcher>(M)) {
// One node can't have two different opcodes!
- return COM->getOpcodeName() != getOpcodeName();
+ return &COM->getOpcode() != &getOpcode();
}
// TODO: CheckMultiOpcodeMatcher?
@@ -272,8 +272,8 @@ bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const {
// ISD::STORE nodes can't have non-void type.
if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M))
// FIXME: This sucks, get void nodes from type constraints.
- return (getOpcodeName() == "ISD::STORE" ||
- getOpcodeName() == "ISD::INTRINSIC_VOID") &&
+ return (getOpcode().getEnumName() == "ISD::STORE" ||
+ getOpcode().getEnumName() == "ISD::INTRINSIC_VOID") &&
CT->getType() != MVT::isVoid;
return false;
diff --git a/utils/TableGen/DAGISelMatcher.h b/utils/TableGen/DAGISelMatcher.h
index f983f5a133..d80f19b334 100644
--- a/utils/TableGen/DAGISelMatcher.h
+++ b/utils/TableGen/DAGISelMatcher.h
@@ -23,6 +23,7 @@ namespace llvm {
class raw_ostream;
class ComplexPattern;
class Record;
+ class SDNodeInfo;
Matcher *ConvertPatternToMatcher(const PatternToMatch &Pattern,
const CodeGenDAGPatterns &CGP);
@@ -386,12 +387,12 @@ private:
/// CheckOpcodeMatcher - This checks to see if the current node has the
/// specified opcode, if not it fails to match.
class CheckOpcodeMatcher : public Matcher {
- StringRef OpcodeName;
+ const SDNodeInfo &Opcode;
public:
- CheckOpcodeMatcher(StringRef opcodename)
- : Matcher(CheckOpcode), OpcodeName(opcodename) {}
+ CheckOpcodeMatcher(const SDNodeInfo &opcode)
+ : Matcher(CheckOpcode), Opcode(opcode) {}
- StringRef getOpcodeName() const { return OpcodeName; }
+ const SDNodeInfo &getOpcode() const { return Opcode; }
static inline bool classof(const Matcher *N) {
return N->getKind() == CheckOpcode;
@@ -402,7 +403,7 @@ public:
private:
virtual void printImpl(raw_ostream &OS, unsigned indent) const;
virtual bool isEqualImpl(const Matcher *M) const {
- return cast<CheckOpcodeMatcher>(M)->OpcodeName == OpcodeName;
+ return &cast<CheckOpcodeMatcher>(M)->Opcode == &Opcode;
}
virtual unsigned getHashImpl() const;
virtual bool isContradictoryImpl(const Matcher *M) const;
@@ -411,13 +412,13 @@ private:
/// CheckMultiOpcodeMatcher - This checks to see if the current node has one
/// of the specified opcode, if not it fails to match.
class CheckMultiOpcodeMatcher : public Matcher {
- SmallVector<StringRef, 4> OpcodeNames;
+ SmallVector<const SDNodeInfo*, 4> Opcodes;
public:
- CheckMultiOpcodeMatcher(const StringRef *opcodes, unsigned numops)
- : Matcher(CheckMultiOpcode), OpcodeNames(opcodes, opcodes+numops) {}
+ CheckMultiOpcodeMatcher(const SDNodeInfo * const *opcodes, unsigned numops)
+ : Matcher(CheckMultiOpcode), Opcodes(opcodes, opcodes+numops) {}
- unsigned getNumOpcodeNames() const { return OpcodeNames.size(); }
- StringRef getOpcodeName(unsigned i) const { return OpcodeNames[i]; }
+ unsigned getNumOpcodes() const { return Opcodes.size(); }
+ const SDNodeInfo &getOpcode(unsigned i) const { return *Opcodes[i]; }
static inline bool classof(const Matcher *N) {
return N->getKind() == CheckMultiOpcode;
@@ -428,7 +429,7 @@ public:
private:
virtual void printImpl(raw_ostream &OS, unsigned indent) const;
virtual bool isEqualImpl(const Matcher *M) const {
- return cast<CheckMultiOpcodeMatcher>(M)->OpcodeNames == OpcodeNames;
+ return cast<CheckMultiOpcodeMatcher>(M)->Opcodes == Opcodes;
}
virtual unsigned getHashImpl() const;
};
diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp
index 7c0846a9df..450a4575bf 100644
--- a/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -269,16 +269,16 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
case Matcher::CheckOpcode:
OS << "OPC_CheckOpcode, "
- << cast<CheckOpcodeMatcher>(N)->getOpcodeName() << ",\n";
+ << cast<CheckOpcodeMatcher>(N)->getOpcode().getEnumName() << ",\n";
return 2;
case Matcher::CheckMultiOpcode: {
const CheckMultiOpcodeMatcher *CMO = cast<CheckMultiOpcodeMatcher>(N);
- OS << "OPC_CheckMultiOpcode, " << CMO->getNumOpcodeNames() << ", ";
- for (unsigned i = 0, e = CMO->getNumOpcodeNames(); i != e; ++i)
- OS << CMO->getOpcodeName(i) << ", ";
+ OS << "OPC_CheckMultiOpcode, " << CMO->getNumOpcodes() << ", ";
+ for (unsigned i = 0, e = CMO->getNumOpcodes(); i != e; ++i)
+ OS << CMO->getOpcode(i).getEnumName() << ", ";
OS << '\n';
- return 2 + CMO->getNumOpcodeNames();
+ return 2 + CMO->getNumOpcodes();
}
case Matcher::CheckType:
diff --git a/utils/TableGen/DAGISelMatcherGen.cpp b/utils/TableGen/DAGISelMatcherGen.cpp
index 1224a1d42c..cae2dfbc59 100644
--- a/utils/TableGen/DAGISelMatcherGen.cpp
+++ b/utils/TableGen/DAGISelMatcherGen.cpp
@@ -252,14 +252,12 @@ void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) {
if (N == Pattern.getSrcPattern()) {
const std::vector<Record*> &OpNodes = CP.getRootNodes();
if (OpNodes.size() == 1) {
- StringRef OpName = CGP.getSDNodeInfo(OpNodes[0]).getEnumName();
- AddMatcher(new CheckOpcodeMatcher(OpName));
+ AddMatcher(new CheckOpcodeMatcher(CGP.getSDNodeInfo(OpNodes[0])));
} else if (!OpNodes.empty()) {
- SmallVector<StringRef, 4> OpNames;
+ SmallVector<const SDNodeInfo*, 4> OpNames;
for (unsigned i = 0, e = OpNodes.size(); i != e; i++)
- OpNames.push_back(CGP.getSDNodeInfo(OpNodes[i]).getEnumName());
- AddMatcher(new CheckMultiOpcodeMatcher(OpNames.data(),
- OpNames.size()));
+ OpNames.push_back(&CGP.getSDNodeInfo(OpNodes[i]));
+ AddMatcher(new CheckMultiOpcodeMatcher(OpNames.data(), OpNames.size()));
}
}
@@ -337,7 +335,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
}
// Check that the current opcode lines up.
- AddMatcher(new CheckOpcodeMatcher(CInfo.getEnumName()));
+ AddMatcher(new CheckOpcodeMatcher(CInfo));
// If there are node predicates for this node, generate their checks.
for (unsigned i = 0, e = N->getPredicateFns().size(); i != e; ++i)
diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp
index 7e517ea9ff..1ce573353f 100644
--- a/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -201,7 +201,9 @@ static void FactorNodes(OwningPtr<Matcher> &MatcherPtr) {
--e;
}
- if (Scan != e) {
+ if (Scan != e &&
+ // Don't print it's obvious nothing extra could be merged anyway.
+ Scan+1 != e) {
DEBUG(errs() << "Couldn't merge this:\n";
Optn->print(errs(), 4);
errs() << "into this:\n";