diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-18 06:15:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-18 06:15:16 +0000 |
commit | 0adae25ec1af9a51eb864a13055dd2f70043cdb0 (patch) | |
tree | 40b2c61ed9050a7bfecdb583029721902dec1b72 /llvm/lib/CodeGen | |
parent | 5de2e2de9308e2bcbea85a24d877bb9eb145356e (diff) | |
download | bcm5719-llvm-0adae25ec1af9a51eb864a13055dd2f70043cdb0.tar.gz bcm5719-llvm-0adae25ec1af9a51eb864a13055dd2f70043cdb0.zip |
Make AsmStreamer maintain a notion of the current section, pushing it up from the
MCAsmStreamer. Based on this, eliminate the current section from AsmPrinter.
While I'm at it, clean up the last of the horrible "switch to null section" stuff
and add an assert. This change is in preparation for completely eliminating
asmprinter::switchtosection.
llvm-svn: 79324
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d8594db9508..e6ee960dc48 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -63,7 +63,6 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm, LastMI(0), LastFn(0), Counter(~0U), PrevDLT(0, ~0U, ~0U) { - CurrentSection = 0; DW = 0; MMI = 0; switch (AsmVerbose) { case cl::BOU_UNSET: VerboseAsm = VDef; break; @@ -91,19 +90,18 @@ TargetLoweringObjectFile &AsmPrinter::getObjFileLowering() const { } /// SwitchToSection - Switch to the specified section of the executable if we -/// are not already in it! If "NS" is null, then this causes us to exit the -/// current section and not reenter another one. This is generally used for -/// asmprinter hacks. -/// -/// FIXME: Remove support for null sections. -/// +/// are not already in it! void AsmPrinter::SwitchToSection(const MCSection *NS) { - CurrentSection = NS; - // FIXME: Remove support for null sections! - if (NS) - OutStreamer.SwitchSection(NS); + assert(NS != 0 && "Must specify a section to switch to"); + OutStreamer.SwitchSection(NS); +} + +/// getCurrentSection() - Return the current section we are emitting to. +const MCSection *AsmPrinter::getCurrentSection() const { + return OutStreamer.getCurrentSection(); } + void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(AU); @@ -143,8 +141,6 @@ bool AsmPrinter::doInitialization(Module &M) { << '\n' << TAI->getCommentString() << " End of file scope inline assembly\n"; - SwitchToSection(0); // Reset back to no section to close off sections. - if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) { MMI = getAnalysisIfAvailable<MachineModuleInfo>(); @@ -174,7 +170,6 @@ bool AsmPrinter::doFinalization(Module &M) { // to stuff that is actually used. Note that doing so would require targets // to notice uses in operands (due to constant exprs etc). This should // happen with the MC stuff eventually. - SwitchToSection(0); // Print out module-level global variables here. for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); @@ -776,7 +771,7 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV, if (TAI->getAlignmentIsInBytes()) NumBits = 1 << NumBits; O << TAI->getAlignDirective() << NumBits; - if (CurrentSection && CurrentSection->getKind().isText()) + if (getCurrentSection()->getKind().isText()) if (unsigned FillValue = TAI->getTextAlignFillValue()) { O << ','; PrintHex(FillValue); |