class MachineConstantPoolValue;
class MachineModuleInfo;
class Mangler;
+ class Section;
class TargetAsmInfo;
class Type;
class raw_ostream;
/// 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.
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
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);