diff options
author | Evan Cheng <evan.cheng@apple.com> | 2006-07-25 20:40:54 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2006-07-25 20:40:54 +0000 |
commit | 55fc28076fa48723bd170e51638b3b5974ca0fa1 (patch) | |
tree | 954eb5ec8c5be4c9a3b5cb6c6cbe7f6398564370 /lib/Target/PowerPC/PPCCodeEmitter.cpp | |
parent | 55371739dec0ade6fcc77de228fb3e4d098845f7 (diff) | |
download | llvm-55fc28076fa48723bd170e51638b3b5974ca0fa1.tar.gz llvm-55fc28076fa48723bd170e51638b3b5974ca0fa1.tar.bz2 llvm-55fc28076fa48723bd170e51638b3b5974ca0fa1.tar.xz |
- Refactor the code that resolve basic block references to a TargetJITInfo
method.
- Added synchronizeICache() to TargetJITInfo. It is called after each block
of code is emitted to flush the icache. This ensures correct execution
on targets that have separate dcache and icache.
- Added PPC / Mac OS X specific code to do icache flushing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29276 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCCodeEmitter.cpp')
-rw-r--r-- | lib/Target/PowerPC/PPCCodeEmitter.cpp | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/lib/Target/PowerPC/PPCCodeEmitter.cpp b/lib/Target/PowerPC/PPCCodeEmitter.cpp index 76dc349b50..73b0436fd1 100644 --- a/lib/Target/PowerPC/PPCCodeEmitter.cpp +++ b/lib/Target/PowerPC/PPCCodeEmitter.cpp @@ -32,9 +32,6 @@ namespace { TargetMachine &TM; MachineCodeEmitter &MCE; - // Tracks which instruction references which BasicBlock - std::vector<std::pair<MachineBasicBlock*, unsigned*> > BBRefs; - /// getMachineOpValue - evaluates the MachineOperand of a given MachineInstr /// int getMachineOpValue(MachineInstr &MI, MachineOperand &MO); @@ -80,39 +77,20 @@ bool PPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, return false; } +#ifdef __APPLE__ +extern "C" void sys_icache_invalidate(const void *Addr, size_t len); +#endif + bool PPCCodeEmitter::runOnMachineFunction(MachineFunction &MF) { assert((MF.getTarget().getRelocationModel() != Reloc::Default || MF.getTarget().getRelocationModel() != Reloc::Static) && "JIT relocation model must be set to static or default!"); do { - BBRefs.clear(); - MCE.startFunction(MF); for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB) emitBasicBlock(*BB); } while (MCE.finishFunction(MF)); - // Resolve branches to BasicBlocks for the entire function - for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) { - intptr_t Location = MCE.getMachineBasicBlockAddress(BBRefs[i].first); - unsigned *Ref = BBRefs[i].second; - DEBUG(std::cerr << "Fixup @ " << (void*)Ref << " to " << (void*)Location - << "\n"); - unsigned Instr = *Ref; - intptr_t BranchTargetDisp = (Location - (intptr_t)Ref) >> 2; - - switch (Instr >> 26) { - default: assert(0 && "Unknown branch user!"); - case 18: // This is B or BL - *Ref |= (BranchTargetDisp & ((1 << 24)-1)) << 2; - break; - case 16: // This is BLT,BLE,BEQ,BGE,BGT,BNE, or other bcx instruction - *Ref |= (BranchTargetDisp & ((1 << 14)-1)) << 2; - break; - } - } - BBRefs.clear(); - return false; } @@ -203,7 +181,7 @@ int PPCCodeEmitter::getMachineOpValue(MachineInstr &MI, MachineOperand &MO) { Reloc, MO.getSymbolName(), 0)); } else if (MO.isMachineBasicBlock()) { unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue(); - BBRefs.push_back(std::make_pair(MO.getMachineBasicBlock(), CurrPC)); + TM.getJITInfo()->addBBRef(MO.getMachineBasicBlock(), (intptr_t)CurrPC); } else if (MO.isConstantPoolIndex() || MO.isJumpTableIndex()) { if (MO.isConstantPoolIndex()) rv = MCE.getConstantPoolEntryAddress(MO.getConstantPoolIndex()); |