1 //===- PIC16Section.h - PIC16-specific section representation -*- 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 // This file declares the PIC16Section class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_PIC16SECTION_H
15 #define LLVM_PIC16SECTION_H
17 #include "llvm/MC/MCSection.h"
18 #include "llvm/GlobalVariable.h"
22 /// PIC16Section - Represents a physical section in PIC16 COFF.
23 /// Contains data objects.
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.
32 /// Name of the section to uniquely identify it.
35 /// User can specify an address at which a section should be placed.
36 /// Negative value here means user hasn't specified any.
39 /// Overlay information - Sections with same color can be overlaid on
43 /// Total size of all data objects contained here.
46 PIC16Section(StringRef name, SectionKind K, StringRef addr, int color)
47 : MCSection(K), Name(name), Address(addr), Color(color), Size(0) {
51 /// Return the name of the section.
52 StringRef getName() const { return Name; }
54 /// Return the Address of the section.
55 StringRef getAddress() const { return Address; }
57 /// Return the Color of the section.
58 int getColor() const { return Color; }
59 void setColor(int color) { Color = color; }
61 /// Return the size of the section.
62 unsigned getSize() const { return Size; }
63 void setSize(unsigned size) { Size = size; }
65 /// Conatined data objects.
66 // FIXME: This vector is leaked because sections are allocated with a
68 std::vector<const GlobalVariable *>Items;
70 /// Check section type.
71 bool isUDATA_Type() const { return T == UDATA; }
72 bool isIDATA_Type() const { return T == IDATA; }
73 bool isROMDATA_Type() const { return T == ROMDATA; }
74 bool isUDATA_OVR_Type() const { return T == UDATA_OVR; }
75 bool isUDATA_SHR_Type() const { return T == UDATA_SHR; }
76 bool isCODE_Type() const { return T == CODE; }
78 PIC16SectionType getType() const { return T; }
80 /// This would be the only way to create a section.
81 static PIC16Section *Create(StringRef Name, PIC16SectionType Ty,
82 StringRef Address, int Color,
85 /// Override this as PIC16 has its own way of printing switching
87 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
88 raw_ostream &OS) const;
91 } // end namespace llvm