mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-09 10:30:47 +00:00
Switch the bitcode reader interface to take a MemoryBuffer instead of knowing
anything about disk I/O itself. This greatly simplifies its interface - eliminating the need for the ReaderWrappers.cpp file. This adds a new option to llvm-dis (-bitcode) which instructs it to read the input file as bitcode. Until/unless the bytecode reader is taught to read from MemoryBuffer, there is no way to handle stdin reading without it. I don't plan to switch the bytecode reader over, I'd rather delete it :), so the option will stay around temporarily. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36554 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
namespace llvm {
|
||||
class BitstreamReader;
|
||||
class MemoryBuffer;
|
||||
|
||||
class BitcodeReaderValueList : public User {
|
||||
std::vector<Use> Uses;
|
||||
@@ -57,6 +58,7 @@ public:
|
||||
|
||||
|
||||
class BitcodeReader : public ModuleProvider {
|
||||
MemoryBuffer *Buffer;
|
||||
const char *ErrorString;
|
||||
|
||||
std::vector<PATypeHolder> TypeList;
|
||||
@@ -64,10 +66,16 @@ class BitcodeReader : public ModuleProvider {
|
||||
std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits;
|
||||
std::vector<std::pair<GlobalAlias*, unsigned> > AliasInits;
|
||||
public:
|
||||
BitcodeReader() : ErrorString(0) {}
|
||||
virtual ~BitcodeReader() {}
|
||||
BitcodeReader(MemoryBuffer *buffer) : Buffer(buffer), ErrorString(0) {}
|
||||
~BitcodeReader();
|
||||
|
||||
virtual void FreeState() {}
|
||||
|
||||
/// releaseMemoryBuffer - This causes the reader to completely forget about
|
||||
/// the memory buffer it contains, which prevents the buffer from being
|
||||
/// destroyed when it is deleted.
|
||||
void releaseMemoryBuffer() {
|
||||
Buffer = 0;
|
||||
}
|
||||
|
||||
virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) {
|
||||
// FIXME: TODO
|
||||
@@ -89,8 +97,7 @@ public:
|
||||
|
||||
/// @brief Main interface to parsing a bitcode buffer.
|
||||
/// @returns true if an error occurred.
|
||||
bool ParseBitcode(unsigned char *Buf, unsigned Length,
|
||||
const std::string &ModuleID);
|
||||
bool ParseBitcode();
|
||||
private:
|
||||
const Type *getTypeByID(unsigned ID, bool isTypeTable = false);
|
||||
|
||||
|
Reference in New Issue
Block a user