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"
19 class PIC16TargetMachine;
21 enum { DataBankSize = 80 };
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.
29 /// FIXME: Reimplement by inheriting from MCSection.
32 const MCSection *S_; // Connection to actual Section.
33 unsigned Size; // Total size of the objects contained.
35 std::vector<const GlobalVariable*> Items;
37 PIC16Section(const MCSection *s) {
40 SectionPrinted = false;
42 bool isPrinted() const { return SectionPrinted; }
43 void setPrintedStatus(bool status) { SectionPrinted = status; }
46 class PIC16TargetObjectFile : public TargetLoweringObjectFile {
47 const TargetMachine *TM;
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;
56 PIC16TargetObjectFile();
57 ~PIC16TargetObjectFile();
59 void Initialize(MCContext &Ctx, const TargetMachine &TM);
62 /// getSpecialCasedSectionGlobals - Allow the target to completely override
63 /// section assignment of a global.
64 virtual const MCSection *
65 getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
66 SectionKind Kind) const;
68 virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
71 const TargetMachine&) const;
73 const MCSection *getSectionForFunction(const std::string &FnName) const;
74 const MCSection *getSectionForFunctionFrame(const std::string &FnName)const;
78 std::string getSectionNameForSym(const std::string &Sym) const;
80 const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const;
81 const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const;
82 const MCSection *getSectionForAuto(const GlobalVariable *GV) const;
83 const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV,
84 std::string Addr = "") const;
85 const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV,
86 std::string Addr = "") const;
87 const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const;
88 const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV,
89 std::string Addr = "") const;
90 const MCSection *CreateSectionForGlobal(const GlobalVariable *GV,
92 const std::string &Addr = "") const;
94 void SetSectionForGVs(Module &M);
95 const std::vector<PIC16Section*> &getBSSSections() const {
98 const std::vector<PIC16Section*> &getIDATASections() const {
101 const std::vector<PIC16Section*> &getAutosSections() const {
102 return AutosSections;
104 const std::vector<PIC16Section*> &getROSections() const {
109 } // end namespace llvm