diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-01 07:05:31 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-01 07:05:31 +0000 |
commit | d9cf9b30eb3c96a3d60545501e690028029e39fb (patch) | |
tree | 75b1ae7cc15fdc1969714af5f97cc95d2c05c076 /llvm/lib/Bytecode/Writer | |
parent | 7c290ed25a5ea5aba07583a797992ca0646dc123 (diff) | |
download | bcm5719-llvm-d9cf9b30eb3c96a3d60545501e690028029e39fb.tar.gz bcm5719-llvm-d9cf9b30eb3c96a3d60545501e690028029e39fb.zip |
Emit & read more compressed bytecode by not emitting a bytecodeblock for
each basic block in function. Instead, just emit a stream of instructions,
chopping up basic blocks based on when we find terminator instructions. This
saves a fairly substantial chunk of bytecode space. In stripped, sample
cases, for example, we get this reduction in size:
197.parser: 163036 -> 137180: 18.8% reduction
254.gap : 844936 -> 689392: 22.6%
255.vortex: 621724 -> 528444: 17.7%
...
Not bad for something this simple. :) Note that this doesn't require a new
bytecode version number at all, though version 1.1 should not need to support
the old format.
llvm-svn: 10280
Diffstat (limited to 'llvm/lib/Bytecode/Writer')
-rw-r--r-- | llvm/lib/Bytecode/Writer/Writer.cpp | 18 | ||||
-rw-r--r-- | llvm/lib/Bytecode/Writer/WriterInternals.h | 1 |
2 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp index 9c9e1abcdd8..7fa22b81017 100644 --- a/llvm/lib/Bytecode/Writer/Writer.cpp +++ b/llvm/lib/Bytecode/Writer/Writer.cpp @@ -225,9 +225,13 @@ void BytecodeWriter::outputFunction(const Function *F) { // Output information about the constants in the function... outputConstants(true); - // Output basic block nodes... - for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I) - processBasicBlock(*I); + { // Output all of the instructions in the body of the function + BytecodeBlock ILBlock(BytecodeFormat::InstructionList, Out); + + for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E;++BB) + for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I) + processInstruction(*I); + } // If needed, output the symbol table for the function... outputSymbolTable(F->getSymbolTable()); @@ -236,14 +240,6 @@ void BytecodeWriter::outputFunction(const Function *F) { } } - -void BytecodeWriter::processBasicBlock(const BasicBlock &BB) { - BytecodeBlock FunctionBlock(BytecodeFormat::BasicBlock, Out); - // Process all the instructions in the bb... - for(BasicBlock::const_iterator I = BB.begin(), E = BB.end(); I != E; ++I) - processInstruction(*I); -} - void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) { BytecodeBlock FunctionBlock(BytecodeFormat::SymbolTable, Out); diff --git a/llvm/lib/Bytecode/Writer/WriterInternals.h b/llvm/lib/Bytecode/Writer/WriterInternals.h index 8cb4bfd8d6c..29465157c7c 100644 --- a/llvm/lib/Bytecode/Writer/WriterInternals.h +++ b/llvm/lib/Bytecode/Writer/WriterInternals.h @@ -36,7 +36,6 @@ public: protected: void outputConstants(bool isFunction); void outputFunction(const Function *F); - void processBasicBlock(const BasicBlock &BB); void processInstruction(const Instruction &I); private : |