summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-23 00:59:59 +0000
committerChris Lattner <sabre@nondot.org>2010-02-23 00:59:59 +0000
commit5007e1e43541114f3737939234104b085fbe4aca (patch)
tree6669ad38ff1c2e6589b9253933071a42c61f96fa /utils
parentec5a4cd14c09e3d36b24411b8cd42166d91102f0 (diff)
downloadllvm-5007e1e43541114f3737939234104b085fbe4aca.tar.gz
llvm-5007e1e43541114f3737939234104b085fbe4aca.tar.bz2
llvm-5007e1e43541114f3737939234104b085fbe4aca.tar.xz
switch the value# in OPC_CompleteMatch and OPC_EmitNode to use a
VBR encoding for the insanity being perpetrated by the spu backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/DAGISelMatcherEmitter.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/utils/TableGen/DAGISelMatcherEmitter.cpp b/utils/TableGen/DAGISelMatcherEmitter.cpp
index 33e37fae94..ed720df808 100644
--- a/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -127,6 +127,25 @@ private:
};
} // end anonymous namespace.
+/// EmitVBRValue - Emit the specified value as a VBR, returning the number of
+/// bytes emitted.
+static unsigned EmitVBRValue(unsigned Val, raw_ostream &OS) {
+ if (Val <= 127) {
+ OS << Val << ", ";
+ return 1;
+ }
+
+ unsigned InVal = Val;
+ unsigned NumBytes = 0;
+ while (Val > 128) {
+ OS << (Val&127) << "|128,";
+ Val >>= 7;
+ ++NumBytes;
+ }
+ OS << Val << "/*" << InVal << "*/, ";
+ return NumBytes+1;
+}
+
/// EmitMatcherOpcodes - Emit bytes for the specified matcher and return
/// the number of bytes emitted.
unsigned MatcherTableEmitter::
@@ -309,22 +328,27 @@ EmitMatcher(const MatcherNode *N, unsigned Indent, formatted_raw_ostream &OS) {
OS << getEnumName(EN->getVT(i)) << ", ";
OS << EN->getNumOperands() << "/*#Ops*/, ";
- for (unsigned i = 0, e = EN->getNumOperands(); i != e; ++i)
- OS << EN->getOperand(i) << ", ";
+ 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);
+ }
OS << '\n';
- return 6+EN->getNumVTs()+EN->getNumOperands();
+ return 6+EN->getNumVTs()+NumOperandBytes;
}
case MatcherNode::CompleteMatch: {
const CompleteMatchMatcherNode *CM = cast<CompleteMatchMatcherNode>(N);
OS << "OPC_CompleteMatch, " << CM->getNumResults() << ", ";
+ unsigned NumResultBytes = 0;
for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i)
- OS << CM->getResult(i) << ", ";
+ NumResultBytes += EmitVBRValue(CM->getResult(i), OS);
OS << '\n';
OS.PadToColumn(Indent*2) << "// Src: "
<< *CM->getPattern().getSrcPattern() << '\n';
OS.PadToColumn(Indent*2) << "// Dst: "
<< *CM->getPattern().getDstPattern() << '\n';
- return 2+CM->getNumResults();
+ return 2 + NumResultBytes;
}
}
assert(0 && "Unreachable");