Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.233 -> 1.234
Reader.h updated: 1.45 -> 1.46
ReaderWrappers.cpp updated: 1.62 -> 1.63
---
Log message:

Move compressor out of the core Reader.cpp file.


---
Diffs of the changes:  (+14 -6)

 Reader.cpp         |    6 +++---
 Reader.h           |    4 ++++
 ReaderWrappers.cpp |   10 +++++++---
 3 files changed, 14 insertions(+), 6 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.233 
llvm/lib/Bytecode/Reader/Reader.cpp:1.234
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.233   Wed Feb  7 00:53:02 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Wed Feb  7 13:49:01 2007
@@ -27,7 +27,6 @@
 #include "llvm/Bytecode/Format.h"
 #include "llvm/Config/alloca.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
-#include "llvm/Support/Compressor.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
@@ -1982,6 +1981,7 @@
 /// and \p Length parameters.
 bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
                                    const std::string &ModuleID,
+                                   Decompressor_t *Decompressor, 
                                    std::string* ErrMsg) {
 
   /// We handle errors by
@@ -2021,8 +2021,8 @@
     // file's magic number which is not part of the compressed block. Hence,
     // the Buf+4 and Length-4. The result goes into decompressedBlock, a data
     // member for retention until BytecodeReader is destructed.
-    unsigned decompressedLength = Compressor::decompressToNewBuffer(
-        (char*)Buf+4,Length-4,decompressedBlock);
+    unsigned decompressedLength = 
+      Decompressor((char*)Buf+4,Length-4,decompressedBlock, 0);
 
     // We must adjust the buffer pointers used by the bytecode reader to point
     // into the new decompressed block. After decompression, the


Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.45 
llvm/lib/Bytecode/Reader/Reader.h:1.46
--- llvm/lib/Bytecode/Reader/Reader.h:1.45      Tue Feb  6 23:08:39 2007
+++ llvm/lib/Bytecode/Reader/Reader.h   Wed Feb  7 13:49:01 2007
@@ -140,12 +140,16 @@
 /// @name Methods
 /// @{
 public:
+    
+  typedef size_t Decompressor_t(const char *, size_t, char*&, std::string*);
+  
   /// @returns true if an error occurred
   /// @brief Main interface to parsing a bytecode buffer.
   bool ParseBytecode(
      volatile BufPtr Buf,         ///< Beginning of the bytecode buffer
      unsigned Length,             ///< Length of the bytecode buffer
      const std::string &ModuleID, ///< An identifier for the module 
constructed.
+     Decompressor_t *Decompressor = 0, ///< Optional decompressor.
      std::string* ErrMsg = 0      ///< Optional place for error message 
   );
 


Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.62 
llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.63
--- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.62    Tue Jan 30 14:08:37 2007
+++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Wed Feb  7 13:49:01 2007
@@ -18,6 +18,7 @@
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compressor.h"
 #include "llvm/System/MappedFile.h"
 #include "llvm/System/Program.h"
 #include <cerrno>
@@ -63,7 +64,8 @@
     return true;
   }
   unsigned char* buffer = reinterpret_cast<unsigned char*>(mapFile.base());
-  return ParseBytecode(buffer, mapFile.size(), fileName, ErrMsg);
+  return ParseBytecode(buffer, mapFile.size(), fileName,
+                       Compressor::decompressToNewBuffer, ErrMsg);
 }
 
 
//===----------------------------------------------------------------------===//
@@ -122,7 +124,8 @@
     ParseBegin = Buffer = Buf;
     MustDelete = false;
   }
-  if (ParseBytecode(ParseBegin, Length, ModuleID, ErrMsg)) {
+  if (ParseBytecode(ParseBegin, Length, ModuleID,
+                    Compressor::decompressToNewBuffer, ErrMsg)) {
     if (MustDelete) delete [] Buffer;
     return true;
   }
@@ -177,7 +180,8 @@
   }
 
   FileBuf = &FileData[0];
-  if (ParseBytecode(FileBuf, FileData.size(), "<stdin>", ErrMsg))
+  if (ParseBytecode(FileBuf, FileData.size(), "<stdin>", 
+                    Compressor::decompressToNewBuffer, ErrMsg))
     return true;
   return false;
 }



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to