2009-10-15 19:46:34 +00:00
|
|
|
//===- PIC16Section.h - PIC16-specific section representation -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares the PIC16Section class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_PIC16SECTION_H
|
|
|
|
#define LLVM_PIC16SECTION_H
|
|
|
|
|
|
|
|
#include "llvm/MC/MCSection.h"
|
|
|
|
#include "llvm/GlobalVariable.h"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
/// PIC16Section - Represents a physical section in PIC16 COFF.
|
|
|
|
/// Contains data objects.
|
|
|
|
///
|
|
|
|
class PIC16Section : public MCSection {
|
|
|
|
/// PIC16 Sections does not really use the SectionKind class to
|
|
|
|
/// to distinguish between various types of sections. PIC16 maintain
|
|
|
|
/// its own Section Type info. See the PIC16SectionType enum in PIC16.h
|
|
|
|
/// for various section types.
|
|
|
|
PIC16SectionType T;
|
|
|
|
|
|
|
|
/// Name of the section to uniquely identify it.
|
2010-03-30 13:28:42 +00:00
|
|
|
StringRef Name;
|
2009-10-15 19:46:34 +00:00
|
|
|
|
|
|
|
/// User can specify an address at which a section should be placed.
|
|
|
|
/// Negative value here means user hasn't specified any.
|
2010-03-30 13:28:42 +00:00
|
|
|
StringRef Address;
|
2009-10-15 19:46:34 +00:00
|
|
|
|
|
|
|
/// Overlay information - Sections with same color can be overlaid on
|
|
|
|
/// one another.
|
|
|
|
int Color;
|
|
|
|
|
|
|
|
/// Total size of all data objects contained here.
|
|
|
|
unsigned Size;
|
|
|
|
|
2010-03-30 13:28:42 +00:00
|
|
|
PIC16Section(StringRef name, SectionKind K, StringRef addr, int color)
|
2010-05-17 21:54:26 +00:00
|
|
|
: MCSection(SV_PIC16, K), Name(name), Address(addr),
|
|
|
|
Color(color), Size(0) {
|
2009-10-15 19:46:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Return the name of the section.
|
2010-03-30 13:28:42 +00:00
|
|
|
StringRef getName() const { return Name; }
|
2009-10-15 19:46:34 +00:00
|
|
|
|
|
|
|
/// Return the Address of the section.
|
2010-03-30 13:28:42 +00:00
|
|
|
StringRef getAddress() const { return Address; }
|
2009-10-15 19:46:34 +00:00
|
|
|
|
|
|
|
/// Return the Color of the section.
|
|
|
|
int getColor() const { return Color; }
|
2009-10-21 10:42:44 +00:00
|
|
|
void setColor(int color) { Color = color; }
|
2009-10-15 19:46:34 +00:00
|
|
|
|
|
|
|
/// Return the size of the section.
|
|
|
|
unsigned getSize() const { return Size; }
|
|
|
|
void setSize(unsigned size) { Size = size; }
|
|
|
|
|
|
|
|
/// Conatined data objects.
|
2010-03-30 14:34:13 +00:00
|
|
|
// FIXME: This vector is leaked because sections are allocated with a
|
|
|
|
// BumpPtrAllocator.
|
2009-10-15 19:46:34 +00:00
|
|
|
std::vector<const GlobalVariable *>Items;
|
|
|
|
|
|
|
|
/// Check section type.
|
|
|
|
bool isUDATA_Type() const { return T == UDATA; }
|
|
|
|
bool isIDATA_Type() const { return T == IDATA; }
|
|
|
|
bool isROMDATA_Type() const { return T == ROMDATA; }
|
|
|
|
bool isUDATA_OVR_Type() const { return T == UDATA_OVR; }
|
|
|
|
bool isUDATA_SHR_Type() const { return T == UDATA_SHR; }
|
|
|
|
bool isCODE_Type() const { return T == CODE; }
|
|
|
|
|
|
|
|
PIC16SectionType getType() const { return T; }
|
|
|
|
|
|
|
|
/// This would be the only way to create a section.
|
2010-03-30 13:28:42 +00:00
|
|
|
static PIC16Section *Create(StringRef Name, PIC16SectionType Ty,
|
|
|
|
StringRef Address, int Color,
|
2009-10-15 19:46:34 +00:00
|
|
|
MCContext &Ctx);
|
|
|
|
|
|
|
|
/// Override this as PIC16 has its own way of printing switching
|
|
|
|
/// to a section.
|
|
|
|
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
|
|
|
|
raw_ostream &OS) const;
|
2010-05-17 21:54:26 +00:00
|
|
|
|
|
|
|
static bool classof(const MCSection *S) {
|
|
|
|
return S->getVariant() == SV_PIC16;
|
|
|
|
}
|
|
|
|
static bool classof(const PIC16Section *) { return true; }
|
2009-10-15 19:46:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|