LLVM API Documentation

PPCJITInfo.cpp
Go to the documentation of this file.
00001 //===-- PPCJITInfo.cpp - Implement the JIT interfaces for the PowerPC -----===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the JIT interfaces for the 32-bit PowerPC target.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #define DEBUG_TYPE "jit"
00015 #include "PPCJITInfo.h"
00016 #include "PPCRelocations.h"
00017 #include "PPCTargetMachine.h"
00018 #include "llvm/IR/Function.h"
00019 #include "llvm/Support/Debug.h"
00020 #include "llvm/Support/ErrorHandling.h"
00021 #include "llvm/Support/Memory.h"
00022 #include "llvm/Support/raw_ostream.h"
00023 using namespace llvm;
00024 
00025 static TargetJITInfo::JITCompilerFn JITCompilerFunction;
00026 
00027 #define BUILD_ADDIS(RD,RS,IMM16) \
00028   ((15 << 26) | ((RD) << 21) | ((RS) << 16) | ((IMM16) & 65535))
00029 #define BUILD_ORI(RD,RS,UIMM16) \
00030   ((24 << 26) | ((RS) << 21) | ((RD) << 16) | ((UIMM16) & 65535))
00031 #define BUILD_ORIS(RD,RS,UIMM16) \
00032   ((25 << 26) | ((RS) << 21) | ((RD) << 16) | ((UIMM16) & 65535))
00033 #define BUILD_RLDICR(RD,RS,SH,ME) \
00034   ((30 << 26) | ((RS) << 21) | ((RD) << 16) | (((SH) & 31) << 11) | \
00035    (((ME) & 63) << 6) | (1 << 2) | ((((SH) >> 5) & 1) << 1))
00036 #define BUILD_MTSPR(RS,SPR)      \
00037   ((31 << 26) | ((RS) << 21) | ((SPR) << 16) | (467 << 1))
00038 #define BUILD_BCCTRx(BO,BI,LINK) \
00039   ((19 << 26) | ((BO) << 21) | ((BI) << 16) | (528 << 1) | ((LINK) & 1))
00040 #define BUILD_B(TARGET, LINK) \
00041   ((18 << 26) | (((TARGET) & 0x00FFFFFF) << 2) | ((LINK) & 1))
00042 
00043 // Pseudo-ops
00044 #define BUILD_LIS(RD,IMM16)    BUILD_ADDIS(RD,0,IMM16)
00045 #define BUILD_SLDI(RD,RS,IMM6) BUILD_RLDICR(RD,RS,IMM6,63-IMM6)
00046 #define BUILD_MTCTR(RS)        BUILD_MTSPR(RS,9)
00047 #define BUILD_BCTR(LINK)       BUILD_BCCTRx(20,0,LINK)
00048 
00049 static void EmitBranchToAt(uint64_t At, uint64_t To, bool isCall, bool is64Bit){
00050   intptr_t Offset = ((intptr_t)To - (intptr_t)At) >> 2;
00051   unsigned *AtI = (unsigned*)(intptr_t)At;
00052 
00053   if (Offset >= -(1 << 23) && Offset < (1 << 23)) {   // In range?
00054     AtI[0] = BUILD_B(Offset, isCall);     // b/bl target
00055   } else if (!is64Bit) {
00056     AtI[0] = BUILD_LIS(12, To >> 16);     // lis r12, hi16(address)
00057     AtI[1] = BUILD_ORI(12, 12, To);       // ori r12, r12, lo16(address)
00058     AtI[2] = BUILD_MTCTR(12);             // mtctr r12
00059     AtI[3] = BUILD_BCTR(isCall);          // bctr/bctrl
00060   } else {
00061     AtI[0] = BUILD_LIS(12, To >> 48);      // lis r12, hi16(address)
00062     AtI[1] = BUILD_ORI(12, 12, To >> 32);  // ori r12, r12, lo16(address)
00063     AtI[2] = BUILD_SLDI(12, 12, 32);       // sldi r12, r12, 32
00064     AtI[3] = BUILD_ORIS(12, 12, To >> 16); // oris r12, r12, hi16(address)
00065     AtI[4] = BUILD_ORI(12, 12, To);        // ori r12, r12, lo16(address)
00066     AtI[5] = BUILD_MTCTR(12);              // mtctr r12
00067     AtI[6] = BUILD_BCTR(isCall);           // bctr/bctrl
00068   }
00069 }
00070 
00071 extern "C" void PPC32CompilationCallback();
00072 extern "C" void PPC64CompilationCallback();
00073 
00074 #if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
00075     !(defined(__ppc64__) || defined(__FreeBSD__))
00076 // CompilationCallback stub - We can't use a C function with inline assembly in
00077 // it, because we the prolog/epilog inserted by GCC won't work for us.  Instead,
00078 // write our own wrapper, which does things our way, so we have complete control
00079 // over register saving and restoring.
00080 asm(
00081     ".text\n"
00082     ".align 2\n"
00083     ".globl _PPC32CompilationCallback\n"
00084 "_PPC32CompilationCallback:\n"
00085     // Make space for 8 ints r[3-10] and 13 doubles f[1-13] and the 
00086     // FIXME: need to save v[0-19] for altivec?
00087     // FIXME: could shrink frame
00088     // Set up a proper stack frame
00089     // FIXME Layout
00090     //   PowerPC32 ABI linkage    -  24 bytes
00091     //                 parameters -  32 bytes
00092     //   13 double registers      - 104 bytes
00093     //   8 int registers          -  32 bytes
00094     "mflr r0\n"
00095     "stw r0,  8(r1)\n"
00096     "stwu r1, -208(r1)\n"
00097     // Save all int arg registers
00098     "stw r10, 204(r1)\n"    "stw r9,  200(r1)\n"
00099     "stw r8,  196(r1)\n"    "stw r7,  192(r1)\n"
00100     "stw r6,  188(r1)\n"    "stw r5,  184(r1)\n"
00101     "stw r4,  180(r1)\n"    "stw r3,  176(r1)\n"
00102     // Save all call-clobbered FP regs.
00103     "stfd f13, 168(r1)\n"   "stfd f12, 160(r1)\n"
00104     "stfd f11, 152(r1)\n"   "stfd f10, 144(r1)\n"
00105     "stfd f9,  136(r1)\n"   "stfd f8,  128(r1)\n"
00106     "stfd f7,  120(r1)\n"   "stfd f6,  112(r1)\n"
00107     "stfd f5,  104(r1)\n"   "stfd f4,   96(r1)\n"
00108     "stfd f3,   88(r1)\n"   "stfd f2,   80(r1)\n"
00109     "stfd f1,   72(r1)\n"
00110     // Arguments to Compilation Callback:
00111     // r3 - our lr (address of the call instruction in stub plus 4)
00112     // r4 - stub's lr (address of instruction that called the stub plus 4)
00113     // r5 - is64Bit - always 0.
00114     "mr   r3, r0\n"
00115     "lwz  r2, 208(r1)\n" // stub's frame
00116     "lwz  r4, 8(r2)\n" // stub's lr
00117     "li   r5, 0\n"       // 0 == 32 bit
00118     "bl _LLVMPPCCompilationCallback\n"
00119     "mtctr r3\n"
00120     // Restore all int arg registers
00121     "lwz r10, 204(r1)\n"    "lwz r9,  200(r1)\n"
00122     "lwz r8,  196(r1)\n"    "lwz r7,  192(r1)\n"
00123     "lwz r6,  188(r1)\n"    "lwz r5,  184(r1)\n"
00124     "lwz r4,  180(r1)\n"    "lwz r3,  176(r1)\n"
00125     // Restore all FP arg registers
00126     "lfd f13, 168(r1)\n"    "lfd f12, 160(r1)\n"
00127     "lfd f11, 152(r1)\n"    "lfd f10, 144(r1)\n"
00128     "lfd f9,  136(r1)\n"    "lfd f8,  128(r1)\n"
00129     "lfd f7,  120(r1)\n"    "lfd f6,  112(r1)\n"
00130     "lfd f5,  104(r1)\n"    "lfd f4,   96(r1)\n"
00131     "lfd f3,   88(r1)\n"    "lfd f2,   80(r1)\n"
00132     "lfd f1,   72(r1)\n"
00133     // Pop 3 frames off the stack and branch to target
00134     "lwz  r1, 208(r1)\n"
00135     "lwz  r2, 8(r1)\n"
00136     "mtlr r2\n"
00137     "bctr\n"
00138     );
00139 
00140 #elif defined(__PPC__) && !defined(__ppc64__)
00141 // Linux & FreeBSD / PPC 32 support
00142 
00143 // CompilationCallback stub - We can't use a C function with inline assembly in
00144 // it, because we the prolog/epilog inserted by GCC won't work for us.  Instead,
00145 // write our own wrapper, which does things our way, so we have complete control
00146 // over register saving and restoring.
00147 asm(
00148     ".text\n"
00149     ".align 2\n"
00150     ".globl PPC32CompilationCallback\n"
00151 "PPC32CompilationCallback:\n"
00152     // Make space for 8 ints r[3-10] and 8 doubles f[1-8] and the 
00153     // FIXME: need to save v[0-19] for altivec?
00154     // FIXME: could shrink frame
00155     // Set up a proper stack frame
00156     // FIXME Layout
00157     //   8 double registers       -  64 bytes
00158     //   8 int registers          -  32 bytes
00159     "mflr 0\n"
00160     "stw 0,  4(1)\n"
00161     "stwu 1, -104(1)\n"
00162     // Save all int arg registers
00163     "stw 10, 100(1)\n"   "stw 9,  96(1)\n"
00164     "stw 8,  92(1)\n"    "stw 7,  88(1)\n"
00165     "stw 6,  84(1)\n"    "stw 5,  80(1)\n"
00166     "stw 4,  76(1)\n"    "stw 3,  72(1)\n"
00167     // Save all call-clobbered FP regs.
00168     "stfd 8,  64(1)\n"
00169     "stfd 7,  56(1)\n"   "stfd 6,  48(1)\n"
00170     "stfd 5,  40(1)\n"   "stfd 4,  32(1)\n"
00171     "stfd 3,  24(1)\n"   "stfd 2,  16(1)\n"
00172     "stfd 1,  8(1)\n"
00173     // Arguments to Compilation Callback:
00174     // r3 - our lr (address of the call instruction in stub plus 4)
00175     // r4 - stub's lr (address of instruction that called the stub plus 4)
00176     // r5 - is64Bit - always 0.
00177     "mr   3, 0\n"
00178     "lwz  5, 104(1)\n" // stub's frame
00179     "lwz  4, 4(5)\n" // stub's lr
00180     "li   5, 0\n"       // 0 == 32 bit
00181     "bl LLVMPPCCompilationCallback\n"
00182     "mtctr 3\n"
00183     // Restore all int arg registers
00184     "lwz 10, 100(1)\n"   "lwz 9,  96(1)\n"
00185     "lwz 8,  92(1)\n"    "lwz 7,  88(1)\n"
00186     "lwz 6,  84(1)\n"    "lwz 5,  80(1)\n"
00187     "lwz 4,  76(1)\n"    "lwz 3,  72(1)\n"
00188     // Restore all FP arg registers
00189     "lfd 8,  64(1)\n"
00190     "lfd 7,  56(1)\n"    "lfd 6,  48(1)\n"
00191     "lfd 5,  40(1)\n"    "lfd 4,  32(1)\n"
00192     "lfd 3,  24(1)\n"    "lfd 2,  16(1)\n"
00193     "lfd 1,  8(1)\n"
00194     // Pop 3 frames off the stack and branch to target
00195     "lwz  1, 104(1)\n"
00196     "lwz  0, 4(1)\n"
00197     "mtlr 0\n"
00198     "bctr\n"
00199     );
00200 #else
00201 void PPC32CompilationCallback() {
00202   llvm_unreachable("This is not a power pc, you can't execute this!");
00203 }
00204 #endif
00205 
00206 #if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
00207     defined(__ppc64__)
00208 #ifdef __ELF__
00209 asm(
00210     ".text\n"
00211     ".align 2\n"
00212     ".globl PPC64CompilationCallback\n"
00213     ".section \".opd\",\"aw\",@progbits\n"
00214     ".align 3\n"
00215 "PPC64CompilationCallback:\n"
00216     ".quad .L.PPC64CompilationCallback,.TOC.@tocbase,0\n"
00217     ".size PPC64CompilationCallback,24\n"
00218     ".previous\n"
00219     ".align 4\n"
00220     ".type PPC64CompilationCallback,@function\n"
00221 ".L.PPC64CompilationCallback:\n"
00222 #else
00223 asm(
00224     ".text\n"
00225     ".align 2\n"
00226     ".globl _PPC64CompilationCallback\n"
00227 "_PPC64CompilationCallback:\n"
00228 #endif
00229     // Make space for 8 ints r[3-10] and 13 doubles f[1-13] and the 
00230     // FIXME: need to save v[0-19] for altivec?
00231     // Set up a proper stack frame
00232     // Layout
00233     //   PowerPC64 ABI linkage    -  48 bytes
00234     //                 parameters -  64 bytes
00235     //   13 double registers      - 104 bytes
00236     //   8 int registers          -  64 bytes
00237     "mflr 0\n"
00238     "std  0,  16(1)\n"
00239     "stdu 1, -280(1)\n"
00240     // Save all int arg registers
00241     "std 10, 272(1)\n"    "std 9,  264(1)\n"
00242     "std 8,  256(1)\n"    "std 7,  248(1)\n"
00243     "std 6,  240(1)\n"    "std 5,  232(1)\n"
00244     "std 4,  224(1)\n"    "std 3,  216(1)\n"
00245     // Save all call-clobbered FP regs.
00246     "stfd 13, 208(1)\n"    "stfd 12, 200(1)\n"
00247     "stfd 11, 192(1)\n"    "stfd 10, 184(1)\n"
00248     "stfd 9,  176(1)\n"    "stfd 8,  168(1)\n"
00249     "stfd 7,  160(1)\n"    "stfd 6,  152(1)\n"
00250     "stfd 5,  144(1)\n"    "stfd 4,  136(1)\n"
00251     "stfd 3,  128(1)\n"    "stfd 2,  120(1)\n"
00252     "stfd 1,  112(1)\n"
00253     // Arguments to Compilation Callback:
00254     // r3 - our lr (address of the call instruction in stub plus 4)
00255     // r4 - stub's lr (address of instruction that called the stub plus 4)
00256     // r5 - is64Bit - always 1.
00257     "mr   3, 0\n"      // return address (still in r0)
00258     "ld   5, 280(1)\n" // stub's frame
00259     "ld   4, 16(5)\n"  // stub's lr
00260     "li   5, 1\n"      // 1 == 64 bit
00261 #ifdef __ELF__
00262     "bl LLVMPPCCompilationCallback\n"
00263     "nop\n"
00264 #else
00265     "bl _LLVMPPCCompilationCallback\n"
00266 #endif
00267     "mtctr 3\n"
00268     // Restore all int arg registers
00269     "ld 10, 272(1)\n"    "ld 9,  264(1)\n"
00270     "ld 8,  256(1)\n"    "ld 7,  248(1)\n"
00271     "ld 6,  240(1)\n"    "ld 5,  232(1)\n"
00272     "ld 4,  224(1)\n"    "ld 3,  216(1)\n"
00273     // Restore all FP arg registers
00274     "lfd 13, 208(1)\n"    "lfd 12, 200(1)\n"
00275     "lfd 11, 192(1)\n"    "lfd 10, 184(1)\n"
00276     "lfd 9,  176(1)\n"    "lfd 8,  168(1)\n"
00277     "lfd 7,  160(1)\n"    "lfd 6,  152(1)\n"
00278     "lfd 5,  144(1)\n"    "lfd 4,  136(1)\n"
00279     "lfd 3,  128(1)\n"    "lfd 2,  120(1)\n"
00280     "lfd 1,  112(1)\n"
00281     // Pop 3 frames off the stack and branch to target
00282     "ld  1, 280(1)\n"
00283     "ld  0, 16(1)\n"
00284     "mtlr 0\n"
00285     // XXX: any special TOC handling in the ELF case for JIT?
00286     "bctr\n"
00287     );
00288 #else
00289 void PPC64CompilationCallback() {
00290   llvm_unreachable("This is not a power pc, you can't execute this!");
00291 }
00292 #endif
00293 
00294 extern "C" {
00295 LLVM_LIBRARY_VISIBILITY void *
00296 LLVMPPCCompilationCallback(unsigned *StubCallAddrPlus4,
00297                            unsigned *OrigCallAddrPlus4,
00298                            bool is64Bit) {
00299   // Adjust the pointer to the address of the call instruction in the stub
00300   // emitted by emitFunctionStub, rather than the instruction after it.
00301   unsigned *StubCallAddr = StubCallAddrPlus4 - 1;
00302   unsigned *OrigCallAddr = OrigCallAddrPlus4 - 1;
00303 
00304   void *Target = JITCompilerFunction(StubCallAddr);
00305 
00306   // Check to see if *OrigCallAddr is a 'bl' instruction, and if we can rewrite
00307   // it to branch directly to the destination.  If so, rewrite it so it does not
00308   // need to go through the stub anymore.
00309   unsigned OrigCallInst = *OrigCallAddr;
00310   if ((OrigCallInst >> 26) == 18) {     // Direct call.
00311     intptr_t Offset = ((intptr_t)Target - (intptr_t)OrigCallAddr) >> 2;
00312     
00313     if (Offset >= -(1 << 23) && Offset < (1 << 23)) {   // In range?
00314       // Clear the original target out.
00315       OrigCallInst &= (63 << 26) | 3;
00316       // Fill in the new target.
00317       OrigCallInst |= (Offset & ((1 << 24)-1)) << 2;
00318       // Replace the call.
00319       *OrigCallAddr = OrigCallInst;
00320     }
00321   }
00322 
00323   // Assert that we are coming from a stub that was created with our
00324   // emitFunctionStub.
00325   if ((*StubCallAddr >> 26) == 18)
00326     StubCallAddr -= 3;
00327   else {
00328   assert((*StubCallAddr >> 26) == 19 && "Call in stub is not indirect!");
00329     StubCallAddr -= is64Bit ? 9 : 6;
00330   }
00331 
00332   // Rewrite the stub with an unconditional branch to the target, for any users
00333   // who took the address of the stub.
00334   EmitBranchToAt((intptr_t)StubCallAddr, (intptr_t)Target, false, is64Bit);
00335   sys::Memory::InvalidateInstructionCache(StubCallAddr, 7*4);
00336 
00337   // Put the address of the target function to call and the address to return to
00338   // after calling the target function in a place that is easy to get on the
00339   // stack after we restore all regs.
00340   return Target;
00341 }
00342 }
00343 
00344 
00345 
00346 TargetJITInfo::LazyResolverFn
00347 PPCJITInfo::getLazyResolverFunction(JITCompilerFn Fn) {
00348   JITCompilerFunction = Fn;
00349   return is64Bit ? PPC64CompilationCallback : PPC32CompilationCallback;
00350 }
00351 
00352 TargetJITInfo::StubLayout PPCJITInfo::getStubLayout() {
00353   // The stub contains up to 10 4-byte instructions, aligned at 4 bytes: 3
00354   // instructions to save the caller's address if this is a lazy-compilation
00355   // stub, plus a 1-, 4-, or 7-instruction sequence to load an arbitrary address
00356   // into a register and jump through it.
00357   StubLayout Result = {10*4, 4};
00358   return Result;
00359 }
00360 
00361 #if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
00362 defined(__APPLE__)
00363 extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
00364 #endif
00365 
00366 void *PPCJITInfo::emitFunctionStub(const Function* F, void *Fn,
00367                                    JITCodeEmitter &JCE) {
00368   // If this is just a call to an external function, emit a branch instead of a
00369   // call.  The code is the same except for one bit of the last instruction.
00370   if (Fn != (void*)(intptr_t)PPC32CompilationCallback && 
00371       Fn != (void*)(intptr_t)PPC64CompilationCallback) {
00372     void *Addr = (void*)JCE.getCurrentPCValue();
00373     JCE.emitWordBE(0);
00374     JCE.emitWordBE(0);
00375     JCE.emitWordBE(0);
00376     JCE.emitWordBE(0);
00377     JCE.emitWordBE(0);
00378     JCE.emitWordBE(0);
00379     JCE.emitWordBE(0);
00380     EmitBranchToAt((intptr_t)Addr, (intptr_t)Fn, false, is64Bit);
00381     sys::Memory::InvalidateInstructionCache(Addr, 7*4);
00382     return Addr;
00383   }
00384 
00385   void *Addr = (void*)JCE.getCurrentPCValue();
00386   if (is64Bit) {
00387     JCE.emitWordBE(0xf821ffb1);     // stdu r1,-80(r1)
00388     JCE.emitWordBE(0x7d6802a6);     // mflr r11
00389     JCE.emitWordBE(0xf9610060);     // std r11, 96(r1)
00390   } else if (TM.getSubtargetImpl()->isDarwinABI()){
00391     JCE.emitWordBE(0x9421ffe0);     // stwu r1,-32(r1)
00392     JCE.emitWordBE(0x7d6802a6);     // mflr r11
00393     JCE.emitWordBE(0x91610028);     // stw r11, 40(r1)
00394   } else {
00395     JCE.emitWordBE(0x9421ffe0);     // stwu r1,-32(r1)
00396     JCE.emitWordBE(0x7d6802a6);     // mflr r11
00397     JCE.emitWordBE(0x91610024);     // stw r11, 36(r1)
00398   }
00399   intptr_t BranchAddr = (intptr_t)JCE.getCurrentPCValue();
00400   JCE.emitWordBE(0);
00401   JCE.emitWordBE(0);
00402   JCE.emitWordBE(0);
00403   JCE.emitWordBE(0);
00404   JCE.emitWordBE(0);
00405   JCE.emitWordBE(0);
00406   JCE.emitWordBE(0);
00407   EmitBranchToAt(BranchAddr, (intptr_t)Fn, true, is64Bit);
00408   sys::Memory::InvalidateInstructionCache(Addr, 10*4);
00409   return Addr;
00410 }
00411 
00412 
00413 void PPCJITInfo::relocate(void *Function, MachineRelocation *MR,
00414                           unsigned NumRelocs, unsigned char* GOTBase) {
00415   for (unsigned i = 0; i != NumRelocs; ++i, ++MR) {
00416     unsigned *RelocPos = (unsigned*)Function + MR->getMachineCodeOffset()/4;
00417     intptr_t ResultPtr = (intptr_t)MR->getResultPointer();
00418     switch ((PPC::RelocationType)MR->getRelocationType()) {
00419     default: llvm_unreachable("Unknown relocation type!");
00420     case PPC::reloc_pcrel_bx:
00421       // PC-relative relocation for b and bl instructions.
00422       ResultPtr = (ResultPtr-(intptr_t)RelocPos) >> 2;
00423       assert(ResultPtr >= -(1 << 23) && ResultPtr < (1 << 23) &&
00424              "Relocation out of range!");
00425       *RelocPos |= (ResultPtr & ((1 << 24)-1))  << 2;
00426       break;
00427     case PPC::reloc_pcrel_bcx:
00428       // PC-relative relocation for BLT,BLE,BEQ,BGE,BGT,BNE, or other
00429       // bcx instructions.
00430       ResultPtr = (ResultPtr-(intptr_t)RelocPos) >> 2;
00431       assert(ResultPtr >= -(1 << 13) && ResultPtr < (1 << 13) &&
00432              "Relocation out of range!");
00433       *RelocPos |= (ResultPtr & ((1 << 14)-1))  << 2;
00434       break;
00435     case PPC::reloc_absolute_high:     // high bits of ref -> low 16 of instr
00436     case PPC::reloc_absolute_low: {    // low bits of ref  -> low 16 of instr
00437       ResultPtr += MR->getConstantVal();
00438 
00439       // If this is a high-part access, get the high-part.
00440       if (MR->getRelocationType() == PPC::reloc_absolute_high) {
00441         // If the low part will have a carry (really a borrow) from the low
00442         // 16-bits into the high 16, add a bit to borrow from.
00443         if (((int)ResultPtr << 16) < 0)
00444           ResultPtr += 1 << 16;
00445         ResultPtr >>= 16;
00446       }
00447 
00448       // Do the addition then mask, so the addition does not overflow the 16-bit
00449       // immediate section of the instruction.
00450       unsigned LowBits  = (*RelocPos + ResultPtr) & 65535;
00451       unsigned HighBits = *RelocPos & ~65535;
00452       *RelocPos = LowBits | HighBits;  // Slam into low 16-bits
00453       break;
00454     }
00455     case PPC::reloc_absolute_low_ix: {  // low bits of ref  -> low 14 of instr
00456       ResultPtr += MR->getConstantVal();
00457       // Do the addition then mask, so the addition does not overflow the 16-bit
00458       // immediate section of the instruction.
00459       unsigned LowBits  = (*RelocPos + ResultPtr) & 0xFFFC;
00460       unsigned HighBits = *RelocPos & 0xFFFF0003;
00461       *RelocPos = LowBits | HighBits;  // Slam into low 14-bits.
00462       break;
00463     }
00464     }
00465   }
00466 }
00467 
00468 void PPCJITInfo::replaceMachineCodeForFunction(void *Old, void *New) {
00469   EmitBranchToAt((intptr_t)Old, (intptr_t)New, false, is64Bit);
00470   sys::Memory::InvalidateInstructionCache(Old, 7*4);
00471 }