mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-11 23:25:15 +00:00
change AsmPrinter to switch sections using AsmStreamer instead of
doing it directly. This requires const'izing a bunch of stuff that took sections, but this seems like the right semantic thing to do: emitting a label to a section shouldn't mutate the MCSection object itself, for example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d3aa25e2a8
commit
975780bb59
@ -81,7 +81,7 @@ namespace llvm {
|
|||||||
/// @param Section.
|
/// @param Section.
|
||||||
///
|
///
|
||||||
/// This corresponds to assembler directives like .section, .text, etc.
|
/// This corresponds to assembler directives like .section, .text, etc.
|
||||||
virtual void SwitchSection(MCSection *Section) = 0;
|
virtual void SwitchSection(const MCSection *Section) = 0;
|
||||||
|
|
||||||
/// EmitLabel - Emit a label for @param Symbol into the current section.
|
/// EmitLabel - Emit a label for @param Symbol into the current section.
|
||||||
///
|
///
|
||||||
|
@ -34,7 +34,7 @@ namespace llvm {
|
|||||||
std::string Name;
|
std::string Name;
|
||||||
/// Section - The section the symbol is defined in, or null if the symbol
|
/// Section - The section the symbol is defined in, or null if the symbol
|
||||||
/// has not been defined in the associated translation unit.
|
/// has not been defined in the associated translation unit.
|
||||||
MCSection *Section;
|
const MCSection *Section;
|
||||||
|
|
||||||
/// IsTemporary - True if this is an assembler temporary label, which
|
/// IsTemporary - True if this is an assembler temporary label, which
|
||||||
/// typically does not survive in the .o file's symbol table. Usually
|
/// typically does not survive in the .o file's symbol table. Usually
|
||||||
@ -55,8 +55,8 @@ namespace llvm {
|
|||||||
void operator=(const MCSymbol&); // DO NOT IMPLEMENT
|
void operator=(const MCSymbol&); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MCSection *getSection() const { return Section; }
|
const MCSection *getSection() const { return Section; }
|
||||||
void setSection(MCSection *Value) { Section = Value; }
|
void setSection(const MCSection *S) { Section = S; }
|
||||||
|
|
||||||
bool isExternal() const { return IsExternal; }
|
bool isExternal() const { return IsExternal; }
|
||||||
void setExternal(bool Value) { IsExternal = Value; }
|
void setExternal(bool Value) { IsExternal = Value; }
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @result - The value's associated section, or null for external or constant
|
/// @result - The value's associated section, or null for external or constant
|
||||||
/// values.
|
/// values.
|
||||||
MCSection *getAssociatedSection() const {
|
const MCSection *getAssociatedSection() const {
|
||||||
return SymA ? SymA->getSection() : 0;
|
return SymA ? SymA->getSection() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,23 +98,18 @@ TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const {
|
|||||||
/// FIXME: Remove support for null sections.
|
/// FIXME: Remove support for null sections.
|
||||||
///
|
///
|
||||||
void AsmPrinter::SwitchToSection(const MCSection *NS) {
|
void AsmPrinter::SwitchToSection(const MCSection *NS) {
|
||||||
// If we're already in this section, we're done.
|
|
||||||
if (CurrentSection == NS) return;
|
|
||||||
|
|
||||||
CurrentSection = NS;
|
CurrentSection = NS;
|
||||||
|
// FIXME: Remove support for null sections!
|
||||||
if (NS == 0) return;
|
if (NS)
|
||||||
|
OutStreamer.SwitchSection(NS);
|
||||||
NS->PrintSwitchToSection(*TAI, O);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
AU.addRequired<GCModuleInfo>();
|
AU.addRequired<GCModuleInfo>();
|
||||||
if (ExuberantAsm) {
|
if (ExuberantAsm)
|
||||||
AU.addRequired<MachineLoopInfo>();
|
AU.addRequired<MachineLoopInfo>();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AsmPrinter::doInitialization(Module &M) {
|
bool AsmPrinter::doInitialization(Module &M) {
|
||||||
|
@ -24,7 +24,7 @@ class MCAsmStreamer : public MCStreamer {
|
|||||||
raw_ostream &OS;
|
raw_ostream &OS;
|
||||||
const TargetAsmInfo &TAI;
|
const TargetAsmInfo &TAI;
|
||||||
AsmPrinter *Printer;
|
AsmPrinter *Printer;
|
||||||
MCSection *CurSection;
|
const MCSection *CurSection;
|
||||||
public:
|
public:
|
||||||
MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const TargetAsmInfo &tai,
|
MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const TargetAsmInfo &tai,
|
||||||
AsmPrinter *_AsmPrinter)
|
AsmPrinter *_AsmPrinter)
|
||||||
@ -35,7 +35,7 @@ public:
|
|||||||
/// @name MCStreamer Interface
|
/// @name MCStreamer Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
virtual void SwitchSection(MCSection *Section);
|
virtual void SwitchSection(const MCSection *Section);
|
||||||
|
|
||||||
virtual void EmitLabel(MCSymbol *Symbol);
|
virtual void EmitLabel(MCSymbol *Symbol);
|
||||||
|
|
||||||
@ -98,12 +98,10 @@ static inline MCValue truncateToSize(const MCValue &Value, unsigned Bytes) {
|
|||||||
truncateToSize(Value.getConstant(), Bytes));
|
truncateToSize(Value.getConstant(), Bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::SwitchSection(MCSection *Section) {
|
void MCAsmStreamer::SwitchSection(const MCSection *Section) {
|
||||||
if (Section != CurSection) {
|
if (Section != CurSection) {
|
||||||
CurSection = Section;
|
CurSection = Section;
|
||||||
|
Section->PrintSwitchToSection(TAI, OS);
|
||||||
// FIXME: Needs TargetAsmInfo!
|
|
||||||
Section->PrintSwitchToSection(*(const TargetAsmInfo*)0, OS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace {
|
|||||||
/// @name MCStreamer Interface
|
/// @name MCStreamer Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
virtual void SwitchSection(MCSection *Section) {}
|
virtual void SwitchSection(const MCSection *Section) {}
|
||||||
|
|
||||||
virtual void EmitLabel(MCSymbol *Symbol) {}
|
virtual void EmitLabel(MCSymbol *Symbol) {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user