diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-03 00:32:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-03 00:32:55 +0000 |
commit | af1563fb62ed76f4818ac172ab1c6cf15fa35a82 (patch) | |
tree | f93013e5cf1e94a354496c46e17b28dc31b8900b /lib | |
parent | 23118b649e15774024e4d81566a16454a91c8e9a (diff) | |
download | external_llvm-af1563fb62ed76f4818ac172ab1c6cf15fa35a82.zip external_llvm-af1563fb62ed76f4818ac172ab1c6cf15fa35a82.tar.gz external_llvm-af1563fb62ed76f4818ac172ab1c6cf15fa35a82.tar.bz2 |
Change the BasicBlockAddrs map to be a vector, indexed by MBB number.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28069 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/ELFWriter.cpp | 2 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 6 | ||||
-rw-r--r-- | lib/Target/PowerPC/PPCCodeEmitter.cpp | 16 | ||||
-rw-r--r-- | lib/Target/X86/X86CodeEmitter.cpp | 15 |
4 files changed, 21 insertions, 18 deletions
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 69302a3..780ba54 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -71,7 +71,7 @@ namespace llvm { } virtual void emitJumpTableInfo(MachineJumpTableInfo *MJTI, - std::map<MachineBasicBlock*,uint64_t> &MBBM){ + std::vector<uint64_t> &MBBM) { assert(0 && "JT not implementated yet!"); } diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index d20c7a2..9a86377 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -392,7 +392,7 @@ public: void emitConstantPool(MachineConstantPool *MCP); void initJumpTableInfo(MachineJumpTableInfo *MJTI); virtual void emitJumpTableInfo(MachineJumpTableInfo *MJTI, - std::map<MachineBasicBlock*,uint64_t> &MBBM); + std::vector<uint64_t> &MBBM); virtual void startFunctionStub(unsigned StubSize); virtual void* finishFunctionStub(const Function *F); @@ -560,7 +560,7 @@ void JITEmitter::initJumpTableInfo(MachineJumpTableInfo *MJTI) { } void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI, - std::map<MachineBasicBlock*,uint64_t> &MBBM){ + std::vector<uint64_t> &MBBM) { const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables(); if (JT.empty() || JumpTableBase == 0) return; @@ -576,7 +576,7 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI, // Store the address of the basic block for this jump table slot in the // memory we allocated for the jump table in 'initJumpTableInfo' for (unsigned mi = 0, me = MBBs.size(); mi != me; ++mi) - *SlotPtr++ = (intptr_t)MBBM[MBBs[mi]]; + *SlotPtr++ = (intptr_t)MBBM[MBBs[mi]->getNumber()]; } } diff --git a/lib/Target/PowerPC/PPCCodeEmitter.cpp b/lib/Target/PowerPC/PPCCodeEmitter.cpp index a01ae99..69bd830 100644 --- a/lib/Target/PowerPC/PPCCodeEmitter.cpp +++ b/lib/Target/PowerPC/PPCCodeEmitter.cpp @@ -33,8 +33,8 @@ namespace { // Tracks which instruction references which BasicBlock std::vector<std::pair<MachineBasicBlock*, unsigned*> > BBRefs; - // Tracks where each BasicBlock starts - std::map<MachineBasicBlock*, uint64_t> BBLocations; + // Tracks where each BasicBlock starts, indexes by BB number. + std::vector<uint64_t> BasicBlockAddrs; /// getMachineOpValue - evaluates the MachineOperand of a given MachineInstr /// @@ -87,17 +87,17 @@ bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) { "JIT relocation model must be set to static or default!"); do { BBRefs.clear(); - BBLocations.clear(); + BasicBlockAddrs.clear(); MCE.startFunction(MF); for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB) emitBasicBlock(*BB); - MCE.emitJumpTableInfo(MF.getJumpTableInfo(), BBLocations); + MCE.emitJumpTableInfo(MF.getJumpTableInfo(), BasicBlockAddrs); } while (MCE.finishFunction(MF)); // Resolve branches to BasicBlocks for the entire function for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) { - intptr_t Location = BBLocations[BBRefs[i].first]; + intptr_t Location = BasicBlockAddrs[BBRefs[i].first->getNumber()]; unsigned *Ref = BBRefs[i].second; DEBUG(std::cerr << "Fixup @ " << (void*)Ref << " to " << (void*)Location << "\n"); @@ -115,13 +115,15 @@ bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) { } } BBRefs.clear(); - BBLocations.clear(); + BasicBlockAddrs.clear(); return false; } void PPCCodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) { - BBLocations[&MBB] = MCE.getCurrentPCValue(); + if (BasicBlockAddrs.size() <= (unsigned)MBB.getNumber()) + BasicBlockAddrs.resize((MBB.getNumber()+1)*2); + BasicBlockAddrs[MBB.getNumber()] = MCE.getCurrentPCValue(); for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I){ MachineInstr &MI = *I; unsigned Opcode = MI.getOpcode(); diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index 20e17d0..ca6c78d 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -35,7 +35,7 @@ namespace { class Emitter : public MachineFunctionPass { const X86InstrInfo *II; MachineCodeEmitter &MCE; - std::map<MachineBasicBlock*, uint64_t> BasicBlockAddrs; + std::vector<uint64_t> BasicBlockAddrs; std::vector<std::pair<MachineBasicBlock *, unsigned> > BBRefs; public: explicit Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {} @@ -93,7 +93,7 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) { // Resolve all forward branches now. for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) { - unsigned Location = BasicBlockAddrs[BBRefs[i].first]; + unsigned Location = BasicBlockAddrs[BBRefs[i].first->getNumber()]; unsigned Ref = BBRefs[i].second; *((unsigned*)(intptr_t)Ref) = Location-Ref-4; } @@ -103,8 +103,9 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) { } void Emitter::emitBasicBlock(MachineBasicBlock &MBB) { - if (uint64_t Addr = MCE.getCurrentPCValue()) - BasicBlockAddrs[&MBB] = Addr; + if (BasicBlockAddrs.size() <= (unsigned)MBB.getNumber()) + BasicBlockAddrs.resize((MBB.getNumber()+1)*2); + BasicBlockAddrs[MBB.getNumber()] = MCE.getCurrentPCValue(); for (MachineBasicBlock::const_iterator I = MBB.begin(), E = MBB.end(); I != E; ++I) @@ -125,9 +126,9 @@ void Emitter::emitPCRelativeValue(unsigned Address) { void Emitter::emitPCRelativeBlockAddress(MachineBasicBlock *MBB) { // If this is a backwards branch, we already know the address of the target, // so just emit the value. - std::map<MachineBasicBlock*,uint64_t>::iterator I = BasicBlockAddrs.find(MBB); - if (I != BasicBlockAddrs.end()) { - emitPCRelativeValue(I->second); + unsigned MBBNo = MBB->getNumber(); + if (MBBNo < BasicBlockAddrs.size() && BasicBlockAddrs[MBBNo]) { + emitPCRelativeValue(BasicBlockAddrs[MBBNo]); } else { // Otherwise, remember where this reference was and where it is to so we can // deal with it later. |