mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 02:33:33 +00:00
968ff11967
should have no state that is specific to particular globals in the section. In this case, it means the removal of the "isWeak" and "ExplicitSection" bits. MCSection uses the new form of SectionKind. To handle isWeak, I introduced a new SectionInfo class, which is SectionKind + isWeak, and it is used by the part of the code generator that does classification of a specific global. The ExplicitSection disappears. It is moved onto MCSection as a new "IsDirective" bit. Since the Name of a section is either a section or directive, it makes sense to keep this bit in MCSection. Ultimately the creator of MCSection should canonicalize (e.g.) .text to whatever the actual section is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77803 91177308-0d34-0410-b5e6-96231b3b80d8
105 lines
4.0 KiB
C++
105 lines
4.0 KiB
C++
//===-- PIC16TargetObjectFile.h - PIC16 Object Info -------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
|
|
#define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
|
|
|
|
#include "llvm/Target/TargetLoweringObjectFile.h"
|
|
#include <vector>
|
|
|
|
namespace llvm {
|
|
class GlobalVariable;
|
|
class Module;
|
|
class PIC16TargetMachine;
|
|
|
|
enum { DataBankSize = 80 };
|
|
|
|
/// PIC16 Splits the global data into mulitple udata and idata sections.
|
|
/// Each udata and idata section needs to contain a list of globals that
|
|
/// they contain, in order to avoid scanning over all the global values
|
|
/// again and printing only those that match the current section.
|
|
/// Keeping values inside the sections make printing a section much easier.
|
|
///
|
|
/// FIXME: Reimplement by inheriting from MCSection.
|
|
///
|
|
struct PIC16Section {
|
|
const MCSection *S_; // Connection to actual Section.
|
|
unsigned Size; // Total size of the objects contained.
|
|
bool SectionPrinted;
|
|
std::vector<const GlobalVariable*> Items;
|
|
|
|
PIC16Section(const MCSection *s) {
|
|
S_ = s;
|
|
Size = 0;
|
|
SectionPrinted = false;
|
|
}
|
|
bool isPrinted() const { return SectionPrinted; }
|
|
void setPrintedStatus(bool status) { SectionPrinted = status; }
|
|
};
|
|
|
|
class PIC16TargetObjectFile : public TargetLoweringObjectFile {
|
|
const TargetMachine *TM;
|
|
public:
|
|
mutable std::vector<PIC16Section*> BSSSections;
|
|
mutable std::vector<PIC16Section*> IDATASections;
|
|
mutable std::vector<PIC16Section*> AutosSections;
|
|
mutable std::vector<PIC16Section*> ROSections;
|
|
mutable PIC16Section *ExternalVarDecls;
|
|
mutable PIC16Section *ExternalVarDefs;
|
|
|
|
~PIC16TargetObjectFile();
|
|
|
|
void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
|
|
|
|
|
/// getSpecialCasedSectionGlobals - Allow the target to completely override
|
|
/// section assignment of a global.
|
|
virtual const MCSection *
|
|
getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
|
|
SectionInfo Info) const;
|
|
virtual const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
|
|
SectionInfo Info,
|
|
Mangler *Mang,
|
|
const TargetMachine&) const;
|
|
private:
|
|
std::string getSectionNameForSym(const std::string &Sym) const;
|
|
|
|
const MCSection *getBSSSectionForGlobal(const GlobalVariable *GV) const;
|
|
const MCSection *getIDATASectionForGlobal(const GlobalVariable *GV) const;
|
|
const MCSection *getSectionForAuto(const GlobalVariable *GV) const;
|
|
const MCSection *CreateBSSSectionForGlobal(const GlobalVariable *GV,
|
|
std::string Addr = "") const;
|
|
const MCSection *CreateIDATASectionForGlobal(const GlobalVariable *GV,
|
|
std::string Addr = "") const;
|
|
const MCSection *getROSectionForGlobal(const GlobalVariable *GV) const;
|
|
const MCSection *CreateROSectionForGlobal(const GlobalVariable *GV,
|
|
std::string Addr = "") const;
|
|
const MCSection *CreateSectionForGlobal(const GlobalVariable *GV,
|
|
Mangler *Mang,
|
|
const std::string &Addr = "") const;
|
|
public:
|
|
void SetSectionForGVs(Module &M);
|
|
const std::vector<PIC16Section*> &getBSSSections() const {
|
|
return BSSSections;
|
|
}
|
|
const std::vector<PIC16Section*> &getIDATASections() const {
|
|
return IDATASections;
|
|
}
|
|
const std::vector<PIC16Section*> &getAutosSections() const {
|
|
return AutosSections;
|
|
}
|
|
const std::vector<PIC16Section*> &getROSections() const {
|
|
return ROSections;
|
|
}
|
|
|
|
};
|
|
} // end namespace llvm
|
|
|
|
#endif
|