[llvm] r195826 - Convert more methods in static helpers.

Rafael Espindola rafael.espindola at gmail.com
Tue Nov 26 23:34:10 PST 2013


Author: rafael
Date: Wed Nov 27 01:34:09 2013
New Revision: 195826

URL: http://llvm.org/viewvc/llvm-project?rev=195826&view=rev
Log:
Convert more methods in static helpers.

Modified:
    llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
    llvm/trunk/lib/Target/X86/X86AsmPrinter.h

Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=195826&r1=195825&r2=195826&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Wed Nov 27 01:34:09 2013
@@ -268,8 +268,9 @@ static void printOperand(X86AsmPrinter &
   }
 }
 
-void X86AsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op,
-                                         raw_ostream &O, const char *Modifier) {
+static void printLeaMemReference(X86AsmPrinter &P, const MachineInstr *MI,
+                                 unsigned Op, raw_ostream &O,
+                                 const char *Modifier = NULL) {
   const MachineOperand &BaseReg  = MI->getOperand(Op);
   const MachineOperand &IndexReg = MI->getOperand(Op+2);
   const MachineOperand &DispSpec = MI->getOperand(Op+3);
@@ -290,7 +291,7 @@ void X86AsmPrinter::printLeaMemReference
   } else {
     assert(DispSpec.isGlobal() || DispSpec.isCPI() ||
            DispSpec.isJTI() || DispSpec.isSymbol());
-    printSymbolOperand(*this, MI->getOperand(Op+3), O);
+    printSymbolOperand(P, MI->getOperand(Op+3), O);
   }
 
   if (Modifier && strcmp(Modifier, "H") == 0)
@@ -302,11 +303,11 @@ void X86AsmPrinter::printLeaMemReference
 
     O << '(';
     if (HasBaseReg)
-      printOperand(*this, MI, Op, O, Modifier);
+      printOperand(P, MI, Op, O, Modifier);
 
     if (IndexReg.getReg()) {
       O << ',';
-      printOperand(*this, MI, Op+2, O, Modifier);
+      printOperand(P, MI, Op+2, O, Modifier);
       unsigned ScaleVal = MI->getOperand(Op+1).getImm();
       if (ScaleVal != 1)
         O << ',' << ScaleVal;
@@ -315,20 +316,22 @@ void X86AsmPrinter::printLeaMemReference
   }
 }
 
-void X86AsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
-                                      raw_ostream &O, const char *Modifier) {
+static void printMemReference(X86AsmPrinter &P, const MachineInstr *MI,
+                              unsigned Op, raw_ostream &O,
+                              const char *Modifier = NULL) {
   assert(isMem(MI, Op) && "Invalid memory reference!");
   const MachineOperand &Segment = MI->getOperand(Op+4);
   if (Segment.getReg()) {
-    printOperand(*this, MI, Op+4, O, Modifier);
+    printOperand(P, MI, Op+4, O, Modifier);
     O << ':';
   }
-  printLeaMemReference(MI, Op, O, Modifier);
+  printLeaMemReference(P, MI, Op, O, Modifier);
 }
 
-void X86AsmPrinter::printIntelMemReference(const MachineInstr *MI, unsigned Op,
-                                           raw_ostream &O, const char *Modifier,
-                                           unsigned AsmVariant){
+static void printIntelMemReference(X86AsmPrinter &P, const MachineInstr *MI,
+                                   unsigned Op, raw_ostream &O,
+                                   const char *Modifier = NULL,
+                                   unsigned AsmVariant = 1) {
   const MachineOperand &BaseReg  = MI->getOperand(Op);
   unsigned ScaleVal = MI->getOperand(Op+1).getImm();
   const MachineOperand &IndexReg = MI->getOperand(Op+2);
@@ -337,7 +340,7 @@ void X86AsmPrinter::printIntelMemReferen
 
   // If this has a segment register, print it.
   if (SegReg.getReg()) {
-    printOperand(*this, MI, Op+4, O, Modifier, AsmVariant);
+    printOperand(P, MI, Op+4, O, Modifier, AsmVariant);
     O << ':';
   }
 
@@ -345,7 +348,7 @@ void X86AsmPrinter::printIntelMemReferen
 
   bool NeedPlus = false;
   if (BaseReg.getReg()) {
-    printOperand(*this, MI, Op, O, Modifier, AsmVariant);
+    printOperand(P, MI, Op, O, Modifier, AsmVariant);
     NeedPlus = true;
   }
 
@@ -353,13 +356,13 @@ void X86AsmPrinter::printIntelMemReferen
     if (NeedPlus) O << " + ";
     if (ScaleVal != 1)
       O << ScaleVal << '*';
-    printOperand(*this, MI, Op+2, O, Modifier, AsmVariant);
+    printOperand(P, MI, Op+2, O, Modifier, AsmVariant);
     NeedPlus = true;
   }
 
   if (!DispSpec.isImm()) {
     if (NeedPlus) O << " + ";
-    printOperand(*this, MI, Op+3, O, Modifier, AsmVariant);
+    printOperand(P, MI, Op+3, O, Modifier, AsmVariant);
   } else {
     int64_t DispVal = DispSpec.getImm();
     if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
@@ -377,8 +380,8 @@ void X86AsmPrinter::printIntelMemReferen
   O << ']';
 }
 
-bool X86AsmPrinter::printAsmMRegister(const MachineOperand &MO, char Mode,
-                                      raw_ostream &O) {
+static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO,
+                              char Mode, raw_ostream &O) {
   unsigned Reg = MO.getReg();
   switch (Mode) {
   default: return true;  // Unknown mode.
@@ -461,7 +464,7 @@ bool X86AsmPrinter::PrintAsmOperand(cons
     case 'k': // Print SImode register
     case 'q': // Print DImode register
       if (MO.isReg())
-        return printAsmMRegister(MO, ExtraCode[0], O);
+        return printAsmMRegister(*this, MO, ExtraCode[0], O);
       printOperand(*this, MI, OpNo, O);
       return false;
 
@@ -489,7 +492,7 @@ bool X86AsmPrinter::PrintAsmMemoryOperan
                                           const char *ExtraCode,
                                           raw_ostream &O) {
   if (AsmVariant) {
-    printIntelMemReference(MI, OpNo, O);
+    printIntelMemReference(*this, MI, OpNo, O);
     return false;
   }
 
@@ -506,14 +509,14 @@ bool X86AsmPrinter::PrintAsmMemoryOperan
       // These only apply to registers, ignore on mem.
       break;
     case 'H':
-      printMemReference(MI, OpNo, O, "H");
+      printMemReference(*this, MI, OpNo, O, "H");
       return false;
     case 'P': // Don't print @PLT, but do print as memory.
-      printMemReference(MI, OpNo, O, "no-rip");
+      printMemReference(*this, MI, OpNo, O, "no-rip");
       return false;
     }
   }
-  printMemReference(MI, OpNo, O);
+  printMemReference(*this, MI, OpNo, O);
   return false;
 }
 

Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.h?rev=195826&r1=195825&r2=195826&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.h (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.h Wed Nov 27 01:34:09 2013
@@ -55,7 +55,6 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrin
 
   virtual void EmitInstruction(const MachineInstr *MI) LLVM_OVERRIDE;
 
-  bool printAsmMRegister(const MachineOperand &MO, char Mode, raw_ostream &O);
   virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
                                unsigned AsmVariant, const char *ExtraCode,
                                raw_ostream &OS) LLVM_OVERRIDE;
@@ -63,15 +62,6 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrin
                                      unsigned AsmVariant, const char *ExtraCode,
                                      raw_ostream &OS) LLVM_OVERRIDE;
 
-  void printMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
-                         const char *Modifier=NULL);
-  void printLeaMemReference(const MachineInstr *MI, unsigned Op, raw_ostream &O,
-                            const char *Modifier=NULL);
-
-  void printIntelMemReference(const MachineInstr *MI, unsigned Op,
-                              raw_ostream &O, const char *Modifier=NULL,
-                              unsigned AsmVariant = 1);
-
   virtual bool runOnMachineFunction(MachineFunction &F) LLVM_OVERRIDE;
 };
 





More information about the llvm-commits mailing list