2010-02-15 16:04:42 +08:00
|
|
|
//===- DAGISelMatcherEmitter.cpp - Matcher Emitter ------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains code to generate C++ code a matcher.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "DAGISelMatcher.h"
|
|
|
|
#include "CodeGenDAGPatterns.h"
|
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
|
|
|
#include "Record.h"
|
2010-02-17 08:31:50 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2010-02-15 16:04:42 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2010-02-16 15:21:10 +08:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2010-02-15 16:04:42 +08:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
enum {
|
2010-02-17 08:39:26 +08:00
|
|
|
CommentIndent = 30
|
2010-02-15 16:04:42 +08:00
|
|
|
};
|
|
|
|
|
2010-02-16 14:52:01 +08:00
|
|
|
namespace {
|
|
|
|
class MatcherTableEmitter {
|
2010-02-16 15:21:10 +08:00
|
|
|
StringMap<unsigned> NodePredicateMap, PatternPredicateMap;
|
|
|
|
std::vector<std::string> NodePredicates, PatternPredicates;
|
2010-02-17 08:31:50 +08:00
|
|
|
|
|
|
|
DenseMap<const ComplexPattern*, unsigned> ComplexPatternMap;
|
|
|
|
std::vector<const ComplexPattern*> ComplexPatterns;
|
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
|
|
|
|
|
|
|
|
|
|
|
DenseMap<Record*, unsigned> NodeXFormMap;
|
2010-03-01 09:54:19 +08:00
|
|
|
std::vector<Record*> NodeXForms;
|
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 03:17:12 +08:00
|
|
|
// Per opcode frequence count.
|
|
|
|
std::vector<unsigned> Histogram;
|
2010-02-16 14:52:01 +08:00
|
|
|
public:
|
2010-02-21 14:30:04 +08:00
|
|
|
MatcherTableEmitter() {}
|
2010-02-16 14:52:01 +08:00
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
unsigned EmitMatcherList(const Matcher *N, unsigned Indent,
|
2010-02-21 15:16:41 +08:00
|
|
|
unsigned StartIdx, formatted_raw_ostream &OS);
|
2010-02-16 15:21:10 +08:00
|
|
|
|
2010-03-01 09:54:19 +08:00
|
|
|
void EmitPredicateFunctions(const CodeGenDAGPatterns &CGP,
|
|
|
|
formatted_raw_ostream &OS);
|
2010-02-25 03:17:12 +08:00
|
|
|
|
|
|
|
void EmitHistogram(formatted_raw_ostream &OS);
|
2010-02-16 14:52:01 +08:00
|
|
|
private:
|
2010-02-26 03:00:39 +08:00
|
|
|
unsigned EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
|
2010-02-21 14:30:04 +08:00
|
|
|
formatted_raw_ostream &OS);
|
2010-02-16 15:21:10 +08:00
|
|
|
|
|
|
|
unsigned getNodePredicate(StringRef PredName) {
|
|
|
|
unsigned &Entry = NodePredicateMap[PredName];
|
|
|
|
if (Entry == 0) {
|
|
|
|
NodePredicates.push_back(PredName.str());
|
|
|
|
Entry = NodePredicates.size();
|
|
|
|
}
|
|
|
|
return Entry-1;
|
|
|
|
}
|
|
|
|
unsigned getPatternPredicate(StringRef PredName) {
|
|
|
|
unsigned &Entry = PatternPredicateMap[PredName];
|
|
|
|
if (Entry == 0) {
|
|
|
|
PatternPredicates.push_back(PredName.str());
|
|
|
|
Entry = PatternPredicates.size();
|
|
|
|
}
|
|
|
|
return Entry-1;
|
|
|
|
}
|
2010-02-17 08:31:50 +08:00
|
|
|
|
|
|
|
unsigned getComplexPat(const ComplexPattern &P) {
|
|
|
|
unsigned &Entry = ComplexPatternMap[&P];
|
|
|
|
if (Entry == 0) {
|
|
|
|
ComplexPatterns.push_back(&P);
|
|
|
|
Entry = ComplexPatterns.size();
|
|
|
|
}
|
|
|
|
return Entry-1;
|
|
|
|
}
|
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
|
|
|
|
|
|
|
unsigned getNodeXFormID(Record *Rec) {
|
|
|
|
unsigned &Entry = NodeXFormMap[Rec];
|
|
|
|
if (Entry == 0) {
|
|
|
|
NodeXForms.push_back(Rec);
|
|
|
|
Entry = NodeXForms.size();
|
|
|
|
}
|
|
|
|
return Entry-1;
|
|
|
|
}
|
|
|
|
|
2010-02-16 14:52:01 +08:00
|
|
|
};
|
|
|
|
} // end anonymous namespace.
|
|
|
|
|
2010-02-26 03:00:39 +08:00
|
|
|
static unsigned GetVBRSize(unsigned Val) {
|
|
|
|
if (Val <= 127) return 1;
|
|
|
|
|
|
|
|
unsigned NumBytes = 0;
|
|
|
|
while (Val >= 128) {
|
|
|
|
Val >>= 7;
|
|
|
|
++NumBytes;
|
|
|
|
}
|
|
|
|
return NumBytes+1;
|
|
|
|
}
|
|
|
|
|
2010-02-23 08:59:59 +08:00
|
|
|
/// EmitVBRValue - Emit the specified value as a VBR, returning the number of
|
|
|
|
/// bytes emitted.
|
2010-03-01 06:14:32 +08:00
|
|
|
static uint64_t EmitVBRValue(uint64_t Val, raw_ostream &OS) {
|
2010-02-23 08:59:59 +08:00
|
|
|
if (Val <= 127) {
|
|
|
|
OS << Val << ", ";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-03-01 06:14:32 +08:00
|
|
|
uint64_t InVal = Val;
|
2010-02-23 08:59:59 +08:00
|
|
|
unsigned NumBytes = 0;
|
2010-02-23 09:07:39 +08:00
|
|
|
while (Val >= 128) {
|
2010-02-23 08:59:59 +08:00
|
|
|
OS << (Val&127) << "|128,";
|
|
|
|
Val >>= 7;
|
|
|
|
++NumBytes;
|
|
|
|
}
|
|
|
|
OS << Val << "/*" << InVal << "*/, ";
|
|
|
|
return NumBytes+1;
|
|
|
|
}
|
|
|
|
|
2010-02-15 16:04:42 +08:00
|
|
|
/// EmitMatcherOpcodes - Emit bytes for the specified matcher and return
|
|
|
|
/// the number of bytes emitted.
|
2010-02-16 14:52:01 +08:00
|
|
|
unsigned MatcherTableEmitter::
|
2010-02-26 03:00:39 +08:00
|
|
|
EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
|
|
|
|
formatted_raw_ostream &OS) {
|
2010-02-15 16:04:42 +08:00
|
|
|
OS.PadToColumn(Indent*2);
|
|
|
|
|
|
|
|
switch (N->getKind()) {
|
2010-02-26 03:00:39 +08:00
|
|
|
case Matcher::Scope: {
|
|
|
|
const ScopeMatcher *SM = cast<ScopeMatcher>(N);
|
|
|
|
assert(SM->getNext() == 0 && "Shouldn't have next after scope");
|
|
|
|
|
|
|
|
unsigned StartIdx = CurrentIdx;
|
|
|
|
|
|
|
|
// Emit all of the children.
|
|
|
|
for (unsigned i = 0, e = SM->getNumChildren(); i != e; ++i) {
|
|
|
|
if (i == 0) {
|
|
|
|
OS << "OPC_Scope, ";
|
|
|
|
++CurrentIdx;
|
|
|
|
} else {
|
|
|
|
OS << "/*" << CurrentIdx << "*/";
|
|
|
|
OS.PadToColumn(Indent*2) << "/*Scope*/ ";
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need to encode the child and the offset of the failure code before
|
|
|
|
// emitting either of them. Handle this by buffering the output into a
|
|
|
|
// string while we get the size. Unfortunately, the offset of the
|
|
|
|
// children depends on the VBR size of the child, so for large children we
|
|
|
|
// have to iterate a bit.
|
|
|
|
SmallString<128> TmpBuf;
|
|
|
|
unsigned ChildSize = 0;
|
|
|
|
unsigned VBRSize = 0;
|
|
|
|
do {
|
|
|
|
VBRSize = GetVBRSize(ChildSize);
|
|
|
|
|
|
|
|
TmpBuf.clear();
|
|
|
|
raw_svector_ostream OS(TmpBuf);
|
|
|
|
formatted_raw_ostream FOS(OS);
|
|
|
|
ChildSize = EmitMatcherList(cast<ScopeMatcher>(N)->getChild(i),
|
|
|
|
Indent+1, CurrentIdx+VBRSize, FOS);
|
|
|
|
} while (GetVBRSize(ChildSize) != VBRSize);
|
|
|
|
|
|
|
|
assert(ChildSize != 0 && "Should not have a zero-sized child!");
|
|
|
|
|
|
|
|
CurrentIdx += EmitVBRValue(ChildSize, OS);
|
2010-02-26 16:15:02 +08:00
|
|
|
OS << "/*->" << CurrentIdx+ChildSize << "*/";
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
OS.PadToColumn(CommentIndent) << "// " << SM->getNumChildren()
|
|
|
|
<< " children in Scope";
|
|
|
|
|
2010-02-26 03:00:39 +08:00
|
|
|
OS << '\n' << TmpBuf.str();
|
|
|
|
CurrentIdx += ChildSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit a zero as a sentinel indicating end of 'Scope'.
|
|
|
|
OS << "/*" << CurrentIdx << "*/";
|
|
|
|
OS.PadToColumn(Indent*2) << "0, /*End of Scope*/\n";
|
|
|
|
return CurrentIdx - StartIdx + 1;
|
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::RecordNode:
|
2010-02-19 06:03:03 +08:00
|
|
|
OS << "OPC_RecordNode,";
|
2010-03-01 10:24:17 +08:00
|
|
|
OS.PadToColumn(CommentIndent) << "// #"
|
|
|
|
<< cast<RecordMatcher>(N)->getResultNo() << " = "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<RecordMatcher>(N)->getWhatFor() << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
return 1;
|
2010-02-24 15:31:45 +08:00
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::RecordChild:
|
|
|
|
OS << "OPC_RecordChild" << cast<RecordChildMatcher>(N)->getChildNo()
|
2010-02-24 15:31:45 +08:00
|
|
|
<< ',';
|
2010-03-01 10:24:17 +08:00
|
|
|
OS.PadToColumn(CommentIndent) << "// #"
|
|
|
|
<< cast<RecordChildMatcher>(N)->getResultNo() << " = "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<RecordChildMatcher>(N)->getWhatFor() << '\n';
|
2010-02-24 15:31:45 +08:00
|
|
|
return 1;
|
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 10:04:40 +08:00
|
|
|
case Matcher::RecordMemRef:
|
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 << "OPC_RecordMemRef,\n";
|
|
|
|
return 1;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CaptureFlagInput:
|
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 << "OPC_CaptureFlagInput,\n";
|
|
|
|
return 1;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::MoveChild:
|
|
|
|
OS << "OPC_MoveChild, " << cast<MoveChildMatcher>(N)->getChildNo() << ",\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::MoveParent:
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << "OPC_MoveParent,\n";
|
|
|
|
return 1;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckSame:
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << "OPC_CheckSame, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<CheckSameMatcher>(N)->getMatchNumber() << ",\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckPatternPredicate: {
|
|
|
|
StringRef Pred = cast<CheckPatternPredicateMatcher>(N)->getPredicate();
|
2010-02-16 15:21:10 +08:00
|
|
|
OS << "OPC_CheckPatternPredicate, " << getPatternPredicate(Pred) << ',';
|
|
|
|
OS.PadToColumn(CommentIndent) << "// " << Pred << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
2010-02-16 15:21:10 +08:00
|
|
|
}
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckPredicate: {
|
|
|
|
StringRef Pred = cast<CheckPredicateMatcher>(N)->getPredicateName();
|
2010-02-16 15:21:10 +08:00
|
|
|
OS << "OPC_CheckPredicate, " << getNodePredicate(Pred) << ',';
|
|
|
|
OS.PadToColumn(CommentIndent) << "// " << Pred << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
2010-02-16 15:21:10 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckOpcode:
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << "OPC_CheckOpcode, "
|
2010-02-28 05:48:43 +08:00
|
|
|
<< cast<CheckOpcodeMatcher>(N)->getOpcode().getEnumName() << ",\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckMultiOpcode: {
|
|
|
|
const CheckMultiOpcodeMatcher *CMO = cast<CheckMultiOpcodeMatcher>(N);
|
2010-02-28 05:48:43 +08:00
|
|
|
OS << "OPC_CheckMultiOpcode, " << CMO->getNumOpcodes() << ", ";
|
|
|
|
for (unsigned i = 0, e = CMO->getNumOpcodes(); i != e; ++i)
|
|
|
|
OS << CMO->getOpcode(i).getEnumName() << ", ";
|
2010-02-23 06:30:37 +08:00
|
|
|
OS << '\n';
|
2010-02-28 05:48:43 +08:00
|
|
|
return 2 + CMO->getNumOpcodes();
|
2010-02-23 06:30:37 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckType:
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << "OPC_CheckType, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckChildType:
|
2010-02-25 04:15:25 +08:00
|
|
|
OS << "OPC_CheckChild"
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<CheckChildTypeMatcher>(N)->getChildNo() << "Type, "
|
|
|
|
<< getEnumName(cast<CheckChildTypeMatcher>(N)->getType()) << ",\n";
|
2010-02-25 04:15:25 +08:00
|
|
|
return 2;
|
|
|
|
|
2010-03-01 06:14:32 +08:00
|
|
|
case Matcher::CheckInteger:
|
|
|
|
OS << "OPC_CheckInteger, ";
|
|
|
|
return 1+EmitVBRValue(cast<CheckIntegerMatcher>(N)->getValue(), OS);
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckCondCode:
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << "OPC_CheckCondCode, ISD::"
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<CheckCondCodeMatcher>(N)->getCondCodeName() << ",\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckValueType:
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << "OPC_CheckValueType, MVT::"
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<CheckValueTypeMatcher>(N)->getTypeName() << ",\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckComplexPat: {
|
2010-02-17 08:39:26 +08:00
|
|
|
const ComplexPattern &Pattern =
|
2010-02-25 10:04:40 +08:00
|
|
|
cast<CheckComplexPatMatcher>(N)->getPattern();
|
2010-02-17 08:39:26 +08:00
|
|
|
OS << "OPC_CheckComplexPat, " << getComplexPat(Pattern) << ',';
|
2010-02-17 14:47:35 +08:00
|
|
|
OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc();
|
|
|
|
OS << ": " << Pattern.getNumOperands() << " operands";
|
|
|
|
if (Pattern.hasProperty(SDNPHasChain))
|
|
|
|
OS << " + chain result and input";
|
|
|
|
OS << '\n';
|
2010-02-15 16:04:42 +08:00
|
|
|
return 2;
|
2010-02-17 08:39:26 +08:00
|
|
|
}
|
2010-02-15 16:04:42 +08:00
|
|
|
|
2010-03-01 06:14:32 +08:00
|
|
|
case Matcher::CheckAndImm:
|
|
|
|
OS << "OPC_CheckAndImm, ";
|
|
|
|
return 1+EmitVBRValue(cast<CheckAndImmMatcher>(N)->getValue(), OS);
|
2010-02-15 16:04:42 +08:00
|
|
|
|
2010-03-01 06:14:32 +08:00
|
|
|
case Matcher::CheckOrImm:
|
|
|
|
OS << "OPC_CheckOrImm, ";
|
|
|
|
return 1+EmitVBRValue(cast<CheckOrImmMatcher>(N)->getValue(), OS);
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckFoldableChainNode:
|
2010-02-17 03:15:55 +08:00
|
|
|
OS << "OPC_CheckFoldableChainNode,\n";
|
2010-02-16 14:10:58 +08:00
|
|
|
return 1;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckChainCompatible:
|
2010-02-17 14:23:39 +08:00
|
|
|
OS << "OPC_CheckChainCompatible, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<CheckChainCompatibleMatcher>(N)->getPreviousOp() << ",\n";
|
2010-02-17 14:23:39 +08:00
|
|
|
return 2;
|
2010-02-19 06:03:03 +08:00
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitInteger: {
|
|
|
|
int64_t Val = cast<EmitIntegerMatcher>(N)->getValue();
|
2010-03-01 06:14:32 +08:00
|
|
|
OS << "OPC_EmitInteger, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< getEnumName(cast<EmitIntegerMatcher>(N)->getVT()) << ", ";
|
2010-03-01 06:14:32 +08:00
|
|
|
return 2+EmitVBRValue(Val, OS);
|
2010-02-19 15:49:56 +08:00
|
|
|
}
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitStringInteger: {
|
|
|
|
const std::string &Val = cast<EmitStringIntegerMatcher>(N)->getValue();
|
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
|
|
|
// These should always fit into one byte.
|
2010-03-01 06:14:32 +08:00
|
|
|
OS << "OPC_EmitInteger, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< getEnumName(cast<EmitStringIntegerMatcher>(N)->getVT()) << ", "
|
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
|
|
|
<< Val << ",\n";
|
|
|
|
return 3;
|
|
|
|
}
|
2010-02-19 15:49:56 +08:00
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitRegister:
|
2010-02-19 15:49:56 +08:00
|
|
|
OS << "OPC_EmitRegister, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< getEnumName(cast<EmitRegisterMatcher>(N)->getVT()) << ", ";
|
|
|
|
if (Record *R = cast<EmitRegisterMatcher>(N)->getReg())
|
2010-02-19 15:49:56 +08:00
|
|
|
OS << getQualifiedName(R) << ",\n";
|
|
|
|
else
|
|
|
|
OS << "0 /*zero_reg*/,\n";
|
|
|
|
return 3;
|
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 10:04:40 +08:00
|
|
|
case Matcher::EmitConvertToTarget:
|
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 << "OPC_EmitConvertToTarget, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<EmitConvertToTargetMatcher>(N)->getSlot() << ",\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
|
|
|
return 2;
|
|
|
|
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitMergeInputChains: {
|
|
|
|
const EmitMergeInputChainsMatcher *MN =
|
|
|
|
cast<EmitMergeInputChainsMatcher>(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 << "OPC_EmitMergeInputChains, " << MN->getNumNodes() << ", ";
|
|
|
|
for (unsigned i = 0, e = MN->getNumNodes(); i != e; ++i)
|
|
|
|
OS << MN->getNode(i) << ", ";
|
|
|
|
OS << '\n';
|
|
|
|
return 2+MN->getNumNodes();
|
|
|
|
}
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitCopyToReg:
|
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 << "OPC_EmitCopyToReg, "
|
2010-02-25 10:04:40 +08:00
|
|
|
<< cast<EmitCopyToRegMatcher>(N)->getSrcSlot() << ", "
|
|
|
|
<< getQualifiedName(cast<EmitCopyToRegMatcher>(N)->getDestPhysReg())
|
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
|
|
|
<< ",\n";
|
|
|
|
return 3;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitNodeXForm: {
|
|
|
|
const EmitNodeXFormMatcher *XF = cast<EmitNodeXFormMatcher>(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 << "OPC_EmitNodeXForm, " << getNodeXFormID(XF->getNodeXForm()) << ", "
|
|
|
|
<< XF->getSlot() << ',';
|
|
|
|
OS.PadToColumn(CommentIndent) << "// "<<XF->getNodeXForm()->getName()<<'\n';
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
|
2010-02-28 10:31:26 +08:00
|
|
|
case Matcher::EmitNode:
|
2010-03-01 04:55:18 +08:00
|
|
|
case Matcher::MorphNodeTo: {
|
2010-02-28 10:31:26 +08:00
|
|
|
const EmitNodeMatcherCommon *EN = cast<EmitNodeMatcherCommon>(N);
|
2010-03-01 04:55:18 +08:00
|
|
|
OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo");
|
2010-02-28 10:31:26 +08:00
|
|
|
OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0";
|
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
|
|
|
|
|
|
|
if (EN->hasChain()) OS << "|OPFL_Chain";
|
2010-03-01 05:53:42 +08:00
|
|
|
if (EN->hasInFlag()) OS << "|OPFL_FlagInput";
|
|
|
|
if (EN->hasOutFlag()) OS << "|OPFL_FlagOutput";
|
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
|
|
|
if (EN->hasMemRefs()) OS << "|OPFL_MemRefs";
|
|
|
|
if (EN->getNumFixedArityOperands() != -1)
|
|
|
|
OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands();
|
|
|
|
OS << ",\n";
|
|
|
|
|
|
|
|
OS.PadToColumn(Indent*2+4) << EN->getNumVTs() << "/*#VTs*/, ";
|
|
|
|
for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i)
|
|
|
|
OS << getEnumName(EN->getVT(i)) << ", ";
|
|
|
|
|
|
|
|
OS << EN->getNumOperands() << "/*#Ops*/, ";
|
2010-02-23 08:59:59 +08:00
|
|
|
unsigned NumOperandBytes = 0;
|
|
|
|
for (unsigned i = 0, e = EN->getNumOperands(); i != e; ++i) {
|
|
|
|
// We emit the operand numbers in VBR encoded format, in case the number
|
|
|
|
// is too large to represent with a byte.
|
|
|
|
NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS);
|
|
|
|
}
|
2010-02-28 10:41:25 +08:00
|
|
|
|
|
|
|
// Print the result #'s for EmitNode.
|
|
|
|
if (const EmitNodeMatcher *E = dyn_cast<EmitNodeMatcher>(EN)) {
|
2010-03-01 07:00:47 +08:00
|
|
|
if (unsigned NumResults = EN->getNumVTs()) {
|
2010-02-28 10:41:25 +08:00
|
|
|
OS.PadToColumn(CommentIndent) << "// Results = ";
|
|
|
|
unsigned First = E->getFirstResultSlot();
|
2010-03-01 04:49:53 +08:00
|
|
|
for (unsigned i = 0; i != NumResults; ++i)
|
2010-02-28 10:41:25 +08:00
|
|
|
OS << "#" << First+i << " ";
|
|
|
|
}
|
|
|
|
}
|
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 << '\n';
|
2010-03-01 04:49:53 +08:00
|
|
|
|
2010-03-01 04:55:18 +08:00
|
|
|
if (const MorphNodeToMatcher *SNT = dyn_cast<MorphNodeToMatcher>(N)) {
|
2010-03-01 04:49:53 +08:00
|
|
|
OS.PadToColumn(Indent*2) << "// Src: "
|
|
|
|
<< *SNT->getPattern().getSrcPattern() << '\n';
|
|
|
|
OS.PadToColumn(Indent*2) << "// Dst: "
|
|
|
|
<< *SNT->getPattern().getDstPattern() << '\n';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-02-23 08:59:59 +08:00
|
|
|
return 6+EN->getNumVTs()+NumOperandBytes;
|
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 10:04:40 +08:00
|
|
|
case Matcher::MarkFlagResults: {
|
|
|
|
const MarkFlagResultsMatcher *CFR = cast<MarkFlagResultsMatcher>(N);
|
2010-02-24 13:33:42 +08:00
|
|
|
OS << "OPC_MarkFlagResults, " << CFR->getNumNodes() << ", ";
|
|
|
|
unsigned NumOperandBytes = 0;
|
|
|
|
for (unsigned i = 0, e = CFR->getNumNodes(); i != e; ++i)
|
|
|
|
NumOperandBytes += EmitVBRValue(CFR->getNode(i), OS);
|
|
|
|
OS << '\n';
|
|
|
|
return 2+NumOperandBytes;
|
|
|
|
}
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CompleteMatch: {
|
|
|
|
const CompleteMatchMatcher *CM = cast<CompleteMatchMatcher>(N);
|
2010-02-21 14:03:07 +08:00
|
|
|
OS << "OPC_CompleteMatch, " << CM->getNumResults() << ", ";
|
2010-02-23 08:59:59 +08:00
|
|
|
unsigned NumResultBytes = 0;
|
2010-02-21 14:03:07 +08:00
|
|
|
for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i)
|
2010-02-23 08:59:59 +08:00
|
|
|
NumResultBytes += EmitVBRValue(CM->getResult(i), OS);
|
2010-02-21 14:03:07 +08:00
|
|
|
OS << '\n';
|
|
|
|
OS.PadToColumn(Indent*2) << "// Src: "
|
|
|
|
<< *CM->getPattern().getSrcPattern() << '\n';
|
|
|
|
OS.PadToColumn(Indent*2) << "// Dst: "
|
|
|
|
<< *CM->getPattern().getDstPattern() << '\n';
|
2010-02-23 08:59:59 +08:00
|
|
|
return 2 + NumResultBytes;
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
2010-02-21 14:03:07 +08:00
|
|
|
}
|
2010-02-15 16:04:42 +08:00
|
|
|
assert(0 && "Unreachable");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-02-18 10:53:41 +08:00
|
|
|
/// EmitMatcherList - Emit the bytes for the specified matcher subtree.
|
2010-02-16 14:52:01 +08:00
|
|
|
unsigned MatcherTableEmitter::
|
2010-02-25 10:04:40 +08:00
|
|
|
EmitMatcherList(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
|
2010-02-21 14:30:04 +08:00
|
|
|
formatted_raw_ostream &OS) {
|
2010-02-15 16:04:42 +08:00
|
|
|
unsigned Size = 0;
|
2010-02-18 10:49:24 +08:00
|
|
|
while (N) {
|
2010-02-25 03:17:12 +08:00
|
|
|
if (unsigned(N->getKind()) >= Histogram.size())
|
|
|
|
Histogram.resize(N->getKind()+1);
|
|
|
|
Histogram[N->getKind()]++;
|
|
|
|
|
2010-02-21 15:16:41 +08:00
|
|
|
OS << "/*" << CurrentIdx << "*/";
|
2010-02-26 03:00:39 +08:00
|
|
|
unsigned MatcherSize = EmitMatcher(N, Indent, CurrentIdx, OS);
|
2010-02-21 15:16:41 +08:00
|
|
|
Size += MatcherSize;
|
|
|
|
CurrentIdx += MatcherSize;
|
2010-02-15 16:04:42 +08:00
|
|
|
|
2010-02-18 10:53:41 +08:00
|
|
|
// If there are other nodes in this list, iterate to them, otherwise we're
|
2010-02-15 16:04:42 +08:00
|
|
|
// done.
|
2010-02-18 10:53:41 +08:00
|
|
|
N = N->getNext();
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
2010-02-18 10:49:24 +08:00
|
|
|
return Size;
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|
|
|
|
|
2010-03-01 09:54:19 +08:00
|
|
|
void MatcherTableEmitter::EmitPredicateFunctions(const CodeGenDAGPatterns &CGP,
|
|
|
|
formatted_raw_ostream &OS) {
|
2010-02-18 14:47:49 +08:00
|
|
|
// FIXME: Don't build off the DAGISelEmitter's predicates, emit them directly
|
|
|
|
// here into the case stmts.
|
|
|
|
|
2010-02-17 08:31:50 +08:00
|
|
|
// Emit pattern predicates.
|
2010-03-01 06:57:03 +08:00
|
|
|
if (!PatternPredicates.empty()) {
|
|
|
|
OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n";
|
|
|
|
OS << " switch (PredNo) {\n";
|
|
|
|
OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
|
|
|
|
for (unsigned i = 0, e = PatternPredicates.size(); i != e; ++i)
|
|
|
|
OS << " case " << i << ": return " << PatternPredicates[i] << ";\n";
|
|
|
|
OS << " }\n";
|
|
|
|
OS << "}\n\n";
|
|
|
|
}
|
2010-03-01 09:54:19 +08:00
|
|
|
|
2010-02-17 08:31:50 +08:00
|
|
|
// Emit Node predicates.
|
2010-03-01 09:54:19 +08:00
|
|
|
// FIXME: Annoyingly, these are stored by name, which we never even emit. Yay?
|
|
|
|
StringMap<TreePattern*> PFsByName;
|
|
|
|
|
|
|
|
for (CodeGenDAGPatterns::pf_iterator I = CGP.pf_begin(), E = CGP.pf_end();
|
|
|
|
I != E; ++I)
|
|
|
|
PFsByName[I->first->getName()] = I->second;
|
|
|
|
|
2010-03-01 06:57:03 +08:00
|
|
|
if (!NodePredicates.empty()) {
|
2010-03-01 09:54:19 +08:00
|
|
|
OS << "bool CheckNodePredicate(SDNode *Node, unsigned PredNo) const {\n";
|
2010-03-01 06:57:03 +08:00
|
|
|
OS << " switch (PredNo) {\n";
|
|
|
|
OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
|
2010-03-01 09:54:19 +08:00
|
|
|
for (unsigned i = 0, e = NodePredicates.size(); i != e; ++i) {
|
|
|
|
// FIXME: Storing this by name is horrible.
|
|
|
|
TreePattern *P =PFsByName[NodePredicates[i].substr(strlen("Predicate_"))];
|
|
|
|
assert(P && "Unknown name?");
|
|
|
|
|
|
|
|
// Emit the predicate code corresponding to this pattern.
|
|
|
|
std::string Code = P->getRecord()->getValueAsCode("Predicate");
|
|
|
|
assert(!Code.empty() && "No code in this predicate");
|
|
|
|
OS << " case " << i << ": { // " << NodePredicates[i] << '\n';
|
|
|
|
std::string ClassName;
|
|
|
|
if (P->getOnlyTree()->isLeaf())
|
|
|
|
ClassName = "SDNode";
|
|
|
|
else
|
|
|
|
ClassName =
|
|
|
|
CGP.getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName();
|
|
|
|
if (ClassName == "SDNode")
|
|
|
|
OS << " SDNode *N = Node;\n";
|
|
|
|
else
|
|
|
|
OS << " " << ClassName << "*N = cast<" << ClassName << ">(Node);\n";
|
|
|
|
OS << Code << "\n }\n";
|
|
|
|
}
|
2010-03-01 06:57:03 +08:00
|
|
|
OS << " }\n";
|
|
|
|
OS << "}\n\n";
|
|
|
|
}
|
2010-02-17 08:31:50 +08:00
|
|
|
|
|
|
|
// Emit CompletePattern matchers.
|
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
|
|
|
// FIXME: This should be const.
|
2010-03-01 06:57:03 +08:00
|
|
|
if (!ComplexPatterns.empty()) {
|
|
|
|
OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n";
|
|
|
|
OS << " unsigned PatternNo, SmallVectorImpl<SDValue> &Result) {\n";
|
|
|
|
OS << " switch (PatternNo) {\n";
|
|
|
|
OS << " default: assert(0 && \"Invalid pattern # in table?\");\n";
|
|
|
|
for (unsigned i = 0, e = ComplexPatterns.size(); i != e; ++i) {
|
|
|
|
const ComplexPattern &P = *ComplexPatterns[i];
|
|
|
|
unsigned NumOps = P.getNumOperands();
|
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-03-01 06:57:03 +08:00
|
|
|
if (P.hasProperty(SDNPHasChain))
|
|
|
|
++NumOps; // Get the chained node too.
|
|
|
|
|
|
|
|
OS << " case " << i << ":\n";
|
|
|
|
OS << " Result.resize(Result.size()+" << NumOps << ");\n";
|
|
|
|
OS << " return " << P.getSelectFunc();
|
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-03-01 06:57:03 +08:00
|
|
|
// FIXME: Temporary hack until old isel dies.
|
|
|
|
if (P.hasProperty(SDNPHasChain))
|
|
|
|
OS << "XXX";
|
|
|
|
|
|
|
|
OS << "(Root, N";
|
|
|
|
for (unsigned i = 0; i != NumOps; ++i)
|
|
|
|
OS << ", Result[Result.size()-" << (NumOps-i) << ']';
|
|
|
|
OS << ");\n";
|
|
|
|
}
|
|
|
|
OS << " }\n";
|
|
|
|
OS << "}\n\n";
|
2010-02-17 08:31:50 +08:00
|
|
|
}
|
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-03-01 09:54:19 +08:00
|
|
|
|
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
|
|
|
// Emit SDNodeXForm handlers.
|
|
|
|
// FIXME: This should be const.
|
2010-03-01 06:57:03 +08:00
|
|
|
if (!NodeXForms.empty()) {
|
|
|
|
OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) {\n";
|
|
|
|
OS << " switch (XFormNo) {\n";
|
|
|
|
OS << " default: assert(0 && \"Invalid xform # in table?\");\n";
|
|
|
|
|
|
|
|
// FIXME: The node xform could take SDValue's instead of SDNode*'s.
|
2010-03-01 09:54:19 +08:00
|
|
|
for (unsigned i = 0, e = NodeXForms.size(); i != e; ++i) {
|
|
|
|
const CodeGenDAGPatterns::NodeXForm &Entry =
|
|
|
|
CGP.getSDNodeTransform(NodeXForms[i]);
|
|
|
|
|
|
|
|
Record *SDNode = Entry.first;
|
|
|
|
const std::string &Code = Entry.second;
|
|
|
|
|
|
|
|
OS << " case " << i << ": { // " << NodeXForms[i]->getName() << '\n';
|
|
|
|
|
|
|
|
std::string ClassName = CGP.getSDNodeInfo(SDNode).getSDClassName();
|
|
|
|
if (ClassName == "SDNode")
|
|
|
|
OS << " SDNode *N = V.getNode();\n";
|
|
|
|
else
|
|
|
|
OS << " " << ClassName << " *N = cast<" << ClassName
|
|
|
|
<< ">(V.getNode());\n";
|
|
|
|
OS << Code << "\n }\n";
|
|
|
|
}
|
2010-03-01 06:57:03 +08:00
|
|
|
OS << " }\n";
|
|
|
|
OS << "}\n\n";
|
|
|
|
}
|
2010-02-16 15:21:10 +08:00
|
|
|
}
|
|
|
|
|
2010-02-25 03:17:12 +08:00
|
|
|
void MatcherTableEmitter::EmitHistogram(formatted_raw_ostream &OS) {
|
|
|
|
OS << " // Opcode Histogram:\n";
|
|
|
|
for (unsigned i = 0, e = Histogram.size(); i != e; ++i) {
|
|
|
|
OS << " // #";
|
2010-02-25 10:04:40 +08:00
|
|
|
switch ((Matcher::KindTy)i) {
|
|
|
|
case Matcher::Scope: OS << "OPC_Scope"; break;
|
|
|
|
case Matcher::RecordNode: OS << "OPC_RecordNode"; break;
|
|
|
|
case Matcher::RecordChild: OS << "OPC_RecordChild"; break;
|
|
|
|
case Matcher::RecordMemRef: OS << "OPC_RecordMemRef"; break;
|
|
|
|
case Matcher::CaptureFlagInput: OS << "OPC_CaptureFlagInput"; break;
|
|
|
|
case Matcher::MoveChild: OS << "OPC_MoveChild"; break;
|
|
|
|
case Matcher::MoveParent: OS << "OPC_MoveParent"; break;
|
|
|
|
case Matcher::CheckSame: OS << "OPC_CheckSame"; break;
|
|
|
|
case Matcher::CheckPatternPredicate:
|
2010-02-25 03:17:12 +08:00
|
|
|
OS << "OPC_CheckPatternPredicate"; break;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::CheckPredicate: OS << "OPC_CheckPredicate"; break;
|
|
|
|
case Matcher::CheckOpcode: OS << "OPC_CheckOpcode"; break;
|
|
|
|
case Matcher::CheckMultiOpcode: OS << "OPC_CheckMultiOpcode"; break;
|
|
|
|
case Matcher::CheckType: OS << "OPC_CheckType"; break;
|
|
|
|
case Matcher::CheckChildType: OS << "OPC_CheckChildType"; break;
|
|
|
|
case Matcher::CheckInteger: OS << "OPC_CheckInteger"; break;
|
|
|
|
case Matcher::CheckCondCode: OS << "OPC_CheckCondCode"; break;
|
|
|
|
case Matcher::CheckValueType: OS << "OPC_CheckValueType"; break;
|
|
|
|
case Matcher::CheckComplexPat: OS << "OPC_CheckComplexPat"; break;
|
|
|
|
case Matcher::CheckAndImm: OS << "OPC_CheckAndImm"; break;
|
|
|
|
case Matcher::CheckOrImm: OS << "OPC_CheckOrImm"; break;
|
|
|
|
case Matcher::CheckFoldableChainNode:
|
2010-02-25 03:17:12 +08:00
|
|
|
OS << "OPC_CheckFoldableChainNode"; break;
|
2010-02-25 10:09:00 +08:00
|
|
|
case Matcher::CheckChainCompatible: OS << "OPC_CheckChainCompatible"; break;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitInteger: OS << "OPC_EmitInteger"; break;
|
|
|
|
case Matcher::EmitStringInteger: OS << "OPC_EmitStringInteger"; break;
|
|
|
|
case Matcher::EmitRegister: OS << "OPC_EmitRegister"; break;
|
2010-02-25 10:09:00 +08:00
|
|
|
case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget"; break;
|
|
|
|
case Matcher::EmitMergeInputChains: OS << "OPC_EmitMergeInputChains"; break;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitCopyToReg: OS << "OPC_EmitCopyToReg"; break;
|
|
|
|
case Matcher::EmitNode: OS << "OPC_EmitNode"; break;
|
2010-03-01 04:55:18 +08:00
|
|
|
case Matcher::MorphNodeTo: OS << "OPC_MorphNodeTo"; break;
|
2010-02-25 10:04:40 +08:00
|
|
|
case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break;
|
|
|
|
case Matcher::MarkFlagResults: OS << "OPC_MarkFlagResults"; break;
|
|
|
|
case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break;
|
2010-02-25 03:17:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
OS.PadToColumn(40) << " = " << Histogram[i] << '\n';
|
|
|
|
}
|
|
|
|
OS << '\n';
|
|
|
|
}
|
|
|
|
|
2010-02-16 15:21:10 +08:00
|
|
|
|
2010-03-01 09:54:19 +08:00
|
|
|
void llvm::EmitMatcherTable(const Matcher *TheMatcher,
|
|
|
|
const CodeGenDAGPatterns &CGP, raw_ostream &O) {
|
2010-02-15 16:04:42 +08:00
|
|
|
formatted_raw_ostream OS(O);
|
|
|
|
|
|
|
|
OS << "// The main instruction selector code.\n";
|
2010-02-24 15:35:09 +08:00
|
|
|
OS << "SDNode *SelectCode(SDNode *N) {\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
|
2010-02-21 14:30:04 +08:00
|
|
|
MatcherTableEmitter MatcherEmitter;
|
2010-02-16 14:52:01 +08:00
|
|
|
|
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 << " // Opcodes are emitted as 2 bytes, TARGET_OPCODE handles this.\n";
|
|
|
|
OS << " #define TARGET_OPCODE(X) X & 255, unsigned(X) >> 8\n";
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << " static const unsigned char MatcherTable[] = {\n";
|
2010-02-25 10:04:40 +08:00
|
|
|
unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 5, 0, OS);
|
2010-02-15 16:04:42 +08:00
|
|
|
OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n";
|
2010-02-25 03:17:12 +08:00
|
|
|
|
|
|
|
MatcherEmitter.EmitHistogram(OS);
|
|
|
|
|
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 << " #undef TARGET_OPCODE\n";
|
2010-02-16 14:52:01 +08:00
|
|
|
OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n";
|
2010-02-16 15:21:10 +08:00
|
|
|
OS << "\n";
|
|
|
|
|
|
|
|
// Next up, emit the function for node and pattern predicates:
|
2010-03-01 09:54:19 +08:00
|
|
|
MatcherEmitter.EmitPredicateFunctions(CGP, OS);
|
2010-02-15 16:04:42 +08:00
|
|
|
}
|