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"
15 #include "llvm/Function.h"
22 class PIC16TargetMachine;
25 enum { DataBankSize = 80 };
27 /// PIC16 Splits the global data into mulitple udata and idata sections.
28 /// Each udata and idata section needs to contain a list of globals that
29 /// they contain, in order to avoid scanning over all the global values
30 /// again and printing only those that match the current section.
31 /// Keeping values inside the sections make printing a section much easier.
33 /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16.
36 const MCSectionPIC16 *S_; // Connection to actual Section.
37 unsigned Size; // Total size of the objects contained.
39 std::vector<const GlobalVariable*> Items;
41 PIC16Section(const MCSectionPIC16 *s) {
44 SectionPrinted = false;
46 bool isPrinted() const { return SectionPrinted; }
47 void setPrintedStatus(bool status) { SectionPrinted = status; }
50 class PIC16TargetObjectFile : public TargetLoweringObjectFile {
51 /// SectionsByName - Bindings of names to allocated sections.
52 mutable StringMap<MCSectionPIC16*> SectionsByName;
54 const TargetMachine *TM;
56 const MCSectionPIC16 *getPIC16Section(const char *Name,
59 mutable std::vector<PIC16Section*> BSSSections;
60 mutable std::vector<PIC16Section*> IDATASections;
61 mutable std::vector<PIC16Section*> AutosSections;
62 mutable std::vector<PIC16Section*> ROSections;
63 mutable PIC16Section *ExternalVarDecls;
64 mutable PIC16Section *ExternalVarDefs;
66 PIC16TargetObjectFile();
67 ~PIC16TargetObjectFile();
69 void Initialize(MCContext &Ctx, const TargetMachine &TM);
72 virtual const MCSection *
73 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
74 Mangler *Mang, const TargetMachine &TM) const;
76 virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
79 const TargetMachine&) const;
81 const MCSection *getSectionForFunction(const std::string &FnName,
82 bool isInterrupt=false) const;
83 const MCSection *getSectionForFunctionFrame(const std::string &FnName)const;
85 // If the current function is cloned then create the new autos section
87 void createClonedSectionForAutos(const std::string &SecName);
88 std::string getNameForFunctFrame(const Function *F,
89 bool IsAutosSection = false);
92 std::string getSectionNameForSym(const std::string &Sym) const;
94 const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const;
95 const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const;
96 const MCSection *getSectionForAuto(const GlobalVariable *GV) const;
97 const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV,
98 std::string Addr = "") const;
99 const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV,
100 std::string Addr = "") const;
101 const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const;
102 const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV,
103 std::string Addr = "") const;
104 const MCSection *CreateSectionForGlobal(const GlobalVariable *GV,
106 const std::string &Addr = "") const;
108 void SetSectionForGVs(Module &M);
109 const std::vector<PIC16Section*> &getBSSSections() const {
112 const std::vector<PIC16Section*> &getIDATASections() const {
113 return IDATASections;
115 const std::vector<PIC16Section*> &getAutosSections() const {
116 return AutosSections;
118 const std::vector<PIC16Section*> &getROSections() const {
123 } // end namespace llvm