1 //=====-- PIC16TargetAsmInfo.h - PIC16 asm properties ---------*- C++ -*--====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the PIC16TargetAsmInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef PIC16TARGETASMINFO_H
15 #define PIC16TARGETASMINFO_H
18 #include "llvm/Target/TargetAsmInfo.h"
20 #include "llvm/Module.h"
24 enum { DataBankSize = 80 };
26 // Forward declaration.
27 class PIC16TargetMachine;
30 /// PIC16 Splits the global data into mulitple udata and idata sections.
31 /// Each udata and idata section needs to contain a list of globals that
32 /// they contain, in order to avoid scanning over all the global values
33 /// again and printing only those that match the current section.
34 /// Keeping values inside the sections make printing a section much easier.
36 const Section *S_; // Connection to actual Section.
37 unsigned Size; // Total size of the objects contained.
39 std::vector<const GlobalVariable*> Items;
41 PIC16Section(const Section *s) {
44 SectionPrinted = false;
46 bool isPrinted() const { return SectionPrinted; }
47 void setPrintedStatus(bool status) { SectionPrinted = status; }
50 struct PIC16TargetAsmInfo : public TargetAsmInfo {
51 std::string getSectionNameForSym(const std::string &Sym) const;
52 PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
53 mutable std::vector<PIC16Section *> BSSSections;
54 mutable std::vector<PIC16Section *> IDATASections;
55 mutable std::vector<PIC16Section *> AutosSections;
56 mutable std::vector<PIC16Section *> ROSections;
57 mutable PIC16Section *ExternalVarDecls;
58 mutable PIC16Section *ExternalVarDefs;
59 virtual ~PIC16TargetAsmInfo();
62 const char *RomData8bitsDirective;
63 const char *RomData16bitsDirective;
64 const char *RomData32bitsDirective;
65 const char *getRomDirective(unsigned size) const;
66 virtual const char *getDataASDirective(unsigned size, unsigned AS) const;
67 const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
68 const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
69 const Section *getSectionForAuto(const GlobalVariable *GV) const;
70 const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV,
71 std::string Addr = "") const;
72 const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV,
73 std::string Addr = "") const;
74 const Section *getROSectionForGlobal(const GlobalVariable *GV) const;
75 const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
76 std::string Addr = "") const;
77 virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
78 const Section *CreateSectionForGlobal(const GlobalVariable *GV,
79 const std::string &Addr = "") const;
81 void SetSectionForGVs(Module &M);
82 const std::vector<PIC16Section*> &getBSSSections() const {
85 const std::vector<PIC16Section*> &getIDATASections() const {
88 const std::vector<PIC16Section*> &getAutosSections() const {
91 const std::vector<PIC16Section*> &getROSections() const {
94 virtual const Section *SectionForGlobal(const GlobalValue *GV) const;