diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
commit | cd749a9c07f1de2fb8affde90537efa4bc3e7c54 (patch) | |
tree | b21f6de4e08b89bb7931806bab798fc2a5e3a686 /include/llvm/Bitcode/ReaderWriter.h | |
parent | 72621d11de5b873f1695f391eb95f0b336c3d2d4 (diff) | |
download | FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.zip FreeBSD-src-cd749a9c07f1de2fb8affde90537efa4bc3e7c54.tar.gz |
Update llvm to r84119.
Diffstat (limited to 'include/llvm/Bitcode/ReaderWriter.h')
-rw-r--r-- | include/llvm/Bitcode/ReaderWriter.h | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/include/llvm/Bitcode/ReaderWriter.h b/include/llvm/Bitcode/ReaderWriter.h index 3d33d75..7b74bdf 100644 --- a/include/llvm/Bitcode/ReaderWriter.h +++ b/include/llvm/Bitcode/ReaderWriter.h @@ -14,7 +14,6 @@ #ifndef LLVM_BITCODE_H #define LLVM_BITCODE_H -#include <iosfwd> #include <string> namespace llvm { @@ -41,10 +40,6 @@ namespace llvm { Module *ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext& Context, std::string *ErrMsg = 0); - /// WriteBitcodeToFile - Write the specified module to the specified output - /// stream. - void WriteBitcodeToFile(const Module *M, std::ostream &Out); - /// WriteBitcodeToFile - Write the specified module to the specified /// raw output stream. void WriteBitcodeToFile(const Module *M, raw_ostream &Out); @@ -53,23 +48,48 @@ namespace llvm { /// raw output stream. void WriteBitcodeToStream(const Module *M, BitstreamWriter &Stream); - /// CreateBitcodeWriterPass - Create and return a pass that writes the module - /// to the specified ostream. - ModulePass *CreateBitcodeWriterPass(std::ostream &Str); - /// createBitcodeWriterPass - Create and return a pass that writes the module /// to the specified ostream. ModulePass *createBitcodeWriterPass(raw_ostream &Str); - /// isBitcodeWrapper - Return true fi this is a wrapper for LLVM IR bitcode - /// files. - static bool inline isBitcodeWrapper(unsigned char *BufPtr, - unsigned char *BufEnd) { - return (BufPtr != BufEnd && BufPtr[0] == 0xDE && BufPtr[1] == 0xC0 && - BufPtr[2] == 0x17 && BufPtr[3] == 0x0B); + /// isBitcodeWrapper - Return true if the given bytes are the magic bytes + /// for an LLVM IR bitcode wrapper. + /// + static inline bool isBitcodeWrapper(const unsigned char *BufPtr, + const unsigned char *BufEnd) { + // See if you can find the hidden message in the magic bytes :-). + // (Hint: it's a little-endian encoding.) + return BufPtr != BufEnd && + BufPtr[0] == 0xDE && + BufPtr[1] == 0xC0 && + BufPtr[2] == 0x17 && + BufPtr[3] == 0x0B; } - + + /// isRawBitcode - Return true if the given bytes are the magic bytes for + /// raw LLVM IR bitcode (without a wrapper). + /// + static inline bool isRawBitcode(const unsigned char *BufPtr, + const unsigned char *BufEnd) { + // These bytes sort of have a hidden message, but it's not in + // little-endian this time, and it's a little redundant. + return BufPtr != BufEnd && + BufPtr[0] == 'B' && + BufPtr[1] == 'C' && + BufPtr[2] == 0xc0 && + BufPtr[3] == 0xde; + } + + /// isBitcode - Return true if the given bytes are the magic bytes for + /// LLVM IR bitcode, either with or without a wrapper. + /// + static bool inline isBitcode(const unsigned char *BufPtr, + const unsigned char *BufEnd) { + return isBitcodeWrapper(BufPtr, BufEnd) || + isRawBitcode(BufPtr, BufEnd); + } + /// SkipBitcodeWrapperHeader - Some systems wrap bc files with a special /// header for padding or other reasons. The format of this header is: /// |