[llvm-commits] [llvm] r56571 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/Target/TargetAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Anton Korobeynikov asl at math.spbu.ru
Wed Sep 24 15:12:10 PDT 2008


Author: asl
Date: Wed Sep 24 17:12:10 2008
New Revision: 56571

URL: http://llvm.org/viewvc/llvm-project?rev=56571&view=rev
Log:
Provide direct function to switch to Section

Modified:
    llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
    llvm/trunk/include/llvm/Target/TargetAsmInfo.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=56571&r1=56570&r2=56571&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Sep 24 17:12:10 2008
@@ -32,6 +32,7 @@
   class MachineConstantPoolValue;
   class MachineModuleInfo;
   class Mangler;
+  class Section;
   class TargetAsmInfo;
   class Type;
   class raw_ostream;
@@ -127,7 +128,11 @@
     /// are the same.
     ///
     void SwitchToDataSection(const char *NewSection, const GlobalValue *GV = NULL);
-    
+
+    /// SwitchToSection - Switch to the specified section of the executable if
+    /// we are not already in it!
+    void SwitchToSection(const Section* NS);
+
     /// getGlobalLinkName - Returns the asm/link name of of the specified
     /// global variable.  Should be overridden by each target asm printer to
     /// generate the appropriate value.

Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=56571&r1=56570&r2=56571&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Sep 24 17:12:10 2008
@@ -114,6 +114,7 @@
     bool isNamed() const { return Flags & SectionFlags::Named; }
     unsigned getEntitySize() const { return (Flags >> 24) & 0xFF; }
     const std::string& getName() const { return Name; }
+    unsigned getFlags() const { return Flags; }
   };
 
   /// TargetAsmInfo - This class is intended to be used as a base class for asm

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

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Sep 24 17:12:10 2008
@@ -105,6 +105,26 @@
   IsInTextSection = false;
 }
 
+/// SwitchToSection - Switch to the specified section of the executable if we
+/// are not already in it!
+void AsmPrinter::SwitchToSection(const Section* NS) {
+  const std::string& NewSection = NS->getName();
+
+  // If we're already in this section, we're done.
+  if (CurrentSection == NewSection) return;
+
+  // Close the current section, if applicable.
+  if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty())
+    O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << '\n';
+
+  // FIXME: Make CurrentSection a Section* in the future
+  CurrentSection = NewSection;
+
+  if (!CurrentSection.empty())
+    O << CurrentSection << TAI->getDataSectionStartSuffix() << '\n';
+
+  IsInTextSection = (NS->getFlags() & SectionFlags::Code);
+}
 
 void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
   MachineFunctionPass::getAnalysisUsage(AU);





More information about the llvm-commits mailing list