Chris Lattner | ae98221 | 2009-07-21 18:38:57 +0000 | [diff] [blame] | 1 | //===-- PIC16AsmPrinter.h - PIC16 LLVM assembly writer ----------*- C++ -*-===// |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 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 PIC16 assembly language. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef PIC16ASMPRINTER_H |
| 16 | #define PIC16ASMPRINTER_H |
| 17 | |
| 18 | #include "PIC16.h" |
| 19 | #include "PIC16TargetMachine.h" |
Sanjiv Gupta | 0d7c800 | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 20 | #include "PIC16DebugInfo.h" |
Chris Lattner | c4c40a9 | 2009-07-28 03:13:23 +0000 | [diff] [blame] | 21 | #include "PIC16TargetObjectFile.h" |
Sanjiv Gupta | 0d7c800 | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 22 | #include "llvm/Analysis/DebugInfo.h" |
Sanjiv Gupta | 5ade9e8 | 2009-05-13 15:13:17 +0000 | [diff] [blame] | 23 | #include "PIC16TargetAsmInfo.h" |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/AsmPrinter.h" |
| 25 | #include "llvm/Support/CommandLine.h" |
| 26 | #include "llvm/Target/TargetAsmInfo.h" |
| 27 | #include "llvm/Target/TargetMachine.h" |
Sanjiv Gupta | 064d830 | 2009-05-11 06:01:38 +0000 | [diff] [blame] | 28 | #include <list> |
| 29 | #include <string> |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 30 | |
| 31 | namespace llvm { |
Chris Lattner | c4c40a9 | 2009-07-28 03:13:23 +0000 | [diff] [blame] | 32 | class VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter { |
| 33 | public: |
Daniel Dunbar | 946686a | 2009-07-15 23:17:20 +0000 | [diff] [blame] | 34 | explicit PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, |
Chris Lattner | c4c40a9 | 2009-07-28 03:13:23 +0000 | [diff] [blame] | 35 | const TargetAsmInfo *T, bool V); |
Chris Lattner | ae98221 | 2009-07-21 18:38:57 +0000 | [diff] [blame] | 36 | private: |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 37 | virtual const char *getPassName() const { |
| 38 | return "PIC16 Assembly Printer"; |
| 39 | } |
| 40 | |
| 41 | bool runOnMachineFunction(MachineFunction &F); |
| 42 | void printOperand(const MachineInstr *MI, int opNum); |
Sanjiv Gupta | 4affaea | 2009-01-13 19:18:47 +0000 | [diff] [blame] | 43 | void printCCOperand(const MachineInstr *MI, int opNum); |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 44 | bool printInstruction(const MachineInstr *MI); // definition autogenerated. |
| 45 | bool printMachineInstruction(const MachineInstr *MI); |
Sanjiv Gupta | 5ade9e8 | 2009-05-13 15:13:17 +0000 | [diff] [blame] | 46 | void EmitFunctionDecls (Module &M); |
| 47 | void EmitUndefinedVars (Module &M); |
| 48 | void EmitDefinedVars (Module &M); |
Sanjiv Gupta | dbe7911 | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 49 | void EmitIData (Module &M); |
| 50 | void EmitUData (Module &M); |
Sanjiv Gupta | 14eba04 | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 51 | void EmitAutos (std::string FunctName); |
Sanjiv Gupta | 69a97ce | 2009-06-09 15:31:19 +0000 | [diff] [blame] | 52 | void EmitRemainingAutos (); |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 53 | void EmitRomData (Module &M); |
Sanjiv Gupta | 14eba04 | 2009-05-28 18:24:11 +0000 | [diff] [blame] | 54 | void EmitFunctionFrame(MachineFunction &MF); |
Sanjiv Gupta | 5ade9e8 | 2009-05-13 15:13:17 +0000 | [diff] [blame] | 55 | void printLibcallDecls(void); |
Chris Lattner | ae98221 | 2009-07-21 18:38:57 +0000 | [diff] [blame] | 56 | protected: |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 57 | bool doInitialization(Module &M); |
| 58 | bool doFinalization(Module &M); |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 59 | |
Chris Lattner | ae98221 | 2009-07-21 18:38:57 +0000 | [diff] [blame] | 60 | /// PrintGlobalVariable - Emit the specified global variable and its |
| 61 | /// initializer to the output stream. |
| 62 | virtual void PrintGlobalVariable(const GlobalVariable *GV) { |
| 63 | // PIC16 doesn't use normal hooks for this. |
| 64 | } |
| 65 | |
| 66 | private: |
Chris Lattner | c4c40a9 | 2009-07-28 03:13:23 +0000 | [diff] [blame] | 67 | PIC16TargetObjectFile *PTOF; |
Sanjiv Gupta | 4ab710d | 2009-04-06 10:54:50 +0000 | [diff] [blame] | 68 | PIC16TargetLowering *PTLI; |
Sanjiv Gupta | 0d7c800 | 2009-05-22 13:58:45 +0000 | [diff] [blame] | 69 | PIC16DbgInfo DbgInfo; |
Sanjiv Gupta | 5ade9e8 | 2009-05-13 15:13:17 +0000 | [diff] [blame] | 70 | const PIC16TargetAsmInfo *PTAI; |
| 71 | std::list<const char *> LibcallDecls; // List of extern decls. |
Sanjiv Gupta | 1db4916 | 2008-11-19 12:12:49 +0000 | [diff] [blame] | 72 | }; |
| 73 | } // end of namespace |
| 74 | |
| 75 | #endif |