mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 23:24:34 +00:00
Add const qualifiers for isBitcodeWrapper, and add new functions
isRawBitcode and isBitcode to allow clients to test whether a given memory buffer holds a bitcode image. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80804 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -53,12 +53,41 @@ namespace llvm {
|
|||||||
ModulePass *createBitcodeWriterPass(raw_ostream &Str);
|
ModulePass *createBitcodeWriterPass(raw_ostream &Str);
|
||||||
|
|
||||||
|
|
||||||
/// isBitcodeWrapper - Return true fi this is a wrapper for LLVM IR bitcode
|
/// isBitcodeWrapper - Return true if the given bytes are the magic bytes
|
||||||
/// files.
|
/// for an LLVM IR bitcode wrapper.
|
||||||
static bool inline isBitcodeWrapper(unsigned char *BufPtr,
|
///
|
||||||
unsigned char *BufEnd) {
|
static inline bool isBitcodeWrapper(const unsigned char *BufPtr,
|
||||||
return (BufPtr != BufEnd && BufPtr[0] == 0xDE && BufPtr[1] == 0xC0 &&
|
const unsigned char *BufEnd) {
|
||||||
BufPtr[2] == 0x17 && BufPtr[3] == 0x0B);
|
// 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
|
/// SkipBitcodeWrapperHeader - Some systems wrap bc files with a special
|
||||||
|
Reference in New Issue
Block a user