blob: 350afb6e91d3fad9820d9fa0e03ca655476a9483 [file] [log] [blame]
Benjamin Kramer5814fef2009-10-15 19:46:34 +00001//===- 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
21namespace 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.
Benjamin Kramer91b1d8f2010-03-30 13:28:42 +000033 StringRef Name;
Benjamin Kramer5814fef2009-10-15 19:46:34 +000034
35 /// User can specify an address at which a section should be placed.
36 /// Negative value here means user hasn't specified any.
Benjamin Kramer91b1d8f2010-03-30 13:28:42 +000037 StringRef Address;
Benjamin Kramer5814fef2009-10-15 19:46:34 +000038
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
Benjamin Kramer91b1d8f2010-03-30 13:28:42 +000046 PIC16Section(StringRef name, SectionKind K, StringRef addr, int color)
Benjamin Kramere5636a32010-03-17 19:55:31 +000047 : MCSection(K), Name(name), Address(addr), Color(color), Size(0) {
Benjamin Kramer5814fef2009-10-15 19:46:34 +000048 }
49
50 public:
51 /// Return the name of the section.
Benjamin Kramer91b1d8f2010-03-30 13:28:42 +000052 StringRef getName() const { return Name; }
Benjamin Kramer5814fef2009-10-15 19:46:34 +000053
54 /// Return the Address of the section.
Benjamin Kramer91b1d8f2010-03-30 13:28:42 +000055 StringRef getAddress() const { return Address; }
Benjamin Kramer5814fef2009-10-15 19:46:34 +000056
57 /// Return the Color of the section.
58 int getColor() const { return Color; }
Sanjiv Gupta4e4bba52009-10-21 10:42:44 +000059 void setColor(int color) { Color = color; }
Benjamin Kramer5814fef2009-10-15 19:46:34 +000060
61 /// Return the size of the section.
62 unsigned getSize() const { return Size; }
63 void setSize(unsigned size) { Size = size; }
64
65 /// Conatined data objects.
66 std::vector<const GlobalVariable *>Items;
67
68 /// Check section type.
69 bool isUDATA_Type() const { return T == UDATA; }
70 bool isIDATA_Type() const { return T == IDATA; }
71 bool isROMDATA_Type() const { return T == ROMDATA; }
72 bool isUDATA_OVR_Type() const { return T == UDATA_OVR; }
73 bool isUDATA_SHR_Type() const { return T == UDATA_SHR; }
74 bool isCODE_Type() const { return T == CODE; }
75
76 PIC16SectionType getType() const { return T; }
77
78 /// This would be the only way to create a section.
Benjamin Kramer91b1d8f2010-03-30 13:28:42 +000079 static PIC16Section *Create(StringRef Name, PIC16SectionType Ty,
80 StringRef Address, int Color,
Benjamin Kramer5814fef2009-10-15 19:46:34 +000081 MCContext &Ctx);
82
83 /// Override this as PIC16 has its own way of printing switching
84 /// to a section.
85 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
86 raw_ostream &OS) const;
87 };
88
89} // end namespace llvm
90
91#endif