diff options
| author | Ed Schouten <ed@FreeBSD.org> | 2009-06-08 15:36:37 +0000 |
|---|---|---|
| committer | Ed Schouten <ed@FreeBSD.org> | 2009-06-08 15:36:37 +0000 |
| commit | 93338c197185f946619794ce011ec27b5b6250e2 (patch) | |
| tree | 674737fb36b447a4141b2fbaf40d3465434fdfad /lib/CodeGen/ELFCodeEmitter.h | |
| parent | d2a7037439ec5d4f4d2b7a813a3f1a83e10756b1 (diff) | |
Notes
Diffstat (limited to 'lib/CodeGen/ELFCodeEmitter.h')
| -rw-r--r-- | lib/CodeGen/ELFCodeEmitter.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/CodeGen/ELFCodeEmitter.h b/lib/CodeGen/ELFCodeEmitter.h index e9ee936a48655..c0289daf3e93b 100644 --- a/lib/CodeGen/ELFCodeEmitter.h +++ b/lib/CodeGen/ELFCodeEmitter.h @@ -20,8 +20,24 @@ namespace llvm { /// emit the code for functions to the ELF file. class ELFCodeEmitter : public MachineCodeEmitter { ELFWriter &EW; + + /// Target machine description TargetMachine &TM; - ELFSection *ES; // Section to write to. + + /// Section containing code for functions + ELFSection *ES; + + /// Relocations - These are the relocations that the function needs, as + /// emitted. + std::vector<MachineRelocation> Relocations; + + /// 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; + + /// FnStartPtr - Pointer to the start location of the current function + /// in the buffer uint8_t *FnStartPtr; public: explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM) {} @@ -30,10 +46,19 @@ namespace llvm { bool finishFunction(MachineFunction &F); void addRelocation(const MachineRelocation &MR) { - assert(0 && "relo not handled yet!"); + Relocations.push_back(MR); } virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) + MBBLocations.resize((MBB->getNumber()+1)*2); + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); + } + + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) { + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); + return MBBLocations[MBB->getNumber()]; } virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const { |
