Add code enough for emission of reg-reg and reg-imm moves. This allows us to compile...
[oota-llvm.git] / lib / Target / MSP430 / MSP430AsmPrinter.cpp
index a9e119f6eaef4a5f6f12a80ca65a605e82b7ca9e..e8004a7d1b42c592bbf10711911247a7b24a6431 100644 (file)
@@ -47,6 +47,7 @@ namespace {
       return "MSP430 Assembly Printer";
     }
 
+    void printOperand(const MachineInstr *MI, int OpNum);
     bool printInstruction(const MachineInstr *MI);  // autogenerated.
     void printMachineInstruction(const MachineInstr * MI);
     bool runOnMachineFunction(MachineFunction &F);
@@ -83,12 +84,32 @@ bool MSP430AsmPrinter::doFinalization(Module &M) {
   return AsmPrinter::doFinalization(M);
 }
 
-bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &F) {
+bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
+  // Print out code for the function.
+  for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
+       I != E; ++I) {
+    // Print a label for the basic block.
+    if (I != MF.begin()) {
+      printBasicBlockLabel(I, true , true);
+      O << '\n';
+    }
+
+    for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
+         II != E; ++II) {
+      // Print the assembly for the instruction.
+      O << "\t";
+      printMachineInstruction(II);
+    }
+
+    // Each Basic Block is separated by a newline
+    O << '\n';
+  }
+
   // We didn't modify anything
   return false;
 }
 
-void MSP430AsmPrinter::printMachineInstruction(const MachineInstr * MI) {
+void MSP430AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
   ++EmittedInsts;
 
   // Call the autogenerated instruction printer routines.
@@ -97,3 +118,23 @@ void MSP430AsmPrinter::printMachineInstruction(const MachineInstr * MI) {
 
   assert(0 && "Should not happen");
 }
+
+void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum) {
+  const MachineOperand &MO = MI->getOperand(OpNum);
+  switch (MO.getType()) {
+  case MachineOperand::MO_Register:
+    if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
+      O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
+    else
+      assert(0 && "not implemented");
+    break;
+  case MachineOperand::MO_Immediate:
+     O << "#" << MO.getImm();
+    break;
+  case MachineOperand::MO_MachineBasicBlock:
+    printBasicBlockLabel(MO.getMBB());
+    break;
+  default:
+    assert(0 && "Not implemented yet!");
+  }
+}