Fix TableGen warnings. This partly reverts my previous change to this file,
[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   class MCSectionPIC16;
21   
22   enum { DataBankSize = 80 };
23
24   /// PIC16 Splits the global data into mulitple udata and idata sections.
25   /// Each udata and idata section needs to contain a list of globals that
26   /// they contain, in order to avoid scanning over all the global values 
27   /// again and printing only those that match the current section. 
28   /// Keeping values inside the sections make printing a section much easier.
29   ///
30   /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16.
31   ///
32   struct PIC16Section {
33     const MCSectionPIC16 *S_; // Connection to actual Section.
34     unsigned Size;  // Total size of the objects contained.
35     bool SectionPrinted;
36     std::vector<const GlobalVariable*> Items;
37     
38     PIC16Section(const MCSectionPIC16 *s) {
39       S_ = s;
40       Size = 0;
41       SectionPrinted = false;
42     }
43     bool isPrinted() const { return SectionPrinted; }
44     void setPrintedStatus(bool status) { SectionPrinted = status; } 
45   };
46   
47   class PIC16TargetObjectFile : public TargetLoweringObjectFile {
48     const TargetMachine *TM;
49     
50     const MCSectionPIC16 *getPIC16Section(const char *Name,
51                                           SectionKind K) const;
52   public:
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
60     PIC16TargetObjectFile();
61     ~PIC16TargetObjectFile();
62     
63     void Initialize(MCContext &Ctx, const TargetMachine &TM);
64
65     
66     virtual const MCSection *
67     getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 
68                              Mangler *Mang, const TargetMachine &TM) const;
69     
70     virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
71                                                     SectionKind Kind,
72                                                     Mangler *Mang,
73                                                     const TargetMachine&) const;
74
75     const MCSection *getSectionForFunction(const std::string &FnName) const;
76     const MCSection *getSectionForFunctionFrame(const std::string &FnName)const;
77     
78     
79   private:
80     std::string getSectionNameForSym(const std::string &Sym) const;
81
82     const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const;
83     const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const;
84     const MCSection *getSectionForAuto(const GlobalVariable *GV) const;
85     const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV,
86                                                std::string Addr = "") const;
87     const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV,
88                                                  std::string Addr = "") const;
89     const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const;
90     const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV,
91                                               std::string Addr = "") const;
92     const MCSection *CreateSectionForGlobal(const GlobalVariable *GV,
93                                             Mangler *Mang,
94                                             const std::string &Addr = "") const;
95   public:
96     void SetSectionForGVs(Module &M);
97     const std::vector<PIC16Section*> &getBSSSections() const {
98       return BSSSections;
99     }
100     const std::vector<PIC16Section*> &getIDATASections() const {
101       return IDATASections;
102     }
103     const std::vector<PIC16Section*> &getAutosSections() const {
104       return AutosSections;
105     }
106     const std::vector<PIC16Section*> &getROSections() const {
107       return ROSections;
108     }
109     
110   };
111 } // end namespace llvm
112
113 #endif