diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-25 06:49:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-25 06:49:58 +0000 |
commit | 58aa834d31c2c0f378c8de5ec0450c2ab5568a2a (patch) | |
tree | 4608987235adbb8d00da2003d1019bbbe3787c4d /utils/TableGen/DAGISelMatcher.cpp | |
parent | e7ee59b6a4ec6c7a360a77aac044a546b0012c37 (diff) | |
download | external_llvm-58aa834d31c2c0f378c8de5ec0450c2ab5568a2a.zip external_llvm-58aa834d31c2c0f378c8de5ec0450c2ab5568a2a.tar.gz external_llvm-58aa834d31c2c0f378c8de5ec0450c2ab5568a2a.tar.bz2 |
add methods to do equality checks and get hashes of Matchers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelMatcher.cpp')
-rw-r--r-- | utils/TableGen/DAGISelMatcher.cpp | 68 |
1 files changed, 67 insertions, 1 deletions
diff --git a/utils/TableGen/DAGISelMatcher.cpp b/utils/TableGen/DAGISelMatcher.cpp index c38b230..4b1ae82 100644 --- a/utils/TableGen/DAGISelMatcher.cpp +++ b/utils/TableGen/DAGISelMatcher.cpp @@ -12,6 +12,7 @@ #include "CodeGenTarget.h" #include "Record.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; void Matcher::dump() const { @@ -23,7 +24,6 @@ void Matcher::printNext(raw_ostream &OS, unsigned indent) const { return Next->print(OS, indent); } - void ScopeMatcher::print(raw_ostream &OS, unsigned indent) const { OS.indent(indent) << "Scope\n"; Check->print(OS, indent+2); @@ -209,3 +209,69 @@ void CompleteMatchMatcher::print(raw_ostream &OS, unsigned indent) const { printNext(OS, indent); } +// getHashImpl Implementation. + +unsigned CheckPatternPredicateMatcher::getHashImpl() const { + return HashString(Predicate); +} + +unsigned CheckPredicateMatcher::getHashImpl() const { + return HashString(PredName); +} + +unsigned CheckOpcodeMatcher::getHashImpl() const { + return HashString(OpcodeName); +} + +unsigned CheckMultiOpcodeMatcher::getHashImpl() const { + unsigned Result = 0; + for (unsigned i = 0, e = OpcodeNames.size(); i != e; ++i) + Result |= HashString(OpcodeNames[i]); + return Result; +} + +unsigned CheckCondCodeMatcher::getHashImpl() const { + return HashString(CondCodeName); +} + +unsigned CheckValueTypeMatcher::getHashImpl() const { + return HashString(TypeName); +} + +unsigned EmitStringIntegerMatcher::getHashImpl() const { + return HashString(Val) ^ VT; +} + +template<typename It> +static unsigned HashUnsigneds(It I, It E) { + unsigned Result = 0; + for (; I != E; ++I) + Result = (Result<<3) ^ *I; + return Result; +} + +unsigned EmitMergeInputChainsMatcher::getHashImpl() const { + return HashUnsigneds(ChainNodes.begin(), ChainNodes.end()); +} + +bool EmitNodeMatcher::isEqualImpl(const Matcher *m) const { + const EmitNodeMatcher *M = cast<EmitNodeMatcher>(m); + return M->OpcodeName == OpcodeName && M->VTs == VTs && + M->Operands == Operands && M->HasChain == HasChain && + M->HasFlag == HasFlag && M->HasMemRefs == HasMemRefs && + M->NumFixedArityOperands == NumFixedArityOperands; +} + +unsigned EmitNodeMatcher::getHashImpl() const { + return (HashString(OpcodeName) << 4) | Operands.size(); +} + + +unsigned MarkFlagResultsMatcher::getHashImpl() const { + return HashUnsigneds(FlagResultNodes.begin(), FlagResultNodes.end()); +} + +unsigned CompleteMatchMatcher::getHashImpl() const { + return HashUnsigneds(Results.begin(), Results.end()) ^ + ((unsigned)(intptr_t)&Pattern << 8); +} |