[llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Fri May 14 01:55:19 PDT 2004


Changes in directory llvm/lib/Target/X86:

X86CodeEmitter.cpp updated: 1.59 -> 1.60

---
Log message:

Don't keep track of references to LLVM BasicBlocks while emitting; use
MachineBasicBlocks instead.


---
Diffs of the changes:  (+9 -11)

Index: llvm/lib/Target/X86/X86CodeEmitter.cpp
diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.59 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.60
--- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.59	Fri Apr 23 12:11:16 2004
+++ llvm/lib/Target/X86/X86CodeEmitter.cpp	Fri May 14 01:54:58 2004
@@ -172,8 +172,8 @@
   class Emitter : public MachineFunctionPass {
     const X86InstrInfo  *II;
     MachineCodeEmitter  &MCE;
-    std::map<const BasicBlock*, unsigned> BasicBlockAddrs;
-    std::vector<std::pair<const BasicBlock*, unsigned> > BBRefs;
+    std::map<const MachineBasicBlock*, unsigned> BasicBlockAddrs;
+    std::vector<std::pair<const MachineBasicBlock *, unsigned> > BBRefs;
   public:
     explicit Emitter(MachineCodeEmitter &mce) : II(0), MCE(mce) {}
     Emitter(MachineCodeEmitter &mce, const X86InstrInfo& ii)
@@ -190,7 +190,7 @@
   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 @@
 
 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 @@
     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<BasicBlock>(MO.getVRegValue()));
+      if (MO.isMachineBasicBlock()) {
+        emitPCRelativeBlockAddress(MO.getMachineBasicBlock());
       } else if (MO.isGlobalAddress()) {
         assert(MO.isPCRelative() && "Call target is not PC Relative?");
         emitGlobalAddressForCall(MO.getGlobal());





More information about the llvm-commits mailing list