diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-17 05:49:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-17 05:49:08 +0000 |
commit | aa1526419c1c3c01bdbc42ffc7b7488f7bffd69d (patch) | |
tree | f48c6ed95569667abcf09c50145ef207a89763e1 /llvm | |
parent | aa464002f0f7d43996f10b43a9536a40cb144bef (diff) | |
download | bcm5719-llvm-aa1526419c1c3c01bdbc42ffc7b7488f7bffd69d.tar.gz bcm5719-llvm-aa1526419c1c3c01bdbc42ffc7b7488f7bffd69d.zip |
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.
llvm-svn: 79227
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/MC/MCStreamer.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/MC/MCSymbol.h | 6 | ||||
-rw-r--r-- | llvm/include/llvm/MC/MCValue.h | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmStreamer.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/MC/MCNullStreamer.cpp | 2 |
6 files changed, 14 insertions, 21 deletions
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h index b8399d0115a..48096c708ac 100644 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -81,7 +81,7 @@ namespace llvm { /// @param Section. /// /// 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. /// diff --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h index e857ebab70b..a5176bc24ff 100644 --- a/llvm/include/llvm/MC/MCSymbol.h +++ b/llvm/include/llvm/MC/MCSymbol.h @@ -34,7 +34,7 @@ namespace llvm { std::string Name; /// Section - The section the symbol is defined in, or null if the symbol /// has not been defined in the associated translation unit. - MCSection *Section; + const MCSection *Section; /// IsTemporary - True if this is an assembler temporary label, which /// 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 public: - MCSection *getSection() const { return Section; } - void setSection(MCSection *Value) { Section = Value; } + const MCSection *getSection() const { return Section; } + void setSection(const MCSection *S) { Section = S; } bool isExternal() const { return IsExternal; } void setExternal(bool Value) { IsExternal = Value; } diff --git a/llvm/include/llvm/MC/MCValue.h b/llvm/include/llvm/MC/MCValue.h index ee5ba84dd0f..ec323fe1b3f 100644 --- a/llvm/include/llvm/MC/MCValue.h +++ b/llvm/include/llvm/MC/MCValue.h @@ -49,7 +49,7 @@ public: /// /// @result - The value's associated section, or null for external or constant /// values. - MCSection *getAssociatedSection() const { + const MCSection *getAssociatedSection() const { return SymA ? SymA->getSection() : 0; } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d46043b29cd..7f23abe4ee1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -98,23 +98,18 @@ TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const { /// FIXME: Remove support for null sections. /// void AsmPrinter::SwitchToSection(const MCSection *NS) { - // If we're already in this section, we're done. - if (CurrentSection == NS) return; - CurrentSection = NS; - - if (NS == 0) return; - - NS->PrintSwitchToSection(*TAI, O); + // FIXME: Remove support for null sections! + if (NS) + OutStreamer.SwitchSection(NS); } void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(AU); AU.addRequired<GCModuleInfo>(); - if (ExuberantAsm) { + if (ExuberantAsm) AU.addRequired<MachineLoopInfo>(); - } } bool AsmPrinter::doInitialization(Module &M) { diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index db39fb8b1cb..60d66f93af9 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -24,7 +24,7 @@ class MCAsmStreamer : public MCStreamer { raw_ostream &OS; const TargetAsmInfo &TAI; AsmPrinter *Printer; - MCSection *CurSection; + const MCSection *CurSection; public: MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const TargetAsmInfo &tai, AsmPrinter *_AsmPrinter) @@ -35,7 +35,7 @@ public: /// @name MCStreamer Interface /// @{ - virtual void SwitchSection(MCSection *Section); + virtual void SwitchSection(const MCSection *Section); virtual void EmitLabel(MCSymbol *Symbol); @@ -98,12 +98,10 @@ static inline MCValue truncateToSize(const MCValue &Value, unsigned Bytes) { truncateToSize(Value.getConstant(), Bytes)); } -void MCAsmStreamer::SwitchSection(MCSection *Section) { +void MCAsmStreamer::SwitchSection(const MCSection *Section) { if (Section != CurSection) { CurSection = Section; - - // FIXME: Needs TargetAsmInfo! - Section->PrintSwitchToSection(*(const TargetAsmInfo*)0, OS); + Section->PrintSwitchToSection(TAI, OS); } } diff --git a/llvm/lib/MC/MCNullStreamer.cpp b/llvm/lib/MC/MCNullStreamer.cpp index 3ac79cbf0a2..fcdd087e67a 100644 --- a/llvm/lib/MC/MCNullStreamer.cpp +++ b/llvm/lib/MC/MCNullStreamer.cpp @@ -26,7 +26,7 @@ namespace { /// @name MCStreamer Interface /// @{ - virtual void SwitchSection(MCSection *Section) {} + virtual void SwitchSection(const MCSection *Section) {} virtual void EmitLabel(MCSymbol *Symbol) {} |