* 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/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h
index 41f0b4d..ff49c1d 100644
--- a/lib/Bytecode/Writer/WriterInternals.h
+++ b/lib/Bytecode/Writer/WriterInternals.h
@@ -14,22 +14,22 @@
#include "llvm/Bytecode/Writer.h"
#include "llvm/Bytecode/Format.h"
-#include "llvm/Bytecode/Primitives.h"
#include "llvm/Analysis/SlotCalculator.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/Bytecode/Primitives.h"
#include "llvm/Instruction.h"
+#include <deque>
-class BytecodeWriter : public ModuleAnalyzer {
- vector<unsigned char> &Out;
+class BytecodeWriter {
+ deque<unsigned char> &Out;
SlotCalculator Table;
public:
- BytecodeWriter(vector<unsigned char> &o, const Module *M);
+ BytecodeWriter(deque<unsigned char> &o, const Module *M);
protected:
- virtual bool processConstPool(const ConstantPool &CP, bool isMethod);
- virtual bool processMethod(const Method *M);
- virtual bool processBasicBlock(const BasicBlock *BB);
- virtual bool processInstruction(const Instruction *I);
+ void outputConstants(bool isMethod);
+ void processMethod(const Method *M);
+ void processBasicBlock(const BasicBlock *BB);
+ void processInstruction(const Instruction *I);
private :
inline void outputSignature() {
@@ -51,12 +51,12 @@
//
class BytecodeBlock {
unsigned Loc;
- vector<unsigned char> &Out;
+ deque<unsigned char> &Out;
BytecodeBlock(const BytecodeBlock &); // do not implement
void operator=(const BytecodeBlock &); // do not implement
public:
- inline BytecodeBlock(unsigned ID, vector<unsigned char> &o) : Out(o) {
+ inline BytecodeBlock(unsigned ID, deque<unsigned char> &o) : Out(o) {
output(ID, Out);
output((unsigned)0, Out); // Reserve the space for the block size...
Loc = Out.size();
@@ -64,7 +64,8 @@
inline ~BytecodeBlock() { // Do backpatch when block goes out
// of scope...
- // cerr << "OldLoc = " << Loc << " NewLoc = " << NewLoc << " diff = " << (NewLoc-Loc) << endl;
+ //cerr << "OldLoc = " << Loc << " NewLoc = " << NewLoc << " diff = "
+ // << (NewLoc-Loc) << endl;
output((unsigned)(Out.size()-Loc), Out, (int)Loc-4);
align32(Out); // Blocks must ALWAYS be aligned
}