mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-08 21:10:31 +00:00
Move compressor out of the core Reader.cpp file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34007 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f5e28d9dfe
commit
0d3382ac92
@ -27,7 +27,6 @@
|
|||||||
#include "llvm/Bytecode/Format.h"
|
#include "llvm/Bytecode/Format.h"
|
||||||
#include "llvm/Config/alloca.h"
|
#include "llvm/Config/alloca.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
#include "llvm/Support/Compressor.h"
|
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
@ -1982,6 +1981,7 @@ void BytecodeReader::ParseModule() {
|
|||||||
/// and \p Length parameters.
|
/// and \p Length parameters.
|
||||||
bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
|
bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
|
||||||
const std::string &ModuleID,
|
const std::string &ModuleID,
|
||||||
|
Decompressor_t *Decompressor,
|
||||||
std::string* ErrMsg) {
|
std::string* ErrMsg) {
|
||||||
|
|
||||||
/// We handle errors by
|
/// We handle errors by
|
||||||
@ -2021,8 +2021,8 @@ bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
|
|||||||
// file's magic number which is not part of the compressed block. Hence,
|
// 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
|
// the Buf+4 and Length-4. The result goes into decompressedBlock, a data
|
||||||
// member for retention until BytecodeReader is destructed.
|
// member for retention until BytecodeReader is destructed.
|
||||||
unsigned decompressedLength = Compressor::decompressToNewBuffer(
|
unsigned decompressedLength =
|
||||||
(char*)Buf+4,Length-4,decompressedBlock);
|
Decompressor((char*)Buf+4,Length-4,decompressedBlock, 0);
|
||||||
|
|
||||||
// We must adjust the buffer pointers used by the bytecode reader to point
|
// We must adjust the buffer pointers used by the bytecode reader to point
|
||||||
// into the new decompressed block. After decompression, the
|
// into the new decompressed block. After decompression, the
|
||||||
|
@ -140,12 +140,16 @@ public:
|
|||||||
/// @name Methods
|
/// @name Methods
|
||||||
/// @{
|
/// @{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
typedef size_t Decompressor_t(const char *, size_t, char*&, std::string*);
|
||||||
|
|
||||||
/// @returns true if an error occurred
|
/// @returns true if an error occurred
|
||||||
/// @brief Main interface to parsing a bytecode buffer.
|
/// @brief Main interface to parsing a bytecode buffer.
|
||||||
bool ParseBytecode(
|
bool ParseBytecode(
|
||||||
volatile BufPtr Buf, ///< Beginning of the bytecode buffer
|
volatile BufPtr Buf, ///< Beginning of the bytecode buffer
|
||||||
unsigned Length, ///< Length of the bytecode buffer
|
unsigned Length, ///< Length of the bytecode buffer
|
||||||
const std::string &ModuleID, ///< An identifier for the module constructed.
|
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
|
std::string* ErrMsg = 0 ///< Optional place for error message
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Instructions.h"
|
#include "llvm/Instructions.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
#include "llvm/Support/Compressor.h"
|
||||||
#include "llvm/System/MappedFile.h"
|
#include "llvm/System/MappedFile.h"
|
||||||
#include "llvm/System/Program.h"
|
#include "llvm/System/Program.h"
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@ -63,7 +64,8 @@ bool BytecodeFileReader::read(std::string* ErrMsg) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
unsigned char* buffer = reinterpret_cast<unsigned char*>(mapFile.base());
|
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 @@ BytecodeBufferReader::read(std::string* ErrMsg) {
|
|||||||
ParseBegin = Buffer = Buf;
|
ParseBegin = Buffer = Buf;
|
||||||
MustDelete = false;
|
MustDelete = false;
|
||||||
}
|
}
|
||||||
if (ParseBytecode(ParseBegin, Length, ModuleID, ErrMsg)) {
|
if (ParseBytecode(ParseBegin, Length, ModuleID,
|
||||||
|
Compressor::decompressToNewBuffer, ErrMsg)) {
|
||||||
if (MustDelete) delete [] Buffer;
|
if (MustDelete) delete [] Buffer;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -177,7 +180,8 @@ BytecodeStdinReader::read(std::string* ErrMsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileBuf = &FileData[0];
|
FileBuf = &FileData[0];
|
||||||
if (ParseBytecode(FileBuf, FileData.size(), "<stdin>", ErrMsg))
|
if (ParseBytecode(FileBuf, FileData.size(), "<stdin>",
|
||||||
|
Compressor::decompressToNewBuffer, ErrMsg))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user