forked from OSchip/llvm-project
Kill ObjectCodeEmitter and BinaryObject, they were unused and superseded by MC.
llvm-svn: 147618
This commit is contained in:
parent
64af53c364
commit
69eab4e0af
|
@ -1,353 +0,0 @@
|
|||
//===-- llvm/CodeGen/BinaryObject.h - Binary Object. -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines a Binary Object Aka. "blob" for holding data from code
|
||||
// generators, ready for data to the object module code writters.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CODEGEN_BINARYOBJECT_H
|
||||
#define LLVM_CODEGEN_BINARYOBJECT_H
|
||||
|
||||
#include "llvm/CodeGen/MachineRelocation.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
typedef std::vector<uint8_t> BinaryData;
|
||||
|
||||
class BinaryObject {
|
||||
protected:
|
||||
std::string Name;
|
||||
bool IsLittleEndian;
|
||||
bool Is64Bit;
|
||||
BinaryData Data;
|
||||
std::vector<MachineRelocation> Relocations;
|
||||
|
||||
public:
|
||||
/// Constructors and destructor
|
||||
BinaryObject() {}
|
||||
|
||||
BinaryObject(bool isLittleEndian, bool is64Bit)
|
||||
: IsLittleEndian(isLittleEndian), Is64Bit(is64Bit) {}
|
||||
|
||||
BinaryObject(const std::string &name, bool isLittleEndian, bool is64Bit)
|
||||
: Name(name), IsLittleEndian(isLittleEndian), Is64Bit(is64Bit) {}
|
||||
|
||||
~BinaryObject() {}
|
||||
|
||||
/// getName - get name of BinaryObject
|
||||
inline std::string getName() const { return Name; }
|
||||
|
||||
/// get size of binary data
|
||||
size_t size() const {
|
||||
return Data.size();
|
||||
}
|
||||
|
||||
/// get binary data
|
||||
BinaryData& getData() {
|
||||
return Data;
|
||||
}
|
||||
|
||||
/// get machine relocations
|
||||
const std::vector<MachineRelocation>& getRelocations() const {
|
||||
return Relocations;
|
||||
}
|
||||
|
||||
/// hasRelocations - Return true if 'Relocations' is not empty
|
||||
bool hasRelocations() const {
|
||||
return !Relocations.empty();
|
||||
}
|
||||
|
||||
/// emitZeros - This callback is invoked to emit a arbitrary number
|
||||
/// of zero bytes to the data stream.
|
||||
inline void emitZeros(unsigned Size) {
|
||||
for (unsigned i=0; i < Size; ++i)
|
||||
emitByte(0);
|
||||
}
|
||||
|
||||
/// emitByte - This callback is invoked when a byte needs to be
|
||||
/// written to the data stream.
|
||||
inline void emitByte(uint8_t B) {
|
||||
Data.push_back(B);
|
||||
}
|
||||
|
||||
/// emitWord16 - This callback is invoked when a 16-bit word needs to be
|
||||
/// written to the data stream in correct endian format and correct size.
|
||||
inline void emitWord16(uint16_t W) {
|
||||
if (IsLittleEndian)
|
||||
emitWord16LE(W);
|
||||
else
|
||||
emitWord16BE(W);
|
||||
}
|
||||
|
||||
/// emitWord16LE - This callback is invoked when a 16-bit word needs to be
|
||||
/// written to the data stream in correct endian format and correct size.
|
||||
inline void emitWord16LE(uint16_t W) {
|
||||
Data.push_back((uint8_t)(W >> 0));
|
||||
Data.push_back((uint8_t)(W >> 8));
|
||||
}
|
||||
|
||||
/// emitWord16BE - This callback is invoked when a 16-bit word needs to be
|
||||
/// written to the data stream in correct endian format and correct size.
|
||||
inline void emitWord16BE(uint16_t W) {
|
||||
Data.push_back((uint8_t)(W >> 8));
|
||||
Data.push_back((uint8_t)(W >> 0));
|
||||
}
|
||||
|
||||
/// emitWord - This callback is invoked when a word needs to be
|
||||
/// written to the data stream in correct endian format and correct size.
|
||||
inline void emitWord(uint64_t W) {
|
||||
if (!Is64Bit)
|
||||
emitWord32(W);
|
||||
else
|
||||
emitWord64(W);
|
||||
}
|
||||
|
||||
/// emitWord32 - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in correct endian format.
|
||||
inline void emitWord32(uint32_t W) {
|
||||
if (IsLittleEndian)
|
||||
emitWordLE(W);
|
||||
else
|
||||
emitWordBE(W);
|
||||
}
|
||||
|
||||
/// emitWord64 - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in correct endian format.
|
||||
inline void emitWord64(uint64_t W) {
|
||||
if (IsLittleEndian)
|
||||
emitDWordLE(W);
|
||||
else
|
||||
emitDWordBE(W);
|
||||
}
|
||||
|
||||
/// emitWord64 - This callback is invoked when a x86_fp80 needs to be
|
||||
/// written to the data stream in correct endian format.
|
||||
inline void emitWordFP80(const uint64_t *W, unsigned PadSize) {
|
||||
if (IsLittleEndian) {
|
||||
emitWord64(W[0]);
|
||||
emitWord16(W[1]);
|
||||
} else {
|
||||
emitWord16(W[1]);
|
||||
emitWord64(W[0]);
|
||||
}
|
||||
emitZeros(PadSize);
|
||||
}
|
||||
|
||||
/// emitWordLE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in little-endian format.
|
||||
inline void emitWordLE(uint32_t W) {
|
||||
Data.push_back((uint8_t)(W >> 0));
|
||||
Data.push_back((uint8_t)(W >> 8));
|
||||
Data.push_back((uint8_t)(W >> 16));
|
||||
Data.push_back((uint8_t)(W >> 24));
|
||||
}
|
||||
|
||||
/// emitWordBE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in big-endian format.
|
||||
///
|
||||
inline void emitWordBE(uint32_t W) {
|
||||
Data.push_back((uint8_t)(W >> 24));
|
||||
Data.push_back((uint8_t)(W >> 16));
|
||||
Data.push_back((uint8_t)(W >> 8));
|
||||
Data.push_back((uint8_t)(W >> 0));
|
||||
}
|
||||
|
||||
/// emitDWordLE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the data stream in little-endian format.
|
||||
inline void emitDWordLE(uint64_t W) {
|
||||
Data.push_back((uint8_t)(W >> 0));
|
||||
Data.push_back((uint8_t)(W >> 8));
|
||||
Data.push_back((uint8_t)(W >> 16));
|
||||
Data.push_back((uint8_t)(W >> 24));
|
||||
Data.push_back((uint8_t)(W >> 32));
|
||||
Data.push_back((uint8_t)(W >> 40));
|
||||
Data.push_back((uint8_t)(W >> 48));
|
||||
Data.push_back((uint8_t)(W >> 56));
|
||||
}
|
||||
|
||||
/// emitDWordBE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the data stream in big-endian format.
|
||||
inline void emitDWordBE(uint64_t W) {
|
||||
Data.push_back((uint8_t)(W >> 56));
|
||||
Data.push_back((uint8_t)(W >> 48));
|
||||
Data.push_back((uint8_t)(W >> 40));
|
||||
Data.push_back((uint8_t)(W >> 32));
|
||||
Data.push_back((uint8_t)(W >> 24));
|
||||
Data.push_back((uint8_t)(W >> 16));
|
||||
Data.push_back((uint8_t)(W >> 8));
|
||||
Data.push_back((uint8_t)(W >> 0));
|
||||
}
|
||||
|
||||
/// fixByte - This callback is invoked when a byte needs to be
|
||||
/// fixup the buffer.
|
||||
inline void fixByte(uint8_t B, uint32_t offset) {
|
||||
Data[offset] = B;
|
||||
}
|
||||
|
||||
/// fixWord16 - This callback is invoked when a 16-bit word needs to
|
||||
/// fixup the data stream in correct endian format.
|
||||
inline void fixWord16(uint16_t W, uint32_t offset) {
|
||||
if (IsLittleEndian)
|
||||
fixWord16LE(W, offset);
|
||||
else
|
||||
fixWord16BE(W, offset);
|
||||
}
|
||||
|
||||
/// emitWord16LE - This callback is invoked when a 16-bit word needs to
|
||||
/// fixup the data stream in little endian format.
|
||||
inline void fixWord16LE(uint16_t W, uint32_t offset) {
|
||||
Data[offset] = (uint8_t)(W >> 0);
|
||||
Data[++offset] = (uint8_t)(W >> 8);
|
||||
}
|
||||
|
||||
/// fixWord16BE - This callback is invoked when a 16-bit word needs to
|
||||
/// fixup data stream in big endian format.
|
||||
inline void fixWord16BE(uint16_t W, uint32_t offset) {
|
||||
Data[offset] = (uint8_t)(W >> 8);
|
||||
Data[++offset] = (uint8_t)(W >> 0);
|
||||
}
|
||||
|
||||
/// emitWord - This callback is invoked when a word needs to
|
||||
/// fixup the data in correct endian format and correct size.
|
||||
inline void fixWord(uint64_t W, uint32_t offset) {
|
||||
if (!Is64Bit)
|
||||
fixWord32(W, offset);
|
||||
else
|
||||
fixWord64(W, offset);
|
||||
}
|
||||
|
||||
/// fixWord32 - This callback is invoked when a 32-bit word needs to
|
||||
/// fixup the data in correct endian format.
|
||||
inline void fixWord32(uint32_t W, uint32_t offset) {
|
||||
if (IsLittleEndian)
|
||||
fixWord32LE(W, offset);
|
||||
else
|
||||
fixWord32BE(W, offset);
|
||||
}
|
||||
|
||||
/// fixWord32LE - This callback is invoked when a 32-bit word needs to
|
||||
/// fixup the data in little endian format.
|
||||
inline void fixWord32LE(uint32_t W, uint32_t offset) {
|
||||
Data[offset] = (uint8_t)(W >> 0);
|
||||
Data[++offset] = (uint8_t)(W >> 8);
|
||||
Data[++offset] = (uint8_t)(W >> 16);
|
||||
Data[++offset] = (uint8_t)(W >> 24);
|
||||
}
|
||||
|
||||
/// fixWord32BE - This callback is invoked when a 32-bit word needs to
|
||||
/// fixup the data in big endian format.
|
||||
inline void fixWord32BE(uint32_t W, uint32_t offset) {
|
||||
Data[offset] = (uint8_t)(W >> 24);
|
||||
Data[++offset] = (uint8_t)(W >> 16);
|
||||
Data[++offset] = (uint8_t)(W >> 8);
|
||||
Data[++offset] = (uint8_t)(W >> 0);
|
||||
}
|
||||
|
||||
/// fixWord64 - This callback is invoked when a 64-bit word needs to
|
||||
/// fixup the data in correct endian format.
|
||||
inline void fixWord64(uint64_t W, uint32_t offset) {
|
||||
if (IsLittleEndian)
|
||||
fixWord64LE(W, offset);
|
||||
else
|
||||
fixWord64BE(W, offset);
|
||||
}
|
||||
|
||||
/// fixWord64BE - This callback is invoked when a 64-bit word needs to
|
||||
/// fixup the data in little endian format.
|
||||
inline void fixWord64LE(uint64_t W, uint32_t offset) {
|
||||
Data[offset] = (uint8_t)(W >> 0);
|
||||
Data[++offset] = (uint8_t)(W >> 8);
|
||||
Data[++offset] = (uint8_t)(W >> 16);
|
||||
Data[++offset] = (uint8_t)(W >> 24);
|
||||
Data[++offset] = (uint8_t)(W >> 32);
|
||||
Data[++offset] = (uint8_t)(W >> 40);
|
||||
Data[++offset] = (uint8_t)(W >> 48);
|
||||
Data[++offset] = (uint8_t)(W >> 56);
|
||||
}
|
||||
|
||||
/// fixWord64BE - This callback is invoked when a 64-bit word needs to
|
||||
/// fixup the data in big endian format.
|
||||
inline void fixWord64BE(uint64_t W, uint32_t offset) {
|
||||
Data[offset] = (uint8_t)(W >> 56);
|
||||
Data[++offset] = (uint8_t)(W >> 48);
|
||||
Data[++offset] = (uint8_t)(W >> 40);
|
||||
Data[++offset] = (uint8_t)(W >> 32);
|
||||
Data[++offset] = (uint8_t)(W >> 24);
|
||||
Data[++offset] = (uint8_t)(W >> 16);
|
||||
Data[++offset] = (uint8_t)(W >> 8);
|
||||
Data[++offset] = (uint8_t)(W >> 0);
|
||||
}
|
||||
|
||||
/// emitAlignment - Pad the data to the specified alignment.
|
||||
void emitAlignment(unsigned Alignment, uint8_t fill = 0) {
|
||||
if (Alignment <= 1) return;
|
||||
unsigned PadSize = -Data.size() & (Alignment-1);
|
||||
for (unsigned i = 0; i<PadSize; ++i)
|
||||
Data.push_back(fill);
|
||||
}
|
||||
|
||||
/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be
|
||||
/// written to the data stream.
|
||||
void emitULEB128Bytes(uint64_t Value) {
|
||||
do {
|
||||
uint8_t Byte = (uint8_t)(Value & 0x7f);
|
||||
Value >>= 7;
|
||||
if (Value) Byte |= 0x80;
|
||||
emitByte(Byte);
|
||||
} while (Value);
|
||||
}
|
||||
|
||||
/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be
|
||||
/// written to the data stream.
|
||||
void emitSLEB128Bytes(int64_t Value) {
|
||||
int Sign = Value >> (8 * sizeof(Value) - 1);
|
||||
bool IsMore;
|
||||
|
||||
do {
|
||||
uint8_t Byte = (uint8_t)(Value & 0x7f);
|
||||
Value >>= 7;
|
||||
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
|
||||
if (IsMore) Byte |= 0x80;
|
||||
emitByte(Byte);
|
||||
} while (IsMore);
|
||||
}
|
||||
|
||||
/// emitString - This callback is invoked when a String needs to be
|
||||
/// written to the data stream.
|
||||
void emitString(const std::string &String) {
|
||||
for (unsigned i = 0, N = static_cast<unsigned>(String.size()); i<N; ++i) {
|
||||
unsigned char C = String[i];
|
||||
emitByte(C);
|
||||
}
|
||||
emitByte(0);
|
||||
}
|
||||
|
||||
/// getCurrentPCOffset - Return the offset from the start of the emitted
|
||||
/// buffer that we are currently writing to.
|
||||
uintptr_t getCurrentPCOffset() const {
|
||||
return Data.size();
|
||||
}
|
||||
|
||||
/// addRelocation - Whenever a relocatable address is needed, it should be
|
||||
/// noted with this interface.
|
||||
void addRelocation(const MachineRelocation& relocation) {
|
||||
Relocations.push_back(relocation);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
|
@ -1,171 +0,0 @@
|
|||
//===-- llvm/CodeGen/ObjectCodeEmitter.h - Object Code Emitter -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Generalized Object Code Emitter, works with ObjectModule and BinaryObject.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CODEGEN_OBJECTCODEEMITTER_H
|
||||
#define LLVM_CODEGEN_OBJECTCODEEMITTER_H
|
||||
|
||||
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BinaryObject;
|
||||
class MachineBasicBlock;
|
||||
class MachineCodeEmitter;
|
||||
class MachineFunction;
|
||||
class MachineConstantPool;
|
||||
class MachineJumpTableInfo;
|
||||
class MachineModuleInfo;
|
||||
|
||||
class ObjectCodeEmitter : public MachineCodeEmitter {
|
||||
protected:
|
||||
|
||||
/// Binary Object (Section or Segment) we are emitting to.
|
||||
BinaryObject *BO;
|
||||
|
||||
/// MBBLocations - This vector is a mapping from MBB ID's to their address.
|
||||
/// It is filled in by the StartMachineBasicBlock callback and queried by
|
||||
/// the getMachineBasicBlockAddress callback.
|
||||
std::vector<uintptr_t> MBBLocations;
|
||||
|
||||
/// LabelLocations - This vector is a mapping from Label ID's to their
|
||||
/// address.
|
||||
std::vector<uintptr_t> LabelLocations;
|
||||
|
||||
/// CPLocations - This is a map of constant pool indices to offsets from the
|
||||
/// start of the section for that constant pool index.
|
||||
std::vector<uintptr_t> CPLocations;
|
||||
|
||||
/// CPSections - This is a map of constant pool indices to the Section
|
||||
/// containing the constant pool entry for that index.
|
||||
std::vector<uintptr_t> CPSections;
|
||||
|
||||
/// JTLocations - This is a map of jump table indices to offsets from the
|
||||
/// start of the section for that jump table index.
|
||||
std::vector<uintptr_t> JTLocations;
|
||||
|
||||
public:
|
||||
ObjectCodeEmitter();
|
||||
ObjectCodeEmitter(BinaryObject *bo);
|
||||
virtual ~ObjectCodeEmitter();
|
||||
|
||||
/// setBinaryObject - set the BinaryObject we are writting to
|
||||
void setBinaryObject(BinaryObject *bo);
|
||||
|
||||
/// emitByte - This callback is invoked when a byte needs to be
|
||||
/// written to the data stream, without buffer overflow testing.
|
||||
void emitByte(uint8_t B);
|
||||
|
||||
/// emitWordLE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in little-endian format.
|
||||
void emitWordLE(uint32_t W);
|
||||
|
||||
/// emitWordBE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in big-endian format.
|
||||
void emitWordBE(uint32_t W);
|
||||
|
||||
/// emitDWordLE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the data stream in little-endian format.
|
||||
void emitDWordLE(uint64_t W);
|
||||
|
||||
/// emitDWordBE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the data stream in big-endian format.
|
||||
void emitDWordBE(uint64_t W);
|
||||
|
||||
/// emitAlignment - Move the CurBufferPtr pointer up to the specified
|
||||
/// alignment (saturated to BufferEnd of course).
|
||||
void emitAlignment(unsigned Alignment = 0, uint8_t fill = 0);
|
||||
|
||||
/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be
|
||||
/// written to the data stream.
|
||||
void emitULEB128Bytes(uint64_t Value);
|
||||
|
||||
/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be
|
||||
/// written to the data stream.
|
||||
void emitSLEB128Bytes(uint64_t Value);
|
||||
|
||||
/// emitString - This callback is invoked when a String needs to be
|
||||
/// written to the data stream.
|
||||
void emitString(const std::string &String);
|
||||
|
||||
/// getCurrentPCValue - This returns the address that the next emitted byte
|
||||
/// will be output to.
|
||||
uintptr_t getCurrentPCValue() const;
|
||||
|
||||
/// getCurrentPCOffset - Return the offset from the start of the emitted
|
||||
/// buffer that we are currently writing to.
|
||||
uintptr_t getCurrentPCOffset() const;
|
||||
|
||||
/// addRelocation - Whenever a relocatable address is needed, it should be
|
||||
/// noted with this interface.
|
||||
void addRelocation(const MachineRelocation& relocation);
|
||||
|
||||
/// earlyResolveAddresses - True if the code emitter can use symbol addresses
|
||||
/// during code emission time. The JIT is capable of doing this because it
|
||||
/// creates jump tables or constant pools in memory on the fly while the
|
||||
/// object code emitters rely on a linker to have real addresses and should
|
||||
/// use relocations instead.
|
||||
bool earlyResolveAddresses() const { return false; }
|
||||
|
||||
/// startFunction - This callback is invoked when the specified function is
|
||||
/// about to be code generated. This initializes the BufferBegin/End/Ptr
|
||||
/// fields.
|
||||
virtual void startFunction(MachineFunction &F) = 0;
|
||||
|
||||
/// finishFunction - This callback is invoked when the specified function has
|
||||
/// finished code generation. If a buffer overflow has occurred, this method
|
||||
/// returns true (the callee is required to try again), otherwise it returns
|
||||
/// false.
|
||||
virtual bool finishFunction(MachineFunction &F) = 0;
|
||||
|
||||
/// StartMachineBasicBlock - This should be called by the target when a new
|
||||
/// basic block is about to be emitted. This way the MCE knows where the
|
||||
/// start of the block is, and can implement getMachineBasicBlockAddress.
|
||||
virtual void StartMachineBasicBlock(MachineBasicBlock *MBB);
|
||||
|
||||
/// getMachineBasicBlockAddress - Return the address of the specified
|
||||
/// MachineBasicBlock, only usable after the label for the MBB has been
|
||||
/// emitted.
|
||||
virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const;
|
||||
|
||||
/// emitJumpTables - Emit all the jump tables for a given jump table info
|
||||
/// record to the appropriate section.
|
||||
virtual void emitJumpTables(MachineJumpTableInfo *MJTI) = 0;
|
||||
|
||||
/// getJumpTableEntryAddress - Return the address of the jump table with index
|
||||
/// 'Index' in the function that last called initJumpTableInfo.
|
||||
virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const;
|
||||
|
||||
/// emitConstantPool - For each constant pool entry, figure out which section
|
||||
/// the constant should live in, allocate space for it, and emit it to the
|
||||
/// Section data buffer.
|
||||
virtual void emitConstantPool(MachineConstantPool *MCP) = 0;
|
||||
|
||||
/// getConstantPoolEntryAddress - Return the address of the 'Index' entry in
|
||||
/// the constant pool that was last emitted with the emitConstantPool method.
|
||||
virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const;
|
||||
|
||||
/// getConstantPoolEntrySection - Return the section of the 'Index' entry in
|
||||
/// the constant pool that was last emitted with the emitConstantPool method.
|
||||
virtual uintptr_t getConstantPoolEntrySection(unsigned Index) const;
|
||||
|
||||
/// Specifies the MachineModuleInfo object. This is used for exception handling
|
||||
/// purposes.
|
||||
virtual void setModuleInfo(MachineModuleInfo* Info) = 0;
|
||||
// to be implemented or depreciated with MachineModuleInfo
|
||||
|
||||
}; // end class ObjectCodeEmitter
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
|
@ -58,7 +58,6 @@ add_llvm_library(LLVMCodeGen
|
|||
MachineSSAUpdater.cpp
|
||||
MachineSink.cpp
|
||||
MachineVerifier.cpp
|
||||
ObjectCodeEmitter.cpp
|
||||
OcamlGC.cpp
|
||||
OptimizePHIs.cpp
|
||||
PHIElimination.cpp
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
//===-- llvm/CodeGen/ObjectCodeEmitter.cpp -------------------- -*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/CodeGen/BinaryObject.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineRelocation.h"
|
||||
#include "llvm/CodeGen/ObjectCodeEmitter.h"
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ObjectCodeEmitter Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace llvm {
|
||||
|
||||
ObjectCodeEmitter::ObjectCodeEmitter() : BO(0) {}
|
||||
ObjectCodeEmitter::ObjectCodeEmitter(BinaryObject *bo) : BO(bo) {}
|
||||
ObjectCodeEmitter::~ObjectCodeEmitter() {}
|
||||
|
||||
/// setBinaryObject - set the BinaryObject we are writting to
|
||||
void ObjectCodeEmitter::setBinaryObject(BinaryObject *bo) { BO = bo; }
|
||||
|
||||
/// emitByte - This callback is invoked when a byte needs to be
|
||||
/// written to the data stream, without buffer overflow testing.
|
||||
void ObjectCodeEmitter::emitByte(uint8_t B) {
|
||||
BO->emitByte(B);
|
||||
}
|
||||
|
||||
/// emitWordLE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in little-endian format.
|
||||
void ObjectCodeEmitter::emitWordLE(uint32_t W) {
|
||||
BO->emitWordLE(W);
|
||||
}
|
||||
|
||||
/// emitWordBE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the data stream in big-endian format.
|
||||
void ObjectCodeEmitter::emitWordBE(uint32_t W) {
|
||||
BO->emitWordBE(W);
|
||||
}
|
||||
|
||||
/// emitDWordLE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the data stream in little-endian format.
|
||||
void ObjectCodeEmitter::emitDWordLE(uint64_t W) {
|
||||
BO->emitDWordLE(W);
|
||||
}
|
||||
|
||||
/// emitDWordBE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the data stream in big-endian format.
|
||||
void ObjectCodeEmitter::emitDWordBE(uint64_t W) {
|
||||
BO->emitDWordBE(W);
|
||||
}
|
||||
|
||||
/// emitAlignment - Align 'BO' to the necessary alignment boundary.
|
||||
void ObjectCodeEmitter::emitAlignment(unsigned Alignment /* 0 */,
|
||||
uint8_t fill /* 0 */) {
|
||||
BO->emitAlignment(Alignment, fill);
|
||||
}
|
||||
|
||||
/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be
|
||||
/// written to the data stream.
|
||||
void ObjectCodeEmitter::emitULEB128Bytes(uint64_t Value) {
|
||||
BO->emitULEB128Bytes(Value);
|
||||
}
|
||||
|
||||
/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be
|
||||
/// written to the data stream.
|
||||
void ObjectCodeEmitter::emitSLEB128Bytes(uint64_t Value) {
|
||||
BO->emitSLEB128Bytes(Value);
|
||||
}
|
||||
|
||||
/// emitString - This callback is invoked when a String needs to be
|
||||
/// written to the data stream.
|
||||
void ObjectCodeEmitter::emitString(const std::string &String) {
|
||||
BO->emitString(String);
|
||||
}
|
||||
|
||||
/// getCurrentPCValue - This returns the address that the next emitted byte
|
||||
/// will be output to.
|
||||
uintptr_t ObjectCodeEmitter::getCurrentPCValue() const {
|
||||
return BO->getCurrentPCOffset();
|
||||
}
|
||||
|
||||
/// getCurrentPCOffset - Return the offset from the start of the emitted
|
||||
/// buffer that we are currently writing to.
|
||||
uintptr_t ObjectCodeEmitter::getCurrentPCOffset() const {
|
||||
return BO->getCurrentPCOffset();
|
||||
}
|
||||
|
||||
/// addRelocation - Whenever a relocatable address is needed, it should be
|
||||
/// noted with this interface.
|
||||
void ObjectCodeEmitter::addRelocation(const MachineRelocation& relocation) {
|
||||
BO->addRelocation(relocation);
|
||||
}
|
||||
|
||||
/// StartMachineBasicBlock - This should be called by the target when a new
|
||||
/// basic block is about to be emitted. This way the MCE knows where the
|
||||
/// start of the block is, and can implement getMachineBasicBlockAddress.
|
||||
void ObjectCodeEmitter::StartMachineBasicBlock(MachineBasicBlock *MBB) {
|
||||
if (MBBLocations.size() <= (unsigned)MBB->getNumber())
|
||||
MBBLocations.resize((MBB->getNumber()+1)*2);
|
||||
MBBLocations[MBB->getNumber()] = getCurrentPCOffset();
|
||||
}
|
||||
|
||||
/// getMachineBasicBlockAddress - Return the address of the specified
|
||||
/// MachineBasicBlock, only usable after the label for the MBB has been
|
||||
/// emitted.
|
||||
uintptr_t
|
||||
ObjectCodeEmitter::getMachineBasicBlockAddress(MachineBasicBlock *MBB) const {
|
||||
assert(MBBLocations.size() > (unsigned)MBB->getNumber() &&
|
||||
MBBLocations[MBB->getNumber()] && "MBB not emitted!");
|
||||
return MBBLocations[MBB->getNumber()];
|
||||
}
|
||||
|
||||
/// getJumpTableEntryAddress - Return the address of the jump table with index
|
||||
/// 'Index' in the function that last called initJumpTableInfo.
|
||||
uintptr_t ObjectCodeEmitter::getJumpTableEntryAddress(unsigned Index) const {
|
||||
assert(JTLocations.size() > Index && "JT not emitted!");
|
||||
return JTLocations[Index];
|
||||
}
|
||||
|
||||
/// getConstantPoolEntryAddress - Return the address of the 'Index' entry in
|
||||
/// the constant pool that was last emitted with the emitConstantPool method.
|
||||
uintptr_t ObjectCodeEmitter::getConstantPoolEntryAddress(unsigned Index) const {
|
||||
assert(CPLocations.size() > Index && "CP not emitted!");
|
||||
return CPLocations[Index];
|
||||
}
|
||||
|
||||
/// getConstantPoolEntrySection - Return the section of the 'Index' entry in
|
||||
/// the constant pool that was last emitted with the emitConstantPool method.
|
||||
uintptr_t ObjectCodeEmitter::getConstantPoolEntrySection(unsigned Index) const {
|
||||
assert(CPSections.size() > Index && "CP not emitted!");
|
||||
return CPSections[Index];
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
Loading…
Reference in New Issue