simplify and tidy up
authorChris Lattner <sabre@nondot.org>
Sun, 14 Nov 2010 20:31:06 +0000 (20:31 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 14 Nov 2010 20:31:06 +0000 (20:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119066 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/ARMMCInstLower.cpp
lib/Target/ARM/ARMMCInstLower.h

index 73d3e1caf2ed5edd32cd978b8e8df80648ea76c4..2d5b4c41c4cc9e4e12bbb2e917b6b6f6b7763a6c 100644 (file)
@@ -802,9 +802,8 @@ void ARMAsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
 void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
   ARMMCInstLower MCInstLowering(OutContext, *Mang, *this);
   switch (MI->getOpcode()) {
-  case ARM::t2MOVi32imm:
-    assert(0 && "Should be lowered by thumb2it pass");
   default: break;
+  case ARM::t2MOVi32imm: assert(0 && "Should be lowered by thumb2it pass");
   case ARM::DBG_VALUE: {
     if (isVerbose() && OutStreamer.hasRawTextSupport()) {
       SmallString<128> TmpStr;
index e2155f1a02ab170e0d62a32e62f420fd99288bf9..12ad3ec57438f0d606cc9a048be0799336f3bb28 100644 (file)
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "ARM.h"
 #include "ARMMCInstLower.h"
+#include "ARM.h"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/Constants.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"
@@ -82,7 +82,7 @@ GetExternalSymbolSymbol(const MachineOperand &MO) const {
 
 
 
-MCSymbol *ARMMCInstLower::
+const MCSymbolRefExpr *ARMMCInstLower::
 GetJumpTableSymbol(const MachineOperand &MO) const {
   SmallString<256> Name;
   raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "JTI"
@@ -94,10 +94,10 @@ GetJumpTableSymbol(const MachineOperand &MO) const {
   }
 
   // Create a symbol for the name.
-  return Ctx.GetOrCreateSymbol(Name.str());
+  return MCSymbolRefExpr::Create(Ctx.GetOrCreateSymbol(Name.str()), Ctx);
 }
 
-MCSymbol *ARMMCInstLower::
+const MCSymbolRefExpr *ARMMCInstLower::
 GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
   SmallString<256> Name;
   raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "CPI"
@@ -109,25 +109,7 @@ GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
   }
 
   // Create a symbol for the name.
-  return Ctx.GetOrCreateSymbol(Name.str());
-}
-
-MCOperand ARMMCInstLower::
-LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const {
-  // FIXME: We would like an efficient form for this, so we don't have to do a
-  // lot of extra uniquing.
-  const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, Ctx);
-
-  switch (MO.getTargetFlags()) {
-  default: assert(0 && "Unknown target flag on Symbol operand");
-  case 0: break;
-  }
-
-  if (!MO.isJTI() && MO.getOffset())
-    Expr = MCBinaryExpr::CreateAdd(Expr,
-                                   MCConstantExpr::Create(MO.getOffset(), Ctx),
-                                   Ctx);
-  return MCOperand::CreateExpr(Expr);
+  return MCSymbolRefExpr::Create(Ctx.GetOrCreateSymbol(Name.str()), Ctx);
 }
 
 MCOperand ARMMCInstLower::
@@ -173,14 +155,15 @@ void ARMMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
       MCOp = LowerSymbolRefOperand(MO, GetExternalSymbolSymbol(MO));
       break;
     case MachineOperand::MO_JumpTableIndex:
-      MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
+      MCOp = LowerSymbolRefOperand(MO, GetJumpTableSymbol(MO));
       break;
     case MachineOperand::MO_ConstantPoolIndex:
-      MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
+      MCOp = LowerSymbolRefOperand(MO, GetConstantPoolIndexSymbol(MO));
       break;
     case MachineOperand::MO_BlockAddress:
-      MCOp = LowerSymbolOperand(MO, Printer.GetBlockAddressSymbol(
-                                              MO.getBlockAddress()));
+      MCOp = LowerSymbolRefOperand(MO,
+                    MCSymbolRefExpr::Create(Printer.GetBlockAddressSymbol(
+                                              MO.getBlockAddress()), Ctx));
       break;
     case MachineOperand::MO_FPImmediate:
       APFloat Val = MO.getFPImm()->getValueAPF();
index c4d27f88df111c53d6964dd8c17c2dbb3875cff2..5645cc5f1718b912fba0154389d746ec2c92d9c2 100644 (file)
@@ -32,31 +32,24 @@ class LLVM_LIBRARY_VISIBILITY ARMMCInstLower {
   MCContext &Ctx;
   Mangler &Mang;
   AsmPrinter &Printer;
-
-  //const ARMSubtarget &getSubtarget() const;
 public:
   ARMMCInstLower(MCContext &ctx, Mangler &mang, AsmPrinter &printer)
     : Ctx(ctx), Mang(mang), Printer(printer) {}
 
   void Lower(const MachineInstr *MI, MCInst &OutMI) const;
 
-  //MCSymbol *GetPICBaseSymbol() const;
+private:
   MCSymbol *GetGlobalAddressSymbol(const GlobalValue *GV) const;
   const MCSymbolRefExpr *GetSymbolRef(const MachineOperand &MO) const;
   const MCSymbolRefExpr *GetExternalSymbolSymbol(const MachineOperand &MO)
     const;
-  MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
-  MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
+  const MCSymbolRefExpr *GetJumpTableSymbol(const MachineOperand &MO) const;
+  const MCSymbolRefExpr *
+  GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
   MCOperand LowerSymbolRefOperand(const MachineOperand &MO,
                                   const MCSymbolRefExpr *Expr) const;
-  MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
-
-/*
-private:
-  MachineModuleInfoMachO &getMachOMMI() const;
- */
 };
 
-}
+} // end namespace llvm
 
 #endif