Add simple operand printing stuff
authorAnton Korobeynikov <asl@math.spbu.ru>
Wed, 21 Oct 2009 00:11:27 +0000 (00:11 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Wed, 21 Oct 2009 00:11:27 +0000 (00:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84704 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.h

index 4612a089c19719b9a2670ebdd4e23cdf9f0ad53d..243a5e1f3ed0d21ee4699d3c14e8e441596876bf 100644 (file)
@@ -33,3 +33,18 @@ using namespace llvm;
 void MSP430InstPrinter::printInst(const MCInst *MI) {
   printInstruction(MI);
 }
+
+void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
+                                     const char *Modifier) {
+  assert((Modifier == 0 || Modifier[0] == 0) && "Cannot print modifiers");
+
+  const MCOperand &Op = MI->getOperand(OpNo);
+  if (Op.isReg()) {
+    O << getRegisterName(Op.getReg());
+  } else if (Op.isImm()) {
+    O << '#' << Op.getImm();
+  } else {
+    assert(Op.isExpr() && "unknown operand kind in printOperand");
+    assert(0 && "Unimplemented!");
+  }
+}
index 93a9f750e009bbcf7749d441203004ae38000268..1047f4886f64166d2bf00b567bcc0ebff1c4de8b 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "llvm/MC/MCInstPrinter.h"
 
-namespace llvm 
+namespace llvm
 {
 
   class MCOperand;
@@ -34,10 +34,10 @@ namespace llvm
     static const char *getRegisterName(unsigned RegNo);
 
     void printOperand(const MCInst *MI, unsigned OpNo,
-                      const char *Modifier = 0) {
-    }
+                      const char *Modifier = 0);
+
     void printSrcMemOperand(const MCInst *MI, unsigned OpNo,
-                           const char *Modifier = 0) {
+                            const char *Modifier = 0) {
     }
     void printCCOperand(const MCInst *MI, unsigned OpNo) {
     }