blob: 5675b2af4913b1a7369c84a140c72ed2a6970c72 [file] [log] [blame]
Chris Lattnerb0a59642004-01-10 19:07:06 +00001//===-- Writer.cpp - Library for writing LLVM bytecode files --------------===//
John Criswell482202a2003-10-20 19:43:21 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner2f7c9632001-06-06 20:29:01 +00009//
10// This library implements the functionality defined in llvm/Bytecode/Writer.h
11//
Chris Lattner2f7c9632001-06-06 20:29:01 +000012// Note that this file uses an unusual technique of outputting all the bytecode
Chris Lattneraf4c95a2003-09-15 00:33:20 +000013// to a deque of unsigned char, then copies the deque to an ostream. The
Chris Lattner2f7c9632001-06-06 20:29:01 +000014// reason for this is that we must do "seeking" in the stream to do back-
15// patching, and some very important ostreams that we want to support (like
16// pipes) do not support seeking. :( :( :(
17//
Chris Lattnerb97ef9f2001-09-07 16:39:41 +000018// The choice of the deque data structure is influenced by the extremely fast
19// "append" speed, plus the free "seek"/replace in the middle of the stream. I
20// didn't use a vector because the stream could end up very large and copying
21// the whole thing to reallocate would be kinda silly.
Chris Lattner2f7c9632001-06-06 20:29:01 +000022//
Chris Lattner2f7c9632001-06-06 20:29:01 +000023//===----------------------------------------------------------------------===//
24
25#include "WriterInternals.h"
Chris Lattner36d2c7c2002-07-23 19:56:44 +000026#include "llvm/Bytecode/WriteBytecodePass.h"
Chris Lattner6229fbf2004-01-14 23:36:54 +000027#include "llvm/Constants.h"
28#include "llvm/DerivedTypes.h"
Chris Lattner2f7c9632001-06-06 20:29:01 +000029#include "llvm/Module.h"
Chris Lattner2f7c9632001-06-06 20:29:01 +000030#include "llvm/SymbolTable.h"
Chris Lattnerb4c67772001-11-29 16:32:16 +000031#include "Support/STLExtras.h"
Chris Lattnerbf3a0992002-10-01 22:38:41 +000032#include "Support/Statistic.h"
Chris Lattner9a38c78f2004-01-14 16:54:21 +000033#include "Support/Debug.h"
Chris Lattner0c530312004-01-10 19:10:01 +000034#include <cstring>
Chris Lattner2f7c9632001-06-06 20:29:01 +000035#include <algorithm>
Chris Lattnerdfe03462004-01-10 18:49:43 +000036using namespace llvm;
Brian Gaeke960707c2003-11-11 22:41:34 +000037
Chris Lattner36d2c7c2002-07-23 19:56:44 +000038static RegisterPass<WriteBytecodePass> X("emitbytecode", "Bytecode Writer");
39
Chris Lattner64eea742002-07-26 18:40:14 +000040static Statistic<>
Chris Lattnerbf3a0992002-10-01 22:38:41 +000041BytesWritten("bytecodewriter", "Number of bytecode bytes written");
Chris Lattner9a38c78f2004-01-14 16:54:21 +000042static Statistic<>
43ConstantTotalBytes("bytecodewriter", "Bytes of constants total");
44static Statistic<>
45FunctionConstantTotalBytes("bytecodewriter", "Bytes of function constants total");
46static Statistic<>
47ConstantPlaneHeaderBytes("bytecodewriter", "Constant plane header bytes");
48static Statistic<>
49InstructionBytes("bytecodewriter", "Bytes of bytes of instructions");
50static Statistic<>
51SymTabBytes("bytecodewriter", "Bytes of symbol table");
52static Statistic<>
53ModuleInfoBytes("bytecodewriter", "Bytes of module info");
Chris Lattner36d2c7c2002-07-23 19:56:44 +000054
Chris Lattner7f74a562002-01-20 22:54:45 +000055BytecodeWriter::BytecodeWriter(std::deque<unsigned char> &o, const Module *M)
Chris Lattner1f018c22004-01-14 02:50:16 +000056 : Out(o), Table(M, true) {
Chris Lattner2f7c9632001-06-06 20:29:01 +000057
Chris Lattner6229fbf2004-01-14 23:36:54 +000058 // Emit the signature...
59 static const unsigned char *Sig = (const unsigned char*)"llvm";
60 output_data(Sig, Sig+4, Out);
Chris Lattner2f7c9632001-06-06 20:29:01 +000061
62 // Emit the top level CLASS block.
63 BytecodeBlock ModuleBlock(BytecodeFormat::Module, Out);
64
Chris Lattner55a07ad2003-08-24 13:47:36 +000065 bool isBigEndian = M->getEndianness() == Module::BigEndian;
66 bool hasLongPointers = M->getPointerSize() == Module::Pointer64;
67 bool hasNoEndianness = M->getEndianness() == Module::AnyEndianness;
68 bool hasNoPointerSize = M->getPointerSize() == Module::AnyPointerSize;
Chris Lattner428bf5a2003-03-19 20:56:46 +000069
Chris Lattner9a38c78f2004-01-14 16:54:21 +000070 // Output the version identifier... we are currently on bytecode version #1,
71 // which corresponds to LLVM v1.2.
72 unsigned Version = (1 << 4) | isBigEndian | (hasLongPointers << 1) |
Chris Lattner55a07ad2003-08-24 13:47:36 +000073 (hasNoEndianness << 2) | (hasNoPointerSize << 3);
Chris Lattner428bf5a2003-03-19 20:56:46 +000074 output_vbr(Version, Out);
Chris Lattner2f7c9632001-06-06 20:29:01 +000075 align32(Out);
76
Chris Lattner428bf5a2003-03-19 20:56:46 +000077 {
78 BytecodeBlock CPool(BytecodeFormat::GlobalTypePlane, Out);
79
80 // Write the type plane for types first because earlier planes (e.g. for a
81 // primitive type like float) may have constants constructed using types
82 // coming later (e.g., via getelementptr from a pointer type). The type
83 // plane is needed before types can be fwd or bkwd referenced.
84 const std::vector<const Value*> &Plane = Table.getPlane(Type::TypeTyID);
85 assert(!Plane.empty() && "No types at all?");
86 unsigned ValNo = Type::FirstDerivedTyID; // Start at the derived types...
87 outputConstantsInPlane(Plane, ValNo); // Write out the types
88 }
Chris Lattner2f7c9632001-06-06 20:29:01 +000089
Chris Lattner9a38c78f2004-01-14 16:54:21 +000090 DEBUG(for (unsigned i = 0; i != Type::TypeTyID; ++i)
91 if (Table.getPlane(i).size())
92 std::cerr << " ModuleLevel["
93 << *Type::getPrimitiveType((Type::PrimitiveID)i)
94 << "] = " << Table.getPlane(i).size() << "\n");
95
Chris Lattner428bf5a2003-03-19 20:56:46 +000096 // The ModuleInfoBlock follows directly after the type information
Chris Lattnerb97ef9f2001-09-07 16:39:41 +000097 outputModuleInfoBlock(M);
98
Chris Lattner428bf5a2003-03-19 20:56:46 +000099 // Output module level constants, used for global variable initializers
100 outputConstants(false);
101
Chris Lattner6915f8f2002-04-07 22:49:37 +0000102 // Do the whole module now! Process each function at a time...
Chris Lattner7076ff22002-06-25 16:13:21 +0000103 for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
Chris Lattner428bf5a2003-03-19 20:56:46 +0000104 outputFunction(I);
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000105
106 // If needed, output the symbol table for the module...
Chris Lattner98cf1f52002-11-20 18:36:02 +0000107 outputSymbolTable(M->getSymbolTable());
Chris Lattner2f7c9632001-06-06 20:29:01 +0000108}
109
Vikram S. Advec1b6474a2002-07-14 23:07:51 +0000110// Helper function for outputConstants().
111// Writes out all the constants in the plane Plane starting at entry StartNo.
112//
113void BytecodeWriter::outputConstantsInPlane(const std::vector<const Value*>
114 &Plane, unsigned StartNo) {
115 unsigned ValNo = StartNo;
116
Chris Lattner6229fbf2004-01-14 23:36:54 +0000117 // Scan through and ignore function arguments, global values, and constant
118 // strings.
119 for (; ValNo < Plane.size() &&
120 (isa<Argument>(Plane[ValNo]) || isa<GlobalValue>(Plane[ValNo]) ||
121 (isa<ConstantArray>(Plane[ValNo]) &&
122 cast<ConstantArray>(Plane[ValNo])->isString())); ValNo++)
Vikram S. Advec1b6474a2002-07-14 23:07:51 +0000123 /*empty*/;
124
125 unsigned NC = ValNo; // Number of constants
126 for (; NC < Plane.size() &&
127 (isa<Constant>(Plane[NC]) || isa<Type>(Plane[NC])); NC++)
128 /*empty*/;
129 NC -= ValNo; // Convert from index into count
130 if (NC == 0) return; // Skip empty type planes...
131
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000132 // FIXME: Most slabs only have 1 or 2 entries! We should encode this much
133 // more compactly.
134
135 ConstantPlaneHeaderBytes -= Out.size();
136
Vikram S. Advec1b6474a2002-07-14 23:07:51 +0000137 // Output type header: [num entries][type id number]
138 //
139 output_vbr(NC, Out);
140
141 // Output the Type ID Number...
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000142 int Slot = Table.getSlot(Plane.front()->getType());
Vikram S. Advec1b6474a2002-07-14 23:07:51 +0000143 assert (Slot != -1 && "Type in constant pool but not in function!!");
144 output_vbr((unsigned)Slot, Out);
145
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000146 ConstantPlaneHeaderBytes += Out.size();
147
148
Vikram S. Advec1b6474a2002-07-14 23:07:51 +0000149 //cerr << "Emitting " << NC << " constants of type '"
150 // << Plane.front()->getType()->getName() << "' = Slot #" << Slot << "\n";
151
152 for (unsigned i = ValNo; i < ValNo+NC; ++i) {
153 const Value *V = Plane[i];
154 if (const Constant *CPV = dyn_cast<Constant>(V)) {
155 //cerr << "Serializing value: <" << V->getType() << ">: " << V << ":"
156 // << Out.size() << "\n";
157 outputConstant(CPV);
158 } else {
Chris Lattner428bf5a2003-03-19 20:56:46 +0000159 outputType(cast<Type>(V));
Vikram S. Advec1b6474a2002-07-14 23:07:51 +0000160 }
161 }
162}
163
Chris Lattner57698e22002-03-26 18:01:55 +0000164void BytecodeWriter::outputConstants(bool isFunction) {
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000165 ConstantTotalBytes -= Out.size();
166 if (isFunction) FunctionConstantTotalBytes -= Out.size();
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000167 BytecodeBlock CPool(BytecodeFormat::ConstantPool, Out);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000168
169 unsigned NumPlanes = Table.getNumPlanes();
Chris Lattner4a207912003-05-22 18:35:38 +0000170
171 // Output the type plane before any constants!
172 if (isFunction && NumPlanes > Type::TypeTyID) {
173 const std::vector<const Value*> &Plane = Table.getPlane(Type::TypeTyID);
Chris Lattner428bf5a2003-03-19 20:56:46 +0000174 if (!Plane.empty()) { // Skip empty type planes...
Chris Lattner4a207912003-05-22 18:35:38 +0000175 unsigned ValNo = Table.getModuleLevel(Type::TypeTyID);
176 outputConstantsInPlane(Plane, ValNo);
Chris Lattnerca1725d2002-10-14 03:34:17 +0000177 }
Chris Lattner2f7c9632001-06-06 20:29:01 +0000178 }
Chris Lattner4a207912003-05-22 18:35:38 +0000179
Chris Lattner6229fbf2004-01-14 23:36:54 +0000180 // Output module-level string constants before any other constants.x
181 if (!isFunction)
182 outputConstantStrings();
183
Chris Lattner4a207912003-05-22 18:35:38 +0000184 for (unsigned pno = 0; pno != NumPlanes; pno++)
185 if (pno != Type::TypeTyID) { // Type plane handled above.
186 const std::vector<const Value*> &Plane = Table.getPlane(pno);
187 if (!Plane.empty()) { // Skip empty type planes...
188 unsigned ValNo = 0;
Misha Brukmanacda7df2003-09-11 22:34:13 +0000189 if (isFunction) // Don't re-emit module constants
Chris Lattner4a207912003-05-22 18:35:38 +0000190 ValNo += Table.getModuleLevel(pno);
191
192 if (pno >= Type::FirstDerivedTyID) {
193 // Skip zero initializer
194 if (ValNo == 0)
195 ValNo = 1;
196 }
197
198 // Write out constants in the plane
199 outputConstantsInPlane(Plane, ValNo);
200 }
201 }
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000202 ConstantTotalBytes += Out.size();
203 if (isFunction) FunctionConstantTotalBytes += Out.size();
Chris Lattner2f7c9632001-06-06 20:29:01 +0000204}
205
Chris Lattner2d05c602003-10-16 18:28:50 +0000206static unsigned getEncodedLinkage(const GlobalValue *GV) {
207 switch (GV->getLinkage()) {
208 default: assert(0 && "Invalid linkage!");
209 case GlobalValue::ExternalLinkage: return 0;
Chris Lattner2d05c602003-10-16 18:28:50 +0000210 case GlobalValue::WeakLinkage: return 1;
211 case GlobalValue::AppendingLinkage: return 2;
212 case GlobalValue::InternalLinkage: return 3;
Chris Lattnerdc832932003-10-18 06:30:21 +0000213 case GlobalValue::LinkOnceLinkage: return 4;
Chris Lattner2d05c602003-10-16 18:28:50 +0000214 }
215}
216
Chris Lattner2f7c9632001-06-06 20:29:01 +0000217void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000218 ModuleInfoBytes -= Out.size();
219
Chris Lattner2f7c9632001-06-06 20:29:01 +0000220 BytecodeBlock ModuleInfoBlock(BytecodeFormat::ModuleGlobalInfo, Out);
221
Chris Lattnerda975502001-09-10 07:58:01 +0000222 // Output the types for the global variables in the module...
223 for (Module::const_giterator I = M->gbegin(), End = M->gend(); I != End;++I) {
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000224 int Slot = Table.getSlot(I->getType());
Chris Lattnerda975502001-09-10 07:58:01 +0000225 assert(Slot != -1 && "Module global vars is broken!");
Chris Lattner37798642001-09-18 04:01:05 +0000226
Chris Lattnerdc832932003-10-18 06:30:21 +0000227 // Fields: bit0 = isConstant, bit1 = hasInitializer, bit2-4=Linkage,
228 // bit5+ = Slot # for type
229 unsigned oSlot = ((unsigned)Slot << 5) | (getEncodedLinkage(I) << 2) |
Chris Lattner7076ff22002-06-25 16:13:21 +0000230 (I->hasInitializer() << 1) | I->isConstant();
Chris Lattner37798642001-09-18 04:01:05 +0000231 output_vbr(oSlot, Out);
232
Chris Lattner81125b62001-10-13 06:48:38 +0000233 // If we have an initializer, output it now.
Chris Lattner7076ff22002-06-25 16:13:21 +0000234 if (I->hasInitializer()) {
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000235 Slot = Table.getSlot((Value*)I->getInitializer());
Chris Lattner37798642001-09-18 04:01:05 +0000236 assert(Slot != -1 && "No slot for global var initializer!");
237 output_vbr((unsigned)Slot, Out);
238 }
Chris Lattnerda975502001-09-10 07:58:01 +0000239 }
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000240 output_vbr((unsigned)Table.getSlot(Type::VoidTy), Out);
Chris Lattnerda975502001-09-10 07:58:01 +0000241
Chris Lattner6915f8f2002-04-07 22:49:37 +0000242 // Output the types of the functions in this module...
Chris Lattner4cee8d82001-06-27 23:41:11 +0000243 for (Module::const_iterator I = M->begin(), End = M->end(); I != End; ++I) {
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000244 int Slot = Table.getSlot(I->getType());
Chris Lattner2f7c9632001-06-06 20:29:01 +0000245 assert(Slot != -1 && "Module const pool is broken!");
246 assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!");
247 output_vbr((unsigned)Slot, Out);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000248 }
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000249 output_vbr((unsigned)Table.getSlot(Type::VoidTy), Out);
Chris Lattnerda975502001-09-10 07:58:01 +0000250
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000251 ModuleInfoBytes += Out.size();
Chris Lattner2f7c9632001-06-06 20:29:01 +0000252}
253
Chris Lattner428bf5a2003-03-19 20:56:46 +0000254void BytecodeWriter::outputFunction(const Function *F) {
Chris Lattnerff874362002-03-29 03:51:11 +0000255 BytecodeBlock FunctionBlock(BytecodeFormat::Function, Out);
Chris Lattner2d05c602003-10-16 18:28:50 +0000256 output_vbr(getEncodedLinkage(F), Out);
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000257 // Only output the constant pool and other goodies if needed...
Chris Lattner7076ff22002-06-25 16:13:21 +0000258 if (!F->isExternal()) {
Chris Lattner22637332001-11-26 18:56:10 +0000259
Chris Lattner6915f8f2002-04-07 22:49:37 +0000260 // Get slot information about the function...
Chris Lattner7076ff22002-06-25 16:13:21 +0000261 Table.incorporateFunction(F);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000262
Chris Lattner6915f8f2002-04-07 22:49:37 +0000263 // Output information about the constants in the function...
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000264 outputConstants(true);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000265
Chris Lattnerd9cf9b32003-12-01 07:05:31 +0000266 { // Output all of the instructions in the body of the function
267 BytecodeBlock ILBlock(BytecodeFormat::InstructionList, Out);
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000268 InstructionBytes -= Out.size();
Chris Lattnerd9cf9b32003-12-01 07:05:31 +0000269 for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E;++BB)
270 for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E;++I)
271 processInstruction(*I);
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000272 InstructionBytes += Out.size();
Chris Lattnerd9cf9b32003-12-01 07:05:31 +0000273 }
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000274
Chris Lattner6915f8f2002-04-07 22:49:37 +0000275 // If needed, output the symbol table for the function...
Chris Lattner98cf1f52002-11-20 18:36:02 +0000276 outputSymbolTable(F->getSymbolTable());
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000277
Chris Lattner6915f8f2002-04-07 22:49:37 +0000278 Table.purgeFunction();
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000279 }
Chris Lattner2f7c9632001-06-06 20:29:01 +0000280}
281
Chris Lattner2f7c9632001-06-06 20:29:01 +0000282void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
Chris Lattnera2bfab82004-01-10 19:56:59 +0000283 // Do not output the Bytecode block for an empty symbol table, it just wastes
284 // space!
285 if (MST.begin() == MST.end()) return;
286
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000287 SymTabBytes -= Out.size();
288
289 BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTable, Out);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000290
Chris Lattner4cee8d82001-06-27 23:41:11 +0000291 for (SymbolTable::const_iterator TI = MST.begin(); TI != MST.end(); ++TI) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000292 SymbolTable::type_const_iterator I = MST.type_begin(TI->first);
293 SymbolTable::type_const_iterator End = MST.type_end(TI->first);
294 int Slot;
295
296 if (I == End) continue; // Don't mess with an absent type...
297
298 // Symtab block header: [num entries][type id number]
299 output_vbr(MST.type_size(TI->first), Out);
300
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000301 Slot = Table.getSlot(TI->first);
Chris Lattner2f7c9632001-06-06 20:29:01 +0000302 assert(Slot != -1 && "Type in symtab, but not in table!");
303 output_vbr((unsigned)Slot, Out);
304
Chris Lattner4cee8d82001-06-27 23:41:11 +0000305 for (; I != End; ++I) {
Chris Lattner2f7c9632001-06-06 20:29:01 +0000306 // Symtab entry: [def slot #][name]
Alkis Evlogimenos8faf8d92003-10-17 02:02:40 +0000307 Slot = Table.getSlot(I->second);
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000308 assert(Slot != -1 && "Value in symtab but has no slot number!!");
Chris Lattner2f7c9632001-06-06 20:29:01 +0000309 output_vbr((unsigned)Slot, Out);
310 output(I->first, Out, false); // Don't force alignment...
311 }
312 }
Chris Lattner9a38c78f2004-01-14 16:54:21 +0000313
314 SymTabBytes += Out.size();
Chris Lattner2f7c9632001-06-06 20:29:01 +0000315}
316
Chris Lattnerdfe03462004-01-10 18:49:43 +0000317void llvm::WriteBytecodeToFile(const Module *C, std::ostream &Out) {
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000318 assert(C && "You can't write a null module!!");
Chris Lattner2f7c9632001-06-06 20:29:01 +0000319
Chris Lattner7f74a562002-01-20 22:54:45 +0000320 std::deque<unsigned char> Buffer;
Chris Lattner2f7c9632001-06-06 20:29:01 +0000321
322 // This object populates buffer for us...
323 BytecodeWriter BCW(Buffer, C);
324
Chris Lattner64eea742002-07-26 18:40:14 +0000325 // Keep track of how much we've written...
326 BytesWritten += Buffer.size();
327
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000328 // Okay, write the deque out to the ostream now... the deque is not
329 // sequential in memory, however, so write out as much as possible in big
330 // chunks, until we're done.
331 //
Chris Lattner7f74a562002-01-20 22:54:45 +0000332 std::deque<unsigned char>::const_iterator I = Buffer.begin(),E = Buffer.end();
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000333 while (I != E) { // Loop until it's all written
334 // Scan to see how big this chunk is...
335 const unsigned char *ChunkPtr = &*I;
336 const unsigned char *LastPtr = ChunkPtr;
337 while (I != E) {
338 const unsigned char *ThisPtr = &*++I;
Chris Lattnerdc194d52001-11-04 21:32:41 +0000339 if (LastPtr+1 != ThisPtr) { // Advanced by more than a byte of memory?
340 ++LastPtr;
341 break;
342 }
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000343 LastPtr = ThisPtr;
344 }
345
346 // Write out the chunk...
Chris Lattner7f74a562002-01-20 22:54:45 +0000347 Out.write((char*)ChunkPtr, LastPtr-ChunkPtr);
Chris Lattnerb97ef9f2001-09-07 16:39:41 +0000348 }
349
Chris Lattner2f7c9632001-06-06 20:29:01 +0000350 Out.flush();
351}