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

Chris Lattner sabre at nondot.org
Sun Nov 14 12:11:21 PST 2010


Author: lattner
Date: Sun Nov 14 14:11:21 2010
New Revision: 119063

URL: http://llvm.org/viewvc/llvm-project?rev=119063&view=rev
Log:
implement several trivial operand printers, reducing
failures in CodeGen/PowerPC from 120 -> 117

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=119063&r1=119062&r2=119063&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp Sun Nov 14 14:11:21 2010
@@ -39,6 +39,56 @@
   printInstruction(MI, O);
 }
 
+void PPCInstPrinter::printS5ImmOperand(const MCInst *MI, unsigned OpNo,
+                                       raw_ostream &O) {
+  char Value = MI->getOperand(OpNo).getImm();
+  Value = (Value << (32-5)) >> (32-5);
+  O << (int)Value;
+}
+
+void PPCInstPrinter::printU5ImmOperand(const MCInst *MI, unsigned OpNo,
+                                       raw_ostream &O) {
+  unsigned char Value = MI->getOperand(OpNo).getImm();
+  assert(Value <= 31 && "Invalid u5imm argument!");
+  O << (unsigned int)Value;
+}
+
+void PPCInstPrinter::printU6ImmOperand(const MCInst *MI, unsigned OpNo,
+                                       raw_ostream &O) {
+  unsigned char Value = MI->getOperand(OpNo).getImm();
+  assert(Value <= 63 && "Invalid u6imm argument!");
+  O << (unsigned int)Value;
+}
+
+void PPCInstPrinter::printS16ImmOperand(const MCInst *MI, unsigned OpNo,
+                                        raw_ostream &O) {
+  O << (short)MI->getOperand(OpNo).getImm();
+}
+
+void PPCInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
+                                        raw_ostream &O) {
+  O << (unsigned short)MI->getOperand(OpNo).getImm();
+}
+
+void PPCInstPrinter::printS16X4ImmOperand(const MCInst *MI, unsigned OpNo,
+                                          raw_ostream &O) {
+  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
+}
+
+
 /// stripRegisterPrefix - This method strips the character prefix from a
 /// register name so that only the number is left.  Used by for linux asm.
 const char *stripRegisterPrefix(const char *RegName) {

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=119063&r1=119062&r2=119063&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h (original)
+++ llvm/trunk/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h Sun Nov 14 14:11:21 2010
@@ -45,12 +45,12 @@
                              raw_ostream &O, const char *Modifier) {}
 
 
-  void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
-  void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
-  void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
-  void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
-  void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
-  void printS16X4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
+  void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+  void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+  void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+  void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+  void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
+  void printS16X4ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
   void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
   void printCallOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}
   void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {}





More information about the llvm-commits mailing list