Changes in directory llvm/lib/Bytecode/Archive:

Archive.cpp updated: 1.15 -> 1.16
ArchiveReader.cpp updated: 1.48 -> 1.49
ArchiveWriter.cpp updated: 1.33 -> 1.34
---
Log message:

push bytecode decompressor out through APIs.  Now the bytecode reader
api's look like this:

ModuleProvider *getBytecodeModuleProvider(
  const std::string &Filename,  ///< Name of file to be read
  BCDecompressor_t *BCDC = Compressor::decompressToNewBuffer,
  std::string* ErrMsg = 0,      ///< Optional error message holder 
  BytecodeHandler* H = 0        ///< Optional handler for reader events
);

This is ugly, but allows a client to say:

  getBytecodeModuleProvider("foo", 0);

If they do this, there is no dependency on the compression libraries, saving
codesize.




---
Diffs of the changes:  (+17 -12)

 Archive.cpp       |    6 +++---
 ArchiveReader.cpp |   17 ++++++++++-------
 ArchiveWriter.cpp |    6 ++++--
 3 files changed, 17 insertions(+), 12 deletions(-)


Index: llvm/lib/Bytecode/Archive/Archive.cpp
diff -u llvm/lib/Bytecode/Archive/Archive.cpp:1.15 
llvm/lib/Bytecode/Archive/Archive.cpp:1.16
--- llvm/lib/Bytecode/Archive/Archive.cpp:1.15  Fri Dec 15 13:44:51 2006
+++ llvm/lib/Bytecode/Archive/Archive.cpp       Wed Feb  7 15:41:01 2007
@@ -138,10 +138,10 @@
 // Archive constructor - this is the only constructor that gets used for the
 // Archive class. Everything else (default,copy) is deprecated. This just
 // initializes and maps the file into memory, if requested.
-Archive::Archive(const sys::Path& filename)
+Archive::Archive(const sys::Path& filename, BCDecompressor_t *BCDC)
   : archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
-    symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
-{
+    symTabSize(0), firstFileOffset(0), modules(), foreignST(0), 
+    Decompressor(BCDC) {
 }
 
 bool


Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.48 
llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.49
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.48    Fri Dec 15 13:44:51 2006
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp Wed Feb  7 15:41:01 2007
@@ -13,8 +13,8 @@
 
 #include "ArchiveInternals.h"
 #include "llvm/Bytecode/Reader.h"
+#include "llvm/Support/Compressor.h"
 #include <memory>
-
 using namespace llvm;
 
 /// Read a variable-bit-rate encoded unsigned integer
@@ -351,7 +351,9 @@
       std::string FullMemberName = archPath.toString() +
         "(" + I->getPath().toString() + ")";
       Module* M = ParseBytecodeBuffer((const unsigned char*)I->getData(),
-          I->getSize(), FullMemberName, ErrMessage);
+                                      I->getSize(), FullMemberName,
+                                      Compressor::decompressToNewBuffer,
+                                      ErrMessage);
       if (!M)
         return true;
 
@@ -486,7 +488,7 @@
     mbr->getPath().toString() + ")";
   ModuleProvider* mp = getBytecodeBufferModuleProvider(
       (const unsigned char*) mbr->getData(), mbr->getSize(),
-      FullMemberName, ErrMsg, 0);
+      FullMemberName, Decompressor, ErrMsg, 0);
   if (!mp)
     return 0;
 
@@ -500,8 +502,7 @@
 bool
 Archive::findModulesDefiningSymbols(std::set<std::string>& symbols,
                                     std::set<ModuleProvider*>& result,
-                                    std::string* error)
-{
+                                    std::string* error) {
   if (!mapfile || !base) {
     if (error)
       *error = "Empty archive invalid for finding modules defining symbols";
@@ -533,8 +534,10 @@
         std::vector<std::string> symbols;
         std::string FullMemberName = archPath.toString() + "(" +
           mbr->getPath().toString() + ")";
-        ModuleProvider* MP = GetBytecodeSymbols((const unsigned char*)At,
-            mbr->getSize(), FullMemberName, symbols, error);
+        ModuleProvider* MP = 
+          GetBytecodeSymbols((const unsigned char*)At, mbr->getSize(),
+                             FullMemberName, symbols, 
+                             Compressor::decompressToNewBuffer, error);
 
         if (MP) {
           // Insert the module's symbols into the symbol table


Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.33 
llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.34
--- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.33    Fri Dec 15 13:44:51 2006
+++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp Wed Feb  7 15:41:01 2007
@@ -225,8 +225,10 @@
     std::string FullMemberName = archPath.toString() + "(" +
       member.getPath().toString()
       + ")";
-    ModuleProvider* MP = GetBytecodeSymbols(
-      (const unsigned char*)data,fSize,FullMemberName, symbols, ErrMsg);
+    ModuleProvider* MP = 
+      GetBytecodeSymbols((const unsigned char*)data,fSize,
+                         FullMemberName, symbols,
+                         Compressor::decompressToNewBuffer, ErrMsg);
 
     // If the bytecode parsed successfully
     if ( MP ) {



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

Reply via email to