Eliminate the printCallOperand method, using a 'call' modifier on
authorChris Lattner <sabre@nondot.org>
Mon, 6 Feb 2006 23:41:19 +0000 (23:41 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 Feb 2006 23:41:19 +0000 (23:41 +0000)
printOperand instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26025 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86ATTAsmPrinter.h
lib/Target/X86/X86InstrInfo.td
lib/Target/X86/X86IntelAsmPrinter.cpp
lib/Target/X86/X86IntelAsmPrinter.h

index d9b263ae62a979df556fb2d020e5c6e213c1e410..353cd5460f9c7bc6defe20220ab137c0f727b708 100755 (executable)
@@ -63,7 +63,9 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   return false;
 }
 
-void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
+void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
+                                    const char *Modifier) {
+  const MachineOperand &MO = MI->getOperand(OpNo);
   const MRegisterInfo &RI = *TM.getRegisterInfo();
   switch (MO.getType()) {
   case MachineOperand::MO_VirtualRegister:
@@ -92,6 +94,7 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
     abort ();
     return;
   case MachineOperand::MO_GlobalAddress: {
+    bool isCallOp = Modifier && !strcmp(Modifier, "call");
     // Darwin block shameless ripped from PowerPCAsmPrinter.cpp
     if (forDarwin) {
       if (!isCallOp) O << '$';
@@ -132,7 +135,8 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
       O << Offset;
     return;
   }
-  case MachineOperand::MO_ExternalSymbol:
+  case MachineOperand::MO_ExternalSymbol: {
+    bool isCallOp = Modifier && !strcmp(Modifier, "call");
     if (isCallOp && forDarwin) {
       std::string Name(GlobalPrefix); Name += MO.getSymbolName();
       FnStubs.insert(Name);
@@ -142,6 +146,7 @@ void X86ATTAsmPrinter::printOp(const MachineOperand &MO, bool isCallOp) {
     if (!isCallOp) O << '$';
     O << GlobalPrefix << MO.getSymbolName();
     return;
+  }
   default:
     O << "<unknown operand type>"; return;
   }
@@ -183,7 +188,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
       O << "+" << DispSpec.getImmedValue();
     if (IndexReg.getReg()) {
       O << "(,";
-      printOp(IndexReg);
+      printOperand(MI, Op+2);
       if (ScaleVal != 1)
         O << "," << ScaleVal;
       O << ")";
@@ -192,7 +197,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
   }
 
   if (DispSpec.isGlobalAddress()) {
-    printOp(DispSpec, true);
+    printOperand(MI, Op+3, "call");
   } else {
     int DispVal = DispSpec.getImmedValue();
     if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
@@ -202,11 +207,11 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
   if (IndexReg.getReg() || BaseReg.getReg()) {
     O << "(";
     if (BaseReg.getReg())
-      printOp(BaseReg);
+      printOperand(MI, Op);
 
     if (IndexReg.getReg()) {
       O << ",";
-      printOp(IndexReg);
+      printOperand(MI, Op+2);
       if (ScaleVal != 1)
         O << "," << ScaleVal;
     }
index 6b2ae8fb00ce7a10f90b8b7ac0b89c417b7c2eb8..6b6ccf4b41f92e5eadc0f0496e38711270a746a7 100755 (executable)
@@ -34,13 +34,9 @@ struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
   /// returns false.
   bool printInstruction(const MachineInstr *MI);
 
-  // This method is used by the tablegen'erated instruction printer.
-  void printOperand(const MachineInstr *MI, unsigned OpNo){
-    printOp(MI->getOperand(OpNo));
-  }
-  void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
-    printOp(MI->getOperand(OpNo), true); // Don't print '$' prefix.
-  }
+  // These methods are used by the tablegen'erated instruction printer.
+  void printOperand(const MachineInstr *MI, unsigned OpNo,
+                    const char *Modifier = 0);
   void printi8mem(const MachineInstr *MI, unsigned OpNo) {
     printMemReference(MI, OpNo);
   }
@@ -64,7 +60,6 @@ struct X86ATTAsmPrinter : public X86SharedAsmPrinter {
   }
   
   void printMachineInstruction(const MachineInstr *MI);
-  void printOp(const MachineOperand &MO, bool isCallOperand = false);
   void printSSECC(const MachineInstr *MI, unsigned Op);
   void printMemReference(const MachineInstr *MI, unsigned Op);
   bool runOnMachineFunction(MachineFunction &F);
index 254cd98a86d6837dfd2bbb0c5fae2c864339893a..fbec3bef662b71f47456cff2476cf028659fb710 100644 (file)
@@ -159,10 +159,6 @@ def i16i8imm  : Operand<i16>;
 // 32-bits but only 8 bits are significant.
 def i32i8imm  : Operand<i32>;
 
-// PCRelative calls need special operand formatting.
-let PrintMethod = "printCallOperand" in
-  def calltarget : Operand<i32>;
-
 // Branch targets have OtherVT type.
 def brtarget : Operand<OtherVT>;
 
@@ -516,7 +512,7 @@ let isCall = 1, noResults = 1 in
   // All calls clobber the non-callee saved registers...
   let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
               XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
-    def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst",
+    def CALLpcrel32 : I<0xE8, RawFrm, (ops i32imm:$dst), "call ${dst:call}",
                       []>;
     def CALL32r     : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst",
                       [(X86call R32:$dst)]>;
@@ -526,7 +522,7 @@ let isCall = 1, noResults = 1 in
 
 // Tail call stuff.
 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
-  def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst  # TAIL CALL", []>;
+  def TAILJMPd : IBr<0xE9, (ops i32imm:$dst), "jmp ${dst:call}  # TAIL CALL", []>;
 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
   def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst  # TAIL CALL", []>;
 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, noResults = 1 in
index 2b91870e42ac41fc81177fc400b46948b7d67cc1..550e081dbddd50c762a259989a37f9c6e054493f 100755 (executable)
@@ -74,8 +74,8 @@ void X86IntelAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
   }
 }
 
-void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
-                                 bool elideOffsetKeyword /* = false */) {
+void X86IntelAsmPrinter::printOp(const MachineOperand &MO, 
+                                 const char *Modifier) {
   const MRegisterInfo &RI = *TM.getRegisterInfo();
   switch (MO.getType()) {
   case MachineOperand::MO_VirtualRegister:
@@ -109,7 +109,7 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
     abort ();
     return;
   case MachineOperand::MO_GlobalAddress: {
-    if (!elideOffsetKeyword)
+    if (!Modifier || strcmp(Modifier, "call"))
       O << "OFFSET ";
     O << Mang->getValueName(MO.getGlobal());
     int Offset = MO.getOffset();
@@ -161,7 +161,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
   O << "[";
   bool NeedPlus = false;
   if (BaseReg.getReg()) {
-    printOp(BaseReg, true);
+    printOp(BaseReg, "call");
     NeedPlus = true;
   }
 
@@ -176,7 +176,7 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op){
   if (DispSpec.isGlobalAddress()) {
     if (NeedPlus)
       O << " + ";
-    printOp(DispSpec, true);
+    printOp(DispSpec, "call");
   } else {
     int DispVal = DispSpec.getImmedValue();
     if (DispVal || (!BaseReg.getReg() && !IndexReg.getReg())) {
index 88a0dd15ca29f838ee624092233e4483fa1ea58f..2fe2d030101a3a95d393989ef3ca78db1b6d7233 100755 (executable)
@@ -37,21 +37,18 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
   bool printInstruction(const MachineInstr *MI);
 
   // This method is used by the tablegen'erated instruction printer.
-  void printOperand(const MachineInstr *MI, unsigned OpNo){
+  void printOperand(const MachineInstr *MI, unsigned OpNo,
+                    const char *Modifier = 0) {
     const MachineOperand &MO = MI->getOperand(OpNo);
     if (MO.getType() == MachineOperand::MO_MachineRegister) {
       assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physref??");
       // Bug Workaround: See note in Printer::doInitialization about %.
       O << "%" << TM.getRegisterInfo()->get(MO.getReg()).Name;
     } else {
-      printOp(MO);
+      printOp(MO, Modifier);
     }
   }
 
-  void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
-    printOp(MI->getOperand(OpNo), true); // Don't print "OFFSET".
-  }
-
   void printi8mem(const MachineInstr *MI, unsigned OpNo) {
     O << "BYTE PTR ";
     printMemReference(MI, OpNo);
@@ -82,7 +79,7 @@ struct X86IntelAsmPrinter : public X86SharedAsmPrinter {
   }
 
   void printMachineInstruction(const MachineInstr *MI);
-  void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false);
+  void printOp(const MachineOperand &MO, const char *Modifier = 0);
   void printSSECC(const MachineInstr *MI, unsigned Op);
   void printMemReference(const MachineInstr *MI, unsigned Op);
   bool runOnMachineFunction(MachineFunction &F);