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-03-07 06:29:26 +00: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();
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
// We can move record nodes across simple predicates.
|
|
|
|
if (isSimplePredicateOrRecordNode())
|
|
|
|
return isSimplePredicateNode();
|
|
|
|
|
|
|
|
// We can't move record nodes across each other etc.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-28 20:49:53 +00: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 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-27 21:48:43 +00:00
|
|
|
OS.indent(indent) << "CheckOpcode " << Opcode.getEnumName() << '\n';
|
2010-02-15 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2010-03-01 06:59:22 +00: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 06:53:39 +00:00
|
|
|
void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
|
2010-03-24 00:41:19 +00:00
|
|
|
OS.indent(indent) << "CheckType " << getEnumName(Type) << ", ResNo="
|
|
|
|
<< ResNo << '\n';
|
2010-02-15 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2010-03-03 06:28:15 +00: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 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 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-28 02:31:26 +00:00
|
|
|
void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned indent) const {
|
|
|
|
OS.indent(indent);
|
2010-02-28 20:55:18 +00:00
|
|
|
OS << (isa<MorphNodeToMatcher>(this) ? "MorphNodeTo: " : "EmitNode: ")
|
2010-02-28 02:31:26 +00: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.
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
|
|
|
|
|
|
|
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 {
|
2010-02-27 21:48:43 +00:00
|
|
|
return HashString(Opcode.getEnumName());
|
2010-02-25 06:49:58 +00: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 06:59:22 +00:00
|
|
|
bool CheckOpcodeMatcher::isEqualImpl(const Matcher *M) const {
|
|
|
|
// Note: pointer equality isn't enough here, we have to check the enum names
|
|
|
|
// to ensure that the nodes are for the same opcode.
|
|
|
|
return cast<CheckOpcodeMatcher>(M)->Opcode.getEnumName() ==
|
|
|
|
Opcode.getEnumName();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-28 02:31:26 +00:00
|
|
|
bool EmitNodeMatcherCommon::isEqualImpl(const Matcher *m) const {
|
|
|
|
const EmitNodeMatcherCommon *M = cast<EmitNodeMatcherCommon>(m);
|
2010-02-25 06:49:58 +00:00
|
|
|
return M->OpcodeName == OpcodeName && M->VTs == VTs &&
|
|
|
|
M->Operands == Operands && M->HasChain == HasChain &&
|
2010-02-28 21:53:42 +00:00
|
|
|
M->HasInFlag == HasInFlag && M->HasOutFlag == HasOutFlag &&
|
|
|
|
M->HasMemRefs == HasMemRefs &&
|
2010-02-25 06:49:58 +00:00
|
|
|
M->NumFixedArityOperands == NumFixedArityOperands;
|
|
|
|
}
|
|
|
|
|
2010-02-28 02:31:26 +00:00
|
|
|
unsigned EmitNodeMatcherCommon::getHashImpl() const {
|
2010-02-25 06:49:58 +00:00
|
|
|
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.
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-28 00:22:30 +00: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 06:59:22 +00:00
|
|
|
// Note: pointer equality isn't enough here, we have to check the enum names
|
|
|
|
// to ensure that the nodes are for the same opcode.
|
|
|
|
return COM->getOpcode().getEnumName() != getOpcode().getEnumName();
|
2010-02-28 00:22:30 +00: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 00:41:19 +00:00
|
|
|
// If checking for a result the opcode doesn't have, it can't match.
|
|
|
|
if (CT->getResNo() >= getOpcode().getNumResults())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
MVT::SimpleValueType NodeType = getOpcode().getKnownType(CT->getResNo());
|
2010-03-19 01:14:27 +00:00
|
|
|
if (NodeType != MVT::Other)
|
|
|
|
return TypesAreContradictory(NodeType, CT->getType());
|
2010-02-28 00:22:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-27 07:49:13 +00: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;
|
|
|
|
|
|
|
|
return TypesAreContradictory(getType(), CC->getType());
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-02-27 08:11:15 +00: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 06:29:26 +00:00
|
|
|
|
|
|
|
bool CheckValueTypeMatcher::isContradictoryImpl(const Matcher *M) const {
|
|
|
|
if (const CheckValueTypeMatcher *CVT = dyn_cast<CheckValueTypeMatcher>(M))
|
|
|
|
return CVT->getTypeName() != getTypeName();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|