From 5d3569e93ce31052a55d6e64b7153d055d60d8e8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 27 Mar 2010 18:49:33 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99722 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelMatcherEmitter.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'utils/TableGen/DAGISelMatcherEmitter.cpp') diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp index 22a3430..8855034 100644 --- a/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/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(N)) + unsigned IdxSize; + if (const SwitchOpcodeMatcher *SOM = dyn_cast(N)) { Child = SOM->getCaseMatcher(i); - else + IdxSize = 2; // size of opcode in table is 2 bytes. + } else { Child = cast(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(N)) { + if (const SwitchOpcodeMatcher *SOM = dyn_cast(N)) OS << "TARGET_OPCODE(" << SOM->getCaseOpcode(i).getEnumName() << "),"; - CurrentIdx += 2; - } else { + else OS << getEnumName(cast(N)->getCaseType(i)) << ','; - ++CurrentIdx; - } - + + CurrentIdx += IdxSize; + if (!OmitComments) OS << "// ->" << CurrentIdx+ChildSize; OS << '\n'; -- cgit v1.1