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