blob: 3ae432e96852a00d18bcfd04353c5ced6365fccd [file] [log] [blame]
Chris Lattnerad27d772009-08-15 06:14:07 +00001//===- MCSectionPIC16.h - PIC16-specific section representation -*- C++ -*-===//
Chris Lattnerf7427e52009-08-08 21:37:01 +00002//
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//
Chris Lattnerad27d772009-08-15 06:14:07 +000010// This file declares the MCSectionPIC16 class.
Chris Lattnerf7427e52009-08-08 21:37:01 +000011//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_PIC16SECTION_H
15#define LLVM_PIC16SECTION_H
16
17#include "llvm/MC/MCSection.h"
Chris Lattnerf7427e52009-08-08 21:37:01 +000018
19namespace llvm {
20
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000021 /// MCSectionPIC16 - Represents a physical section in PIC16 COFF.
22 /// Contains data objects.
23 ///
Chris Lattnerf7427e52009-08-08 21:37:01 +000024 class MCSectionPIC16 : public MCSection {
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000025 /// Name of the section to uniquely identify it.
Chris Lattner93b6db32009-08-08 23:39:42 +000026 std::string Name;
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000027
28 /// User can specify an address at which a section should be placed.
29 /// Negative value here means user hasn't specified any.
30 int Address;
31
32 /// FIXME: Keep overlay information here. uncomment the decl below.
33 /// Overlay information - Sections with same color can be overlaid on
34 /// one another.
35 /// std::string Color;
36
37 /// Conatined data objects.
38 std::vector<const GlobalVariable *>Items;
39
40 /// Total size of all data objects contained here.
41 unsigned Size;
Chris Lattner93b6db32009-08-08 23:39:42 +000042
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000043 MCSectionPIC16(const StringRef &name, SectionKind K, int addr)
44 : MCSection(K), Name(name), Address(addr) {
Chris Lattner873bc4c2009-08-13 00:26:52 +000045 }
46
Chris Lattnerf7427e52009-08-08 21:37:01 +000047 public:
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000048 /// Return the name of the section.
Chris Lattner93b6db32009-08-08 23:39:42 +000049 const std::string &getName() const { return Name; }
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000050
51 /// Return the Address of the section.
52 int getAddress() const { return Address; }
53
54 /// PIC16 Terminology for section kinds is as below.
55 /// UDATA - BSS
56 /// IDATA - initialized data (equiv to Metadata)
57 /// ROMDATA - ReadOnly.
58 /// UDATA_OVR - Sections that can be overlaid. Section of such type is
59 /// used to contain function autos an frame. We can think of
60 /// it as equiv to llvm ThreadBSS)
61 /// So, let's have some convenience functions to Map PIC16 Section types
62 /// to SectionKind just for the sake of better readability.
63 static SectionKind UDATA_Kind() { return SectionKind::getBSS(); }
64 static SectionKind IDATA_Kind() { return SectionKind::getMetadata(); }
65 static SectionKind ROMDATA_Kind() { return SectionKind::getReadOnly(); }
66 static SectionKind UDATA_OVR_Kind() { return SectionKind::getThreadBSS(); }
67
68 // If we could just do getKind() == UDATA_Kind() ?
69 bool isUDATA_Kind() { return getKind().isBSS(); }
70 bool isIDATA_Kind() { return getKind().isMetadata(); }
71 bool isROMDATA_Kind() { return getKind().isMetadata(); }
72 bool isUDATA_OVR_Kind() { return getKind().isThreadBSS(); }
73
74 /// This would be the only way to create a section.
75 static MCSectionPIC16 *Create(const StringRef &Name, SectionKind K,
76 int Address, MCContext &Ctx);
Chris Lattnerec3579f2009-08-21 23:08:09 +000077
Sanjiv Guptab9ef7642009-08-25 19:39:05 +000078 /// Override this as PIC16 has its own way of printing switching
79 /// to a section.
Chris Lattner33adcfb2009-08-22 21:43:10 +000080 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
Chris Lattner93b6db32009-08-08 23:39:42 +000081 raw_ostream &OS) const;
Chris Lattnerf7427e52009-08-08 21:37:01 +000082 };
Chris Lattnerf7427e52009-08-08 21:37:01 +000083
84} // end namespace llvm
85
86#endif