Dummy MSP430 backend
[oota-llvm.git] / lib / Target / MSP430 / MSP430AsmPrinter.cpp
1 //===-- MSP430AsmPrinter.cpp - MSP430 LLVM assembly writer ------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to the MSP430 assembly language.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #define DEBUG_TYPE "asm-printer"
16 #include "MSP430.h"
17 #include "MSP430InstrInfo.h"
18 #include "MSP430TargetMachine.h"
19 #include "llvm/Constants.h"
20 #include "llvm/DerivedTypes.h"
21 #include "llvm/Module.h"
22 #include "llvm/CodeGen/AsmPrinter.h"
23 #include "llvm/CodeGen/DwarfWriter.h"
24 #include "llvm/CodeGen/MachineModuleInfo.h"
25 #include "llvm/CodeGen/MachineFunctionPass.h"
26 #include "llvm/CodeGen/MachineConstantPool.h"
27 #include "llvm/CodeGen/MachineInstr.h"
28 #include "llvm/Target/TargetAsmInfo.h"
29 #include "llvm/Target/TargetData.h"
30 #include "llvm/ADT/Statistic.h"
31 #include "llvm/Support/Compiler.h"
32 #include "llvm/Support/Mangler.h"
33 #include "llvm/Support/raw_ostream.h"
34
35 using namespace llvm;
36
37 STATISTIC(EmittedInsts, "Number of machine instrs printed");
38
39 namespace {
40   class VISIBILITY_HIDDEN MSP430AsmPrinter : public AsmPrinter {
41   public:
42     MSP430AsmPrinter(raw_ostream &O, MSP430TargetMachine &TM,
43                     const TargetAsmInfo *TAI, bool Fast, bool Verbose)
44       : AsmPrinter(O, TM, TAI, Fast, Verbose) {}
45
46     virtual const char *getPassName() const {
47       return "MSP430 Assembly Printer";
48     }
49
50     bool printInstruction(const MachineInstr *MI);  // autogenerated.
51     void printMachineInstruction(const MachineInstr * MI);
52     bool runOnMachineFunction(MachineFunction &F);
53     bool doInitialization(Module &M);
54     bool doFinalization(Module &M);
55
56     void getAnalysisUsage(AnalysisUsage &AU) const {
57       AsmPrinter::getAnalysisUsage(AU);
58       AU.setPreservesAll();
59     }
60   };
61 } // end of anonymous namespace
62
63 #include "MSP430GenAsmWriter.inc"
64
65 /// createMSP430CodePrinterPass - Returns a pass that prints the MSP430
66 /// assembly code for a MachineFunction to the given output stream,
67 /// using the given target machine description.  This should work
68 /// regardless of whether the function is in SSA form.
69 ///
70 FunctionPass *llvm::createMSP430CodePrinterPass(raw_ostream &o,
71                                                 MSP430TargetMachine &tm,
72                                                 bool fast, bool verbose) {
73   return new MSP430AsmPrinter(o, tm, tm.getTargetAsmInfo(), fast, verbose);
74 }
75
76 bool MSP430AsmPrinter::doInitialization(Module &M) {
77   Mang = new Mangler(M, "", TAI->getPrivateGlobalPrefix());
78   return false; // success
79 }
80
81
82 bool MSP430AsmPrinter::doFinalization(Module &M) {
83   return AsmPrinter::doFinalization(M);
84 }
85
86 bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &F) {
87   // We didn't modify anything
88   return false;
89 }
90
91 void MSP430AsmPrinter::printMachineInstruction(const MachineInstr * MI) {
92   ++EmittedInsts;
93
94   // Call the autogenerated instruction printer routines.
95   if (printInstruction(MI))
96     return;
97
98   assert(0 && "Should not happen");
99 }