summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-27 18:49:33 +0000
committerChris Lattner <sabre@nondot.org>2010-03-27 18:49:33 +0000
commite7e9f06d3bd7df3f28bd260607020d1f7db80ecf (patch)
treebaed1322e11ff0c18d19c8a73706bad8511d8037 /llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
parent273f31d08dac055288fbfedf4a84e3333ea24890 (diff)
downloadbcm5719-llvm-e7e9f06d3bd7df3f28bd260607020d1f7db80ecf.tar.gz
bcm5719-llvm-e7e9f06d3bd7df3f28bd260607020d1f7db80ecf.zip
fix a bug in my recent patch that increased opcode size to 2 bytes:
the index comments nested under OPC_SwitchOpcode were off by one. This fixes the comments. llvm-svn: 99722
Diffstat (limited to 'llvm/utils/TableGen/DAGISelMatcherEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/DAGISelMatcherEmitter.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 22a3430f98a..885503476ad 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -280,10 +280,14 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
// For each case we emit the size, then the opcode, then the matcher.
for (unsigned i = 0, e = NumCases; i != e; ++i) {
const Matcher *Child;
- if (const SwitchOpcodeMatcher *SOM = dyn_cast<SwitchOpcodeMatcher>(N))
+ unsigned IdxSize;
+ if (const SwitchOpcodeMatcher *SOM = dyn_cast<SwitchOpcodeMatcher>(N)) {
Child = SOM->getCaseMatcher(i);
- else
+ IdxSize = 2; // size of opcode in table is 2 bytes.
+ } else {
Child = cast<SwitchTypeMatcher>(N)->getCaseMatcher(i);
+ IdxSize = 1; // size of type in table is 1 byte.
+ }
// We need to encode the opcode and the offset of the case code before
// emitting the case code. Handle this by buffering the output into a
@@ -299,7 +303,8 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
TmpBuf.clear();
raw_svector_ostream OS(TmpBuf);
formatted_raw_ostream FOS(OS);
- ChildSize = EmitMatcherList(Child, Indent+1, CurrentIdx+VBRSize+1, FOS);
+ ChildSize = EmitMatcherList(Child, Indent+1, CurrentIdx+VBRSize+IdxSize,
+ FOS);
} while (GetVBRSize(ChildSize) != VBRSize);
assert(ChildSize != 0 && "Should not have a zero-sized child!");
@@ -315,14 +320,13 @@ EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
CurrentIdx += EmitVBRValue(ChildSize, OS);
OS << ' ';
- if (const SwitchOpcodeMatcher *SOM = dyn_cast<SwitchOpcodeMatcher>(N)) {
+ if (const SwitchOpcodeMatcher *SOM = dyn_cast<SwitchOpcodeMatcher>(N))
OS << "TARGET_OPCODE(" << SOM->getCaseOpcode(i).getEnumName() << "),";
- CurrentIdx += 2;
- } else {
+ else
OS << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i)) << ',';
- ++CurrentIdx;
- }
-
+
+ CurrentIdx += IdxSize;
+
if (!OmitComments)
OS << "// ->" << CurrentIdx+ChildSize;
OS << '\n';
OpenPOWER on IntegriCloud