summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-21 07:16:41 +0000
committerChris Lattner <sabre@nondot.org>2010-02-21 07:16:41 +0000
commit8fbad244bd436163296d81d4f182750e000fd16d (patch)
treebdf02b2db6911326ddf4a73e6b2c7840a371da09 /utils
parenta7399e4abfab24b31429c07beca53c4647ba75d5 (diff)
downloadllvm-8fbad244bd436163296d81d4f182750e000fd16d.tar.gz
llvm-8fbad244bd436163296d81d4f182750e000fd16d.tar.bz2
llvm-8fbad244bd436163296d81d4f182750e000fd16d.tar.xz
emit table indexes before each row so that it is debuggable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96730 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/DAGISelMatcherEmitter.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp
index e1a625be89..2c835cc462 100644
--- a/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -82,7 +82,7 @@ public:
MatcherTableEmitter() {}
unsigned EmitMatcherList(const MatcherNode *N, unsigned Indent,
- formatted_raw_ostream &OS);
+ unsigned StartIdx, formatted_raw_ostream &OS);
void EmitPredicateFunctions(formatted_raw_ostream &OS);
private:
@@ -324,7 +324,7 @@ EmitMatcher(const MatcherNode *N, unsigned Indent, formatted_raw_ostream &OS) {
/// EmitMatcherList - Emit the bytes for the specified matcher subtree.
unsigned MatcherTableEmitter::
-EmitMatcherList(const MatcherNode *N, unsigned Indent,
+EmitMatcherList(const MatcherNode *N, unsigned Indent, unsigned CurrentIdx,
formatted_raw_ostream &OS) {
unsigned Size = 0;
while (N) {
@@ -339,7 +339,7 @@ EmitMatcherList(const MatcherNode *N, unsigned Indent,
raw_svector_ostream OS(TmpBuf);
formatted_raw_ostream FOS(OS);
NextSize = EmitMatcherList(cast<PushMatcherNode>(N)->getNext(),
- Indent+1, FOS);
+ Indent+1, CurrentIdx+2, FOS);
}
if (NextSize > 255) {
@@ -348,17 +348,21 @@ EmitMatcherList(const MatcherNode *N, unsigned Indent,
// FIXME: exit(1);
}
+ OS << "/*" << CurrentIdx << "*/";
OS.PadToColumn(Indent*2);
OS << "OPC_Push, " << NextSize << ",\n";
OS << TmpBuf.str();
- Size += 2 + NextSize;
-
+ Size += 2+NextSize;
+ CurrentIdx += 2+NextSize;
N = PMN->getFailure();
continue;
}
- Size += EmitMatcher(N, Indent, OS);
+ OS << "/*" << CurrentIdx << "*/";
+ unsigned MatcherSize = EmitMatcher(N, Indent, OS);
+ Size += MatcherSize;
+ CurrentIdx += MatcherSize;
// If there are other nodes in this list, iterate to them, otherwise we're
// done.
@@ -444,7 +448,7 @@ void llvm::EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &O) {
OS << " // Opcodes are emitted as 2 bytes, TARGET_OPCODE handles this.\n";
OS << " #define TARGET_OPCODE(X) X & 255, unsigned(X) >> 8\n";
OS << " static const unsigned char MatcherTable[] = {\n";
- unsigned TotalSize = MatcherEmitter.EmitMatcherList(Matcher, 2, OS);
+ unsigned TotalSize = MatcherEmitter.EmitMatcherList(Matcher, 5, 0, OS);
OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n";
OS << " #undef TARGET_OPCODE\n";
OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n";