[llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed May 3 10:11:06 PDT 2006
Changes in directory llvm/lib/Target/X86:
X86CodeEmitter.cpp updated: 1.100 -> 1.101
---
Log message:
Suck block address tracking out of targets into the JIT Emitter. This
simplifies the MachineCodeEmitter interface just a little bit and makes
BasicBlocks work like constant pools and jump tables.
---
Diffs of the changes: (+9 -24)
X86CodeEmitter.cpp | 33 +++++++++------------------------
1 files changed, 9 insertions(+), 24 deletions(-)
Index: llvm/lib/Target/X86/X86CodeEmitter.cpp
diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.100 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.101
--- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.100 Tue May 2 23:52:47 2006
+++ llvm/lib/Target/X86/X86CodeEmitter.cpp Wed May 3 12:10:41 2006
@@ -35,7 +35,6 @@
class Emitter : public MachineFunctionPass {
const X86InstrInfo *II;
MachineCodeEmitter &MCE;
- std::vector<uint64_t> BasicBlockAddrs;
std::vector<std::pair<MachineBasicBlock *, unsigned> > BBRefs;
public:
explicit Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {}
@@ -83,30 +82,24 @@
do {
BBRefs.clear();
- BasicBlockAddrs.clear();
MCE.startFunction(MF);
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
emitBasicBlock(*I);
- MCE.emitJumpTableInfo(MF.getJumpTableInfo(), BasicBlockAddrs);
} while (MCE.finishFunction(MF));
// Resolve all forward branches now.
for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) {
- unsigned Location = BasicBlockAddrs[BBRefs[i].first->getNumber()];
+ unsigned Location = MCE.getMachineBasicBlockAddress(BBRefs[i].first);
unsigned Ref = BBRefs[i].second;
*((unsigned*)(intptr_t)Ref) = Location-Ref-4;
}
BBRefs.clear();
- BasicBlockAddrs.clear();
return false;
}
void Emitter::emitBasicBlock(MachineBasicBlock &MBB) {
- if (BasicBlockAddrs.size() <= (unsigned)MBB.getNumber())
- BasicBlockAddrs.resize((MBB.getNumber()+1)*2);
- BasicBlockAddrs[MBB.getNumber()] = MCE.getCurrentPCValue();
-
+ MCE.StartMachineBasicBlock(&MBB);
for (MachineBasicBlock::const_iterator I = MBB.begin(), E = MBB.end();
I != E; ++I)
emitInstruction(*I);
@@ -118,23 +111,15 @@
MCE.emitWordLE(Address-MCE.getCurrentPCValue()-4);
}
-/// emitPCRelativeBlockAddress - This method emits the PC relative address of
-/// the specified basic block, or if the basic block hasn't been emitted yet
-/// (because this is a forward branch), it keeps track of the information
-/// necessary to resolve this address later (and emits a dummy value).
+/// emitPCRelativeBlockAddress - This method keeps track of the information
+/// necessary to resolve the address of this block later and emits a dummy
+/// value.
///
void Emitter::emitPCRelativeBlockAddress(MachineBasicBlock *MBB) {
- // If this is a backwards branch, we already know the address of the target,
- // so just emit the value.
- 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.
- BBRefs.push_back(std::make_pair(MBB, MCE.getCurrentPCValue()));
- MCE.emitWordLE(0);
- }
+ // Remember where this reference was and where it is to so we can
+ // deal with it later.
+ BBRefs.push_back(std::make_pair(MBB, MCE.getCurrentPCValue()));
+ MCE.emitWordLE(0);
}
/// emitGlobalAddressForCall - Emit the specified address to the code stream
More information about the llvm-commits
mailing list