[llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Nov 15 20:31:05 PST 2004
Changes in directory llvm/lib/Target/X86:
X86CodeEmitter.cpp updated: 1.72 -> 1.73
---
Log message:
Implement a simple FIXME: if we are emitting a basic block address that has
already been emitted, we don't have to remember it and deal with it later,
just emit it directly.
---
Diffs of the changes: (+13 -3)
Index: llvm/lib/Target/X86/X86CodeEmitter.cpp
diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.72 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.73
--- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.72 Mon Nov 15 22:21:18 2004
+++ llvm/lib/Target/X86/X86CodeEmitter.cpp Mon Nov 15 22:30:51 2004
@@ -278,9 +278,19 @@
/// necessary to resolve this address later (and emits a dummy value).
///
void Emitter::emitPCRelativeBlockAddress(const MachineBasicBlock *MBB) {
- // FIXME: Emit backward branches directly
- BBRefs.push_back(std::make_pair(MBB, MCE.getCurrentPCValue()));
- MCE.emitWord(0);
+ // If this is a backwards branch, we already know the address of the target,
+ // so just emit the value.
+ std::map<const MachineBasicBlock*, unsigned>::iterator I =
+ BasicBlockAddrs.find(MBB);
+ if (I != BasicBlockAddrs.end()) {
+ unsigned Location = I->second;
+ MCE.emitWord(Location-MCE.getCurrentPCValue()-4);
+ } 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.emitWord(0);
+ }
}
/// emitPCRelativeValue - Emit a 32-bit PC relative address.
More information about the llvm-commits
mailing list