1 //===-- PIC16TargetObjectFile.h - PIC16 Object Info -------------*- 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 #ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
11 #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
13 #include "llvm/Target/TargetLoweringObjectFile.h"
14 #include "llvm/ADT/StringMap.h"
21 class PIC16TargetMachine;
24 enum { DataBankSize = 80 };
26 /// PIC16 Splits the global data into mulitple udata and idata sections.
27 /// Each udata and idata section needs to contain a list of globals that
28 /// they contain, in order to avoid scanning over all the global values
29 /// again and printing only those that match the current section.
30 /// Keeping values inside the sections make printing a section much easier.
32 /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16.
35 const MCSectionPIC16 *S_; // Connection to actual Section.
36 unsigned Size; // Total size of the objects contained.
38 std::vector<const GlobalVariable*> Items;
40 PIC16Section(const MCSectionPIC16 *s) {
43 SectionPrinted = false;
45 bool isPrinted() const { return SectionPrinted; }
46 void setPrintedStatus(bool status) { SectionPrinted = status; }
49 class PIC16TargetObjectFile : public TargetLoweringObjectFile {
50 /// SectionsByName - Bindings of names to allocated sections.
51 mutable StringMap<MCSectionPIC16*> SectionsByName;
53 const TargetMachine *TM;
55 const MCSectionPIC16 *getPIC16Section(const char *Name,
58 int Color = -1) const;
60 mutable std::vector<PIC16Section*> BSSSections;
61 mutable std::vector<PIC16Section*> IDATASections;
62 mutable std::vector<PIC16Section*> AutosSections;
63 mutable std::vector<PIC16Section*> ROSections;
64 mutable PIC16Section *ExternalVarDecls;
65 mutable PIC16Section *ExternalVarDefs;
67 PIC16TargetObjectFile();
68 ~PIC16TargetObjectFile();
70 void Initialize(MCContext &Ctx, const TargetMachine &TM);
73 virtual const MCSection *
74 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
75 Mangler *Mang, const TargetMachine &TM) const;
77 virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
80 const TargetMachine&) const;
82 const MCSection *getSectionForFunction(const std::string &FnName) const;
83 const MCSection *getSectionForFunctionFrame(const std::string &FnName)const;
87 std::string getSectionNameForSym(const std::string &Sym) const;
89 const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const;
90 const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const;
91 const MCSection *getSectionForAuto(const GlobalVariable *GV) const;
92 const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV,
93 std::string Addr = "") const;
94 const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV,
95 std::string Addr = "") const;
96 const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const;
97 const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV,
98 std::string Addr = "") const;
99 const MCSection *CreateSectionForGlobal(const GlobalVariable *GV,
101 const std::string &Addr = "") const;
103 void SetSectionForGVs(Module &M);
104 const std::vector<PIC16Section*> &getBSSSections() const {
107 const std::vector<PIC16Section*> &getIDATASections() const {
108 return IDATASections;
110 const std::vector<PIC16Section*> &getAutosSections() const {
111 return AutosSections;
113 const std::vector<PIC16Section*> &getROSections() const {
118 } // end namespace llvm