aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/X86/X86CodeEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-16 04:30:51 +0000
committerChris Lattner <sabre@nondot.org>2004-11-16 04:30:51 +0000
commitf2d552eca65253bd8fc5934e4019921bc32b2364 (patch)
treeb4b60aa37c280c332498d028fccb491b1d8e373d /lib/Target/X86/X86CodeEmitter.cpp
parent16fe6f5f24062c5e1ce6178989e135c51e6d9c76 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86CodeEmitter.cpp')
-rw-r--r--lib/Target/X86/X86CodeEmitter.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index c7477448dd..853e6c12cd 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -278,9 +278,19 @@ void Emitter::emitBasicBlock(const MachineBasicBlock &MBB) {
/// 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.