mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-12 01:25:49 +00:00
Start refactoring PIC16 TargetObjectFile code. Eventually, all the stuff from
PIC16Section will move to MCSectionPIC16. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80021 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -18,20 +18,65 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
/// MCSectionPIC16 - Represents a physical section in PIC16 COFF.
|
||||||
|
/// Contains data objects.
|
||||||
|
///
|
||||||
class MCSectionPIC16 : public MCSection {
|
class MCSectionPIC16 : public MCSection {
|
||||||
|
/// Name of the section to uniquely identify it.
|
||||||
std::string Name;
|
std::string Name;
|
||||||
|
|
||||||
|
/// User can specify an address at which a section should be placed.
|
||||||
|
/// Negative value here means user hasn't specified any.
|
||||||
|
int Address;
|
||||||
|
|
||||||
|
/// FIXME: Keep overlay information here. uncomment the decl below.
|
||||||
|
/// Overlay information - Sections with same color can be overlaid on
|
||||||
|
/// one another.
|
||||||
|
/// std::string Color;
|
||||||
|
|
||||||
|
/// Conatined data objects.
|
||||||
|
std::vector<const GlobalVariable *>Items;
|
||||||
|
|
||||||
|
/// Total size of all data objects contained here.
|
||||||
|
unsigned Size;
|
||||||
|
|
||||||
MCSectionPIC16(const StringRef &name, SectionKind K)
|
MCSectionPIC16(const StringRef &name, SectionKind K, int addr)
|
||||||
: MCSection(K), Name(name) {
|
: MCSection(K), Name(name), Address(addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// Return the name of the section.
|
||||||
const std::string &getName() const { return Name; }
|
const std::string &getName() const { return Name; }
|
||||||
|
|
||||||
|
/// Return the Address of the section.
|
||||||
|
int getAddress() const { return Address; }
|
||||||
|
|
||||||
|
/// PIC16 Terminology for section kinds is as below.
|
||||||
|
/// UDATA - BSS
|
||||||
|
/// IDATA - initialized data (equiv to Metadata)
|
||||||
|
/// ROMDATA - ReadOnly.
|
||||||
|
/// UDATA_OVR - Sections that can be overlaid. Section of such type is
|
||||||
|
/// used to contain function autos an frame. We can think of
|
||||||
|
/// it as equiv to llvm ThreadBSS)
|
||||||
|
/// So, let's have some convenience functions to Map PIC16 Section types
|
||||||
|
/// to SectionKind just for the sake of better readability.
|
||||||
|
static SectionKind UDATA_Kind() { return SectionKind::getBSS(); }
|
||||||
|
static SectionKind IDATA_Kind() { return SectionKind::getMetadata(); }
|
||||||
|
static SectionKind ROMDATA_Kind() { return SectionKind::getReadOnly(); }
|
||||||
|
static SectionKind UDATA_OVR_Kind() { return SectionKind::getThreadBSS(); }
|
||||||
|
|
||||||
|
// If we could just do getKind() == UDATA_Kind() ?
|
||||||
|
bool isUDATA_Kind() { return getKind().isBSS(); }
|
||||||
|
bool isIDATA_Kind() { return getKind().isMetadata(); }
|
||||||
|
bool isROMDATA_Kind() { return getKind().isMetadata(); }
|
||||||
|
bool isUDATA_OVR_Kind() { return getKind().isThreadBSS(); }
|
||||||
|
|
||||||
|
/// This would be the only way to create a section.
|
||||||
|
static MCSectionPIC16 *Create(const StringRef &Name, SectionKind K,
|
||||||
|
int Address, MCContext &Ctx);
|
||||||
|
|
||||||
static MCSectionPIC16 *Create(const StringRef &Name,
|
/// Override this as PIC16 has its own way of printing switching
|
||||||
SectionKind K, MCContext &Ctx);
|
/// to a section.
|
||||||
|
|
||||||
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
|
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||||
raw_ostream &OS) const;
|
raw_ostream &OS) const;
|
||||||
};
|
};
|
||||||
|
@@ -19,9 +19,9 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
|
||||||
MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name,
|
MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, SectionKind K,
|
||||||
SectionKind K, MCContext &Ctx) {
|
int Address, MCContext &Ctx) {
|
||||||
return new (Ctx) MCSectionPIC16(Name, K);
|
return new (Ctx) MCSectionPIC16(Name, K, Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -38,12 +38,12 @@ PIC16TargetObjectFile::PIC16TargetObjectFile()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MCSectionPIC16 *PIC16TargetObjectFile::
|
const MCSectionPIC16 *PIC16TargetObjectFile::
|
||||||
getPIC16Section(const char *Name, SectionKind Kind) const {
|
getPIC16Section(const char *Name, SectionKind Kind, int Address) const {
|
||||||
MCSectionPIC16 *&Entry = SectionsByName[Name];
|
MCSectionPIC16 *&Entry = SectionsByName[Name];
|
||||||
if (Entry)
|
if (Entry)
|
||||||
return Entry;
|
return Entry;
|
||||||
|
|
||||||
return Entry = MCSectionPIC16::Create(Name, Kind, getContext());
|
return Entry = MCSectionPIC16::Create(Name, Kind, Address, getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -53,7 +53,8 @@ namespace llvm {
|
|||||||
const TargetMachine *TM;
|
const TargetMachine *TM;
|
||||||
|
|
||||||
const MCSectionPIC16 *getPIC16Section(const char *Name,
|
const MCSectionPIC16 *getPIC16Section(const char *Name,
|
||||||
SectionKind K) const;
|
SectionKind K,
|
||||||
|
int Address = -1) const;
|
||||||
public:
|
public:
|
||||||
mutable std::vector<PIC16Section*> BSSSections;
|
mutable std::vector<PIC16Section*> BSSSections;
|
||||||
mutable std::vector<PIC16Section*> IDATASections;
|
mutable std::vector<PIC16Section*> IDATASections;
|
||||||
|
Reference in New Issue
Block a user