Benjamin Kramer | e62d85d | 2009-10-15 19:46:34 +0000 | [diff] [blame] | 1 | //===- PIC16Section.h - PIC16-specific section representation -*- 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 | // This file declares the PIC16Section class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_PIC16SECTION_H |
| 15 | #define LLVM_PIC16SECTION_H |
| 16 | |
| 17 | #include "llvm/MC/MCSection.h" |
| 18 | #include "llvm/GlobalVariable.h" |
| 19 | #include <vector> |
| 20 | |
| 21 | namespace llvm { |
| 22 | /// PIC16Section - Represents a physical section in PIC16 COFF. |
| 23 | /// Contains data objects. |
| 24 | /// |
| 25 | class PIC16Section : public MCSection { |
| 26 | /// PIC16 Sections does not really use the SectionKind class to |
| 27 | /// to distinguish between various types of sections. PIC16 maintain |
| 28 | /// its own Section Type info. See the PIC16SectionType enum in PIC16.h |
| 29 | /// for various section types. |
| 30 | PIC16SectionType T; |
| 31 | |
| 32 | /// Name of the section to uniquely identify it. |
| 33 | std::string Name; |
| 34 | |
| 35 | /// User can specify an address at which a section should be placed. |
| 36 | /// Negative value here means user hasn't specified any. |
| 37 | std::string Address; |
| 38 | |
| 39 | /// Overlay information - Sections with same color can be overlaid on |
| 40 | /// one another. |
| 41 | int Color; |
| 42 | |
| 43 | /// Total size of all data objects contained here. |
| 44 | unsigned Size; |
| 45 | |
| 46 | PIC16Section(const StringRef &name, SectionKind K, const std::string &addr, |
| 47 | int color) |
| 48 | : MCSection(K), Name(name), Address(addr), Color(color) { |
| 49 | } |
| 50 | |
| 51 | public: |
| 52 | /// Return the name of the section. |
| 53 | const std::string &getName() const { return Name; } |
| 54 | |
| 55 | /// Return the Address of the section. |
| 56 | const std::string &getAddress() const { return Address; } |
| 57 | |
| 58 | /// Return the Color of the section. |
| 59 | int getColor() const { return Color; } |
Sanjiv Gupta | 00e8f5a | 2009-10-21 10:42:44 +0000 | [diff] [blame] | 60 | void setColor(int color) { Color = color; } |
Benjamin Kramer | e62d85d | 2009-10-15 19:46:34 +0000 | [diff] [blame] | 61 | |
| 62 | /// Return the size of the section. |
| 63 | unsigned getSize() const { return Size; } |
| 64 | void setSize(unsigned size) { Size = size; } |
| 65 | |
| 66 | /// Conatined data objects. |
| 67 | std::vector<const GlobalVariable *>Items; |
| 68 | |
| 69 | /// Check section type. |
| 70 | bool isUDATA_Type() const { return T == UDATA; } |
| 71 | bool isIDATA_Type() const { return T == IDATA; } |
| 72 | bool isROMDATA_Type() const { return T == ROMDATA; } |
| 73 | bool isUDATA_OVR_Type() const { return T == UDATA_OVR; } |
| 74 | bool isUDATA_SHR_Type() const { return T == UDATA_SHR; } |
| 75 | bool isCODE_Type() const { return T == CODE; } |
| 76 | |
| 77 | PIC16SectionType getType() const { return T; } |
| 78 | |
| 79 | /// This would be the only way to create a section. |
| 80 | static PIC16Section *Create(const StringRef &Name, PIC16SectionType Ty, |
| 81 | const std::string &Address, int Color, |
| 82 | MCContext &Ctx); |
| 83 | |
| 84 | /// Override this as PIC16 has its own way of printing switching |
| 85 | /// to a section. |
| 86 | virtual void PrintSwitchToSection(const MCAsmInfo &MAI, |
| 87 | raw_ostream &OS) const; |
| 88 | }; |
| 89 | |
| 90 | } // end namespace llvm |
| 91 | |
| 92 | #endif |