[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32JITInfo.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Nov 22 22:27:17 PST 2004
Changes in directory llvm/lib/Target/PowerPC:
PPC32JITInfo.cpp updated: 1.1 -> 1.2
---
Log message:
Implement the stub needed to get into compilation callback.
---
Diffs of the changes: (+14 -5)
Index: llvm/lib/Target/PowerPC/PPC32JITInfo.cpp
diff -u llvm/lib/Target/PowerPC/PPC32JITInfo.cpp:1.1 llvm/lib/Target/PowerPC/PPC32JITInfo.cpp:1.2
--- llvm/lib/Target/PowerPC/PPC32JITInfo.cpp:1.1 Tue Nov 23 00:02:06 2004
+++ llvm/lib/Target/PowerPC/PPC32JITInfo.cpp Tue Nov 23 00:27:02 2004
@@ -45,7 +45,7 @@
return CompilationCallback;
}
-static void EmitBranchToAt(void *At, void *To) {
+static void EmitBranchToAt(void *At, void *To, bool isCall) {
intptr_t Addr = (intptr_t)To;
// FIXME: should special case the short branch case.
@@ -54,7 +54,7 @@
AtI[0] = BUILD_LIS(12, Addr >> 16); // lis r12, hi16(address)
AtI[1] = BUILD_ORI(12, 12, Addr); // ori r12, r12, low16(address)
AtI[2] = BUILD_MTCTR(12); // mtctr r12
- AtI[3] = BUILD_BCTR(0); // bctr
+ AtI[3] = BUILD_BCTR(isCall); // bctr/bctrl
}
void *PPC32JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
@@ -67,11 +67,20 @@
MCE.emitWord(0);
MCE.emitWord(0);
MCE.emitWord(0);
- EmitBranchToAt(Addr, Fn);
+ EmitBranchToAt(Addr, Fn, false);
return MCE.finishFunctionStub(0);
}
- MCE.startFunctionStub(4*4);
+ MCE.startFunctionStub(4*7);
+ MCE.emitWord(0x9421ffe0); // stwu r1,-32(r1)
+ MCE.emitWord(0x7d6802a6); // mflr r11
+ MCE.emitWord(0x91610028); // stw r11, 40(r1)
+ void *Addr = (void*)(intptr_t)MCE.getCurrentPCValue();
+ MCE.emitWord(0);
+ MCE.emitWord(0);
+ MCE.emitWord(0);
+ MCE.emitWord(0);
+ EmitBranchToAt(Addr, Fn, true/*is call*/);
return MCE.finishFunctionStub(0);
}
@@ -113,5 +122,5 @@
}
void PPC32JITInfo::replaceMachineCodeForFunction(void *Old, void *New) {
- EmitBranchToAt(Old, New);
+ EmitBranchToAt(Old, New, false);
}
More information about the llvm-commits
mailing list