Chris Lattner | ad27d77 | 2009-08-15 06:14:07 +0000 | [diff] [blame] | 1 | //===- MCSectionPIC16.h - PIC16-specific section representation -*- C++ -*-===// |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 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 | // |
Chris Lattner | ad27d77 | 2009-08-15 06:14:07 +0000 | [diff] [blame] | 10 | // This file declares the MCSectionPIC16 class. |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_PIC16SECTION_H |
| 15 | #define LLVM_PIC16SECTION_H |
| 16 | |
| 17 | #include "llvm/MC/MCSection.h" |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
| 20 | |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 21 | /// MCSectionPIC16 - Represents a physical section in PIC16 COFF. |
| 22 | /// Contains data objects. |
| 23 | /// |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 24 | class MCSectionPIC16 : public MCSection { |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 25 | /// Name of the section to uniquely identify it. |
Chris Lattner | 93b6db3 | 2009-08-08 23:39:42 +0000 | [diff] [blame] | 26 | std::string Name; |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 27 | |
| 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 | |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 32 | /// Overlay information - Sections with same color can be overlaid on |
| 33 | /// one another. |
Sanjiv Gupta | 72f9ab0 | 2009-09-01 10:47:31 +0000 | [diff] [blame] | 34 | int Color; |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 35 | |
| 36 | /// Conatined data objects. |
| 37 | std::vector<const GlobalVariable *>Items; |
| 38 | |
| 39 | /// Total size of all data objects contained here. |
| 40 | unsigned Size; |
Chris Lattner | 93b6db3 | 2009-08-08 23:39:42 +0000 | [diff] [blame] | 41 | |
Sanjiv Gupta | 72f9ab0 | 2009-09-01 10:47:31 +0000 | [diff] [blame] | 42 | MCSectionPIC16(const StringRef &name, SectionKind K, int addr, int color) |
| 43 | : MCSection(K), Name(name), Address(addr), Color(color) { |
Chris Lattner | 873bc4c | 2009-08-13 00:26:52 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 46 | public: |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 47 | /// Return the name of the section. |
Chris Lattner | 93b6db3 | 2009-08-08 23:39:42 +0000 | [diff] [blame] | 48 | const std::string &getName() const { return Name; } |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 49 | |
| 50 | /// Return the Address of the section. |
| 51 | int getAddress() const { return Address; } |
| 52 | |
Sanjiv Gupta | 72f9ab0 | 2009-09-01 10:47:31 +0000 | [diff] [blame] | 53 | /// Return the Color of the section. |
| 54 | int getColor() const { return Color; } |
| 55 | |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 56 | /// PIC16 Terminology for section kinds is as below. |
| 57 | /// UDATA - BSS |
| 58 | /// IDATA - initialized data (equiv to Metadata) |
| 59 | /// ROMDATA - ReadOnly. |
| 60 | /// UDATA_OVR - Sections that can be overlaid. Section of such type is |
| 61 | /// used to contain function autos an frame. We can think of |
| 62 | /// it as equiv to llvm ThreadBSS) |
| 63 | /// So, let's have some convenience functions to Map PIC16 Section types |
| 64 | /// to SectionKind just for the sake of better readability. |
| 65 | static SectionKind UDATA_Kind() { return SectionKind::getBSS(); } |
| 66 | static SectionKind IDATA_Kind() { return SectionKind::getMetadata(); } |
| 67 | static SectionKind ROMDATA_Kind() { return SectionKind::getReadOnly(); } |
| 68 | static SectionKind UDATA_OVR_Kind() { return SectionKind::getThreadBSS(); } |
| 69 | |
| 70 | // If we could just do getKind() == UDATA_Kind() ? |
| 71 | bool isUDATA_Kind() { return getKind().isBSS(); } |
| 72 | bool isIDATA_Kind() { return getKind().isMetadata(); } |
| 73 | bool isROMDATA_Kind() { return getKind().isMetadata(); } |
| 74 | bool isUDATA_OVR_Kind() { return getKind().isThreadBSS(); } |
| 75 | |
| 76 | /// This would be the only way to create a section. |
| 77 | static MCSectionPIC16 *Create(const StringRef &Name, SectionKind K, |
Sanjiv Gupta | 72f9ab0 | 2009-09-01 10:47:31 +0000 | [diff] [blame] | 78 | int Address, int Color, MCContext &Ctx); |
Chris Lattner | ec3579f | 2009-08-21 23:08:09 +0000 | [diff] [blame] | 79 | |
Sanjiv Gupta | b9ef764 | 2009-08-25 19:39:05 +0000 | [diff] [blame] | 80 | /// Override this as PIC16 has its own way of printing switching |
| 81 | /// to a section. |
Chris Lattner | 33adcfb | 2009-08-22 21:43:10 +0000 | [diff] [blame] | 82 | virtual void PrintSwitchToSection(const MCAsmInfo &MAI, |
Chris Lattner | 93b6db3 | 2009-08-08 23:39:42 +0000 | [diff] [blame] | 83 | raw_ostream &OS) const; |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 84 | }; |
Chris Lattner | f7427e5 | 2009-08-08 21:37:01 +0000 | [diff] [blame] | 85 | |
| 86 | } // end namespace llvm |
| 87 | |
| 88 | #endif |