[llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Dec 19 20:04:01 PST 2003
Changes in directory llvm/lib/Target/X86:
X86CodeEmitter.cpp updated: 1.43 -> 1.44
---
Log message:
A minor cleanup for better encapsulation
---
Diffs of the changes: (+13 -12)
Index: llvm/lib/Target/X86/X86CodeEmitter.cpp
diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.43 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.44
--- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.43 Fri Dec 19 19:22:04 2003
+++ llvm/lib/Target/X86/X86CodeEmitter.cpp Fri Dec 19 20:03:14 2003
@@ -50,13 +50,17 @@
unsigned resolveFunctionReference(unsigned RetAddr);
};
- JITResolver *TheJITResolver;
+ static JITResolver &getResolver(MachineCodeEmitter &MCE) {
+ static JITResolver *TheJITResolver = 0;
+ if (TheJITResolver == 0)
+ TheJITResolver = new JITResolver(MCE);
+ return *TheJITResolver;
+ }
}
+
void *X86JITInfo::getJITStubForFunction(Function *F, MachineCodeEmitter &MCE) {
- if (TheJITResolver == 0)
- TheJITResolver = new JITResolver(MCE);
- return (void*)((unsigned long)TheJITResolver->getLazyResolver(F));
+ return (void*)((unsigned long)getResolver(MCE).getLazyResolver(F));
}
void X86JITInfo::replaceMachineCodeForFunction (void *Old, void *New) {
@@ -126,7 +130,8 @@
// Sanity check to make sure this really is a call instruction...
assert(((unsigned char*)(intptr_t)RetAddr)[-1] == 0xE8 &&"Not a call instr!");
- unsigned NewVal = TheJITResolver->resolveFunctionReference(RetAddr);
+ JITResolver &JR = getResolver(*(MachineCodeEmitter*)0);
+ unsigned NewVal = JR.resolveFunctionReference(RetAddr);
// Rewrite the call target... so that we don't fault every time we execute
// the call.
@@ -267,10 +272,8 @@
if (Address == 0) {
// FIXME: this is JIT specific!
- if (TheJITResolver == 0)
- TheJITResolver = new JITResolver(MCE);
- Address = TheJITResolver->addFunctionReference(MCE.getCurrentPCValue(),
- cast<Function>(GV));
+ Address = getResolver(MCE).addFunctionReference(MCE.getCurrentPCValue(),
+ cast<Function>(GV));
}
emitMaybePCRelativeValue(Address, true);
}
@@ -288,9 +291,7 @@
//
if (Address == 0) {
// FIXME: this is JIT specific!
- if (TheJITResolver == 0)
- TheJITResolver = new JITResolver(MCE);
- Address = TheJITResolver->getLazyResolver((Function*)GV);
+ Address = getResolver(MCE).getLazyResolver((Function*)GV);
}
emitMaybePCRelativeValue(Address, false);
More information about the llvm-commits
mailing list