2010-02-15 08:04:42 +00:00
|
|
|
//===- DAGISelMatcher.cpp - Representation of DAG pattern matcher ---------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "DAGISelMatcher.h"
|
|
|
|
#include "CodeGenDAGPatterns.h"
|
|
|
|
#include "CodeGenTarget.h"
|
2010-02-18 22:03:03 +00:00
|
|
|
#include "Record.h"
|
2010-02-15 08:04:42 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2010-02-25 06:49:58 +00:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2010-02-15 08:04:42 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2010-02-25 02:04:40 +00:00
|
|
|
void Matcher::dump() const {
|
2010-02-25 06:53:39 +00:00
|
|
|
print(errs(), 0);
|
2010-02-15 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void Matcher::print(raw_ostream &OS, unsigned indent) const {
|
|
|
|
printImpl(OS, indent);
|
2010-02-18 02:53:41 +00:00
|
|
|
if (Next)
|
|
|
|
return Next->print(OS, indent);
|
2010-02-15 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2010-02-27 07:49:13 +00:00
|
|
|
void Matcher::printOne(raw_ostream &OS) const {
|
|
|
|
printImpl(OS, 0);
|
|
|
|
}
|
|
|
|
|
2010-02-25 19:00:39 +00:00
|
|
|
ScopeMatcher::~ScopeMatcher() {
|
|
|
|
for (unsigned i = 0, e = Children.size(); i != e; ++i)
|
|
|
|
delete Children[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// printImpl methods.
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void ScopeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-25 01:56:48 +00:00
|
|
|
OS.indent(indent) << "Scope\n";
|
2010-02-25 19:00:39 +00:00
|
|
|
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
|
|
|
getChild(i)->print(OS, indent+2);
|
2010-02-15 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void RecordMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "Record\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-24 07:31:45 +00:00
|
|
|
OS.indent(indent) << "RecordChild: " << ChildNo << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "RecordMemRef\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CaptureFlagInputMatcher::printImpl(raw_ostream &OS, unsigned indent) const{
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "CaptureFlagInput\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "MoveChild " << ChildNo << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "MoveParent\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 02:04:40 +00:00
|
|
|
void CheckPatternPredicateMatcher::
|
2010-02-25 06:53:39 +00:00
|
|
|
printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckPredicate " << PredName << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckMultiOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const{
|
2010-02-22 22:30:37 +00:00
|
|
|
OS.indent(indent) << "CheckMultiOpcode <todo args>\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-24 20:15:25 +00:00
|
|
|
OS.indent(indent) << "CheckChildType " << ChildNo << " "
|
|
|
|
<< getEnumName(Type) << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckInteger " << Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckAndImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckAndImm " << Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckOrImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 08:04:42 +00:00
|
|
|
OS.indent(indent) << "CheckOrImm " << Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS,
|
2010-02-16 19:15:55 +00:00
|
|
|
unsigned indent) const {
|
|
|
|
OS.indent(indent) << "CheckFoldableChainNode\n";
|
2010-02-16 06:10:58 +00:00
|
|
|
}
|
2010-02-17 06:23:39 +00:00
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CheckChainCompatibleMatcher::printImpl(raw_ostream &OS,
|
2010-02-17 06:23:39 +00:00
|
|
|
unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "CheckChainCompatible " << PreviousOp << "\n";
|
2010-02-17 06:23:39 +00:00
|
|
|
}
|
2010-02-18 22:03:03 +00:00
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitInteger " << Val << " VT=" << VT << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 02:04:40 +00:00
|
|
|
void EmitStringIntegerMatcher::
|
2010-02-25 06:53:39 +00:00
|
|
|
printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << VT << '\n';
|
2010-02-18 22:03:03 +00:00
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitRegister ";
|
2010-02-18 22:03:03 +00:00
|
|
|
if (Reg)
|
|
|
|
OS << Reg->getName();
|
|
|
|
else
|
|
|
|
OS << "zero_reg";
|
|
|
|
OS << " VT=" << VT << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 02:04:40 +00:00
|
|
|
void EmitConvertToTargetMatcher::
|
2010-02-25 06:53:39 +00:00
|
|
|
printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 02:04:40 +00:00
|
|
|
void EmitMergeInputChainsMatcher::
|
2010-02-25 06:53:39 +00:00
|
|
|
printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitMergeInputChains <todo: args>\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitCopyToReg <todo: args>\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName()
|
|
|
|
<< " Slot=" << Slot << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void EmitNodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "EmitNode: " << OpcodeName << ": <todo flags> ";
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = VTs.size(); i != e; ++i)
|
|
|
|
OS << ' ' << getEnumName(VTs[i]);
|
|
|
|
OS << '(';
|
|
|
|
for (unsigned i = 0, e = Operands.size(); i != e; ++i)
|
|
|
|
OS << Operands[i] << ' ';
|
|
|
|
OS << ")\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void MarkFlagResultsMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-24 05:33:42 +00:00
|
|
|
OS.indent(indent) << "MarkFlagResults <todo: args>\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:53:39 +00:00
|
|
|
void CompleteMatchMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-21 06:03:07 +00:00
|
|
|
OS.indent(indent) << "CompleteMatch <todo args>\n";
|
Lots of improvements to the new dagisel emitter. This gets it to
the point where it is to the 95% feature complete mark, it just
needs result updating to be done (then testing, optimization
etc).
More specificallly, this adds support for chain and flag handling
on the result nodes, support for sdnodexforms, support for variadic
nodes, memrefs, pinned physreg inputs, and probably lots of other
stuff.
In the old DAGISelEmitter, this deletes the dead code related to
OperatorMap, cleans up a variety of dead stuff handling "implicit
remapping" from things like globaladdr -> targetglobaladdr (which
is no longer used because globaladdr always needs to be legalized),
and some minor formatting fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96716 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21 03:22:59 +00:00
|
|
|
OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n";
|
|
|
|
OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 06:49:58 +00:00
|
|
|
// 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);
|
|
|
|
}
|
2010-02-27 07:49:13 +00:00
|
|
|
|
|
|
|
// isContradictoryImpl Implementations.
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: CheckMultiOpcodeMatcher?
|
|
|
|
// TODO: CheckType?
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool TypesAreContradictory(MVT::SimpleValueType T1,
|
|
|
|
MVT::SimpleValueType T2) {
|
|
|
|
// If the two types are the same, then they are the same, so they don't
|
|
|
|
// contradict.
|
|
|
|
if (T1 == T2) return false;
|
|
|
|
|
|
|
|
// If either type is about iPtr, then they don't conflict unless the other
|
|
|
|
// one is not a scalar integer type.
|
|
|
|
if (T1 == MVT::iPTR)
|
|
|
|
return !MVT(T2).isInteger() || MVT(T2).isVector();
|
|
|
|
|
|
|
|
if (T2 == MVT::iPTR)
|
|
|
|
return !MVT(T1).isInteger() || MVT(T1).isVector();
|
|
|
|
|
|
|
|
// Otherwise, they are two different non-iPTR types, they conflict.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CheckTypeMatcher::isContradictoryImpl(const Matcher *M) const {
|
|
|
|
if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M))
|
|
|
|
return TypesAreContradictory(getType(), CT->getType());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CheckChildTypeMatcher::isContradictoryImpl(const Matcher *M) const {
|
|
|
|
if (const CheckChildTypeMatcher *CC = dyn_cast<CheckChildTypeMatcher>(M)) {
|
|
|
|
// If the two checks are about different nodes, we don't know if they
|
|
|
|
// conflict!
|
|
|
|
if (CC->getChildNo() != getChildNo())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return TypesAreContradictory(getType(), CC->getType());
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|