pass the mangler down into the various SectionForGlobal methods.
[oota-llvm.git] / lib / Target / PIC16 / PIC16TargetObjectFile.h
1 //===-- PIC16TargetObjectFile.h - PIC16 Object Info -------------*- C++ -*-===//
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 #ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
11 #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
12
13 #include "llvm/Target/TargetLoweringObjectFile.h"
14 #include <vector>
15
16 namespace llvm {
17   class GlobalVariable;
18   class Module;
19   class PIC16TargetMachine;
20   
21   enum { DataBankSize = 80 };
22
23   /// PIC16 Splits the global data into mulitple udata and idata sections.
24   /// Each udata and idata section needs to contain a list of globals that
25   /// they contain, in order to avoid scanning over all the global values 
26   /// again and printing only those that match the current section. 
27   /// Keeping values inside the sections make printing a section much easier.
28   ///
29   /// FIXME: Reimplement by inheriting from MCSection.
30   ///
31   struct PIC16Section {
32     const Section *S_; // Connection to actual Section.
33     unsigned Size;  // Total size of the objects contained.
34     bool SectionPrinted;
35     std::vector<const GlobalVariable*> Items;
36     
37     PIC16Section(const Section *s) {
38       S_ = s;
39       Size = 0;
40       SectionPrinted = false;
41     }
42     bool isPrinted() const { return SectionPrinted; }
43     void setPrintedStatus(bool status) { SectionPrinted = status; } 
44   };
45   
46   class PIC16TargetObjectFile : public TargetLoweringObjectFile {
47     const PIC16TargetMachine &TM;
48   public:
49     mutable std::vector<PIC16Section*> BSSSections;
50     mutable std::vector<PIC16Section*> IDATASections;
51     mutable std::vector<PIC16Section*> AutosSections;
52     mutable std::vector<PIC16Section*> ROSections;
53     mutable PIC16Section *ExternalVarDecls;
54     mutable PIC16Section *ExternalVarDefs;
55     
56     PIC16TargetObjectFile(const PIC16TargetMachine &TM);
57     ~PIC16TargetObjectFile();
58     
59     /// getSpecialCasedSectionGlobals - Allow the target to completely override
60     /// section assignment of a global.
61     virtual const Section *
62     getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
63                                   SectionKind Kind) const;
64     virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
65                                                   SectionKind Kind,
66                                                   Mangler *Mang,
67                                                   const TargetMachine&) const;
68   private:
69     std::string getSectionNameForSym(const std::string &Sym) const;
70
71     const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
72     const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
73     const Section *getSectionForAuto(const GlobalVariable *GV) const;
74     const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV,
75                                              std::string Addr = "") const;
76     const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV,
77                                                std::string Addr = "") const;
78     const Section *getROSectionForGlobal(const GlobalVariable *GV) const;
79     const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
80                                             std::string Addr = "") const;
81     const Section *CreateSectionForGlobal(const GlobalVariable *GV,
82                                           Mangler *Mang,
83                                           const std::string &Addr = "") const;
84   public:
85     void SetSectionForGVs(Module &M);
86     const std::vector<PIC16Section*> &getBSSSections() const {
87       return BSSSections;
88     }
89     const std::vector<PIC16Section*> &getIDATASections() const {
90       return IDATASections;
91     }
92     const std::vector<PIC16Section*> &getAutosSections() const {
93       return AutosSections;
94     }
95     const std::vector<PIC16Section*> &getROSections() const {
96       return ROSections;
97     }
98     
99   };
100 } // end namespace llvm
101
102 #endif