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/X86/X86CodeEmitter.cpp | |
parent | 55371739dec0ade6fcc77de228fb3e4d098845f7 (diff) | |
download | external_llvm-55fc28076fa48723bd170e51638b3b5974ca0fa1.tar.gz external_llvm-55fc28076fa48723bd170e51638b3b5974ca0fa1.tar.bz2 external_llvm-55fc28076fa48723bd170e51638b3b5974ca0fa1.zip |
- 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/X86/X86CodeEmitter.cpp')
-rw-r--r-- | lib/Target/X86/X86CodeEmitter.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index 9179890b39..31b4bdf185 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -35,12 +35,14 @@ namespace { namespace { class VISIBILITY_HIDDEN Emitter : public MachineFunctionPass { const X86InstrInfo *II; + TargetMachine &TM; MachineCodeEmitter &MCE; - std::vector<std::pair<MachineBasicBlock *, unsigned> > BBRefs; public: - explicit Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {} - Emitter(MachineCodeEmitter &mce, const X86InstrInfo& ii) - : II(&ii), MCE(mce) {} + explicit Emitter(TargetMachine &tm, MachineCodeEmitter &mce) + : II(0), TM(tm), MCE(mce) {} + Emitter(TargetMachine &tm, MachineCodeEmitter &mce, + const X86InstrInfo& ii) + : II(&ii), TM(tm), MCE(mce) {} bool runOnMachineFunction(MachineFunction &MF); @@ -71,8 +73,9 @@ namespace { /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code /// to the specified MCE object. -FunctionPass *llvm::createX86CodeEmitterPass(MachineCodeEmitter &MCE) { - return new Emitter(MCE); +FunctionPass *llvm::createX86CodeEmitterPass(X86TargetMachine &TM, + MachineCodeEmitter &MCE) { + return new Emitter(TM, MCE); } bool Emitter::runOnMachineFunction(MachineFunction &MF) { @@ -82,8 +85,6 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) { II = ((X86TargetMachine&)MF.getTarget()).getInstrInfo(); do { - BBRefs.clear(); - MCE.startFunction(MF); for (MachineFunction::iterator MBB = MF.begin(), E = MF.end(); MBB != E; ++MBB) { @@ -94,13 +95,6 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) { } } while (MCE.finishFunction(MF)); - // Resolve all forward branches now. - for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) { - unsigned Location = MCE.getMachineBasicBlockAddress(BBRefs[i].first); - unsigned Ref = BBRefs[i].second; - *((unsigned*)(intptr_t)Ref) = Location-Ref-4; - } - BBRefs.clear(); return false; } @@ -117,7 +111,7 @@ void Emitter::emitPCRelativeValue(unsigned Address) { void Emitter::emitPCRelativeBlockAddress(MachineBasicBlock *MBB) { // 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())); + TM.getJITInfo()->addBBRef(MBB, MCE.getCurrentPCValue()); MCE.emitWordLE(0); } |