2010-02-15 16:04:42 +08: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"
|
2011-10-02 00:41:13 +08:00
|
|
|
#include "llvm/TableGen/Record.h"
|
2010-02-15 16:04:42 +08:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2010-02-25 14:49:58 +08:00
|
|
|
#include "llvm/ADT/StringExtras.h"
|
2010-02-15 16:04:42 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void Matcher::anchor() { }
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
void Matcher::dump() const {
|
2010-02-25 14:53:39 +08:00
|
|
|
print(errs(), 0);
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void Matcher::print(raw_ostream &OS, unsigned indent) const {
|
|
|
|
printImpl(OS, indent);
|
2010-02-18 10:53:41 +08:00
|
|
|
if (Next)
|
|
|
|
return Next->print(OS, indent);
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-02-27 15:49:13 +08:00
|
|
|
void Matcher::printOne(raw_ostream &OS) const {
|
|
|
|
printImpl(OS, 0);
|
|
|
|
}
|
|
|
|
|
2010-03-07 14:29:26 +08:00
|
|
|
/// unlinkNode - Unlink the specified node from this chain. If Other == this,
|
|
|
|
/// we unlink the next pointer and return it. Otherwise we unlink Other from
|
|
|
|
/// the list and return this.
|
|
|
|
Matcher *Matcher::unlinkNode(Matcher *Other) {
|
|
|
|
if (this == Other)
|
|
|
|
return takeNext();
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-03-07 14:29:26 +08:00
|
|
|
// Scan until we find the predecessor of Other.
|
|
|
|
Matcher *Cur = this;
|
|
|
|
for (; Cur && Cur->getNext() != Other; Cur = Cur->getNext())
|
|
|
|
/*empty*/;
|
|
|
|
|
|
|
|
if (Cur == 0) return 0;
|
|
|
|
Cur->takeNext();
|
|
|
|
Cur->setNext(Other->takeNext());
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// canMoveBefore - Return true if this matcher is the same as Other, or if
|
|
|
|
/// we can move this matcher past all of the nodes in-between Other and this
|
|
|
|
/// node. Other must be equal to or before this.
|
|
|
|
bool Matcher::canMoveBefore(const Matcher *Other) const {
|
|
|
|
for (;; Other = Other->getNext()) {
|
|
|
|
assert(Other && "Other didn't come before 'this'?");
|
|
|
|
if (this == Other) return true;
|
|
|
|
|
|
|
|
// We have to be able to move this node across the Other node.
|
|
|
|
if (!canMoveBeforeNode(Other))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// canMoveBefore - Return true if it is safe to move the current matcher
|
|
|
|
/// across the specified one.
|
|
|
|
bool Matcher::canMoveBeforeNode(const Matcher *Other) const {
|
|
|
|
// We can move simple predicates before record nodes.
|
|
|
|
if (isSimplePredicateNode())
|
|
|
|
return Other->isSimplePredicateOrRecordNode();
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-03-07 14:29:26 +08:00
|
|
|
// We can move record nodes across simple predicates.
|
|
|
|
if (isSimplePredicateOrRecordNode())
|
|
|
|
return isSimplePredicateNode();
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-03-07 14:29:26 +08:00
|
|
|
// We can't move record nodes across each other etc.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-26 03:00:39 +08:00
|
|
|
ScopeMatcher::~ScopeMatcher() {
|
|
|
|
for (unsigned i = 0, e = Children.size(); i != e; ++i)
|
|
|
|
delete Children[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-18 05:38:24 +08:00
|
|
|
CheckPredicateMatcher::CheckPredicateMatcher(const TreePredicateFn &pred)
|
|
|
|
: Matcher(CheckPredicate), Pred(pred.getOrigPatFragRecord()) {}
|
|
|
|
|
|
|
|
TreePredicateFn CheckPredicateMatcher::getPredicate() const {
|
|
|
|
return TreePredicateFn(Pred);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-26 03:00:39 +08:00
|
|
|
// printImpl methods.
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void ScopeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-25 09:56:48 +08:00
|
|
|
OS.indent(indent) << "Scope\n";
|
2010-03-01 04:49:53 +08:00
|
|
|
for (unsigned i = 0, e = getNumChildren(); i != e; ++i) {
|
|
|
|
if (getChild(i) == 0)
|
|
|
|
OS.indent(indent+1) << "NULL POINTER\n";
|
|
|
|
else
|
|
|
|
getChild(i)->print(OS, indent+2);
|
|
|
|
}
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void RecordMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "Record\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-24 15:31:45 +08:00
|
|
|
OS.indent(indent) << "RecordChild: " << ChildNo << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "RecordMemRef\n";
|
|
|
|
}
|
|
|
|
|
2010-12-24 01:03:20 +08:00
|
|
|
void CaptureGlueInputMatcher::printImpl(raw_ostream &OS, unsigned indent) const{
|
|
|
|
OS.indent(indent) << "CaptureGlueInput\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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "MoveChild " << ChildNo << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "MoveParent\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
void CheckPatternPredicateMatcher::
|
2010-02-25 14:53:39 +08:00
|
|
|
printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2011-04-18 05:38:24 +08:00
|
|
|
OS.indent(indent) << "CheckPredicate " << getPredicate().getFnName() << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-28 05:48:43 +08:00
|
|
|
OS.indent(indent) << "CheckOpcode " << Opcode.getEnumName() << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-03-01 14:59:22 +08:00
|
|
|
void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
|
|
|
OS.indent(indent) << "SwitchOpcode: {\n";
|
|
|
|
for (unsigned i = 0, e = Cases.size(); i != e; ++i) {
|
|
|
|
OS.indent(indent) << "case " << Cases[i].first->getEnumName() << ":\n";
|
|
|
|
Cases[i].second->print(OS, indent+2);
|
|
|
|
}
|
|
|
|
OS.indent(indent) << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-03-24 08:41:19 +08:00
|
|
|
OS.indent(indent) << "CheckType " << getEnumName(Type) << ", ResNo="
|
|
|
|
<< ResNo << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-03-03 14:28:15 +08:00
|
|
|
void SwitchTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
|
|
|
OS.indent(indent) << "SwitchType: {\n";
|
|
|
|
for (unsigned i = 0, e = Cases.size(); i != e; ++i) {
|
|
|
|
OS.indent(indent) << "case " << getEnumName(Cases[i].first) << ":\n";
|
|
|
|
Cases[i].second->print(OS, indent+2);
|
|
|
|
}
|
|
|
|
OS.indent(indent) << "}\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-25 04:15:25 +08:00
|
|
|
OS.indent(indent) << "CheckChildType " << ChildNo << " "
|
|
|
|
<< getEnumName(Type) << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckInteger " << Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckAndImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckAndImm " << Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckOrImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.indent(indent) << "CheckOrImm " << Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS,
|
2010-02-17 03:15:55 +08:00
|
|
|
unsigned indent) const {
|
|
|
|
OS.indent(indent) << "CheckFoldableChainNode\n";
|
2010-02-16 14:10:58 +08:00
|
|
|
}
|
2010-02-17 14:23:39 +08:00
|
|
|
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitInteger " << Val << " VT=" << VT << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
void EmitStringIntegerMatcher::
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << VT << '\n';
|
2010-02-19 06:03:03 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitRegister ";
|
2010-02-19 06:03:03 +08:00
|
|
|
if (Reg)
|
|
|
|
OS << Reg->getName();
|
|
|
|
else
|
|
|
|
OS << "zero_reg";
|
|
|
|
OS << " VT=" << VT << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
void EmitConvertToTargetMatcher::
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
void EmitMergeInputChainsMatcher::
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitMergeInputChains <todo: args>\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitCopyToReg <todo: args>\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName()
|
|
|
|
<< " Slot=" << Slot << '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-28 10:31:26 +08:00
|
|
|
void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned indent) const {
|
|
|
|
OS.indent(indent);
|
2010-03-01 04:55:18 +08:00
|
|
|
OS << (isa<MorphNodeToMatcher>(this) ? "MorphNodeTo: " : "EmitNode: ")
|
2010-02-28 10:31:26 +08:00
|
|
|
<< OpcodeName << ": <todo flags> ";
|
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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
|
|
|
|
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-12-24 01:03:20 +08:00
|
|
|
void MarkGlueResultsMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
|
|
|
OS.indent(indent) << "MarkGlueResults <todo: args>\n";
|
2010-02-24 13:33:42 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 14:53:39 +08:00
|
|
|
void CompleteMatchMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-02-21 14:03:07 +08: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.
llvm-svn: 96716
2010-02-21 11:22:59 +08:00
|
|
|
OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n";
|
|
|
|
OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n";
|
|
|
|
}
|
|
|
|
|
2010-02-25 14:49:58 +08:00
|
|
|
// getHashImpl Implementation.
|
|
|
|
|
|
|
|
unsigned CheckPatternPredicateMatcher::getHashImpl() const {
|
|
|
|
return HashString(Predicate);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CheckPredicateMatcher::getHashImpl() const {
|
2011-04-18 05:38:24 +08:00
|
|
|
return HashString(getPredicate().getFnName());
|
2010-02-25 14:49:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CheckOpcodeMatcher::getHashImpl() const {
|
2010-02-28 05:48:43 +08:00
|
|
|
return HashString(Opcode.getEnumName());
|
2010-02-25 14:49:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2010-03-01 14:59:22 +08:00
|
|
|
bool CheckOpcodeMatcher::isEqualImpl(const Matcher *M) const {
|
|
|
|
// Note: pointer equality isn't enough here, we have to check the enum names
|
2010-12-22 00:16:00 +08:00
|
|
|
// to ensure that the nodes are for the same opcode.
|
2010-03-01 14:59:22 +08:00
|
|
|
return cast<CheckOpcodeMatcher>(M)->Opcode.getEnumName() ==
|
|
|
|
Opcode.getEnumName();
|
|
|
|
}
|
|
|
|
|
2010-02-28 10:31:26 +08:00
|
|
|
bool EmitNodeMatcherCommon::isEqualImpl(const Matcher *m) const {
|
|
|
|
const EmitNodeMatcherCommon *M = cast<EmitNodeMatcherCommon>(m);
|
2010-02-25 14:49:58 +08:00
|
|
|
return M->OpcodeName == OpcodeName && M->VTs == VTs &&
|
|
|
|
M->Operands == Operands && M->HasChain == HasChain &&
|
2010-12-24 02:28:41 +08:00
|
|
|
M->HasInGlue == HasInGlue && M->HasOutGlue == HasOutGlue &&
|
2010-03-01 05:53:42 +08:00
|
|
|
M->HasMemRefs == HasMemRefs &&
|
2010-02-25 14:49:58 +08:00
|
|
|
M->NumFixedArityOperands == NumFixedArityOperands;
|
|
|
|
}
|
|
|
|
|
2010-02-28 10:31:26 +08:00
|
|
|
unsigned EmitNodeMatcherCommon::getHashImpl() const {
|
2010-02-25 14:49:58 +08:00
|
|
|
return (HashString(OpcodeName) << 4) | Operands.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-20 10:50:00 +08:00
|
|
|
void EmitNodeMatcher::anchor() { }
|
|
|
|
|
|
|
|
void MorphNodeToMatcher::anchor() { }
|
|
|
|
|
2010-12-24 01:03:20 +08:00
|
|
|
unsigned MarkGlueResultsMatcher::getHashImpl() const {
|
|
|
|
return HashUnsigneds(GlueResultNodes.begin(), GlueResultNodes.end());
|
2010-02-25 14:49:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CompleteMatchMatcher::getHashImpl() const {
|
2010-12-22 00:16:00 +08:00
|
|
|
return HashUnsigneds(Results.begin(), Results.end()) ^
|
2010-02-25 14:49:58 +08:00
|
|
|
((unsigned)(intptr_t)&Pattern << 8);
|
|
|
|
}
|
2010-02-27 15:49:13 +08:00
|
|
|
|
|
|
|
// isContradictoryImpl Implementations.
|
|
|
|
|
|
|
|
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;
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-27 15:49:13 +08:00
|
|
|
// 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();
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-27 15:49:13 +08:00
|
|
|
if (T2 == MVT::iPTR)
|
|
|
|
return !MVT(T1).isInteger() || MVT(T1).isVector();
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-27 15:49:13 +08:00
|
|
|
// Otherwise, they are two different non-iPTR types, they conflict.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-02-28 08:22:30 +08:00
|
|
|
bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const {
|
|
|
|
if (const CheckOpcodeMatcher *COM = dyn_cast<CheckOpcodeMatcher>(M)) {
|
|
|
|
// One node can't have two different opcodes!
|
2010-03-01 14:59:22 +08:00
|
|
|
// Note: pointer equality isn't enough here, we have to check the enum names
|
2010-12-22 00:16:00 +08:00
|
|
|
// to ensure that the nodes are for the same opcode.
|
2010-03-01 14:59:22 +08:00
|
|
|
return COM->getOpcode().getEnumName() != getOpcode().getEnumName();
|
2010-02-28 08:22:30 +08:00
|
|
|
}
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-28 08:22:30 +08:00
|
|
|
// If the node has a known type, and if the type we're checking for is
|
|
|
|
// different, then we know they contradict. For example, a check for
|
|
|
|
// ISD::STORE will never be true at the same time a check for Type i32 is.
|
|
|
|
if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M)) {
|
2010-03-24 08:41:19 +08:00
|
|
|
// If checking for a result the opcode doesn't have, it can't match.
|
|
|
|
if (CT->getResNo() >= getOpcode().getNumResults())
|
|
|
|
return true;
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-03-24 08:41:19 +08:00
|
|
|
MVT::SimpleValueType NodeType = getOpcode().getKnownType(CT->getResNo());
|
2010-03-19 09:14:27 +08:00
|
|
|
if (NodeType != MVT::Other)
|
|
|
|
return TypesAreContradictory(NodeType, CT->getType());
|
2010-02-28 08:22:30 +08:00
|
|
|
}
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-28 08:22:30 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-27 15:49:13 +08:00
|
|
|
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;
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-27 15:49:13 +08:00
|
|
|
return TypesAreContradictory(getType(), CC->getType());
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2010-12-22 00:16:00 +08:00
|
|
|
|
2010-02-27 16:11:15 +08:00
|
|
|
bool CheckIntegerMatcher::isContradictoryImpl(const Matcher *M) const {
|
|
|
|
if (const CheckIntegerMatcher *CIM = dyn_cast<CheckIntegerMatcher>(M))
|
|
|
|
return CIM->getValue() != getValue();
|
|
|
|
return false;
|
|
|
|
}
|
2010-03-07 14:29:26 +08:00
|
|
|
|
|
|
|
bool CheckValueTypeMatcher::isContradictoryImpl(const Matcher *M) const {
|
|
|
|
if (const CheckValueTypeMatcher *CVT = dyn_cast<CheckValueTypeMatcher>(M))
|
|
|
|
return CVT->getTypeName() != getTypeName();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|