2009-08-13 16:37:05 +00:00
|
|
|
//===-- PIC16AsmPrinter.h - PIC16 LLVM assembly writer ----------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains a printer that converts from our internal representation
|
|
|
|
// of machine-dependent LLVM code to PIC16 assembly language.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef PIC16ASMPRINTER_H
|
|
|
|
#define PIC16ASMPRINTER_H
|
|
|
|
|
|
|
|
#include "PIC16.h"
|
|
|
|
#include "PIC16TargetMachine.h"
|
|
|
|
#include "PIC16DebugInfo.h"
|
2009-08-22 20:48:53 +00:00
|
|
|
#include "PIC16MCAsmInfo.h"
|
2009-08-13 16:37:05 +00:00
|
|
|
#include "PIC16TargetObjectFile.h"
|
|
|
|
#include "llvm/Analysis/DebugInfo.h"
|
|
|
|
#include "llvm/CodeGen/AsmPrinter.h"
|
|
|
|
#include "llvm/Support/CommandLine.h"
|
|
|
|
#include "llvm/Target/TargetMachine.h"
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class VISIBILITY_HIDDEN PIC16AsmPrinter : public AsmPrinter {
|
|
|
|
public:
|
|
|
|
explicit PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
|
2009-08-22 20:48:53 +00:00
|
|
|
const MCAsmInfo *T, bool V);
|
2009-08-13 16:37:05 +00:00
|
|
|
private:
|
|
|
|
virtual const char *getPassName() const {
|
|
|
|
return "PIC16 Assembly Printer";
|
|
|
|
}
|
|
|
|
|
|
|
|
PIC16TargetObjectFile &getObjFileLowering() const {
|
|
|
|
return (PIC16TargetObjectFile &)AsmPrinter::getObjFileLowering();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
|
|
|
void printOperand(const MachineInstr *MI, int opNum);
|
|
|
|
void printCCOperand(const MachineInstr *MI, int opNum);
|
|
|
|
void printInstruction(const MachineInstr *MI); // definition autogenerated.
|
2009-09-13 20:19:22 +00:00
|
|
|
static const char *getRegisterName(unsigned RegNo);
|
2009-09-13 20:08:00 +00:00
|
|
|
|
2009-08-13 16:37:05 +00:00
|
|
|
bool printMachineInstruction(const MachineInstr *MI);
|
|
|
|
void EmitFunctionDecls (Module &M);
|
|
|
|
void EmitUndefinedVars (Module &M);
|
|
|
|
void EmitDefinedVars (Module &M);
|
|
|
|
void EmitIData (Module &M);
|
|
|
|
void EmitUData (Module &M);
|
2009-10-15 19:26:25 +00:00
|
|
|
void EmitAllAutos (Module &M);
|
2009-08-13 16:37:05 +00:00
|
|
|
void EmitRomData (Module &M);
|
2009-10-25 08:14:11 +00:00
|
|
|
void EmitSharedUdata(Module &M);
|
2009-10-15 19:26:25 +00:00
|
|
|
void EmitUserSections (Module &M);
|
2009-08-13 16:37:05 +00:00
|
|
|
void EmitFunctionFrame(MachineFunction &MF);
|
|
|
|
void printLibcallDecls();
|
2009-10-15 19:26:25 +00:00
|
|
|
void EmitUninitializedDataSection(const PIC16Section *S);
|
|
|
|
void EmitInitializedDataSection(const PIC16Section *S);
|
2009-10-16 08:58:34 +00:00
|
|
|
void EmitSingleSection(const PIC16Section *S);
|
|
|
|
void EmitSectionList(Module &M,
|
|
|
|
const std::vector< PIC16Section *> &SList);
|
2009-10-21 10:42:44 +00:00
|
|
|
void ColorAutoSection(const Function *F);
|
2009-08-13 16:37:05 +00:00
|
|
|
protected:
|
|
|
|
bool doInitialization(Module &M);
|
|
|
|
bool doFinalization(Module &M);
|
|
|
|
|
2010-01-19 05:38:33 +00:00
|
|
|
/// EmitGlobalVariable - Emit the specified global variable and its
|
2009-08-13 16:37:05 +00:00
|
|
|
/// initializer to the output stream.
|
2010-01-19 05:38:33 +00:00
|
|
|
virtual void EmitGlobalVariable(const GlobalVariable *GV) {
|
2009-08-13 16:37:05 +00:00
|
|
|
// PIC16 doesn't use normal hooks for this.
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PIC16TargetObjectFile *PTOF;
|
|
|
|
PIC16TargetLowering *PTLI;
|
|
|
|
PIC16DbgInfo DbgInfo;
|
2009-08-22 21:43:10 +00:00
|
|
|
const PIC16MCAsmInfo *PMAI;
|
2009-08-13 16:37:05 +00:00
|
|
|
std::list<const char *> LibcallDecls; // List of extern decls.
|
2009-10-15 19:26:25 +00:00
|
|
|
std::vector<const GlobalVariable *> ExternalVarDecls;
|
|
|
|
std::vector<const GlobalVariable *> ExternalVarDefs;
|
2009-08-13 16:37:05 +00:00
|
|
|
};
|
|
|
|
} // end of namespace
|
|
|
|
|
|
|
|
#endif
|