LLVM API Documentation
#include <ObjectCodeEmitter.h>
Public Member Functions | |
| ObjectCodeEmitter () | |
| ObjectCodeEmitter (BinaryObject *bo) | |
| virtual | ~ObjectCodeEmitter () |
| void | setBinaryObject (BinaryObject *bo) |
| setBinaryObject - set the BinaryObject we are writting to | |
| void | emitByte (uint8_t B) |
| void | emitWordLE (uint32_t W) |
| void | emitWordBE (uint32_t W) |
| void | emitDWordLE (uint64_t W) |
| void | emitDWordBE (uint64_t W) |
| void | emitAlignment (unsigned Alignment=0, uint8_t fill=0) |
| emitAlignment - Align 'BO' to the necessary alignment boundary. | |
| void | emitULEB128Bytes (uint64_t Value) |
| void | emitSLEB128Bytes (uint64_t Value) |
| void | emitString (const std::string &String) |
| uintptr_t | getCurrentPCValue () const |
| uintptr_t | getCurrentPCOffset () const |
| void | addRelocation (const MachineRelocation &relocation) |
| bool | earlyResolveAddresses () const |
| virtual void | startFunction (MachineFunction &F)=0 |
| virtual bool | finishFunction (MachineFunction &F)=0 |
| virtual void | StartMachineBasicBlock (MachineBasicBlock *MBB) |
| virtual uintptr_t | getMachineBasicBlockAddress (MachineBasicBlock *MBB) const |
| virtual void | emitLabel (uint64_t LabelID)=0 |
| emitLabel - Emits a label | |
| virtual uintptr_t | getLabelAddress (uint64_t LabelID) const =0 |
| virtual void | emitJumpTables (MachineJumpTableInfo *MJTI)=0 |
| virtual uintptr_t | getJumpTableEntryAddress (unsigned Index) const |
| virtual void | emitConstantPool (MachineConstantPool *MCP)=0 |
| virtual uintptr_t | getConstantPoolEntryAddress (unsigned Index) const |
| virtual uintptr_t | getConstantPoolEntrySection (unsigned Index) const |
| virtual void | setModuleInfo (MachineModuleInfo *Info)=0 |
Protected Attributes | |
| BinaryObject * | BO |
| Binary Object (Section or Segment) we are emitting to. | |
| std::vector< uintptr_t > | MBBLocations |
| std::vector< uintptr_t > | LabelLocations |
| std::vector< uintptr_t > | CPLocations |
| std::vector< uintptr_t > | CPSections |
| std::vector< uintptr_t > | JTLocations |
Definition at line 29 of file ObjectCodeEmitter.h.
| llvm::ObjectCodeEmitter::ObjectCodeEmitter | ( | ) |
Definition at line 21 of file ObjectCodeEmitter.cpp.
| llvm::ObjectCodeEmitter::ObjectCodeEmitter | ( | BinaryObject * | bo | ) |
Definition at line 22 of file ObjectCodeEmitter.cpp.
| llvm::ObjectCodeEmitter::~ObjectCodeEmitter | ( | ) | [virtual] |
Definition at line 23 of file ObjectCodeEmitter.cpp.
| void llvm::ObjectCodeEmitter::setBinaryObject | ( | BinaryObject * | bo | ) |
setBinaryObject - set the BinaryObject we are writting to
Definition at line 26 of file ObjectCodeEmitter.cpp.
References BO.
Referenced by llvm::ELFCodeEmitter::startFunction().
| void llvm::ObjectCodeEmitter::emitByte | ( | uint8_t | B | ) |
emitByte - This callback is invoked when a byte needs to be written to the data stream, without buffer overflow testing.
emitByte - This callback is invoked when a byte needs to be written to the data stream, without buffer overflow testing.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 30 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitByte().
| void llvm::ObjectCodeEmitter::emitWordLE | ( | uint32_t | W | ) |
emitWordLE - This callback is invoked when a 32-bit word needs to be written to the data stream in little-endian format.
emitWordLE - This callback is invoked when a 32-bit word needs to be written to the data stream in little-endian format.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 36 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitWordLE().
| void llvm::ObjectCodeEmitter::emitWordBE | ( | 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.
emitWordBE - This callback is invoked when a 32-bit word needs to be written to the data stream in big-endian format.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 42 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitWordBE().
| void llvm::ObjectCodeEmitter::emitDWordLE | ( | uint64_t | W | ) |
emitDWordLE - This callback is invoked when a 64-bit word needs to be written to the data stream in little-endian format.
emitDWordLE - This callback is invoked when a 64-bit word needs to be written to the data stream in little-endian format.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 48 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitDWordLE().
| void llvm::ObjectCodeEmitter::emitDWordBE | ( | 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.
emitDWordBE - This callback is invoked when a 64-bit word needs to be written to the data stream in big-endian format.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 54 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitDWordBE().
| void llvm::ObjectCodeEmitter::emitAlignment | ( | unsigned | Alignment = 0, |
|
| uint8_t | fill = 0 | |||
| ) |
emitAlignment - Align 'BO' to the necessary alignment boundary.
emitAlignment - Move the CurBufferPtr pointer up the the specified alignment (saturated to BufferEnd of course).
Definition at line 59 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitAlignment().
| void llvm::ObjectCodeEmitter::emitULEB128Bytes | ( | uint64_t | Value | ) |
emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be written to the data stream.
emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be written to the data stream.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 66 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitULEB128Bytes().
| void llvm::ObjectCodeEmitter::emitSLEB128Bytes | ( | uint64_t | Value | ) |
emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be written to the data stream.
emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be written to the data stream.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 72 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitSLEB128Bytes().
| void llvm::ObjectCodeEmitter::emitString | ( | const std::string & | String | ) |
emitString - This callback is invoked when a String needs to be written to the data stream.
emitString - This callback is invoked when a String needs to be written to the data stream.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 78 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::emitString().
| uintptr_t llvm::ObjectCodeEmitter::getCurrentPCValue | ( | ) | const [virtual] |
getCurrentPCValue - This returns the address that the next emitted byte will be output to.
getCurrentPCValue - This returns the address that the next emitted byte will be output to.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 84 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::getCurrentPCOffset().
| uintptr_t llvm::ObjectCodeEmitter::getCurrentPCOffset | ( | ) | const [virtual] |
getCurrentPCOffset - Return the offset from the start of the emitted buffer that we are currently writing to.
getCurrentPCOffset - Return the offset from the start of the emitted buffer that we are currently writing to.
Reimplemented from llvm::MachineCodeEmitter.
Definition at line 90 of file ObjectCodeEmitter.cpp.
References BO, and llvm::BinaryObject::getCurrentPCOffset().
Referenced by llvm::MachOCodeEmitter::emitLabel(), llvm::MachOCodeEmitter::startFunction(), and StartMachineBasicBlock().
| void llvm::ObjectCodeEmitter::addRelocation | ( | const MachineRelocation & | relocation | ) | [virtual] |
addRelocation - Whenever a relocatable address is needed, it should be noted with this interface.
addRelocation - Whenever a relocatable address is needed, it should be noted with this interface.
Implements llvm::MachineCodeEmitter.
Reimplemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
Definition at line 96 of file ObjectCodeEmitter.cpp.
References llvm::BinaryObject::addRelocation(), and BO.
| bool llvm::ObjectCodeEmitter::earlyResolveAddresses | ( | ) | const [inline, virtual] |
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.
Implements llvm::MachineCodeEmitter.
Definition at line 117 of file ObjectCodeEmitter.h.
| virtual void llvm::ObjectCodeEmitter::startFunction | ( | MachineFunction & | F | ) | [pure virtual] |
startFunction - This callback is invoked when the specified function is about to be code generated. This initializes the BufferBegin/End/Ptr fields.
Implements llvm::MachineCodeEmitter.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
| virtual bool llvm::ObjectCodeEmitter::finishFunction | ( | MachineFunction & | F | ) | [pure virtual] |
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.
Implements llvm::MachineCodeEmitter.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
| void llvm::ObjectCodeEmitter::StartMachineBasicBlock | ( | MachineBasicBlock * | MBB | ) | [virtual] |
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.
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.
Implements llvm::MachineCodeEmitter.
Definition at line 103 of file ObjectCodeEmitter.cpp.
References getCurrentPCOffset(), llvm::MachineBasicBlock::getNumber(), and MBBLocations.
| uintptr_t llvm::ObjectCodeEmitter::getMachineBasicBlockAddress | ( | MachineBasicBlock * | MBB | ) | const [virtual] |
getMachineBasicBlockAddress - Return the address of the specified MachineBasicBlock, only usable after the label for the MBB has been emitted.
getMachineBasicBlockAddress - Return the address of the specified MachineBasicBlock, only usable after the label for the MBB has been emitted.
Implements llvm::MachineCodeEmitter.
Definition at line 113 of file ObjectCodeEmitter.cpp.
References llvm::MachineBasicBlock::getNumber(), and MBBLocations.
Referenced by llvm::ELFCodeEmitter::finishFunction(), and llvm::MachOCodeEmitter::finishFunction().
| virtual void llvm::ObjectCodeEmitter::emitLabel | ( | uint64_t | LabelID | ) | [pure virtual] |
emitLabel - Emits a label
Implements llvm::MachineCodeEmitter.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
| virtual uintptr_t llvm::ObjectCodeEmitter::getLabelAddress | ( | uint64_t | LabelID | ) | const [pure virtual] |
getLabelAddress - Return the address of the specified LabelID, only usable after the LabelID has been emitted.
Implements llvm::MachineCodeEmitter.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
| virtual void llvm::ObjectCodeEmitter::emitJumpTables | ( | MachineJumpTableInfo * | MJTI | ) | [pure virtual] |
emitJumpTables - Emit all the jump tables for a given jump table info record to the appropriate section.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
| uintptr_t llvm::ObjectCodeEmitter::getJumpTableEntryAddress | ( | unsigned | Index | ) | const [virtual] |
getJumpTableEntryAddress - Return the address of the jump table with index 'Index' in the function that last called initJumpTableInfo.
getJumpTableEntryAddress - Return the address of the jump table with index 'Index' in the function that last called initJumpTableInfo.
Implements llvm::MachineCodeEmitter.
Definition at line 121 of file ObjectCodeEmitter.cpp.
References JTLocations.
Referenced by llvm::ELFCodeEmitter::finishFunction(), and llvm::MachOCodeEmitter::finishFunction().
| virtual void llvm::ObjectCodeEmitter::emitConstantPool | ( | MachineConstantPool * | MCP | ) | [pure virtual] |
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.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
| uintptr_t llvm::ObjectCodeEmitter::getConstantPoolEntryAddress | ( | unsigned | Index | ) | const [virtual] |
getConstantPoolEntryAddress - Return the address of the 'Index' entry in the constant pool that was last emitted with the emitConstantPool method.
getConstantPoolEntryAddress - Return the address of the 'Index' entry in the constant pool that was last emitted with the emitConstantPool method.
Implements llvm::MachineCodeEmitter.
Definition at line 128 of file ObjectCodeEmitter.cpp.
References CPLocations.
Referenced by llvm::ELFCodeEmitter::finishFunction(), and llvm::MachOCodeEmitter::finishFunction().
| uintptr_t llvm::ObjectCodeEmitter::getConstantPoolEntrySection | ( | unsigned | Index | ) | const [virtual] |
getConstantPoolEntrySection - Return the section of the 'Index' entry in the constant pool that was last emitted with the emitConstantPool method.
getConstantPoolEntrySection - Return the section of the 'Index' entry in the constant pool that was last emitted with the emitConstantPool method.
Definition at line 135 of file ObjectCodeEmitter.cpp.
References CPSections.
| virtual void llvm::ObjectCodeEmitter::setModuleInfo | ( | MachineModuleInfo * | Info | ) | [pure virtual] |
Specifies the MachineModuleInfo object. This is used for exception handling purposes.
Implements llvm::MachineCodeEmitter.
Implemented in llvm::ELFCodeEmitter, and llvm::MachOCodeEmitter.
BinaryObject* llvm::ObjectCodeEmitter::BO [protected] |
Binary Object (Section or Segment) we are emitting to.
Definition at line 33 of file ObjectCodeEmitter.h.
Referenced by addRelocation(), emitAlignment(), emitByte(), emitDWordBE(), emitDWordLE(), emitSLEB128Bytes(), emitString(), emitULEB128Bytes(), emitWordBE(), emitWordLE(), getCurrentPCOffset(), getCurrentPCValue(), and setBinaryObject().
std::vector<uintptr_t> llvm::ObjectCodeEmitter::MBBLocations [protected] |
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.
Definition at line 38 of file ObjectCodeEmitter.h.
Referenced by llvm::ELFCodeEmitter::finishFunction(), llvm::MachOCodeEmitter::finishFunction(), getMachineBasicBlockAddress(), and StartMachineBasicBlock().
std::vector<uintptr_t> llvm::ObjectCodeEmitter::LabelLocations [protected] |
LabelLocations - This vector is a mapping from Label ID's to their address.
Definition at line 42 of file ObjectCodeEmitter.h.
std::vector<uintptr_t> llvm::ObjectCodeEmitter::CPLocations [protected] |
CPLocations - This is a map of constant pool indices to offsets from the start of the section for that constant pool index.
Definition at line 46 of file ObjectCodeEmitter.h.
Referenced by llvm::MachOCodeEmitter::emitConstantPool(), llvm::ELFCodeEmitter::emitConstantPool(), llvm::ELFCodeEmitter::finishFunction(), llvm::MachOCodeEmitter::finishFunction(), and getConstantPoolEntryAddress().
std::vector<uintptr_t> llvm::ObjectCodeEmitter::CPSections [protected] |
CPSections - This is a map of constant pool indices to the Section containing the constant pool entry for that index.
Definition at line 50 of file ObjectCodeEmitter.h.
Referenced by llvm::MachOCodeEmitter::emitConstantPool(), llvm::ELFCodeEmitter::emitConstantPool(), llvm::ELFCodeEmitter::finishFunction(), llvm::MachOCodeEmitter::finishFunction(), and getConstantPoolEntrySection().
std::vector<uintptr_t> llvm::ObjectCodeEmitter::JTLocations [protected] |
JTLocations - This is a map of jump table indices to offsets from the start of the section for that jump table index.
Definition at line 54 of file ObjectCodeEmitter.h.
Referenced by llvm::ELFCodeEmitter::emitJumpTables(), llvm::MachOCodeEmitter::emitJumpTables(), llvm::ELFCodeEmitter::finishFunction(), llvm::MachOCodeEmitter::finishFunction(), and getJumpTableEntryAddress().