[llvm-commits] [llvm] r119082 - in /llvm/trunk/lib/Target/PowerPC/InstPrinter: PPCInstPrinter.cpp PPCInstPrinter.h

Chris Lattner sabre at nondot.org
Sun Nov 14 13:51:38 PST 2010


Author: lattner
Date: Sun Nov 14 15:51:37 2010
New Revision: 119082

URL: http://llvm.org/viewvc/llvm-project?rev=119082&view=rev
Log:
wire up a few more things, down to 4 test failures, all
about handling $stub, lo/hi etc.

Modified:
    llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
    llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h

Modified: llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp?rev=119082&r1=119081&r2=119082&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp Sun Nov 14 15:51:37 2010
@@ -13,14 +13,12 @@
 
 #define DEBUG_TYPE "asm-printer"
 #include "PPCInstPrinter.h"
+#include "PPCPredicates.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
 //#include "llvm/MC/MCAsmInfo.h"
 //#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/raw_ostream.h"
-
-#include "PPCGenRegisterNames.inc"
-#include "PPCGenInstrNames.inc"
 using namespace llvm;
 
 #define GET_INSTRUCTION_NAME
@@ -84,6 +82,34 @@
   printInstruction(MI, O);
 }
 
+
+void PPCInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNo,
+                                           raw_ostream &O, 
+                                           const char *Modifier) {
+  assert(Modifier && "Must specify 'cc' or 'reg' as predicate op modifier!");
+  unsigned Code = MI->getOperand(OpNo).getImm();
+  if (StringRef(Modifier) == "cc") {
+    switch ((PPC::Predicate)Code) {
+    default: assert(0 && "Invalid predicate");
+    case PPC::PRED_ALWAYS: return; // Don't print anything for always.
+    case PPC::PRED_LT: O << "lt"; return;
+    case PPC::PRED_LE: O << "le"; return;
+    case PPC::PRED_EQ: O << "eq"; return;
+    case PPC::PRED_GE: O << "ge"; return;
+    case PPC::PRED_GT: O << "gt"; return;
+    case PPC::PRED_NE: O << "ne"; return;
+    case PPC::PRED_UN: O << "un"; return;
+    case PPC::PRED_NU: O << "nu"; return;
+    }
+  }
+  
+  assert(StringRef(Modifier) == "reg" &&
+         "Need to specify 'cc' or 'reg' as predicate op modifier!");
+  // Don't print the register for 'always'.
+  if (Code == PPC::PRED_ALWAYS) return;
+  printOperand(MI, OpNo+1, O);
+}
+
 void PPCInstPrinter::printS5ImmOperand(const MCInst *MI, unsigned OpNo,
                                        raw_ostream &O) {
   char Value = MI->getOperand(OpNo).getImm();
@@ -117,20 +143,10 @@
 
 void PPCInstPrinter::printS16X4ImmOperand(const MCInst *MI, unsigned OpNo,
                                           raw_ostream &O) {
-  if (MI->getOperand(OpNo).isImm()) {
+  if (MI->getOperand(OpNo).isImm())
     O << (short)(MI->getOperand(OpNo).getImm()*4);
-    return;
-  }
-  
-  assert(0 && "Unhandled operand");
-#if 0
-  O << "lo16(";
-  printOp(MI->getOperand(OpNo), O);
-  if (TM.getRelocationModel() == Reloc::PIC_)
-    O << "-\"L" << getFunctionNumber() << "$pb\")";
   else
-    O << ')';
-#endif
+    printOperand(MI, OpNo, O);
 }
 
 void PPCInstPrinter::printBranchOperand(const MCInst *MI, unsigned OpNo,
@@ -140,10 +156,14 @@
 
   // Branches can take an immediate operand.  This is used by the branch
   // selection pass to print $+8, an eight byte displacement from the PC.
-  O << "$+" << MI->getOperand(OpNo).getImm()*4;
+  O << "$+";
+  printAbsAddrOperand(MI, OpNo, O);
 }
 
-
+void PPCInstPrinter::printAbsAddrOperand(const MCInst *MI, unsigned OpNo,
+                                         raw_ostream &O) {
+  O << (int)MI->getOperand(OpNo).getImm()*4;
+}
 
 
 void PPCInstPrinter::printcrbitm(const MCInst *MI, unsigned OpNo,

Modified: llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h?rev=119082&r1=119081&r2=119082&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h (original)
+++ llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h Sun Nov 14 15:51:37 2010
@@ -42,7 +42,7 @@
 
   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printPredicateOperand(const MCInst *MI, unsigned OpNo,
-                             raw_ostream &O, const char *Modifier) {}
+                             raw_ostream &O, const char *Modifier);
 
 
   void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
@@ -55,7 +55,7 @@
   void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
     printOperand(MI, OpNo, O);
   }
-  void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
+  void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
 
   void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
 





More information about the llvm-commits mailing list