[llvm-commits] [llvm] r79227 - in /llvm/trunk: include/llvm/MC/MCStreamer.h include/llvm/MC/MCSymbol.h include/llvm/MC/MCValue.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/MC/MCAsmStreamer.cpp lib/MC/MCNullStreamer.cpp

Chris Lattner sabre at nondot.org
Sun Aug 16 22:49:09 PDT 2009


Author: lattner
Date: Mon Aug 17 00:49:08 2009
New Revision: 79227

URL: http://llvm.org/viewvc/llvm-project?rev=79227&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/include/llvm/MC/MCSymbol.h
    llvm/trunk/include/llvm/MC/MCValue.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/MC/MCAsmStreamer.cpp
    llvm/trunk/lib/MC/MCNullStreamer.cpp

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=79227&r1=79226&r2=79227&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Aug 17 00:49:08 2009
@@ -81,7 +81,7 @@
     /// @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.
     ///

Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=79227&r1=79226&r2=79227&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbol.h Mon Aug 17 00:49:08 2009
@@ -34,7 +34,7 @@
     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 @@
     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; }

Modified: llvm/trunk/include/llvm/MC/MCValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCValue.h?rev=79227&r1=79226&r2=79227&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCValue.h (original)
+++ llvm/trunk/include/llvm/MC/MCValue.h Mon Aug 17 00:49:08 2009
@@ -49,7 +49,7 @@
   ///
   /// @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;
   }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=79227&r1=79226&r2=79227&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Aug 17 00:49:08 2009
@@ -98,23 +98,18 @@
 /// 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) {

Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=79227&r1=79226&r2=79227&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Mon Aug 17 00:49:08 2009
@@ -24,7 +24,7 @@
   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 @@
   /// @name MCStreamer Interface
   /// @{
 
-  virtual void SwitchSection(MCSection *Section);
+  virtual void SwitchSection(const MCSection *Section);
 
   virtual void EmitLabel(MCSymbol *Symbol);
 
@@ -98,12 +98,10 @@
                       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);
   }
 }
 

Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=79227&r1=79226&r2=79227&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCNullStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCNullStreamer.cpp Mon Aug 17 00:49:08 2009
@@ -26,7 +26,7 @@
     /// @name MCStreamer Interface
     /// @{
 
-    virtual void SwitchSection(MCSection *Section) {}
+    virtual void SwitchSection(const MCSection *Section) {}
 
     virtual void EmitLabel(MCSymbol *Symbol) {}
 





More information about the llvm-commits mailing list