From: Brian Gaeke Date: Fri, 14 May 2004 06:54:58 +0000 (+0000) Subject: Don't keep track of references to LLVM BasicBlocks while emitting; use X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=09015d9468abc3afb9880f9405bde31346d2b27d;p=oota-llvm.git Don't keep track of references to LLVM BasicBlocks while emitting; use MachineBasicBlocks instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13568 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index ddd5f563d77..185423a2f3e 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -172,8 +172,8 @@ namespace { class Emitter : public MachineFunctionPass { const X86InstrInfo *II; MachineCodeEmitter &MCE; - std::map BasicBlockAddrs; - std::vector > BBRefs; + std::map BasicBlockAddrs; + std::vector > BBRefs; public: explicit Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {} Emitter(MachineCodeEmitter &mce, const X86InstrInfo& ii) @@ -190,7 +190,7 @@ namespace { private: void emitBasicBlock(const MachineBasicBlock &MBB); - void emitPCRelativeBlockAddress(const BasicBlock *BB); + void emitPCRelativeBlockAddress(const MachineBasicBlock *BB); void emitMaybePCRelativeValue(unsigned Address, bool isPCRelative); void emitGlobalAddressForCall(GlobalValue *GV); void emitGlobalAddressForPtr(GlobalValue *GV); @@ -249,22 +249,21 @@ bool Emitter::runOnMachineFunction(MachineFunction &MF) { void Emitter::emitBasicBlock(const MachineBasicBlock &MBB) { if (uint64_t Addr = MCE.getCurrentPCValue()) - BasicBlockAddrs[MBB.getBasicBlock()] = Addr; + BasicBlockAddrs[&MBB] = Addr; for (MachineBasicBlock::const_iterator I = MBB.begin(), E = MBB.end(); I != E; ++I) emitInstruction(*I); } - /// emitPCRelativeBlockAddress - This method emits the PC relative address of /// the specified basic block, or if the basic block hasn't been emitted yet /// (because this is a forward branch), it keeps track of the information /// necessary to resolve this address later (and emits a dummy value). /// -void Emitter::emitPCRelativeBlockAddress(const BasicBlock *BB) { +void Emitter::emitPCRelativeBlockAddress(const MachineBasicBlock *MBB) { // FIXME: Emit backward branches directly - BBRefs.push_back(std::make_pair(BB, MCE.getCurrentPCValue())); - MCE.emitWord(0); // Emit a dummy value + BBRefs.push_back(std::make_pair(MBB, MCE.getCurrentPCValue())); + MCE.emitWord(0); } /// emitMaybePCRelativeValue - Emit a 32-bit address which may be PC relative. @@ -527,9 +526,8 @@ void Emitter::emitInstruction(const MachineInstr &MI) { MCE.emitByte(BaseOpcode); if (MI.getNumOperands() == 1) { const MachineOperand &MO = MI.getOperand(0); - if (MO.isPCRelativeDisp()) { - // Conditional branch... FIXME: this should use an MBB destination! - emitPCRelativeBlockAddress(cast(MO.getVRegValue())); + if (MO.isMachineBasicBlock()) { + emitPCRelativeBlockAddress(MO.getMachineBasicBlock()); } else if (MO.isGlobalAddress()) { assert(MO.isPCRelative() && "Call target is not PC Relative?"); emitGlobalAddressForCall(MO.getGlobal());