[llvm-commits] [llvm] r81628 - in /llvm/trunk: include/llvm/MC/MCInst.h lib/MC/MCInst.cpp lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/AsmPrinter/X86MCInstLower.h

Chris Lattner sabre at nondot.org
Sat Sep 12 13:45:03 PDT 2009


Author: lattner
Date: Sat Sep 12 15:45:03 2009
New Revision: 81628

URL: http://llvm.org/viewvc/llvm-project?rev=81628&view=rev
Log:
eliminate the "MBBLabel" MCOperand type, and just use a MCSymbol for
MBB labels like everything else.

Modified:
    llvm/trunk/include/llvm/MC/MCInst.h
    llvm/trunk/lib/MC/MCInst.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h

Modified: llvm/trunk/include/llvm/MC/MCInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=81628&r1=81627&r2=81628&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCInst.h (original)
+++ llvm/trunk/include/llvm/MC/MCInst.h Sat Sep 12 15:45:03 2009
@@ -31,7 +31,6 @@
     kInvalid,                 ///< Uninitialized.
     kRegister,                ///< Register operand.
     kImmediate,               ///< Immediate operand.
-    kMBBLabel,                ///< Basic block label.
     kExpr                     ///< Relocatable immediate operand.
   };
   unsigned char Kind;
@@ -40,10 +39,6 @@
     unsigned RegVal;
     int64_t ImmVal;
     const MCExpr *ExprVal;
-    struct {
-      unsigned FunctionNo;
-      unsigned BlockNo;
-    } MBBLabel;
   };
 public:
   
@@ -53,7 +48,6 @@
   bool isValid() const { return Kind != kInvalid; }
   bool isReg() const { return Kind == kRegister; }
   bool isImm() const { return Kind == kImmediate; }
-  bool isMBBLabel() const { return Kind == kMBBLabel; }
   bool isExpr() const { return Kind == kExpr; }
   
   /// getReg - Returns the register number.
@@ -77,15 +71,6 @@
     ImmVal = Val;
   }
   
-  unsigned getMBBLabelFunction() const {
-    assert(isMBBLabel() && "This is not a machine basic block");
-    return MBBLabel.FunctionNo; 
-  }
-  unsigned getMBBLabelBlock() const {
-    assert(isMBBLabel() && "This is not a machine basic block");
-    return MBBLabel.BlockNo; 
-  }
-
   const MCExpr *getExpr() const {
     assert(isExpr() && "This is not an expression");
     return ExprVal;
@@ -107,13 +92,6 @@
     Op.ImmVal = Val;
     return Op;
   }
-  static MCOperand CreateMBBLabel(unsigned Fn, unsigned MBB) {
-    MCOperand Op;
-    Op.Kind = kMBBLabel;
-    Op.MBBLabel.FunctionNo = Fn;
-    Op.MBBLabel.BlockNo = MBB;
-    return Op;
-  }
   static MCOperand CreateExpr(const MCExpr *Val) {
     MCOperand Op;
     Op.Kind = kExpr;

Modified: llvm/trunk/lib/MC/MCInst.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCInst.cpp?rev=81628&r1=81627&r2=81628&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCInst.cpp (original)
+++ llvm/trunk/lib/MC/MCInst.cpp Sat Sep 12 15:45:03 2009
@@ -21,9 +21,6 @@
     OS << "Reg:" << getReg();
   else if (isImm())
     OS << "Imm:" << getImm();
-  else if (isMBBLabel())
-    OS << "MBB:(" << getMBBLabelFunction() << ","
-       << getMBBLabelBlock() << ")";
   else if (isExpr()) {
     OS << "Expr:(";
     getExpr()->print(OS, MAI);

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=81628&r1=81627&r2=81628&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Sat Sep 12 15:45:03 2009
@@ -58,11 +58,6 @@
     O << Op.getImm();
   else if (Op.isExpr())
     Op.getExpr()->print(O, MAI);
-  else if (Op.isMBBLabel())
-    // FIXME: Keep in sync with printBasicBlockLabel.  printBasicBlockLabel
-    // should eventually call into this code, not the other way around.
-    O << MAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction()
-      << '_' << Op.getMBBLabelBlock();
   else
     llvm_unreachable("Unknown pcrel immediate operand");
 }

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=81628&r1=81627&r2=81628&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Sat Sep 12 15:45:03 2009
@@ -45,6 +45,16 @@
   return Ctx.GetOrCreateSymbol(Name.str());
 }
 
+MCOperand X86MCInstLower::LowerMBBOperand(const MachineOperand &MO) const {
+  SmallString<60> Name;
+  raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "BB"
+      << AsmPrinter.getFunctionNumber() << '_' << MO.getMBB()->getNumber();
+
+  MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str());
+  return MCOperand::CreateExpr(MCSymbolRefExpr::Create(Sym, Ctx));
+}
+
+
 
 /// LowerGlobalAddressOperand - Lower an MO_GlobalAddress operand to an
 /// MCOperand.
@@ -331,9 +341,7 @@
       MCOp = MCOperand::CreateImm(MO.getImm());
       break;
     case MachineOperand::MO_MachineBasicBlock:
-// FIXME: Kill MBBLabel operand type!
-      MCOp = MCOperand::CreateMBBLabel(AsmPrinter.getFunctionNumber(), 
-                                       MO.getMBB()->getNumber());
+      MCOp = LowerMBBOperand(MO);
       break;
     case MachineOperand::MO_GlobalAddress:
       MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h?rev=81628&r1=81627&r2=81628&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h Sat Sep 12 15:45:03 2009
@@ -37,6 +37,7 @@
 private:
   const X86Subtarget &getSubtarget() const;
   
+  MCOperand LowerMBBOperand(const MachineOperand &MO) const;
   MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
   MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
   MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;





More information about the llvm-commits mailing list