blob: c365b5a30dba9f4db0933d5e6e51ba83c4595e8d [file] [log] [blame]
Chris Lattnerae982212009-07-21 18:38:57 +00001//===-- PIC16AsmPrinter.h - PIC16 LLVM assembly writer ----------*- C++ -*-===//
Sanjiv Gupta1db49162008-11-19 12:12:49 +00002//
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 Gupta0d7c8002009-05-22 13:58:45 +000020#include "PIC16DebugInfo.h"
Chris Lattnerc4c40a92009-07-28 03:13:23 +000021#include "PIC16TargetObjectFile.h"
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +000022#include "llvm/Analysis/DebugInfo.h"
Sanjiv Gupta5ade9e82009-05-13 15:13:17 +000023#include "PIC16TargetAsmInfo.h"
Sanjiv Gupta1db49162008-11-19 12:12:49 +000024#include "llvm/CodeGen/AsmPrinter.h"
25#include "llvm/Support/CommandLine.h"
26#include "llvm/Target/TargetAsmInfo.h"
27#include "llvm/Target/TargetMachine.h"
Sanjiv Gupta064d8302009-05-11 06:01:38 +000028#include <list>
29#include <string>
Sanjiv Gupta1db49162008-11-19 12:12:49 +000030
31namespace llvm {
Chris Lattnerc4c40a92009-07-28 03:13:23 +000032 class VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
33 public:
Daniel Dunbar946686a2009-07-15 23:17:20 +000034 explicit PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
Chris Lattnerc4c40a92009-07-28 03:13:23 +000035 const TargetAsmInfo *T, bool V);
Chris Lattnerae982212009-07-21 18:38:57 +000036 private:
Sanjiv Gupta1db49162008-11-19 12:12:49 +000037 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 Gupta4affaea2009-01-13 19:18:47 +000043 void printCCOperand(const MachineInstr *MI, int opNum);
Sanjiv Gupta1db49162008-11-19 12:12:49 +000044 bool printInstruction(const MachineInstr *MI); // definition autogenerated.
45 bool printMachineInstruction(const MachineInstr *MI);
Sanjiv Gupta5ade9e82009-05-13 15:13:17 +000046 void EmitFunctionDecls (Module &M);
47 void EmitUndefinedVars (Module &M);
48 void EmitDefinedVars (Module &M);
Sanjiv Guptadbe79112009-05-12 17:07:27 +000049 void EmitIData (Module &M);
50 void EmitUData (Module &M);
Sanjiv Gupta14eba042009-05-28 18:24:11 +000051 void EmitAutos (std::string FunctName);
Sanjiv Gupta69a97ce2009-06-09 15:31:19 +000052 void EmitRemainingAutos ();
Sanjiv Gupta1db49162008-11-19 12:12:49 +000053 void EmitRomData (Module &M);
Sanjiv Gupta14eba042009-05-28 18:24:11 +000054 void EmitFunctionFrame(MachineFunction &MF);
Sanjiv Gupta5ade9e82009-05-13 15:13:17 +000055 void printLibcallDecls(void);
Chris Lattnerae982212009-07-21 18:38:57 +000056 protected:
Sanjiv Gupta1db49162008-11-19 12:12:49 +000057 bool doInitialization(Module &M);
58 bool doFinalization(Module &M);
Sanjiv Gupta1db49162008-11-19 12:12:49 +000059
Chris Lattnerae982212009-07-21 18:38:57 +000060 /// 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 Lattnerc4c40a92009-07-28 03:13:23 +000067 PIC16TargetObjectFile *PTOF;
Sanjiv Gupta4ab710d2009-04-06 10:54:50 +000068 PIC16TargetLowering *PTLI;
Sanjiv Gupta0d7c8002009-05-22 13:58:45 +000069 PIC16DbgInfo DbgInfo;
Sanjiv Gupta5ade9e82009-05-13 15:13:17 +000070 const PIC16TargetAsmInfo *PTAI;
71 std::list<const char *> LibcallDecls; // List of extern decls.
Sanjiv Gupta1db49162008-11-19 12:12:49 +000072 };
73} // end of namespace
74
75#endif