LLVM API Documentation
00001 //===-- PIC16TargetObjectFile.h - PIC16 Object Info -------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H 00011 #define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H 00012 00013 #include "llvm/Target/TargetLoweringObjectFile.h" 00014 #include "llvm/ADT/StringMap.h" 00015 #include <vector> 00016 #include <string> 00017 00018 namespace llvm { 00019 class GlobalVariable; 00020 class Module; 00021 class PIC16TargetMachine; 00022 class MCSectionPIC16; 00023 00024 enum { DataBankSize = 80 }; 00025 00026 /// PIC16 Splits the global data into mulitple udata and idata sections. 00027 /// Each udata and idata section needs to contain a list of globals that 00028 /// they contain, in order to avoid scanning over all the global values 00029 /// again and printing only those that match the current section. 00030 /// Keeping values inside the sections make printing a section much easier. 00031 /// 00032 /// FIXME: MOVE ALL THIS STUFF TO MCSectionPIC16. 00033 /// 00034 struct PIC16Section { 00035 const MCSectionPIC16 *S_; // Connection to actual Section. 00036 unsigned Size; // Total size of the objects contained. 00037 bool SectionPrinted; 00038 std::vector<const GlobalVariable*> Items; 00039 00040 PIC16Section(const MCSectionPIC16 *s) { 00041 S_ = s; 00042 Size = 0; 00043 SectionPrinted = false; 00044 } 00045 bool isPrinted() const { return SectionPrinted; } 00046 void setPrintedStatus(bool status) { SectionPrinted = status; } 00047 }; 00048 00049 class PIC16TargetObjectFile : public TargetLoweringObjectFile { 00050 /// SectionsByName - Bindings of names to allocated sections. 00051 mutable StringMap<MCSectionPIC16*> SectionsByName; 00052 00053 const TargetMachine *TM; 00054 00055 const MCSectionPIC16 *getPIC16Section(const char *Name, 00056 SectionKind K) const; 00057 public: 00058 mutable std::vector<PIC16Section*> BSSSections; 00059 mutable std::vector<PIC16Section*> IDATASections; 00060 mutable std::vector<PIC16Section*> AutosSections; 00061 mutable std::vector<PIC16Section*> ROSections; 00062 mutable PIC16Section *ExternalVarDecls; 00063 mutable PIC16Section *ExternalVarDefs; 00064 00065 PIC16TargetObjectFile(); 00066 ~PIC16TargetObjectFile(); 00067 00068 void Initialize(MCContext &Ctx, const TargetMachine &TM); 00069 00070 00071 virtual const MCSection * 00072 getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 00073 Mangler *Mang, const TargetMachine &TM) const; 00074 00075 virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV, 00076 SectionKind Kind, 00077 Mangler *Mang, 00078 const TargetMachine&) const; 00079 00080 const MCSection *getSectionForFunction(const std::string &FnName) const; 00081 const MCSection *getSectionForFunctionFrame(const std::string &FnName)const; 00082 00083 00084 private: 00085 std::string getSectionNameForSym(const std::string &Sym) const; 00086 00087 const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const; 00088 const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const; 00089 const MCSection *getSectionForAuto(const GlobalVariable *GV) const; 00090 const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV, 00091 std::string Addr = "") const; 00092 const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV, 00093 std::string Addr = "") const; 00094 const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const; 00095 const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV, 00096 std::string Addr = "") const; 00097 const MCSection *CreateSectionForGlobal(const GlobalVariable *GV, 00098 Mangler *Mang, 00099 const std::string &Addr = "") const; 00100 public: 00101 void SetSectionForGVs(Module &M); 00102 const std::vector<PIC16Section*> &getBSSSections() const { 00103 return BSSSections; 00104 } 00105 const std::vector<PIC16Section*> &getIDATASections() const { 00106 return IDATASections; 00107 } 00108 const std::vector<PIC16Section*> &getAutosSections() const { 00109 return AutosSections; 00110 } 00111 const std::vector<PIC16Section*> &getROSections() const { 00112 return ROSections; 00113 } 00114 00115 }; 00116 } // end namespace llvm 00117 00118 #endif