* Emit bytecode using a deque instead of a vector to be faster
* Internal rep no longer has a constant pool
* Support emission of recursive types
* Don't output a constant pool for an external method
* The bytecode writer is no longer a module analyzer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@449 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp
index 3ab882f..3859ea8 100644
--- a/lib/Bytecode/Writer/InstructionWriter.cpp
+++ b/lib/Bytecode/Writer/InstructionWriter.cpp
@@ -26,7 +26,7 @@
//
static void outputInstructionFormat0(const Instruction *I,
const SlotCalculator &Table,
- unsigned Type, vector<uchar> &Out) {
+ unsigned Type, deque<uchar> &Out) {
// Opcode must have top two bits clear...
output_vbr(I->getOpcode(), Out); // Instruction Opcode ID
output_vbr(Type, Out); // Result type
@@ -54,7 +54,7 @@
//
static void outputInstrVarArgsCall(const Instruction *I,
const SlotCalculator &Table, unsigned Type,
- vector<uchar> &Out) {
+ deque<uchar> &Out) {
assert(I->getOpcode() == Instruction::Call /*||
I->getOpcode() == Instruction::ICall */);
// Opcode must have top two bits clear...
@@ -94,7 +94,7 @@
//
static void outputInstructionFormat1(const Instruction *I,
const SlotCalculator &Table, int *Slots,
- unsigned Type, vector<uchar> &Out) {
+ unsigned Type, deque<uchar> &Out) {
unsigned IType = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
@@ -115,7 +115,7 @@
//
static void outputInstructionFormat2(const Instruction *I,
const SlotCalculator &Table, int *Slots,
- unsigned Type, vector<uchar> &Out) {
+ unsigned Type, deque<uchar> &Out) {
unsigned IType = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
@@ -139,7 +139,7 @@
//
static void outputInstructionFormat3(const Instruction *I,
const SlotCalculator &Table, int *Slots,
- unsigned Type, vector<uchar> &Out) {
+ unsigned Type, deque<uchar> &Out) {
unsigned IType = I->getOpcode(); // Instruction Opcode ID
// bits Instruction format:
@@ -158,7 +158,9 @@
output(Opcode, Out);
}
-bool BytecodeWriter::processInstruction(const Instruction *I) {
+#include "llvm/Assembly/Writer.h"
+
+void BytecodeWriter::processInstruction(const Instruction *I) {
assert(I->getOpcode() < 64 && "Opcode too big???");
unsigned NumOperands = I->getNumOperands();
@@ -215,7 +217,7 @@
} else if (I->getOpcode() == Instruction::Call && // Handle VarArg calls
I->getOperand(0)->getType()->isMethodType()->isVarArg()) {
outputInstrVarArgsCall(I, Table, Type, Out);
- return false;
+ return;
}
// Decide which instruction encoding to use. This is determined primarily by
@@ -228,21 +230,21 @@
case 1:
if (MaxOpSlot < (1 << 12)-1) { // -1 because we use 4095 to indicate 0 ops
outputInstructionFormat1(I, Table, Slots, Type, Out);
- return false;
+ return;
}
break;
case 2:
if (MaxOpSlot < (1 << 8)) {
outputInstructionFormat2(I, Table, Slots, Type, Out);
- return false;
+ return;
}
break;
case 3:
if (MaxOpSlot < (1 << 6)) {
outputInstructionFormat3(I, Table, Slots, Type, Out);
- return false;
+ return;
}
break;
}
@@ -250,5 +252,4 @@
// If we weren't handled before here, we either have a large number of
// operands or a large operand index that we are refering to.
outputInstructionFormat0(I, Table, Type, Out);
- return false;
}