llvm.org GIT mirror llvm / b9ef764
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 Sanjiv Gupta 11 years ago
3 changed file(s) with 59 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
1717
1818 namespace llvm {
1919
20 /// MCSectionPIC16 - Represents a physical section in PIC16 COFF.
21 /// Contains data objects.
22 ///
2023 class MCSectionPIC16 : public MCSection {
24 /// Name of the section to uniquely identify it.
2125 std::string Name;
26
27 /// User can specify an address at which a section should be placed.
28 /// Negative value here means user hasn't specified any.
29 int Address;
30
31 /// FIXME: Keep overlay information here. uncomment the decl below.
32 /// Overlay information - Sections with same color can be overlaid on
33 /// one another.
34 /// std::string Color;
35
36 /// Conatined data objects.
37 std::vectorItems;
38
39 /// Total size of all data objects contained here.
40 unsigned Size;
2241
23 MCSectionPIC16(const StringRef &name, SectionKind K)
24 : MCSection(K), Name(name) {
42 MCSectionPIC16(const StringRef &name, SectionKind K, int addr)
43 : MCSection(K), Name(name), Address(addr) {
2544 }
2645
2746 public:
47 /// Return the name of the section.
48 const std::string &getName() const { return Name; }
49
50 /// Return the Address of the section.
51 int getAddress() const { return Address; }
52
53 /// PIC16 Terminology for section kinds is as below.
54 /// UDATA - BSS
55 /// IDATA - initialized data (equiv to Metadata)
56 /// ROMDATA - ReadOnly.
57 /// UDATA_OVR - Sections that can be overlaid. Section of such type is
58 /// used to contain function autos an frame. We can think of
59 /// it as equiv to llvm ThreadBSS)
60 /// So, let's have some convenience functions to Map PIC16 Section types
61 /// to SectionKind just for the sake of better readability.
62 static SectionKind UDATA_Kind() { return SectionKind::getBSS(); }
63 static SectionKind IDATA_Kind() { return SectionKind::getMetadata(); }
64 static SectionKind ROMDATA_Kind() { return SectionKind::getReadOnly(); }
65 static SectionKind UDATA_OVR_Kind() { return SectionKind::getThreadBSS(); }
66
67 // If we could just do getKind() == UDATA_Kind() ?
68 bool isUDATA_Kind() { return getKind().isBSS(); }
69 bool isIDATA_Kind() { return getKind().isMetadata(); }
70 bool isROMDATA_Kind() { return getKind().isMetadata(); }
71 bool isUDATA_OVR_Kind() { return getKind().isThreadBSS(); }
72
73 /// This would be the only way to create a section.
74 static MCSectionPIC16 *Create(const StringRef &Name, SectionKind K,
75 int Address, MCContext &Ctx);
2876
29 const std::string &getName() const { return Name; }
30
31 static MCSectionPIC16 *Create(const StringRef &Name,
32 SectionKind K, MCContext &Ctx);
33
77 /// Override this as PIC16 has its own way of printing switching
78 /// to a section.
3479 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
3580 raw_ostream &OS) const;
3681 };
1818 using namespace llvm;
1919
2020
21 MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name,
22 SectionKind K, MCContext &Ctx) {
23 return new (Ctx) MCSectionPIC16(Name, K);
21 MCSectionPIC16 *MCSectionPIC16::Create(const StringRef &Name, SectionKind K,
22 int Address, MCContext &Ctx) {
23 return new (Ctx) MCSectionPIC16(Name, K, Address);
2424 }
2525
2626
3737 }
3838
3939 const MCSectionPIC16 *PIC16TargetObjectFile::
40 getPIC16Section(const char *Name, SectionKind Kind) const {
40 getPIC16Section(const char *Name, SectionKind Kind, int Address) const {
4141 MCSectionPIC16 *&Entry = SectionsByName[Name];
4242 if (Entry)
4343 return Entry;
4444
45 return Entry = MCSectionPIC16::Create(Name, Kind, getContext());
45 return Entry = MCSectionPIC16::Create(Name, Kind, Address, getContext());
4646 }
4747
4848
5252 const TargetMachine *TM;
5353
5454 const MCSectionPIC16 *getPIC16Section(const char *Name,
55 SectionKind K) const;
55 SectionKind K,
56 int Address = -1) const;
5657 public:
5758 mutable std::vector BSSSections;
5859 mutable std::vector IDATASections;