From: Lang Hames Date: Fri, 24 Apr 2015 19:11:51 +0000 (+0000) Subject: [AsmPrinter] Make AsmPrinter's OutStreamer member a unique_ptr. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ff69c8f4de60cfe4d832247a720b936183c08e5;p=platform%2Fupstream%2Fllvm.git [AsmPrinter] Make AsmPrinter's OutStreamer member a unique_ptr. AsmPrinter owns the OutStreamer, so an owning pointer makes sense here. Using a reference for this is crufty. llvm-svn: 235752 --- diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h index 11f98ca..ea135d73 100644 --- a/llvm/include/llvm/CodeGen/AsmPrinter.h +++ b/llvm/include/llvm/CodeGen/AsmPrinter.h @@ -78,7 +78,7 @@ public: /// This is the MCStreamer object for the file we are generating. This /// contains the transient state for the current translation unit that we are /// generating (such as the current section etc). - MCStreamer &OutStreamer; + std::unique_ptr OutStreamer; /// The current machine function. const MachineFunction *MF; diff --git a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp index 9a16e15..4cb460a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ARMException.cpp @@ -41,7 +41,7 @@ ARMException::ARMException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {} ARMException::~ARMException() {} ARMTargetStreamer &ARMException::getTargetStreamer() { - MCTargetStreamer &TS = *Asm->OutStreamer.getTargetStreamer(); + MCTargetStreamer &TS = *Asm->OutStreamer->getTargetStreamer(); return static_cast(TS); } @@ -49,7 +49,7 @@ ARMTargetStreamer &ARMException::getTargetStreamer() { /// content. void ARMException::endModule() { if (shouldEmitCFI) - Asm->OutStreamer.EmitCFISections(false, true); + Asm->OutStreamer->EmitCFISections(false, true); } void ARMException::beginFunction(const MachineFunction *MF) { @@ -61,7 +61,7 @@ void ARMException::beginFunction(const MachineFunction *MF) { "non-EH CFI not yet supported in prologue with EHABI lowering"); if (MoveType == AsmPrinter::CFI_M_Debug) { shouldEmitCFI = true; - Asm->OutStreamer.EmitCFIStartProc(false); + Asm->OutStreamer->EmitCFIStartProc(false); } } @@ -77,7 +77,7 @@ void ARMException::endFunction(const MachineFunction *MF) { // Emit references to personality. if (const Function *Personality = MMI->getPersonality()) { MCSymbol *PerSym = Asm->getSymbol(Personality); - Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global); + Asm->OutStreamer->EmitSymbolAttribute(PerSym, MCSA_Global); ATS.emitPersonality(PerSym); } @@ -97,13 +97,13 @@ void ARMException::emitTypeInfos(unsigned TTypeEncoding) { const std::vector &TypeInfos = MMI->getTypeInfos(); const std::vector &FilterIds = MMI->getFilterIds(); - bool VerboseAsm = Asm->OutStreamer.isVerboseAsm(); + bool VerboseAsm = Asm->OutStreamer->isVerboseAsm(); int Entry = 0; // Emit the Catch TypeInfos. if (VerboseAsm && !TypeInfos.empty()) { - Asm->OutStreamer.AddComment(">> Catch TypeInfos <<"); - Asm->OutStreamer.AddBlankLine(); + Asm->OutStreamer->AddComment(">> Catch TypeInfos <<"); + Asm->OutStreamer->AddBlankLine(); Entry = TypeInfos.size(); } @@ -111,14 +111,14 @@ void ARMException::emitTypeInfos(unsigned TTypeEncoding) { I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) { const GlobalValue *GV = *I; if (VerboseAsm) - Asm->OutStreamer.AddComment("TypeInfo " + Twine(Entry--)); + Asm->OutStreamer->AddComment("TypeInfo " + Twine(Entry--)); Asm->EmitTTypeReference(GV, TTypeEncoding); } // Emit the Exception Specifications. if (VerboseAsm && !FilterIds.empty()) { - Asm->OutStreamer.AddComment(">> Filter TypeInfos <<"); - Asm->OutStreamer.AddBlankLine(); + Asm->OutStreamer->AddComment(">> Filter TypeInfos <<"); + Asm->OutStreamer->AddBlankLine(); Entry = 0; } for (std::vector::const_iterator @@ -127,7 +127,7 @@ void ARMException::emitTypeInfos(unsigned TTypeEncoding) { if (VerboseAsm) { --Entry; if (TypeID != 0) - Asm->OutStreamer.AddComment("FilterInfo " + Twine(Entry)); + Asm->OutStreamer->AddComment("FilterInfo " + Twine(Entry)); } Asm->EmitTTypeReference((TypeID == 0 ? nullptr : TypeInfos[TypeID - 1]), diff --git a/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp b/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp index 8dab5e5..4dc5e9f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AddressPool.cpp @@ -29,7 +29,7 @@ void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) { return; // Start the dwarf addr section. - Asm.OutStreamer.SwitchSection(AddrSection); + Asm.OutStreamer->SwitchSection(AddrSection); // Order the address pool entries by ID SmallVector Entries(Pool.size()); @@ -41,5 +41,5 @@ void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) { : MCSymbolRefExpr::Create(I.first, Asm.OutContext); for (const MCExpr *Entry : Entries) - Asm.OutStreamer.EmitValue(Entry, Asm.getDataLayout().getPointerSize()); + Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize()); } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index ec76cd6..a8fb9b7 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -102,7 +102,7 @@ static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &DL, AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr Streamer) : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()), - OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()), + OutContext(Streamer->getContext()), OutStreamer(std::move(Streamer)), LastMI(nullptr), LastFn(0), Counter(~0U) { DD = nullptr; MMI = nullptr; @@ -112,7 +112,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr Streamer) CurrentFnBegin = nullptr; CurrentFnEnd = nullptr; GCMetadataPrinters = nullptr; - VerboseAsm = OutStreamer.isVerboseAsm(); + VerboseAsm = OutStreamer->isVerboseAsm(); } AsmPrinter::~AsmPrinter() { @@ -124,8 +124,6 @@ AsmPrinter::~AsmPrinter() { delete &GCMap; GCMetadataPrinters = nullptr; } - - delete &OutStreamer; } /// getFunctionNumber - Return a unique ID for the current function. @@ -158,7 +156,7 @@ StringRef AsmPrinter::getTargetTriple() const { /// getCurrentSection() - Return the current section we are emitting to. const MCSection *AsmPrinter::getCurrentSection() const { - return OutStreamer.getCurrentSection().first; + return OutStreamer->getCurrentSection().first; } @@ -180,7 +178,7 @@ bool AsmPrinter::doInitialization(Module &M) { const_cast(getObjFileLowering()) .Initialize(OutContext, TM); - OutStreamer.InitSections(false); + OutStreamer->InitSections(false); Mang = new Mangler(TM.getDataLayout()); @@ -198,9 +196,9 @@ bool AsmPrinter::doInitialization(Module &M) { TT.getOSVersion(Major, Minor, Update); // If there is a version specified, Major will be non-zero. if (Major) - OutStreamer.EmitVersionMin((TT.isMacOSX() ? - MCVM_OSXVersionMin : MCVM_IOSVersionMin), - Major, Minor, Update); + OutStreamer->EmitVersionMin((TT.isMacOSX() ? + MCVM_OSXVersionMin : MCVM_IOSVersionMin), + Major, Minor, Update); } // Allow the target to emit any magic that it wants at the start of the file. @@ -210,7 +208,7 @@ bool AsmPrinter::doInitialization(Module &M) { // don't, this at least helps the user find where a global came from. if (MAI->hasSingleParameterDotFile()) { // .file "foo.c" - OutStreamer.EmitFileDirective(M.getModuleIdentifier()); + OutStreamer->EmitFileDirective(M.getModuleIdentifier()); } GCModuleInfo *MI = getAnalysisIfAvailable(); @@ -225,11 +223,11 @@ bool AsmPrinter::doInitialization(Module &M) { // and target triple. std::unique_ptr STI(TM.getTarget().createMCSubtargetInfo( TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); - OutStreamer.AddComment("Start of file scope inline assembly"); - OutStreamer.AddBlankLine(); + OutStreamer->AddComment("Start of file scope inline assembly"); + OutStreamer->AddBlankLine(); EmitInlineAsm(M.getModuleInlineAsm()+"\n", *STI); - OutStreamer.AddComment("End of file scope inline assembly"); - OutStreamer.AddBlankLine(); + OutStreamer->AddComment("End of file scope inline assembly"); + OutStreamer->AddBlankLine(); } if (MAI->doesSupportDebugInformation()) { @@ -296,20 +294,20 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const { case GlobalValue::WeakODRLinkage: if (MAI->hasWeakDefDirective()) { // .globl _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global); if (!canBeHidden(GV, *MAI)) // .weak_definition _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_WeakDefinition); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_WeakDefinition); else - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_WeakDefAutoPrivate); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_WeakDefAutoPrivate); } else if (MAI->hasLinkOnceDirective()) { // .globl _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global); //NOTE: linkonce is handled by the section the symbol was assigned to. } else { // .weak _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Weak); } return; case GlobalValue::AppendingLinkage: @@ -318,7 +316,7 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const { case GlobalValue::ExternalLinkage: // If external or appending, declare as a global symbol. // .globl _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global); return; case GlobalValue::PrivateLinkage: case GlobalValue::InternalLinkage: @@ -353,9 +351,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { return; if (isVerbose()) { - GV->printAsOperand(OutStreamer.GetCommentOS(), + GV->printAsOperand(OutStreamer->GetCommentOS(), /*PrintType=*/false, GV->getParent()); - OutStreamer.GetCommentOS() << '\n'; + OutStreamer->GetCommentOS() << '\n'; } } @@ -371,7 +369,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { "' is already defined"); if (MAI->hasDotTypeDotSizeDirective()) - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM); @@ -399,7 +397,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { Align = 0; // .comm _foo, 42, 4 - OutStreamer.EmitCommonSymbol(GVSym, Size, Align); + OutStreamer->EmitCommonSymbol(GVSym, Size, Align); return; } @@ -408,7 +406,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { const MCSection *TheSection = getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM); // .zerofill __DATA, __bss, _foo, 400, 5 - OutStreamer.EmitZerofill(TheSection, GVSym, Size, Align); + OutStreamer->EmitZerofill(TheSection, GVSym, Size, Align); return; } @@ -420,7 +418,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { // Prefer to simply fall back to .local / .comm in this case. if (MAI->getLCOMMDirectiveAlignmentType() != LCOMM::NoAlignment) { // .lcomm _foo, 42 - OutStreamer.EmitLocalCommonSymbol(GVSym, Size, Align); + OutStreamer->EmitLocalCommonSymbol(GVSym, Size, Align); return; } @@ -428,9 +426,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { Align = 0; // .local _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Local); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Local); // .comm _foo, 42, 4 - OutStreamer.EmitCommonSymbol(GVSym, Size, Align); + OutStreamer->EmitCommonSymbol(GVSym, Size, Align); return; } @@ -443,9 +441,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { if (Size == 0) Size = 1; // zerofill of 0 bytes is undefined. // .globl _foo - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global); // .zerofill __DATA, __common, _foo, 400, 5 - OutStreamer.EmitZerofill(TheSection, GVSym, Size, 1 << AlignLog); + OutStreamer->EmitZerofill(TheSection, GVSym, Size, 1 << AlignLog); return; } @@ -466,55 +464,55 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { if (GVKind.isThreadBSS()) { TheSection = getObjFileLowering().getTLSBSSSection(); - OutStreamer.EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog); + OutStreamer->EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog); } else if (GVKind.isThreadData()) { - OutStreamer.SwitchSection(TheSection); + OutStreamer->SwitchSection(TheSection); EmitAlignment(AlignLog, GV); - OutStreamer.EmitLabel(MangSym); + OutStreamer->EmitLabel(MangSym); EmitGlobalConstant(GV->getInitializer()); } - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); // Emit the variable struct for the runtime. const MCSection *TLVSect = getObjFileLowering().getTLSExtraDataSection(); - OutStreamer.SwitchSection(TLVSect); + OutStreamer->SwitchSection(TLVSect); // Emit the linkage here. EmitLinkage(GV, GVSym); - OutStreamer.EmitLabel(GVSym); + OutStreamer->EmitLabel(GVSym); // Three pointers in size: // - __tlv_bootstrap - used to make sure support exists // - spare pointer, used when mapped by the runtime // - pointer to mangled symbol above with initializer unsigned PtrSize = DL->getPointerTypeSize(GV->getType()); - OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"), + OutStreamer->EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"), PtrSize); - OutStreamer.EmitIntValue(0, PtrSize); - OutStreamer.EmitSymbolValue(MangSym, PtrSize); + OutStreamer->EmitIntValue(0, PtrSize); + OutStreamer->EmitSymbolValue(MangSym, PtrSize); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); return; } - OutStreamer.SwitchSection(TheSection); + OutStreamer->SwitchSection(TheSection); EmitLinkage(GV, GVSym); EmitAlignment(AlignLog, GV); - OutStreamer.EmitLabel(GVSym); + OutStreamer->EmitLabel(GVSym); EmitGlobalConstant(GV->getInitializer()); if (MAI->hasDotTypeDotSizeDirective()) // .size foo, 42 - OutStreamer.EmitELFSize(GVSym, MCConstantExpr::Create(Size, OutContext)); + OutStreamer->EmitELFSize(GVSym, MCConstantExpr::Create(Size, OutContext)); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } /// EmitFunctionHeader - This method emits the header for the current @@ -526,7 +524,7 @@ void AsmPrinter::EmitFunctionHeader() { // Print the 'header' of function. const Function *F = MF->getFunction(); - OutStreamer.SwitchSection( + OutStreamer->SwitchSection( getObjFileLowering().SectionForGlobal(F, *Mang, TM)); EmitVisibility(CurrentFnSym, F->getVisibility()); @@ -535,12 +533,12 @@ void AsmPrinter::EmitFunctionHeader() { EmitAlignment(MF->getAlignment(), F); if (MAI->hasDotTypeDotSizeDirective()) - OutStreamer.EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction); + OutStreamer->EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction); if (isVerbose()) { - F->printAsOperand(OutStreamer.GetCommentOS(), + F->printAsOperand(OutStreamer->GetCommentOS(), /*PrintType=*/false, F->getParent()); - OutStreamer.GetCommentOS() << '\n'; + OutStreamer->GetCommentOS() << '\n'; } // Emit the prefix data. @@ -557,18 +555,18 @@ void AsmPrinter::EmitFunctionHeader() { std::vector DeadBlockSyms; MMI->takeDeletedSymbolsForFunction(F, DeadBlockSyms); for (unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) { - OutStreamer.AddComment("Address taken block that was later removed"); - OutStreamer.EmitLabel(DeadBlockSyms[i]); + OutStreamer->AddComment("Address taken block that was later removed"); + OutStreamer->EmitLabel(DeadBlockSyms[i]); } if (CurrentFnBegin) { if (MAI->useAssignmentForEHBegin()) { MCSymbol *CurPos = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(CurPos); - OutStreamer.EmitAssignment(CurrentFnBegin, + OutStreamer->EmitLabel(CurPos); + OutStreamer->EmitAssignment(CurrentFnBegin, MCSymbolRefExpr::Create(CurPos, OutContext)); } else { - OutStreamer.EmitLabel(CurrentFnBegin); + OutStreamer->EmitLabel(CurrentFnBegin); } } @@ -597,7 +595,7 @@ void AsmPrinter::EmitFunctionEntryLabel() { report_fatal_error("'" + Twine(CurrentFnSym->getName()) + "' label emitted multiple times to assembly file"); - return OutStreamer.EmitLabel(CurrentFnSym); + return OutStreamer->EmitLabel(CurrentFnSym); } /// emitComments - Pretty-print comments for instructions. @@ -640,9 +638,9 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) { /// that is an implicit def. void AsmPrinter::emitImplicitDef(const MachineInstr *MI) const { unsigned RegNo = MI->getOperand(0).getReg(); - OutStreamer.AddComment(Twine("implicit-def: ") + - MMI->getContext().getRegisterInfo()->getName(RegNo)); - OutStreamer.AddBlankLine(); + OutStreamer->AddComment(Twine("implicit-def: ") + + MMI->getContext().getRegisterInfo()->getName(RegNo)); + OutStreamer->AddBlankLine(); } static void emitKill(const MachineInstr *MI, AsmPrinter &AP) { @@ -654,8 +652,8 @@ static void emitKill(const MachineInstr *MI, AsmPrinter &AP) { Str += AP.MMI->getContext().getRegisterInfo()->getName(Op.getReg()); Str += (Op.isDef() ? "" : ""); } - AP.OutStreamer.AddComment(Str); - AP.OutStreamer.AddBlankLine(); + AP.OutStreamer->AddComment(Str); + AP.OutStreamer->AddBlankLine(); } /// emitDebugValueComment - This method handles the target-independent form @@ -722,7 +720,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) { // Suppress offset, it is not meaningful here. OS << "undef"; // NOTE: Want this comment at start of line, don't emit with AddComment. - AP.OutStreamer.emitRawComment(OS.str()); + AP.OutStreamer->emitRawComment(OS.str()); return true; } if (Deref) @@ -734,7 +732,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) { OS << '+' << Offset << ']'; // NOTE: Want this comment at start of line, don't emit with AddComment. - AP.OutStreamer.emitRawComment(OS.str()); + AP.OutStreamer->emitRawComment(OS.str()); return true; } @@ -775,7 +773,7 @@ void AsmPrinter::emitFrameAlloc(const MachineInstr &MI) { int FrameOffset = MI.getOperand(1).getImm(); // Emit a symbol assignment. - OutStreamer.EmitAssignment(FrameAllocSym, + OutStreamer->EmitAssignment(FrameAllocSym, MCConstantExpr::Create(FrameOffset, OutContext)); } @@ -812,7 +810,7 @@ void AsmPrinter::EmitFunctionBody() { } if (isVerbose()) - emitComments(MI, OutStreamer.GetCommentOS()); + emitComments(MI, OutStreamer->GetCommentOS()); switch (MI.getOpcode()) { case TargetOpcode::CFI_INSTRUCTION: @@ -825,7 +823,7 @@ void AsmPrinter::EmitFunctionBody() { case TargetOpcode::EH_LABEL: case TargetOpcode::GC_LABEL: - OutStreamer.EmitLabel(MI.getOperand(0).getMCSymbol()); + OutStreamer->EmitLabel(MI.getOperand(0).getMCSymbol()); break; case TargetOpcode::INLINEASM: EmitInlineAsm(&MI); @@ -865,12 +863,12 @@ void AsmPrinter::EmitFunctionBody() { if ((MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode)) { MCInst Noop; MF->getSubtarget().getInstrInfo()->getNoopForMachoTarget(Noop); - OutStreamer.AddComment("avoids zero-length function"); + OutStreamer->AddComment("avoids zero-length function"); // Targets can opt-out of emitting the noop here by leaving the opcode // unspecified. if (Noop.getOpcode()) - OutStreamer.EmitInstruction(Noop, getSubtargetInfo()); + OutStreamer->EmitInstruction(Noop, getSubtargetInfo()); } const Function *F = MF->getFunction(); @@ -880,8 +878,8 @@ void AsmPrinter::EmitFunctionBody() { MCSymbol *Sym = GetBlockAddressSymbol(&BB); if (Sym->isDefined()) continue; - OutStreamer.AddComment("Address of block that was removed by CodeGen"); - OutStreamer.EmitLabel(Sym); + OutStreamer->AddComment("Address of block that was removed by CodeGen"); + OutStreamer->EmitLabel(Sym); } // Emit target-specific gunk after the function body. @@ -891,7 +889,7 @@ void AsmPrinter::EmitFunctionBody() { MAI->hasDotTypeDotSizeDirective()) { // Create a symbol for the end of function. CurrentFnEnd = createTempSymbol("func_end"); - OutStreamer.EmitLabel(CurrentFnEnd); + OutStreamer->EmitLabel(CurrentFnEnd); } // If the target wants a .size directive for the size of the function, emit @@ -904,7 +902,7 @@ void AsmPrinter::EmitFunctionBody() { MCSymbolRefExpr::Create(CurrentFnSymForSize, OutContext), OutContext); - OutStreamer.EmitELFSize(CurrentFnSym, SizeExp); + OutStreamer->EmitELFSize(CurrentFnSym, SizeExp); } for (const HandlerInfo &HI : Handlers) { @@ -922,7 +920,7 @@ void AsmPrinter::EmitFunctionBody() { } MMI->EndFunction(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } /// \brief Compute the number of Global Variables that uses a Constant. @@ -1040,7 +1038,7 @@ bool AsmPrinter::doFinalization(Module &M) { SmallVector ModuleFlags; M.getModuleFlagsMetadata(ModuleFlags); if (!ModuleFlags.empty()) - TLOF.emitModuleFlags(OutStreamer, ModuleFlags, *Mang, TM); + TLOF.emitModuleFlags(*OutStreamer, ModuleFlags, *Mang, TM); Triple TT(TM.getTargetTriple()); if (TT.isOSBinFormatELF()) { @@ -1049,19 +1047,19 @@ bool AsmPrinter::doFinalization(Module &M) { // Output stubs for external and common global variables. MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList(); if (!Stubs.empty()) { - OutStreamer.SwitchSection(TLOF.getDataRelSection()); + OutStreamer->SwitchSection(TLOF.getDataRelSection()); const DataLayout *DL = TM.getDataLayout(); for (const auto &Stub : Stubs) { - OutStreamer.EmitLabel(Stub.first); - OutStreamer.EmitSymbolValue(Stub.second.getPointer(), - DL->getPointerSize()); + OutStreamer->EmitLabel(Stub.first); + OutStreamer->EmitSymbolValue(Stub.second.getPointer(), + DL->getPointerSize()); } } } // Make sure we wrote out everything we need. - OutStreamer.Flush(); + OutStreamer->Flush(); // Finalize debug and EH information. for (const HandlerInfo &HI : Handlers) { @@ -1084,31 +1082,31 @@ bool AsmPrinter::doFinalization(Module &M) { for (const auto &G : M.globals()) { if (!G.hasExternalWeakLinkage()) continue; - OutStreamer.EmitSymbolAttribute(getSymbol(&G), MCSA_WeakReference); + OutStreamer->EmitSymbolAttribute(getSymbol(&G), MCSA_WeakReference); } for (const auto &F : M) { if (!F.hasExternalWeakLinkage()) continue; - OutStreamer.EmitSymbolAttribute(getSymbol(&F), MCSA_WeakReference); + OutStreamer->EmitSymbolAttribute(getSymbol(&F), MCSA_WeakReference); } } - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); for (const auto &Alias : M.aliases()) { MCSymbol *Name = getSymbol(&Alias); if (Alias.hasExternalLinkage() || !MAI->getWeakRefDirective()) - OutStreamer.EmitSymbolAttribute(Name, MCSA_Global); + OutStreamer->EmitSymbolAttribute(Name, MCSA_Global); else if (Alias.hasWeakLinkage() || Alias.hasLinkOnceLinkage()) - OutStreamer.EmitSymbolAttribute(Name, MCSA_WeakReference); + OutStreamer->EmitSymbolAttribute(Name, MCSA_WeakReference); else assert(Alias.hasLocalLinkage() && "Invalid alias linkage"); EmitVisibility(Name, Alias.getVisibility()); // Emit the directives as assignments aka .set: - OutStreamer.EmitAssignment(Name, lowerConstant(Alias.getAliasee())); + OutStreamer->EmitAssignment(Name, lowerConstant(Alias.getAliasee())); } GCModuleInfo *MI = getAnalysisIfAvailable(); @@ -1125,15 +1123,15 @@ bool AsmPrinter::doFinalization(Module &M) { const MCSection *ReadOnlySection = getObjFileLowering().getSectionForConstant(SectionKind::getReadOnly(), /*C=*/nullptr); - OutStreamer.SwitchSection(ReadOnlySection); + OutStreamer->SwitchSection(ReadOnlySection); MCSymbol *AddrSymbol = OutContext.GetOrCreateSymbol(StringRef("__morestack_addr")); - OutStreamer.EmitLabel(AddrSymbol); + OutStreamer->EmitLabel(AddrSymbol); unsigned PtrSize = TM.getDataLayout()->getPointerSize(0); - OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("__morestack"), - PtrSize); + OutStreamer->EmitSymbolValue(GetExternalSymbolSymbol("__morestack"), + PtrSize); } // If we don't have any trampolines, then we don't require stack memory @@ -1141,7 +1139,7 @@ bool AsmPrinter::doFinalization(Module &M) { Function *InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline"); if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty()) if (const MCSection *S = MAI->getNonexecutableStackSection(OutContext)) - OutStreamer.SwitchSection(S); + OutStreamer->SwitchSection(S); // Allow the target to emit any magic that it wants at the end of the file, // after everything else has gone out. @@ -1150,8 +1148,8 @@ bool AsmPrinter::doFinalization(Module &M) { delete Mang; Mang = nullptr; MMI = nullptr; - OutStreamer.Finish(); - OutStreamer.reset(); + OutStreamer->Finish(); + OutStreamer->reset(); return false; } @@ -1248,7 +1246,7 @@ void AsmPrinter::EmitConstantPool() { continue; if (CurSection != CPSections[i].S) { - OutStreamer.SwitchSection(CPSections[i].S); + OutStreamer->SwitchSection(CPSections[i].S); EmitAlignment(Log2_32(CPSections[i].Alignment)); CurSection = CPSections[i].S; Offset = 0; @@ -1259,13 +1257,13 @@ void AsmPrinter::EmitConstantPool() { // Emit inter-object padding for alignment. unsigned AlignMask = CPE.getAlignment() - 1; unsigned NewOffset = (Offset + AlignMask) & ~AlignMask; - OutStreamer.EmitZeros(NewOffset - Offset); + OutStreamer->EmitZeros(NewOffset - Offset); Type *Ty = CPE.getType(); Offset = NewOffset + TM.getDataLayout()->getTypeAllocSize(Ty); - OutStreamer.EmitLabel(Sym); + OutStreamer->EmitLabel(Sym); if (CPE.isMachineConstantPoolEntry()) EmitMachineConstantPoolValue(CPE.Val.MachineCPVal); else @@ -1296,7 +1294,7 @@ void AsmPrinter::EmitJumpTableInfo() { // Drop it in the readonly section. const MCSection *ReadOnlySection = TLOF.getSectionForJumpTable(*F, *Mang, TM); - OutStreamer.SwitchSection(ReadOnlySection); + OutStreamer->SwitchSection(ReadOnlySection); } EmitAlignment(Log2_32( @@ -1305,7 +1303,7 @@ void AsmPrinter::EmitJumpTableInfo() { // Jump tables in code sections are marked with a data_region directive // where that's supported. if (!JTInDiffSection) - OutStreamer.EmitDataRegion(MCDR_DataRegionJT32); + OutStreamer->EmitDataRegion(MCDR_DataRegionJT32); for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) { const std::vector &JTBBs = JT[JTI].MBBs; @@ -1328,8 +1326,9 @@ void AsmPrinter::EmitJumpTableInfo() { // .set LJTSet, LBB32-base const MCExpr *LHS = MCSymbolRefExpr::Create(MBB->getSymbol(), OutContext); - OutStreamer.EmitAssignment(GetJTSetSymbol(JTI, MBB->getNumber()), - MCBinaryExpr::CreateSub(LHS, Base, OutContext)); + OutStreamer->EmitAssignment(GetJTSetSymbol(JTI, MBB->getNumber()), + MCBinaryExpr::CreateSub(LHS, Base, + OutContext)); } } @@ -1340,15 +1339,15 @@ void AsmPrinter::EmitJumpTableInfo() { if (JTInDiffSection && DL->hasLinkerPrivateGlobalPrefix()) // FIXME: This doesn't have to have any specific name, just any randomly // named and numbered 'l' label would work. Simplify GetJTISymbol. - OutStreamer.EmitLabel(GetJTISymbol(JTI, true)); + OutStreamer->EmitLabel(GetJTISymbol(JTI, true)); - OutStreamer.EmitLabel(GetJTISymbol(JTI)); + OutStreamer->EmitLabel(GetJTISymbol(JTI)); for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) EmitJumpTableEntry(MJTI, JTBBs[ii], JTI); } if (!JTInDiffSection) - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); } /// EmitJumpTableEntry - Emit a jump table entry for the specified MBB to the @@ -1375,7 +1374,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, // with a relocation as gp-relative, e.g.: // .gprel32 LBB123 MCSymbol *MBBSym = MBB->getSymbol(); - OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext)); + OutStreamer->EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext)); return; } @@ -1384,7 +1383,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, // with a relocation as gp-relative, e.g.: // .gpdword LBB123 MCSymbol *MBBSym = MBB->getSymbol(); - OutStreamer.EmitGPRel64Value(MCSymbolRefExpr::Create(MBBSym, OutContext)); + OutStreamer->EmitGPRel64Value(MCSymbolRefExpr::Create(MBBSym, OutContext)); return; } @@ -1413,7 +1412,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, unsigned EntrySize = MJTI->getEntrySize(*TM.getDataLayout()); - OutStreamer.EmitValue(Value, EntrySize); + OutStreamer->EmitValue(Value, EntrySize); } @@ -1442,8 +1441,8 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { if (TM.getRelocationModel() == Reloc::Static && MAI->hasStaticCtorDtorReferenceInStaticMode()) { StringRef Sym(".constructors_used"); - OutStreamer.EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym), - MCSA_Reference); + OutStreamer->EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym), + MCSA_Reference); } return true; } @@ -1454,8 +1453,8 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { if (TM.getRelocationModel() == Reloc::Static && MAI->hasStaticCtorDtorReferenceInStaticMode()) { StringRef Sym(".destructors_used"); - OutStreamer.EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym), - MCSA_Reference); + OutStreamer->EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym), + MCSA_Reference); } return true; } @@ -1472,7 +1471,7 @@ void AsmPrinter::EmitLLVMUsedList(const ConstantArray *InitList) { const GlobalValue *GV = dyn_cast(InitList->getOperand(i)->stripPointerCasts()); if (GV) - OutStreamer.EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip); + OutStreamer->EmitSymbolAttribute(getSymbol(GV), MCSA_NoDeadStrip); } } @@ -1541,8 +1540,8 @@ void AsmPrinter::EmitXXStructorList(const Constant *List, bool isCtor) { const MCSection *OutputSection = (isCtor ? Obj.getStaticCtorSection(S.Priority, KeySym) : Obj.getStaticDtorSection(S.Priority, KeySym)); - OutStreamer.SwitchSection(OutputSection); - if (OutStreamer.getCurrentSection() != OutStreamer.getPreviousSection()) + OutStreamer->SwitchSection(OutputSection); + if (OutStreamer->getCurrentSection() != OutStreamer->getPreviousSection()) EmitAlignment(Align); EmitXXStructor(S.Func); } @@ -1558,7 +1557,7 @@ void AsmPrinter::EmitModuleIdents(Module &M) { assert(N->getNumOperands() == 1 && "llvm.ident metadata entry can have only one operand"); const MDString *S = cast(N->getOperand(0)); - OutStreamer.EmitIdent(S->getString()); + OutStreamer->EmitIdent(S->getString()); } } } @@ -1570,19 +1569,19 @@ void AsmPrinter::EmitModuleIdents(Module &M) { /// EmitInt8 - Emit a byte directive and value. /// void AsmPrinter::EmitInt8(int Value) const { - OutStreamer.EmitIntValue(Value, 1); + OutStreamer->EmitIntValue(Value, 1); } /// EmitInt16 - Emit a short directive and value. /// void AsmPrinter::EmitInt16(int Value) const { - OutStreamer.EmitIntValue(Value, 2); + OutStreamer->EmitIntValue(Value, 2); } /// EmitInt32 - Emit a long directive and value. /// void AsmPrinter::EmitInt32(int Value) const { - OutStreamer.EmitIntValue(Value, 4); + OutStreamer->EmitIntValue(Value, 4); } /// Emit something like ".long Hi-Lo" where the size in bytes of the directive @@ -1597,14 +1596,14 @@ void AsmPrinter::EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, OutContext); if (!MAI->doesSetDirectiveSuppressesReloc()) { - OutStreamer.EmitValue(Diff, Size); + OutStreamer->EmitValue(Diff, Size); return; } // Otherwise, emit with .set (aka assignment). MCSymbol *SetLabel = createTempSymbol("set"); - OutStreamer.EmitAssignment(SetLabel, Diff); - OutStreamer.EmitSymbolValue(SetLabel, Size); + OutStreamer->EmitAssignment(SetLabel, Diff); + OutStreamer->EmitSymbolValue(SetLabel, Size); } /// EmitLabelPlusOffset - Emit something like ".long Label+Offset" @@ -1614,7 +1613,7 @@ void AsmPrinter::EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative) const { if (MAI->needsDwarfSectionOffsetDirective() && IsSectionRelative) { - OutStreamer.EmitCOFFSecRel32(Label); + OutStreamer->EmitCOFFSecRel32(Label); return; } @@ -1624,7 +1623,7 @@ void AsmPrinter::EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, Expr = MCBinaryExpr::CreateAdd( Expr, MCConstantExpr::Create(Offset, OutContext), OutContext); - OutStreamer.EmitValue(Expr, Size); + OutStreamer->EmitValue(Expr, Size); } //===----------------------------------------------------------------------===// @@ -1646,9 +1645,9 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalObject *GV) const { static_cast(std::numeric_limits::digits) && "undefined behavior"); if (getCurrentSection()->getKind().isText()) - OutStreamer.EmitCodeAlignment(1u << NumBits); + OutStreamer->EmitCodeAlignment(1u << NumBits); else - OutStreamer.EmitValueToAlignment(1u << NumBits); + OutStreamer->EmitValueToAlignment(1u << NumBits); } //===----------------------------------------------------------------------===// @@ -1860,22 +1859,22 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS, CDS->getType()); // Don't emit a 1-byte object as a .fill. if (Bytes > 1) - return AP.OutStreamer.EmitFill(Bytes, Value); + return AP.OutStreamer->EmitFill(Bytes, Value); } // If this can be emitted with .ascii/.asciz, emit it as such. if (CDS->isString()) - return AP.OutStreamer.EmitBytes(CDS->getAsString()); + return AP.OutStreamer->EmitBytes(CDS->getAsString()); // Otherwise, emit the values in successive locations. unsigned ElementByteSize = CDS->getElementByteSize(); if (isa(CDS->getElementType())) { for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) { if (AP.isVerbose()) - AP.OutStreamer.GetCommentOS() << format("0x%" PRIx64 "\n", - CDS->getElementAsInteger(i)); - AP.OutStreamer.EmitIntValue(CDS->getElementAsInteger(i), - ElementByteSize); + AP.OutStreamer->GetCommentOS() << format("0x%" PRIx64 "\n", + CDS->getElementAsInteger(i)); + AP.OutStreamer->EmitIntValue(CDS->getElementAsInteger(i), + ElementByteSize); } } else if (ElementByteSize == 4) { // FP Constants are printed as integer constants to avoid losing @@ -1889,8 +1888,8 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS, F = CDS->getElementAsFloat(i); if (AP.isVerbose()) - AP.OutStreamer.GetCommentOS() << "float " << F << '\n'; - AP.OutStreamer.EmitIntValue(I, 4); + AP.OutStreamer->GetCommentOS() << "float " << F << '\n'; + AP.OutStreamer->EmitIntValue(I, 4); } } else { assert(CDS->getElementType()->isDoubleTy()); @@ -1902,8 +1901,8 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS, F = CDS->getElementAsDouble(i); if (AP.isVerbose()) - AP.OutStreamer.GetCommentOS() << "double " << F << '\n'; - AP.OutStreamer.EmitIntValue(I, 8); + AP.OutStreamer->GetCommentOS() << "double " << F << '\n'; + AP.OutStreamer->EmitIntValue(I, 8); } } @@ -1912,7 +1911,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS, unsigned EmittedSize = DL.getTypeAllocSize(CDS->getType()->getElementType()) * CDS->getNumElements(); if (unsigned Padding = Size - EmittedSize) - AP.OutStreamer.EmitZeros(Padding); + AP.OutStreamer->EmitZeros(Padding); } @@ -1925,7 +1924,7 @@ static void emitGlobalConstantArray(const ConstantArray *CA, AsmPrinter &AP, if (Value != -1) { uint64_t Bytes = DL.getTypeAllocSize(CA->getType()); - AP.OutStreamer.EmitFill(Bytes, Value); + AP.OutStreamer->EmitFill(Bytes, Value); } else { for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i) { @@ -1944,7 +1943,7 @@ static void emitGlobalConstantVector(const ConstantVector *CV, AsmPrinter &AP) { unsigned EmittedSize = DL.getTypeAllocSize(CV->getType()->getElementType()) * CV->getType()->getNumElements(); if (unsigned Padding = Size - EmittedSize) - AP.OutStreamer.EmitZeros(Padding); + AP.OutStreamer->EmitZeros(Padding); } static void emitGlobalConstantStruct(const ConstantStruct *CS, AsmPrinter &AP, @@ -1969,7 +1968,7 @@ static void emitGlobalConstantStruct(const ConstantStruct *CS, AsmPrinter &AP, // Insert padding - this may include padding to increase the size of the // current field up to the ABI size (if the struct is not packed) as well // as padding to ensure that the next field starts at the right offset. - AP.OutStreamer.EmitZeros(PadSize); + AP.OutStreamer->EmitZeros(PadSize); } assert(SizeSoFar == Layout->getSizeInBytes() && "Layout of constant struct may be incorrect!"); @@ -1985,10 +1984,10 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) { CFP->getValueAPF().toString(StrVal); if (CFP->getType()) - CFP->getType()->print(AP.OutStreamer.GetCommentOS()); + CFP->getType()->print(AP.OutStreamer->GetCommentOS()); else - AP.OutStreamer.GetCommentOS() << "Printing Type"; - AP.OutStreamer.GetCommentOS() << ' ' << StrVal << '\n'; + AP.OutStreamer->GetCommentOS() << "Printing Type"; + AP.OutStreamer->GetCommentOS() << ' ' << StrVal << '\n'; } // Now iterate through the APInt chunks, emitting them in endian-correct @@ -2005,23 +2004,23 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) { int Chunk = API.getNumWords() - 1; if (TrailingBytes) - AP.OutStreamer.EmitIntValue(p[Chunk--], TrailingBytes); + AP.OutStreamer->EmitIntValue(p[Chunk--], TrailingBytes); for (; Chunk >= 0; --Chunk) - AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t)); + AP.OutStreamer->EmitIntValue(p[Chunk], sizeof(uint64_t)); } else { unsigned Chunk; for (Chunk = 0; Chunk < NumBytes / sizeof(uint64_t); ++Chunk) - AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t)); + AP.OutStreamer->EmitIntValue(p[Chunk], sizeof(uint64_t)); if (TrailingBytes) - AP.OutStreamer.EmitIntValue(p[Chunk], TrailingBytes); + AP.OutStreamer->EmitIntValue(p[Chunk], TrailingBytes); } // Emit the tail padding for the long double. const DataLayout &DL = *AP.TM.getDataLayout(); - AP.OutStreamer.EmitZeros(DL.getTypeAllocSize(CFP->getType()) - - DL.getTypeStoreSize(CFP->getType())); + AP.OutStreamer->EmitZeros(DL.getTypeAllocSize(CFP->getType()) - + DL.getTypeStoreSize(CFP->getType())); } static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) { @@ -2064,7 +2063,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) { const uint64_t *RawData = Realigned.getRawData(); for (unsigned i = 0, e = BitWidth / 64; i != e; ++i) { uint64_t Val = DL->isBigEndian() ? RawData[e - i - 1] : RawData[i]; - AP.OutStreamer.EmitIntValue(Val, 8); + AP.OutStreamer->EmitIntValue(Val, 8); } if (ExtraBitsSize) { @@ -2077,7 +2076,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) { assert(Size && Size * 8 >= ExtraBitsSize && (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize))) == ExtraBits && "Directive too small for extra bits."); - AP.OutStreamer.EmitIntValue(ExtraBits, Size); + AP.OutStreamer->EmitIntValue(ExtraBits, Size); } } @@ -2160,7 +2159,7 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME, const GlobalValue *FinalGV = dyn_cast(GV->getOperand(0)); const MCSymbol *FinalSym = AP.getSymbol(FinalGV); *ME = AP.getObjFileLowering().getIndirectSymViaGOTPCRel( - FinalSym, MV, Offset, AP.MMI, AP.OutStreamer); + FinalSym, MV, Offset, AP.MMI, *AP.OutStreamer); // Update GOT equivalent usage information --NumUses; @@ -2180,7 +2179,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP, BaseCV = dyn_cast(CV->user_back()); if (isa(CV) || isa(CV)) - return AP.OutStreamer.EmitZeros(Size); + return AP.OutStreamer->EmitZeros(Size); if (const ConstantInt *CI = dyn_cast(CV)) { switch (Size) { @@ -2189,9 +2188,9 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP, case 4: case 8: if (AP.isVerbose()) - AP.OutStreamer.GetCommentOS() << format("0x%" PRIx64 "\n", - CI->getZExtValue()); - AP.OutStreamer.EmitIntValue(CI->getZExtValue(), Size); + AP.OutStreamer->GetCommentOS() << format("0x%" PRIx64 "\n", + CI->getZExtValue()); + AP.OutStreamer->EmitIntValue(CI->getZExtValue(), Size); return; default: emitGlobalConstantLargeInt(CI, AP); @@ -2203,7 +2202,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP, return emitGlobalConstantFP(CFP, AP); if (isa(CV)) { - AP.OutStreamer.EmitIntValue(0, Size); + AP.OutStreamer->EmitIntValue(0, Size); return; } @@ -2245,7 +2244,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP, if (AP.getObjFileLowering().supportIndirectSymViaGOTPCRel()) handleIndirectSymViaGOTPCRel(AP, &ME, BaseCV, Offset); - AP.OutStreamer.EmitValue(ME, Size); + AP.OutStreamer->EmitValue(ME, Size); } /// EmitGlobalConstant - Print a general LLVM constant to the .s file. @@ -2257,7 +2256,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) { else if (MAI->hasSubsectionsViaSymbols()) { // If the global has zero size, emit a single byte so that two labels don't // look like they are at the same location. - OutStreamer.EmitIntValue(0, 1); + OutStreamer->EmitIntValue(0, 1); } } @@ -2367,16 +2366,16 @@ static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB, // If this block is not a loop header, just print out what is the loop header // and return. if (Header != &MBB) { - AP.OutStreamer.AddComment(" in Loop: Header=BB" + - Twine(AP.getFunctionNumber())+"_" + - Twine(Loop->getHeader()->getNumber())+ - " Depth="+Twine(Loop->getLoopDepth())); + AP.OutStreamer->AddComment(" in Loop: Header=BB" + + Twine(AP.getFunctionNumber())+"_" + + Twine(Loop->getHeader()->getNumber())+ + " Depth="+Twine(Loop->getLoopDepth())); return; } // Otherwise, it is a loop header. Print out information about child and // parent loops. - raw_ostream &OS = AP.OutStreamer.GetCommentOS(); + raw_ostream &OS = AP.OutStreamer->GetCommentOS(); PrintParentLoopComment(OS, Loop->getParentLoop(), AP.getFunctionNumber()); @@ -2407,18 +2406,18 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock &MBB) const { if (MBB.hasAddressTaken()) { const BasicBlock *BB = MBB.getBasicBlock(); if (isVerbose()) - OutStreamer.AddComment("Block address taken"); + OutStreamer->AddComment("Block address taken"); std::vector Symbols = MMI->getAddrLabelSymbolToEmit(BB); for (auto *Sym : Symbols) - OutStreamer.EmitLabel(Sym); + OutStreamer->EmitLabel(Sym); } // Print some verbose block comments. if (isVerbose()) { if (const BasicBlock *BB = MBB.getBasicBlock()) if (BB->hasName()) - OutStreamer.AddComment("%" + BB->getName()); + OutStreamer->AddComment("%" + BB->getName()); emitBasicBlockLoopComments(MBB, LI, *this); } @@ -2426,10 +2425,10 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock &MBB) const { if (MBB.pred_empty() || isBlockOnlyReachableByFallthrough(&MBB)) { if (isVerbose()) { // NOTE: Want this comment at start of line, don't emit with AddComment. - OutStreamer.emitRawComment(" BB#" + Twine(MBB.getNumber()) + ":", false); + OutStreamer->emitRawComment(" BB#" + Twine(MBB.getNumber()) + ":", false); } } else { - OutStreamer.EmitLabel(MBB.getSymbol()); + OutStreamer->EmitLabel(MBB.getSymbol()); } } @@ -2451,7 +2450,7 @@ void AsmPrinter::EmitVisibility(MCSymbol *Sym, unsigned Visibility, } if (Attr != MCSA_Invalid) - OutStreamer.EmitSymbolAttribute(Sym, Attr); + OutStreamer->EmitSymbolAttribute(Sym, Attr); } /// isBlockOnlyReachableByFallthough - Return true if the basic block has diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index 9de36da..6f48767 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -42,30 +42,30 @@ using namespace llvm; /// EmitSLEB128 - emit the specified signed leb128 value. void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const { if (isVerbose() && Desc) - OutStreamer.AddComment(Desc); + OutStreamer->AddComment(Desc); - OutStreamer.EmitSLEB128IntValue(Value); + OutStreamer->EmitSLEB128IntValue(Value); } /// EmitULEB128 - emit the specified signed leb128 value. void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc, unsigned PadTo) const { if (isVerbose() && Desc) - OutStreamer.AddComment(Desc); + OutStreamer->AddComment(Desc); - OutStreamer.EmitULEB128IntValue(Value, PadTo); + OutStreamer->EmitULEB128IntValue(Value, PadTo); } /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value. void AsmPrinter::EmitCFAByte(unsigned Val) const { if (isVerbose()) { if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset + 64) - OutStreamer.AddComment("DW_CFA_offset + Reg (" + - Twine(Val - dwarf::DW_CFA_offset) + ")"); + OutStreamer->AddComment("DW_CFA_offset + Reg (" + + Twine(Val - dwarf::DW_CFA_offset) + ")"); else - OutStreamer.AddComment(dwarf::CallFrameString(Val)); + OutStreamer->AddComment(dwarf::CallFrameString(Val)); } - OutStreamer.EmitIntValue(Val, 1); + OutStreamer->EmitIntValue(Val, 1); } static const char *DecodeDWARFEncoding(unsigned Encoding) { @@ -116,13 +116,13 @@ static const char *DecodeDWARFEncoding(unsigned Encoding) { void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) const { if (isVerbose()) { if (Desc) - OutStreamer.AddComment(Twine(Desc) + " Encoding = " + - Twine(DecodeDWARFEncoding(Val))); + OutStreamer->AddComment(Twine(Desc) + " Encoding = " + + Twine(DecodeDWARFEncoding(Val))); else - OutStreamer.AddComment(Twine("Encoding = ") + DecodeDWARFEncoding(Val)); + OutStreamer->AddComment(Twine("Encoding = ") + DecodeDWARFEncoding(Val)); } - OutStreamer.EmitIntValue(Val, 1); + OutStreamer->EmitIntValue(Val, 1); } /// GetSizeOfEncodedValue - Return the size of the encoding in bytes. @@ -150,10 +150,11 @@ void AsmPrinter::EmitTTypeReference(const GlobalValue *GV, const TargetLoweringObjectFile &TLOF = getObjFileLowering(); const MCExpr *Exp = - TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI, OutStreamer); - OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding)); + TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI, + *OutStreamer); + OutStreamer->EmitValue(Exp, GetSizeOfEncodedValue(Encoding)); } else - OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding)); + OutStreamer->EmitIntValue(0, GetSizeOfEncodedValue(Encoding)); } /// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its @@ -166,13 +167,13 @@ void AsmPrinter::EmitTTypeReference(const GlobalValue *GV, void AsmPrinter::emitSectionOffset(const MCSymbol *Label) const { // On COFF targets, we have to emit the special .secrel32 directive. if (MAI->needsDwarfSectionOffsetDirective()) { - OutStreamer.EmitCOFFSecRel32(Label); + OutStreamer->EmitCOFFSecRel32(Label); return; } // If the format uses relocations with dwarf, refer to the symbol directly. if (MAI->doesDwarfUseRelocationsAcrossSections()) { - OutStreamer.EmitSymbolValue(Label, 4); + OutStreamer->EmitSymbolValue(Label, 4); return; } @@ -219,25 +220,25 @@ void AsmPrinter::emitCFIInstruction(const MCCFIInstruction &Inst) const { default: llvm_unreachable("Unexpected instruction"); case MCCFIInstruction::OpDefCfaOffset: - OutStreamer.EmitCFIDefCfaOffset(Inst.getOffset()); + OutStreamer->EmitCFIDefCfaOffset(Inst.getOffset()); break; case MCCFIInstruction::OpDefCfa: - OutStreamer.EmitCFIDefCfa(Inst.getRegister(), Inst.getOffset()); + OutStreamer->EmitCFIDefCfa(Inst.getRegister(), Inst.getOffset()); break; case MCCFIInstruction::OpDefCfaRegister: - OutStreamer.EmitCFIDefCfaRegister(Inst.getRegister()); + OutStreamer->EmitCFIDefCfaRegister(Inst.getRegister()); break; case MCCFIInstruction::OpOffset: - OutStreamer.EmitCFIOffset(Inst.getRegister(), Inst.getOffset()); + OutStreamer->EmitCFIOffset(Inst.getRegister(), Inst.getOffset()); break; case MCCFIInstruction::OpRegister: - OutStreamer.EmitCFIRegister(Inst.getRegister(), Inst.getRegister2()); + OutStreamer->EmitCFIRegister(Inst.getRegister(), Inst.getRegister2()); break; case MCCFIInstruction::OpWindowSave: - OutStreamer.EmitCFIWindowSave(); + OutStreamer->EmitCFIWindowSave(); break; case MCCFIInstruction::OpSameValue: - OutStreamer.EmitCFISameValue(Inst.getRegister()); + OutStreamer->EmitCFISameValue(Inst.getRegister()); break; } } @@ -248,10 +249,10 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const { // Emit the code (index) for the abbreviation. if (isVerbose()) - OutStreamer.AddComment("Abbrev [" + Twine(Abbrev.getNumber()) + - "] 0x" + Twine::utohexstr(Die.getOffset()) + - ":0x" + Twine::utohexstr(Die.getSize()) + " " + - dwarf::TagString(Abbrev.getTag())); + OutStreamer->AddComment("Abbrev [" + Twine(Abbrev.getNumber()) + + "] 0x" + Twine::utohexstr(Die.getOffset()) + + ":0x" + Twine::utohexstr(Die.getSize()) + " " + + dwarf::TagString(Abbrev.getTag())); EmitULEB128(Abbrev.getNumber()); const SmallVectorImpl &Values = Die.getValues(); @@ -264,9 +265,9 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const { assert(Form && "Too many attributes for DIE (check abbreviation)"); if (isVerbose()) { - OutStreamer.AddComment(dwarf::AttributeString(Attr)); + OutStreamer->AddComment(dwarf::AttributeString(Attr)); if (Attr == dwarf::DW_AT_accessibility) - OutStreamer.AddComment(dwarf::AccessibilityString( + OutStreamer->AddComment(dwarf::AccessibilityString( cast(Values[i])->getValue())); } @@ -279,7 +280,7 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const { for (auto &Child : Die.getChildren()) emitDwarfDIE(*Child); - OutStreamer.AddComment("End Of Children Mark"); + OutStreamer->AddComment("End Of Children Mark"); EmitInt8(0); } } diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index bf63b1b..04ab2d1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -91,9 +91,9 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI, const MCAsmInfo *MCAI = TM.getMCAsmInfo(); assert(MCAI && "No MCAsmInfo"); if (!MCAI->useIntegratedAssembler() && - !OutStreamer.isIntegratedAssemblerRequired()) { + !OutStreamer->isIntegratedAssemblerRequired()) { emitInlineAsmStart(); - OutStreamer.EmitRawText(Str); + OutStreamer->EmitRawText(Str); emitInlineAsmEnd(STI, nullptr); return; } @@ -124,7 +124,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI, SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc()); std::unique_ptr Parser( - createMCAsmParser(SrcMgr, OutContext, OutStreamer, *MAI)); + createMCAsmParser(SrcMgr, OutContext, *OutStreamer, *MAI)); // Create a temporary copy of the original STI because the parser may modify // it. For example, when switching between arm and thumb mode. If the target @@ -448,14 +448,14 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const { // If this asmstr is empty, just print the #APP/#NOAPP markers. // These are useful to see where empty asm's wound up. if (AsmStr[0] == 0) { - OutStreamer.emitRawComment(MAI->getInlineAsmStart()); - OutStreamer.emitRawComment(MAI->getInlineAsmEnd()); + OutStreamer->emitRawComment(MAI->getInlineAsmStart()); + OutStreamer->emitRawComment(MAI->getInlineAsmEnd()); return; } // Emit the #APP start marker. This has to happen even if verbose-asm isn't // enabled, so we use emitRawComment. - OutStreamer.emitRawComment(MAI->getInlineAsmStart()); + OutStreamer->emitRawComment(MAI->getInlineAsmStart()); // Get the !srcloc metadata node if we have it, and decode the loc cookie from // it. @@ -492,7 +492,7 @@ void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const { // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't // enabled, so we use emitRawComment. - OutStreamer.emitRawComment(MAI->getInlineAsmEnd()); + OutStreamer->emitRawComment(MAI->getInlineAsmEnd()); } diff --git a/llvm/lib/CodeGen/AsmPrinter/ByteStreamer.h b/llvm/lib/CodeGen/AsmPrinter/ByteStreamer.h index 179a4d4..0576720 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ByteStreamer.h +++ b/llvm/lib/CodeGen/AsmPrinter/ByteStreamer.h @@ -40,15 +40,15 @@ private: public: APByteStreamer(AsmPrinter &Asm) : AP(Asm) {} void EmitInt8(uint8_t Byte, const Twine &Comment) override { - AP.OutStreamer.AddComment(Comment); + AP.OutStreamer->AddComment(Comment); AP.EmitInt8(Byte); } void EmitSLEB128(uint64_t DWord, const Twine &Comment) override { - AP.OutStreamer.AddComment(Comment); + AP.OutStreamer->AddComment(Comment); AP.EmitSLEB128(DWord); } void EmitULEB128(uint64_t DWord, const Twine &Comment) override { - AP.OutStreamer.AddComment(Comment); + AP.OutStreamer->AddComment(Comment); AP.EmitULEB128(DWord); } }; diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index bb4cf66..aa6647f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -211,7 +211,7 @@ void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { case dwarf::DW_FORM_flag_present: // Emit something to keep the lines and comments in sync. // FIXME: Is there a better way to do this? - Asm->OutStreamer.AddBlankLine(); + Asm->OutStreamer->AddBlankLine(); return; case dwarf::DW_FORM_flag: // Fall thru case dwarf::DW_FORM_ref1: // Fall thru @@ -236,7 +236,7 @@ void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { break; default: llvm_unreachable("DIE Value form not supported yet"); } - Asm->OutStreamer.EmitIntValue(Integer, Size); + Asm->OutStreamer->EmitIntValue(Integer, Size); } /// SizeOf - Determine size of integer value in bytes. @@ -262,7 +262,7 @@ unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { case dwarf::DW_FORM_sdata: return getSLEB128Size(Integer); case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize(); case dwarf::DW_FORM_ref_addr: - if (AP->OutStreamer.getContext().getDwarfVersion() == 2) + if (AP->OutStreamer->getContext().getDwarfVersion() == 2) return AP->getDataLayout().getPointerSize(); return sizeof(int32_t); default: llvm_unreachable("DIE Value form not supported yet"); @@ -283,7 +283,7 @@ void DIEInteger::print(raw_ostream &O) const { /// EmitValue - Emit expression value. /// void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { - AP->OutStreamer.EmitValue(Expr, SizeOf(AP, Form)); + AP->OutStreamer->EmitValue(Expr, SizeOf(AP, Form)); } /// SizeOf - Determine size of expression value in bytes. @@ -400,7 +400,7 @@ void DIEEntry::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { AP->EmitLabelPlusOffset(CU->getSectionSym(), Addr, DIEEntry::getRefAddrSize(AP)); else - AP->OutStreamer.EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP)); + AP->OutStreamer->EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP)); } else AP->EmitInt32(Entry.getOffset()); } @@ -428,7 +428,7 @@ void DIEEntry::print(raw_ostream &O) const { //===----------------------------------------------------------------------===// void DIETypeSignature::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { assert(Form == dwarf::DW_FORM_ref_sig8); - Asm->OutStreamer.EmitIntValue(Unit.getTypeSignature(), 8); + Asm->OutStreamer->EmitIntValue(Unit.getTypeSignature(), 8); } #ifndef NDEBUG diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp index f64338e..dfc61e6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp @@ -111,27 +111,27 @@ void DwarfAccelTable::FinalizeTable(AsmPrinter *Asm, StringRef Prefix) { // Emits the header for the table via the AsmPrinter. void DwarfAccelTable::EmitHeader(AsmPrinter *Asm) { - Asm->OutStreamer.AddComment("Header Magic"); + Asm->OutStreamer->AddComment("Header Magic"); Asm->EmitInt32(Header.magic); - Asm->OutStreamer.AddComment("Header Version"); + Asm->OutStreamer->AddComment("Header Version"); Asm->EmitInt16(Header.version); - Asm->OutStreamer.AddComment("Header Hash Function"); + Asm->OutStreamer->AddComment("Header Hash Function"); Asm->EmitInt16(Header.hash_function); - Asm->OutStreamer.AddComment("Header Bucket Count"); + Asm->OutStreamer->AddComment("Header Bucket Count"); Asm->EmitInt32(Header.bucket_count); - Asm->OutStreamer.AddComment("Header Hash Count"); + Asm->OutStreamer->AddComment("Header Hash Count"); Asm->EmitInt32(Header.hashes_count); - Asm->OutStreamer.AddComment("Header Data Length"); + Asm->OutStreamer->AddComment("Header Data Length"); Asm->EmitInt32(Header.header_data_len); - Asm->OutStreamer.AddComment("HeaderData Die Offset Base"); + Asm->OutStreamer->AddComment("HeaderData Die Offset Base"); Asm->EmitInt32(HeaderData.die_offset_base); - Asm->OutStreamer.AddComment("HeaderData Atom Count"); + Asm->OutStreamer->AddComment("HeaderData Atom Count"); Asm->EmitInt32(HeaderData.Atoms.size()); for (size_t i = 0; i < HeaderData.Atoms.size(); i++) { Atom A = HeaderData.Atoms[i]; - Asm->OutStreamer.AddComment(dwarf::AtomTypeString(A.type)); + Asm->OutStreamer->AddComment(dwarf::AtomTypeString(A.type)); Asm->EmitInt16(A.type); - Asm->OutStreamer.AddComment(dwarf::FormEncodingString(A.form)); + Asm->OutStreamer->AddComment(dwarf::FormEncodingString(A.form)); Asm->EmitInt16(A.form); } } @@ -141,7 +141,7 @@ void DwarfAccelTable::EmitHeader(AsmPrinter *Asm) { void DwarfAccelTable::EmitBuckets(AsmPrinter *Asm) { unsigned index = 0; for (size_t i = 0, e = Buckets.size(); i < e; ++i) { - Asm->OutStreamer.AddComment("Bucket " + Twine(i)); + Asm->OutStreamer->AddComment("Bucket " + Twine(i)); if (Buckets[i].size() != 0) Asm->EmitInt32(index); else @@ -169,7 +169,7 @@ void DwarfAccelTable::EmitHashes(AsmPrinter *Asm) { uint32_t HashValue = (*HI)->HashValue; if (PrevHash == HashValue) continue; - Asm->OutStreamer.AddComment("Hash in Bucket " + Twine(i)); + Asm->OutStreamer->AddComment("Hash in Bucket " + Twine(i)); Asm->EmitInt32(HashValue); PrevHash = HashValue; } @@ -190,12 +190,12 @@ void DwarfAccelTable::emitOffsets(AsmPrinter *Asm, const MCSymbol *SecBegin) { if (PrevHash == HashValue) continue; PrevHash = HashValue; - Asm->OutStreamer.AddComment("Offset in Bucket " + Twine(i)); - MCContext &Context = Asm->OutStreamer.getContext(); + Asm->OutStreamer->AddComment("Offset in Bucket " + Twine(i)); + MCContext &Context = Asm->OutStreamer->getContext(); const MCExpr *Sub = MCBinaryExpr::CreateSub( MCSymbolRefExpr::Create((*HI)->Sym, Context), MCSymbolRefExpr::Create(SecBegin, Context), Context); - Asm->OutStreamer.EmitValue(Sub, sizeof(uint32_t)); + Asm->OutStreamer->EmitValue(Sub, sizeof(uint32_t)); } } } @@ -214,10 +214,10 @@ void DwarfAccelTable::EmitData(AsmPrinter *Asm, DwarfDebug *D) { if (PrevHash != UINT64_MAX && PrevHash != (*HI)->HashValue) Asm->EmitInt32(0); // Remember to emit the label for our offset. - Asm->OutStreamer.EmitLabel((*HI)->Sym); - Asm->OutStreamer.AddComment((*HI)->Str); + Asm->OutStreamer->EmitLabel((*HI)->Sym); + Asm->OutStreamer->AddComment((*HI)->Str); Asm->emitSectionOffset((*HI)->Data.StrSym); - Asm->OutStreamer.AddComment("Num DIEs"); + Asm->OutStreamer->AddComment("Num DIEs"); Asm->EmitInt32((*HI)->Data.Values.size()); for (HashDataContents *HD : (*HI)->Data.Values) { // Emit the DIE offset diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp index 1bee367..0bc873e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp @@ -44,7 +44,7 @@ DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A) void DwarfCFIExceptionBase::markFunctionEnd() { if (shouldEmitCFI) - Asm->OutStreamer.EmitCFIEndProc(); + Asm->OutStreamer->EmitCFIEndProc(); if (MMI->getLandingPads().empty()) return; @@ -64,7 +64,7 @@ DwarfCFIException::~DwarfCFIException() {} /// content. void DwarfCFIException::endModule() { if (moveTypeModule == AsmPrinter::CFI_M_Debug) - Asm->OutStreamer.EmitCFISections(false, true); + Asm->OutStreamer->EmitCFISections(false, true); // SjLj uses this pass and it doesn't need this info. if (!Asm->MAI->usesCFIForEH()) @@ -83,7 +83,7 @@ void DwarfCFIException::endModule() { if (!Personalities[i]) continue; MCSymbol *Sym = Asm->getSymbol(Personalities[i]); - TLOF.emitPersonalityValue(Asm->OutStreamer, Asm->TM, Sym); + TLOF.emitPersonalityValue(*Asm->OutStreamer, Asm->TM, Sym); } } @@ -117,7 +117,7 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { if (!shouldEmitCFI) return; - Asm->OutStreamer.EmitCFIStartProc(/*IsSimple=*/false); + Asm->OutStreamer->EmitCFIStartProc(/*IsSimple=*/false); // Indicate personality routine, if any. if (!shouldEmitPersonality) @@ -125,13 +125,13 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) { const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI); - Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); + Asm->OutStreamer->EmitCFIPersonality(Sym, PerEncoding); // Provide LSDA information. if (!shouldEmitLSDA) return; - Asm->OutStreamer.EmitCFILsda(Asm->getCurExceptionSym(), LSDAEncoding); + Asm->OutStreamer->EmitCFILsda(Asm->getCurExceptionSym(), LSDAEncoding); } /// endFunction - Gather and emit post-function exception information. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index dbaf1c6..856920f 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -64,9 +64,9 @@ unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName, // FIXME: add a better feature test than hasRawTextSupport. Even better, // extend .file to support this. - return Asm->OutStreamer.EmitDwarfFileDirective( + return Asm->OutStreamer->EmitDwarfFileDirective( 0, DirName, FileName, - Asm->OutStreamer.hasRawTextSupport() ? 0 : getUniqueID()); + Asm->OutStreamer->hasRawTextSupport() ? 0 : getUniqueID()); } // Return const expression if value is a GEP to access merged global @@ -240,7 +240,7 @@ void DwarfCompileUnit::addSectionLabel(DIE &Die, dwarf::Attribute Attribute, void DwarfCompileUnit::initStmtList() { // Define start line table label for each Compile Unit. MCSymbol *LineTableStartSym = - Asm->OutStreamer.getDwarfLineTableSymbol(getUniqueID()); + Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID()); stmtListIndex = UnitDie.getValues().size(); @@ -700,7 +700,7 @@ void DwarfCompileUnit::emitHeader(bool UseOffsets) { // Don't bother labeling the .dwo unit, as its offset isn't used. if (!Skeleton) { LabelBegin = Asm->createTempSymbol("cu_begin"); - Asm->OutStreamer.EmitLabel(LabelBegin); + Asm->OutStreamer->EmitLabel(LabelBegin); } DwarfUnit::emitHeader(UseOffsets); diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index fdea05e..345eea6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -234,7 +234,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) // Everybody else uses GNU's. UseGNUTLSOpcode = !(IsDarwin || IsPS4) || DwarfVersion < 3; - Asm->OutStreamer.getContext().setDwarfVersion(DwarfVersion); + Asm->OutStreamer->getContext().setDwarfVersion(DwarfVersion); { NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); @@ -380,8 +380,8 @@ DwarfDebug::constructDwarfCompileUnit(const MDCompileUnit *DIUnit) { // To avoid the compilation directory being ambiguous, let the line table // explicitly describe the directory of all files, never relying on the // compilation directory. - if (!Asm->OutStreamer.hasRawTextSupport() || SingleCU) - Asm->OutStreamer.getContext().setMCLineTableCompilationDir( + if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU) + Asm->OutStreamer->getContext().setMCLineTableCompilationDir( NewCU.getUniqueID(), CompilationDir); NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit->getProducer()); @@ -972,7 +972,7 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) { Flags |= DWARF2_FLAG_IS_STMT; } if (DL.getLine() != - Asm->OutStreamer.getContext().getCurrentDwarfLoc().getLine()) + Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine()) Flags |= DWARF2_FLAG_IS_STMT; const MDNode *Scope = DL.getScope(); @@ -998,7 +998,7 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) { if (!PrevLabel) { PrevLabel = MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.EmitLabel(PrevLabel); + Asm->OutStreamer->EmitLabel(PrevLabel); } I->second = PrevLabel; } @@ -1026,7 +1026,7 @@ void DwarfDebug::endInstruction() { // We need a label after this instruction. if (!PrevLabel) { PrevLabel = MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.EmitLabel(PrevLabel); + Asm->OutStreamer->EmitLabel(PrevLabel); } I->second = PrevLabel; } @@ -1110,11 +1110,11 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) { // is absolute (such as an <> lookup header))) DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode()); assert(TheCU && "Unable to find compile unit!"); - if (Asm->OutStreamer.hasRawTextSupport()) + if (Asm->OutStreamer->hasRawTextSupport()) // Use a single line table if we are generating assembly. - Asm->OutStreamer.getContext().setDwarfCompileUnitID(0); + Asm->OutStreamer->getContext().setDwarfCompileUnitID(0); else - Asm->OutStreamer.getContext().setDwarfCompileUnitID(TheCU->getUniqueID()); + Asm->OutStreamer->getContext().setDwarfCompileUnitID(TheCU->getUniqueID()); // Calculate history for local variables. calculateDbgValueHistory(MF, Asm->MF->getSubtarget().getRegisterInfo(), @@ -1183,7 +1183,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) { } // Set DwarfDwarfCompileUnitID in MCContext to default value. - Asm->OutStreamer.getContext().setDwarfCompileUnitID(0); + Asm->OutStreamer->getContext().setDwarfCompileUnitID(0); LexicalScope *FnScope = LScopes.getCurrentFunctionScope(); auto *SP = cast(FnScope->getScopeNode()); @@ -1260,12 +1260,12 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S, if (auto *LBF = dyn_cast(Scope)) Discriminator = LBF->getDiscriminator(); - unsigned CUID = Asm->OutStreamer.getContext().getDwarfCompileUnitID(); + unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID(); Src = static_cast(*InfoHolder.getUnits()[CUID]) .getOrCreateSourceID(Fn, Dir); } - Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0, - Discriminator, Fn); + Asm->OutStreamer->EmitDwarfLocDirective(Src, Line, Col, Flags, 0, + Discriminator, Fn); } //===----------------------------------------------------------------------===// @@ -1288,7 +1288,7 @@ void DwarfDebug::emitAbbreviations() { void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section, StringRef TableName) { Accel.FinalizeTable(Asm, TableName); - Asm->OutStreamer.SwitchSection(Section); + Asm->OutStreamer->SwitchSection(Section); // Emit the full data. Accel.emit(Asm, Section->getBeginSymbol(), this); @@ -1402,23 +1402,23 @@ void DwarfDebug::emitDebugPubSection( TheU = Skeleton; // Start the dwarf pubnames section. - Asm->OutStreamer.SwitchSection(PSec); + Asm->OutStreamer->SwitchSection(PSec); // Emit the header. - Asm->OutStreamer.AddComment("Length of Public " + Name + " Info"); + Asm->OutStreamer->AddComment("Length of Public " + Name + " Info"); MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin"); MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end"); Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); - Asm->OutStreamer.EmitLabel(BeginLabel); + Asm->OutStreamer->EmitLabel(BeginLabel); - Asm->OutStreamer.AddComment("DWARF Version"); + Asm->OutStreamer->AddComment("DWARF Version"); Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION); - Asm->OutStreamer.AddComment("Offset of Compilation Unit Info"); + Asm->OutStreamer->AddComment("Offset of Compilation Unit Info"); Asm->emitSectionOffset(TheU->getLabelBegin()); - Asm->OutStreamer.AddComment("Compilation Unit Length"); + Asm->OutStreamer->AddComment("Compilation Unit Length"); Asm->EmitInt32(TheU->getLength()); // Emit the pubnames for this compilation unit. @@ -1426,24 +1426,24 @@ void DwarfDebug::emitDebugPubSection( const char *Name = GI.getKeyData(); const DIE *Entity = GI.second; - Asm->OutStreamer.AddComment("DIE offset"); + Asm->OutStreamer->AddComment("DIE offset"); Asm->EmitInt32(Entity->getOffset()); if (GnuStyle) { dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity); - Asm->OutStreamer.AddComment( + Asm->OutStreamer->AddComment( Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " + dwarf::GDBIndexEntryLinkageString(Desc.Linkage)); Asm->EmitInt8(Desc.toBits()); } - Asm->OutStreamer.AddComment("External Name"); - Asm->OutStreamer.EmitBytes(StringRef(Name, GI.getKeyLength() + 1)); + Asm->OutStreamer->AddComment("External Name"); + Asm->OutStreamer->EmitBytes(StringRef(Name, GI.getKeyLength() + 1)); } - Asm->OutStreamer.AddComment("End Mark"); + Asm->OutStreamer->AddComment("End Mark"); Asm->EmitInt32(0); - Asm->OutStreamer.EmitLabel(EndLabel); + Asm->OutStreamer->EmitLabel(EndLabel); } } @@ -1545,26 +1545,26 @@ void DebugLocEntry::finalize(const AsmPrinter &AP, DebugLocStream &Locs, } void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry) { - Asm->OutStreamer.AddComment("Loc expr size"); - MCSymbol *begin = Asm->OutStreamer.getContext().CreateTempSymbol(); - MCSymbol *end = Asm->OutStreamer.getContext().CreateTempSymbol(); + Asm->OutStreamer->AddComment("Loc expr size"); + MCSymbol *begin = Asm->OutStreamer->getContext().CreateTempSymbol(); + MCSymbol *end = Asm->OutStreamer->getContext().CreateTempSymbol(); Asm->EmitLabelDifference(end, begin, 2); - Asm->OutStreamer.EmitLabel(begin); + Asm->OutStreamer->EmitLabel(begin); // Emit the entry. APByteStreamer Streamer(*Asm); emitDebugLocEntry(Streamer, Entry); // Close the range. - Asm->OutStreamer.EmitLabel(end); + Asm->OutStreamer->EmitLabel(end); } // Emit locations into the debug loc section. void DwarfDebug::emitDebugLoc() { // Start the dwarf loc section. - Asm->OutStreamer.SwitchSection( + Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getDwarfLocSection()); unsigned char Size = Asm->getDataLayout().getPointerSize(); for (const auto &List : DebugLocs.getLists()) { - Asm->OutStreamer.EmitLabel(List.Label); + Asm->OutStreamer->EmitLabel(List.Label); const DwarfCompileUnit *CU = List.CU; for (const auto &Entry : DebugLocs.getEntries(List)) { // Set up the range. This range is relative to the entry point of the @@ -1574,22 +1574,22 @@ void DwarfDebug::emitDebugLoc() { Asm->EmitLabelDifference(Entry.BeginSym, Base, Size); Asm->EmitLabelDifference(Entry.EndSym, Base, Size); } else { - Asm->OutStreamer.EmitSymbolValue(Entry.BeginSym, Size); - Asm->OutStreamer.EmitSymbolValue(Entry.EndSym, Size); + Asm->OutStreamer->EmitSymbolValue(Entry.BeginSym, Size); + Asm->OutStreamer->EmitSymbolValue(Entry.EndSym, Size); } emitDebugLocEntryLocation(Entry); } - Asm->OutStreamer.EmitIntValue(0, Size); - Asm->OutStreamer.EmitIntValue(0, Size); + Asm->OutStreamer->EmitIntValue(0, Size); + Asm->OutStreamer->EmitIntValue(0, Size); } } void DwarfDebug::emitDebugLocDWO() { - Asm->OutStreamer.SwitchSection( + Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getDwarfLocDWOSection()); for (const auto &List : DebugLocs.getLists()) { - Asm->OutStreamer.EmitLabel(List.Label); + Asm->OutStreamer->EmitLabel(List.Label); for (const auto &Entry : DebugLocs.getEntries(List)) { // Just always use start_length for now - at least that's one address // rather than two. We could get fancier and try to, say, reuse an @@ -1637,7 +1637,7 @@ void DwarfDebug::emitDebugARanges() { MCSymbol *Sym = nullptr; if (Section) - Sym = Asm->OutStreamer.endSection(Section); + Sym = Asm->OutStreamer->endSection(Section); // Insert a final terminator. SectionMap[Section].push_back(SymbolCU(nullptr, Sym)); @@ -1667,8 +1667,8 @@ void DwarfDebug::emitDebugARanges() { // Sort the symbols by offset within the section. std::sort(List.begin(), List.end(), [&](const SymbolCU &A, const SymbolCU &B) { - unsigned IA = A.Sym ? Asm->OutStreamer.GetSymbolOrder(A.Sym) : 0; - unsigned IB = B.Sym ? Asm->OutStreamer.GetSymbolOrder(B.Sym) : 0; + unsigned IA = A.Sym ? Asm->OutStreamer->GetSymbolOrder(A.Sym) : 0; + unsigned IB = B.Sym ? Asm->OutStreamer->GetSymbolOrder(B.Sym) : 0; // Symbols with no order assigned should be placed at the end. // (e.g. section end labels) @@ -1697,7 +1697,7 @@ void DwarfDebug::emitDebugARanges() { } // Start the dwarf aranges section. - Asm->OutStreamer.SwitchSection( + Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getDwarfARangesSection()); unsigned PtrSize = Asm->getDataLayout().getPointerSize(); @@ -1739,18 +1739,18 @@ void DwarfDebug::emitDebugARanges() { ContentSize += (List.size() + 1) * TupleSize; // For each compile unit, write the list of spans it covers. - Asm->OutStreamer.AddComment("Length of ARange Set"); + Asm->OutStreamer->AddComment("Length of ARange Set"); Asm->EmitInt32(ContentSize); - Asm->OutStreamer.AddComment("DWARF Arange version number"); + Asm->OutStreamer->AddComment("DWARF Arange version number"); Asm->EmitInt16(dwarf::DW_ARANGES_VERSION); - Asm->OutStreamer.AddComment("Offset Into Debug Info Section"); + Asm->OutStreamer->AddComment("Offset Into Debug Info Section"); Asm->emitSectionOffset(CU->getLabelBegin()); - Asm->OutStreamer.AddComment("Address Size (in bytes)"); + Asm->OutStreamer->AddComment("Address Size (in bytes)"); Asm->EmitInt8(PtrSize); - Asm->OutStreamer.AddComment("Segment Size (in bytes)"); + Asm->OutStreamer->AddComment("Segment Size (in bytes)"); Asm->EmitInt8(0); - Asm->OutStreamer.EmitFill(Padding, 0xff); + Asm->OutStreamer->EmitFill(Padding, 0xff); for (const ArangeSpan &Span : List) { Asm->EmitLabelReference(Span.Start, PtrSize); @@ -1765,20 +1765,20 @@ void DwarfDebug::emitDebugARanges() { if (Size == 0) Size = 1; - Asm->OutStreamer.EmitIntValue(Size, PtrSize); + Asm->OutStreamer->EmitIntValue(Size, PtrSize); } } - Asm->OutStreamer.AddComment("ARange terminator"); - Asm->OutStreamer.EmitIntValue(0, PtrSize); - Asm->OutStreamer.EmitIntValue(0, PtrSize); + Asm->OutStreamer->AddComment("ARange terminator"); + Asm->OutStreamer->EmitIntValue(0, PtrSize); + Asm->OutStreamer->EmitIntValue(0, PtrSize); } } // Emit visible names into a debug ranges section. void DwarfDebug::emitDebugRanges() { // Start the dwarf ranges section. - Asm->OutStreamer.SwitchSection( + Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getDwarfRangesSection()); // Size for our labels. @@ -1794,7 +1794,7 @@ void DwarfDebug::emitDebugRanges() { // Iterate over the misc ranges for the compile units in the module. for (const RangeSpanList &List : TheCU->getRangeLists()) { // Emit our symbol so we can find the beginning of the range. - Asm->OutStreamer.EmitLabel(List.getSym()); + Asm->OutStreamer->EmitLabel(List.getSym()); for (const RangeSpan &Range : List.getRanges()) { const MCSymbol *Begin = Range.getStart(); @@ -1805,14 +1805,14 @@ void DwarfDebug::emitDebugRanges() { Asm->EmitLabelDifference(Begin, Base, Size); Asm->EmitLabelDifference(End, Base, Size); } else { - Asm->OutStreamer.EmitSymbolValue(Begin, Size); - Asm->OutStreamer.EmitSymbolValue(End, Size); + Asm->OutStreamer->EmitSymbolValue(Begin, Size); + Asm->OutStreamer->EmitSymbolValue(End, Size); } } // And terminate the list with two 0 values. - Asm->OutStreamer.EmitIntValue(0, Size); - Asm->OutStreamer.EmitIntValue(0, Size); + Asm->OutStreamer->EmitIntValue(0, Size); + Asm->OutStreamer->EmitIntValue(0, Size); } } } @@ -1866,9 +1866,9 @@ void DwarfDebug::emitDebugAbbrevDWO() { void DwarfDebug::emitDebugLineDWO() { assert(useSplitDwarf() && "No split dwarf?"); - Asm->OutStreamer.SwitchSection( + Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getDwarfLineDWOSection()); - SplitTypeUnitFileTable.Emit(Asm->OutStreamer); + SplitTypeUnitFileTable.Emit(*Asm->OutStreamer); } // Emit the .debug_str.dwo section for separated dwarf. This contains the diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp index 29a163b..50dbb41 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp @@ -51,7 +51,7 @@ void DwarfFile::emitUnits(bool UseOffsets) { for (const auto &TheU : CUs) { DIE &Die = TheU->getUnitDie(); const MCSection *USection = TheU->getSection(); - Asm->OutStreamer.SwitchSection(USection); + Asm->OutStreamer->SwitchSection(USection); TheU->emitHeader(UseOffsets); @@ -124,7 +124,7 @@ void DwarfFile::emitAbbrevs(const MCSection *Section) { // Check to see if it is worth the effort. if (!Abbreviations.empty()) { // Start the debug abbrev section. - Asm->OutStreamer.SwitchSection(Section); + Asm->OutStreamer->SwitchSection(Section); Asm->emitDwarfAbbrevs(Abbreviations); } } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp index 165ef16..ee224f8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp @@ -38,7 +38,7 @@ void DwarfStringPool::emit(AsmPrinter &Asm, const MCSection *StrSection, return; // Start the dwarf str section. - Asm.OutStreamer.SwitchSection(StrSection); + Asm.OutStreamer->SwitchSection(StrSection); // Get all of the string pool entries and put them in an array by their ID so // we can sort them. @@ -50,20 +50,20 @@ void DwarfStringPool::emit(AsmPrinter &Asm, const MCSection *StrSection, for (const auto &Entry : Entries) { // Emit a label for reference from debug information entries. - Asm.OutStreamer.EmitLabel(Entry->getValue().first); + Asm.OutStreamer->EmitLabel(Entry->getValue().first); // Emit the string itself with a terminating null byte. - Asm.OutStreamer.EmitBytes( + Asm.OutStreamer->EmitBytes( StringRef(Entry->getKeyData(), Entry->getKeyLength() + 1)); } // If we've got an offset section go ahead and emit that now as well. if (OffsetSection) { - Asm.OutStreamer.SwitchSection(OffsetSection); + Asm.OutStreamer->SwitchSection(OffsetSection); unsigned offset = 0; unsigned size = 4; // FIXME: DWARF64 is 8. for (const auto &Entry : Entries) { - Asm.OutStreamer.EmitIntValue(offset, size); + Asm.OutStreamer->EmitIntValue(offset, size); offset += Entry->getKeyLength() + 1; } } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 6e00ed8..b721077 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1494,12 +1494,12 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) { void DwarfUnit::emitHeader(bool UseOffsets) { // Emit size of content not including length itself - Asm->OutStreamer.AddComment("Length of Unit"); + Asm->OutStreamer->AddComment("Length of Unit"); Asm->EmitInt32(getHeaderSize() + UnitDie.getSize()); - Asm->OutStreamer.AddComment("DWARF version number"); + Asm->OutStreamer->AddComment("DWARF version number"); Asm->EmitInt16(DD->getDwarfVersion()); - Asm->OutStreamer.AddComment("Offset Into Abbrev. Section"); + Asm->OutStreamer->AddComment("Offset Into Abbrev. Section"); // We share one abbreviations table across all units so it's always at the // start of the section. Use a relocatable offset where needed to ensure @@ -1510,7 +1510,7 @@ void DwarfUnit::emitHeader(bool UseOffsets) { else Asm->EmitInt32(0); - Asm->OutStreamer.AddComment("Address Size (in bytes)"); + Asm->OutStreamer->AddComment("Address Size (in bytes)"); Asm->EmitInt8(Asm->getDataLayout().getPointerSize()); } @@ -1521,12 +1521,12 @@ void DwarfUnit::initSection(const MCSection *Section) { void DwarfTypeUnit::emitHeader(bool UseOffsets) { DwarfUnit::emitHeader(UseOffsets); - Asm->OutStreamer.AddComment("Type Signature"); - Asm->OutStreamer.EmitIntValue(TypeSignature, sizeof(TypeSignature)); - Asm->OutStreamer.AddComment("Type DIE Offset"); + Asm->OutStreamer->AddComment("Type Signature"); + Asm->OutStreamer->EmitIntValue(TypeSignature, sizeof(TypeSignature)); + Asm->OutStreamer->AddComment("Type DIE Offset"); // In a skeleton type unit there is no type DIE so emit a zero offset. - Asm->OutStreamer.EmitIntValue(Ty ? Ty->getOffset() : 0, - sizeof(Ty->getOffset())); + Asm->OutStreamer->EmitIntValue(Ty ? Ty->getOffset() : 0, + sizeof(Ty->getOffset())); } bool DwarfTypeUnit::isDwoUnit() const { diff --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp index 6f64d8f..1ae5b57 100644 --- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp @@ -434,15 +434,15 @@ void EHStreamer::emitExceptionTable() { // Sometimes we want not to emit the data into separate section (e.g. ARM // EHABI). In this case LSDASection will be NULL. if (LSDASection) - Asm->OutStreamer.SwitchSection(LSDASection); + Asm->OutStreamer->SwitchSection(LSDASection); Asm->EmitAlignment(2); // Emit the LSDA. MCSymbol *GCCETSym = Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+ Twine(Asm->getFunctionNumber())); - Asm->OutStreamer.EmitLabel(GCCETSym); - Asm->OutStreamer.EmitLabel(Asm->getCurExceptionSym()); + Asm->OutStreamer->EmitLabel(GCCETSym); + Asm->OutStreamer->EmitLabel(Asm->getCurExceptionSym()); // Emit the LSDA header. Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart"); @@ -486,7 +486,7 @@ void EHStreamer::emitExceptionTable() { SizeAlign = 0; } - bool VerboseAsm = Asm->OutStreamer.isVerboseAsm(); + bool VerboseAsm = Asm->OutStreamer->isVerboseAsm(); // SjLj Exception handling if (IsSJLJ) { @@ -504,8 +504,8 @@ void EHStreamer::emitExceptionTable() { // Offset of the landing pad, counted in 16-byte bundles relative to the // @LPStart address. if (VerboseAsm) { - Asm->OutStreamer.AddComment(">> Call Site " + Twine(idx) + " <<"); - Asm->OutStreamer.AddComment(" On exception at call site "+Twine(idx)); + Asm->OutStreamer->AddComment(">> Call Site " + Twine(idx) + " <<"); + Asm->OutStreamer->AddComment(" On exception at call site "+Twine(idx)); } Asm->EmitULEB128(idx); @@ -514,10 +514,10 @@ void EHStreamer::emitExceptionTable() { // the action table), and 0 indicates that there are no actions. if (VerboseAsm) { if (S.Action == 0) - Asm->OutStreamer.AddComment(" Action: cleanup"); + Asm->OutStreamer->AddComment(" Action: cleanup"); else - Asm->OutStreamer.AddComment(" Action: " + - Twine((S.Action - 1) / 2 + 1)); + Asm->OutStreamer->AddComment(" Action: " + + Twine((S.Action - 1) / 2 + 1)); } Asm->EmitULEB128(S.Action); } @@ -566,24 +566,24 @@ void EHStreamer::emitExceptionTable() { // number of 16-byte bundles. The first call site is counted relative to // the start of the procedure fragment. if (VerboseAsm) - Asm->OutStreamer.AddComment(">> Call Site " + Twine(++Entry) + " <<"); + Asm->OutStreamer->AddComment(">> Call Site " + Twine(++Entry) + " <<"); Asm->EmitLabelDifference(BeginLabel, EHFuncBeginSym, 4); if (VerboseAsm) - Asm->OutStreamer.AddComment(Twine(" Call between ") + - BeginLabel->getName() + " and " + - EndLabel->getName()); + Asm->OutStreamer->AddComment(Twine(" Call between ") + + BeginLabel->getName() + " and " + + EndLabel->getName()); Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Offset of the landing pad, counted in 16-byte bundles relative to the // @LPStart address. if (!S.LPad) { if (VerboseAsm) - Asm->OutStreamer.AddComment(" has no landing pad"); - Asm->OutStreamer.EmitIntValue(0, 4/*size*/); + Asm->OutStreamer->AddComment(" has no landing pad"); + Asm->OutStreamer->EmitIntValue(0, 4/*size*/); } else { if (VerboseAsm) - Asm->OutStreamer.AddComment(Twine(" jumps to ") + - S.LPad->LandingPadLabel->getName()); + Asm->OutStreamer->AddComment(Twine(" jumps to ") + + S.LPad->LandingPadLabel->getName()); Asm->EmitLabelDifference(S.LPad->LandingPadLabel, EHFuncBeginSym, 4); } @@ -592,10 +592,10 @@ void EHStreamer::emitExceptionTable() { // the action table), and 0 indicates that there are no actions. if (VerboseAsm) { if (S.Action == 0) - Asm->OutStreamer.AddComment(" On action: cleanup"); + Asm->OutStreamer->AddComment(" On action: cleanup"); else - Asm->OutStreamer.AddComment(" On action: " + - Twine((S.Action - 1) / 2 + 1)); + Asm->OutStreamer->AddComment(" On action: " + + Twine((S.Action - 1) / 2 + 1)); } Asm->EmitULEB128(S.Action); } @@ -609,7 +609,7 @@ void EHStreamer::emitExceptionTable() { if (VerboseAsm) { // Emit comments that decode the action table. - Asm->OutStreamer.AddComment(">> Action Record " + Twine(++Entry) + " <<"); + Asm->OutStreamer->AddComment(">> Action Record " + Twine(++Entry) + " <<"); } // Type Filter @@ -618,13 +618,13 @@ void EHStreamer::emitExceptionTable() { // type of the catch clauses or the types in the exception specification. if (VerboseAsm) { if (Action.ValueForTypeID > 0) - Asm->OutStreamer.AddComment(" Catch TypeInfo " + - Twine(Action.ValueForTypeID)); + Asm->OutStreamer->AddComment(" Catch TypeInfo " + + Twine(Action.ValueForTypeID)); else if (Action.ValueForTypeID < 0) - Asm->OutStreamer.AddComment(" Filter TypeInfo " + - Twine(Action.ValueForTypeID)); + Asm->OutStreamer->AddComment(" Filter TypeInfo " + + Twine(Action.ValueForTypeID)); else - Asm->OutStreamer.AddComment(" Cleanup"); + Asm->OutStreamer->AddComment(" Cleanup"); } Asm->EmitSLEB128(Action.ValueForTypeID); @@ -634,10 +634,10 @@ void EHStreamer::emitExceptionTable() { // or 0 if there is no next action record. if (VerboseAsm) { if (Action.NextAction == 0) { - Asm->OutStreamer.AddComment(" No further actions"); + Asm->OutStreamer->AddComment(" No further actions"); } else { unsigned NextAction = Entry + (Action.NextAction + 1) / 2; - Asm->OutStreamer.AddComment(" Continue to action "+Twine(NextAction)); + Asm->OutStreamer->AddComment(" Continue to action "+Twine(NextAction)); } } Asm->EmitSLEB128(Action.NextAction); @@ -652,13 +652,13 @@ void EHStreamer::emitTypeInfos(unsigned TTypeEncoding) { const std::vector &TypeInfos = MMI->getTypeInfos(); const std::vector &FilterIds = MMI->getFilterIds(); - bool VerboseAsm = Asm->OutStreamer.isVerboseAsm(); + bool VerboseAsm = Asm->OutStreamer->isVerboseAsm(); int Entry = 0; // Emit the Catch TypeInfos. if (VerboseAsm && !TypeInfos.empty()) { - Asm->OutStreamer.AddComment(">> Catch TypeInfos <<"); - Asm->OutStreamer.AddBlankLine(); + Asm->OutStreamer->AddComment(">> Catch TypeInfos <<"); + Asm->OutStreamer->AddBlankLine(); Entry = TypeInfos.size(); } @@ -666,14 +666,14 @@ void EHStreamer::emitTypeInfos(unsigned TTypeEncoding) { I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) { const GlobalValue *GV = *I; if (VerboseAsm) - Asm->OutStreamer.AddComment("TypeInfo " + Twine(Entry--)); + Asm->OutStreamer->AddComment("TypeInfo " + Twine(Entry--)); Asm->EmitTTypeReference(GV, TTypeEncoding); } // Emit the Exception Specifications. if (VerboseAsm && !FilterIds.empty()) { - Asm->OutStreamer.AddComment(">> Filter TypeInfos <<"); - Asm->OutStreamer.AddBlankLine(); + Asm->OutStreamer->AddComment(">> Filter TypeInfos <<"); + Asm->OutStreamer->AddBlankLine(); Entry = 0; } for (std::vector::const_iterator @@ -682,7 +682,7 @@ void EHStreamer::emitTypeInfos(unsigned TTypeEncoding) { if (VerboseAsm) { --Entry; if (isFilterEHSelector(TypeID)) - Asm->OutStreamer.AddComment("FilterInfo " + Twine(Entry)); + Asm->OutStreamer->AddComment("FilterInfo " + Twine(Entry)); } Asm->EmitULEB128(TypeID); diff --git a/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp index 97a3234..eb9e4c1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/ErlangGCPrinter.cpp @@ -47,11 +47,11 @@ void llvm::linkErlangGCPrinter() {} void ErlangGCPrinter::finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) { - MCStreamer &OS = AP.OutStreamer; + MCStreamer &OS = *AP.OutStreamer; unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(); // Put this in a custom .note section. - AP.OutStreamer.SwitchSection( + OS.SwitchSection( AP.getObjFileLowering().getContext().getELFSection(".note.gc", ELF::SHT_PROGBITS, 0)); diff --git a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp index 76d6a06..c49e7a1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp @@ -62,16 +62,16 @@ static void EmitCamlGlobal(const Module &M, AsmPrinter &AP, const char *Id) { MCSymbol *Sym = AP.OutContext.GetOrCreateSymbol(TmpStr); - AP.OutStreamer.EmitSymbolAttribute(Sym, MCSA_Global); - AP.OutStreamer.EmitLabel(Sym); + AP.OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global); + AP.OutStreamer->EmitLabel(Sym); } void OcamlGCMetadataPrinter::beginAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) { - AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection()); + AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getTextSection()); EmitCamlGlobal(M, AP, "code_begin"); - AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); + AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getDataSection()); EmitCamlGlobal(M, AP, "data_begin"); } @@ -95,16 +95,16 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) { unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(); - AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection()); + AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getTextSection()); EmitCamlGlobal(M, AP, "code_end"); - AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); + AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getDataSection()); EmitCamlGlobal(M, AP, "data_end"); // FIXME: Why does ocaml emit this?? - AP.OutStreamer.EmitIntValue(0, IntPtrSize); + AP.OutStreamer->EmitIntValue(0, IntPtrSize); - AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); + AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getDataSection()); EmitCamlGlobal(M, AP, "frametable"); int NumDescriptors = 0; @@ -146,9 +146,9 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info, Twine(uintptr_t(&FI)) + ")"); } - AP.OutStreamer.AddComment("live roots for " + - Twine(FI.getFunction().getName())); - AP.OutStreamer.AddBlankLine(); + AP.OutStreamer->AddComment("live roots for " + + Twine(FI.getFunction().getName())); + AP.OutStreamer->AddBlankLine(); for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) { size_t LiveCount = FI.live_size(J); @@ -160,7 +160,7 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info, Twine(LiveCount) + " >= 65536."); } - AP.OutStreamer.EmitSymbolValue(J->Label, IntPtrSize); + AP.OutStreamer->EmitSymbolValue(J->Label, IntPtrSize); AP.EmitInt16(FrameSize); AP.EmitInt16(LiveCount); diff --git a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp index be15989..b89ca01 100644 --- a/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/Win64Exception.cpp @@ -83,7 +83,7 @@ void Win64Exception::beginFunction(const MachineFunction *MF) { GlobalValue::getRealLinkageName(F->getName())); // Emit a symbol assignment. - Asm->OutStreamer.EmitAssignment( + Asm->OutStreamer->EmitAssignment( HandlerTypeParentFrameOffset, MCConstantExpr::Create(I->second, Asm->OutContext)); } @@ -92,14 +92,14 @@ void Win64Exception::beginFunction(const MachineFunction *MF) { if (!shouldEmitPersonality && !shouldEmitMoves) return; - Asm->OutStreamer.EmitWinCFIStartProc(Asm->CurrentFnSym); + Asm->OutStreamer->EmitWinCFIStartProc(Asm->CurrentFnSym); if (!shouldEmitPersonality) return; const MCSymbol *PersHandlerSym = TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI); - Asm->OutStreamer.EmitWinEHHandler(PersHandlerSym, true, true); + Asm->OutStreamer->EmitWinEHHandler(PersHandlerSym, true, true); } /// endFunction - Gather and emit post-function exception information. @@ -117,10 +117,10 @@ void Win64Exception::endFunction(const MachineFunction *MF) { MMI->TidyLandingPads(); if (shouldEmitPersonality) { - Asm->OutStreamer.PushSection(); + Asm->OutStreamer->PushSection(); // Emit an UNWIND_INFO struct describing the prologue. - Asm->OutStreamer.EmitWinEHHandlerData(); + Asm->OutStreamer->EmitWinEHHandlerData(); // Emit the tables appropriate to the personality function in use. If we // don't recognize the personality, assume it uses an Itanium-style LSDA. @@ -131,9 +131,9 @@ void Win64Exception::endFunction(const MachineFunction *MF) { else emitExceptionTable(); - Asm->OutStreamer.PopSection(); + Asm->OutStreamer->PopSection(); } - Asm->OutStreamer.EmitWinCFIEndProc(); + Asm->OutStreamer->EmitWinCFIEndProc(); } const MCExpr *Win64Exception::createImageRel32(const MCSymbol *Value) { @@ -208,7 +208,7 @@ void Win64Exception::emitCSpecificHandlerTable() { continue; // Ignore gaps. NumEntries += CSE.LPad->SEHHandlers.size(); } - Asm->OutStreamer.EmitIntValue(NumEntries, 4); + Asm->OutStreamer->EmitIntValue(NumEntries, 4); // If there are no actions, we don't need to iterate again. if (NumEntries == 0) @@ -241,25 +241,25 @@ void Win64Exception::emitCSpecificHandlerTable() { // Emit an entry for each action. for (SEHHandler Handler : LPad->SEHHandlers) { - Asm->OutStreamer.EmitValue(Begin, 4); - Asm->OutStreamer.EmitValue(End, 4); + Asm->OutStreamer->EmitValue(Begin, 4); + Asm->OutStreamer->EmitValue(End, 4); // Emit the filter or finally function pointer, if present. Otherwise, // emit '1' to indicate a catch-all. const Function *F = Handler.FilterOrFinally; if (F) - Asm->OutStreamer.EmitValue(createImageRel32(Asm->getSymbol(F)), 4); + Asm->OutStreamer->EmitValue(createImageRel32(Asm->getSymbol(F)), 4); else - Asm->OutStreamer.EmitIntValue(1, 4); + Asm->OutStreamer->EmitIntValue(1, 4); // Emit the recovery address, if present. Otherwise, this must be a // finally. const BlockAddress *BA = Handler.RecoverBA; if (BA) - Asm->OutStreamer.EmitValue( + Asm->OutStreamer->EmitValue( createImageRel32(Asm->GetBlockAddressSymbol(BA)), 4); else - Asm->OutStreamer.EmitIntValue(0, 4); + Asm->OutStreamer->EmitIntValue(0, 4); } } } @@ -267,7 +267,7 @@ void Win64Exception::emitCSpecificHandlerTable() { void Win64Exception::emitCXXFrameHandler3Table(const MachineFunction *MF) { const Function *F = MF->getFunction(); const Function *ParentF = MMI->getWinEHParent(F); - auto &OS = Asm->OutStreamer; + auto &OS = *Asm->OutStreamer; WinEHFuncInfo &FuncInfo = MMI->getWinEHFuncInfo(ParentF); StringRef ParentLinkageName = diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp index a8f17c6..ff21781 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp @@ -95,7 +95,7 @@ void WinCodeViewLineTables::maybeRecordLocation(DebugLoc DL, FileNameRegistry.add(Filename); MCSymbol *MCL = Asm->MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.EmitLabel(MCL); + Asm->OutStreamer->EmitLabel(MCL); CurFn->Instrs.push_back(MCL); InstrInfo[MCL] = InstrInfoTy(Filename, DL.getLine()); } @@ -120,7 +120,7 @@ void WinCodeViewLineTables::endModule() { return; assert(Asm != nullptr); - Asm->OutStreamer.SwitchSection( + Asm->OutStreamer->SwitchSection( Asm->getObjFileLowering().getCOFFDebugSymbolsSection()); Asm->EmitInt32(COFF::DEBUG_SECTION_MAGIC); @@ -135,7 +135,7 @@ void WinCodeViewLineTables::endModule() { emitDebugInfoForFunction(VisitedFunctions[I]); // This subsection holds a file index to offset in string table table. - Asm->OutStreamer.AddComment("File index to string table offset subsection"); + Asm->OutStreamer->AddComment("File index to string table offset subsection"); Asm->EmitInt32(COFF::DEBUG_INDEX_SUBSECTION); size_t NumFilenames = FileNameRegistry.Infos.size(); Asm->EmitInt32(8 * NumFilenames); @@ -148,7 +148,7 @@ void WinCodeViewLineTables::endModule() { } // This subsection holds the string table. - Asm->OutStreamer.AddComment("String table"); + Asm->OutStreamer->AddComment("String table"); Asm->EmitInt32(COFF::DEBUG_STRING_TABLE_SUBSECTION); Asm->EmitInt32(FileNameRegistry.LastOffset); // The payload starts with a null character. @@ -156,12 +156,12 @@ void WinCodeViewLineTables::endModule() { for (size_t I = 0, E = FileNameRegistry.Filenames.size(); I != E; ++I) { // Just emit unique filenames one by one, separated by a null character. - Asm->OutStreamer.EmitBytes(FileNameRegistry.Filenames[I]); + Asm->OutStreamer->EmitBytes(FileNameRegistry.Filenames[I]); Asm->EmitInt8(0); } // No more subsections. Fill with zeros to align the end of the section by 4. - Asm->OutStreamer.EmitFill((-FileNameRegistry.LastOffset) % 4, 0); + Asm->OutStreamer->EmitFill((-FileNameRegistry.LastOffset) % 4, 0); clear(); } @@ -203,39 +203,39 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) { // Emit a symbol subsection, required by VS2012+ to find function boundaries. MCSymbol *SymbolsBegin = Asm->MMI->getContext().CreateTempSymbol(), *SymbolsEnd = Asm->MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.AddComment("Symbol subsection for " + Twine(FuncName)); + Asm->OutStreamer->AddComment("Symbol subsection for " + Twine(FuncName)); Asm->EmitInt32(COFF::DEBUG_SYMBOL_SUBSECTION); - EmitLabelDiff(Asm->OutStreamer, SymbolsBegin, SymbolsEnd); - Asm->OutStreamer.EmitLabel(SymbolsBegin); + EmitLabelDiff(*Asm->OutStreamer, SymbolsBegin, SymbolsEnd); + Asm->OutStreamer->EmitLabel(SymbolsBegin); { MCSymbol *ProcSegmentBegin = Asm->MMI->getContext().CreateTempSymbol(), *ProcSegmentEnd = Asm->MMI->getContext().CreateTempSymbol(); - EmitLabelDiff(Asm->OutStreamer, ProcSegmentBegin, ProcSegmentEnd, 2); - Asm->OutStreamer.EmitLabel(ProcSegmentBegin); + EmitLabelDiff(*Asm->OutStreamer, ProcSegmentBegin, ProcSegmentEnd, 2); + Asm->OutStreamer->EmitLabel(ProcSegmentBegin); Asm->EmitInt16(COFF::DEBUG_SYMBOL_TYPE_PROC_START); // Some bytes of this segment don't seem to be required for basic debugging, // so just fill them with zeroes. - Asm->OutStreamer.EmitFill(12, 0); + Asm->OutStreamer->EmitFill(12, 0); // This is the important bit that tells the debugger where the function // code is located and what's its size: - EmitLabelDiff(Asm->OutStreamer, Fn, FI.End); - Asm->OutStreamer.EmitFill(12, 0); - Asm->OutStreamer.EmitCOFFSecRel32(Fn); - Asm->OutStreamer.EmitCOFFSectionIndex(Fn); + EmitLabelDiff(*Asm->OutStreamer, Fn, FI.End); + Asm->OutStreamer->EmitFill(12, 0); + Asm->OutStreamer->EmitCOFFSecRel32(Fn); + Asm->OutStreamer->EmitCOFFSectionIndex(Fn); Asm->EmitInt8(0); // Emit the function display name as a null-terminated string. - Asm->OutStreamer.EmitBytes(FuncName); + Asm->OutStreamer->EmitBytes(FuncName); Asm->EmitInt8(0); - Asm->OutStreamer.EmitLabel(ProcSegmentEnd); + Asm->OutStreamer->EmitLabel(ProcSegmentEnd); // We're done with this function. Asm->EmitInt16(0x0002); Asm->EmitInt16(COFF::DEBUG_SYMBOL_TYPE_PROC_END); } - Asm->OutStreamer.EmitLabel(SymbolsEnd); + Asm->OutStreamer->EmitLabel(SymbolsEnd); // Every subsection must be aligned to a 4-byte boundary. - Asm->OutStreamer.EmitFill((-FuncName.size()) % 4, 0); + Asm->OutStreamer->EmitFill((-FuncName.size()) % 4, 0); // PCs/Instructions are grouped into segments sharing the same filename. // Pre-calculate the lengths (in instructions) of these segments and store @@ -254,21 +254,21 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) { FilenameSegmentLengths[LastSegmentEnd] = FI.Instrs.size() - LastSegmentEnd; // Emit a line table subsection, requred to do PC-to-file:line lookup. - Asm->OutStreamer.AddComment("Line table subsection for " + Twine(FuncName)); + Asm->OutStreamer->AddComment("Line table subsection for " + Twine(FuncName)); Asm->EmitInt32(COFF::DEBUG_LINE_TABLE_SUBSECTION); MCSymbol *LineTableBegin = Asm->MMI->getContext().CreateTempSymbol(), *LineTableEnd = Asm->MMI->getContext().CreateTempSymbol(); - EmitLabelDiff(Asm->OutStreamer, LineTableBegin, LineTableEnd); - Asm->OutStreamer.EmitLabel(LineTableBegin); + EmitLabelDiff(*Asm->OutStreamer, LineTableBegin, LineTableEnd); + Asm->OutStreamer->EmitLabel(LineTableBegin); // Identify the function this subsection is for. - Asm->OutStreamer.EmitCOFFSecRel32(Fn); - Asm->OutStreamer.EmitCOFFSectionIndex(Fn); + Asm->OutStreamer->EmitCOFFSecRel32(Fn); + Asm->OutStreamer->EmitCOFFSectionIndex(Fn); // Insert padding after a 16-bit section index. Asm->EmitInt16(0); // Length of the function's code, in bytes. - EmitLabelDiff(Asm->OutStreamer, Fn, FI.End); + EmitLabelDiff(*Asm->OutStreamer, Fn, FI.End); // PC-to-linenumber lookup table: MCSymbol *FileSegmentEnd = nullptr; @@ -279,17 +279,17 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) { if (FilenameSegmentLengths.count(J)) { // We came to a beginning of a new filename segment. if (FileSegmentEnd) - Asm->OutStreamer.EmitLabel(FileSegmentEnd); + Asm->OutStreamer->EmitLabel(FileSegmentEnd); StringRef CurFilename = InstrInfo[FI.Instrs[J]].Filename; assert(FileNameRegistry.Infos.count(CurFilename)); size_t IndexInStringTable = FileNameRegistry.Infos[CurFilename].FilenameID; // Each segment starts with the offset of the filename // in the string table. - Asm->OutStreamer.AddComment( + Asm->OutStreamer->AddComment( "Segment for file '" + Twine(CurFilename) + "' begins"); MCSymbol *FileSegmentBegin = Asm->MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.EmitLabel(FileSegmentBegin); + Asm->OutStreamer->EmitLabel(FileSegmentBegin); Asm->EmitInt32(8 * IndexInStringTable); // Number of PC records in the lookup table. @@ -299,17 +299,17 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) { // Full size of the segment for this filename, including the prev two // records. FileSegmentEnd = Asm->MMI->getContext().CreateTempSymbol(); - EmitLabelDiff(Asm->OutStreamer, FileSegmentBegin, FileSegmentEnd); + EmitLabelDiff(*Asm->OutStreamer, FileSegmentBegin, FileSegmentEnd); } // The first PC with the given linenumber and the linenumber itself. - EmitLabelDiff(Asm->OutStreamer, Fn, Instr); + EmitLabelDiff(*Asm->OutStreamer, Fn, Instr); Asm->EmitInt32(InstrInfo[Instr].LineNumber); } if (FileSegmentEnd) - Asm->OutStreamer.EmitLabel(FileSegmentEnd); - Asm->OutStreamer.EmitLabel(LineTableEnd); + Asm->OutStreamer->EmitLabel(FileSegmentEnd); + Asm->OutStreamer->EmitLabel(LineTableEnd); } void WinCodeViewLineTables::beginFunction(const MachineFunction *MF) { diff --git a/llvm/lib/CodeGen/StackMaps.cpp b/llvm/lib/CodeGen/StackMaps.cpp index aa18dea..a786832 100644 --- a/llvm/lib/CodeGen/StackMaps.cpp +++ b/llvm/lib/CodeGen/StackMaps.cpp @@ -273,9 +273,9 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID, MachineInstr::const_mop_iterator MOE, bool recordResult) { - MCContext &OutContext = AP.OutStreamer.getContext(); + MCContext &OutContext = AP.OutStreamer->getContext(); MCSymbol *MILabel = OutContext.CreateTempSymbol(); - AP.OutStreamer.EmitLabel(MILabel); + AP.OutStreamer->EmitLabel(MILabel); LocationVec Locations; LiveOutVec LiveOuts; @@ -521,8 +521,8 @@ void StackMaps::serializeToStackMapSection() { if (CSInfos.empty()) return; - MCContext &OutContext = AP.OutStreamer.getContext(); - MCStreamer &OS = AP.OutStreamer; + MCContext &OutContext = AP.OutStreamer->getContext(); + MCStreamer &OS = *AP.OutStreamer; // Create the section. const MCSection *StackMapSection = diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp index 0821cff..4db8f21 100644 --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -128,7 +128,7 @@ void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) { // implementation of multiple entry points). If this doesn't occur, the // linker can safely perform dead code stripping. Since LLVM never // generates code that does this, it is always safe to set. - OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); + OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); SM.serializeToStackMapSection(); } } @@ -156,7 +156,7 @@ void AArch64AsmPrinter::EmitLOHs() { "Label hasn't been inserted for LOH related instruction"); MCArgs.push_back(LabelIt->second); } - OutStreamer.EmitLOHDirective(D.getKind(), MCArgs); + OutStreamer->EmitLOHDirective(D.getKind(), MCArgs); MCArgs.clear(); } } @@ -436,7 +436,7 @@ void AArch64AsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM, void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { // Do any auto-generated pseudo lowerings. - if (emitPseudoExpansionLowering(OutStreamer, MI)) + if (emitPseudoExpansionLowering(*OutStreamer, MI)) return; if (AArch64FI->getLOHRelated().count(MI)) { @@ -444,7 +444,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbol *LOHLabel = createTempSymbol("loh"); // Associate the instruction with the label LOHInstToLabel[MI] = LOHLabel; - OutStreamer.EmitLabel(LOHLabel); + OutStreamer->EmitLabel(LOHLabel); } // Do any manual lowerings. @@ -452,11 +452,11 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { default: break; case AArch64::DBG_VALUE: { - if (isVerbose() && OutStreamer.hasRawTextSupport()) { + if (isVerbose() && OutStreamer->hasRawTextSupport()) { SmallString<128> TmpStr; raw_svector_ostream OS(TmpStr); PrintDebugValueComment(MI, OS); - OutStreamer.EmitRawText(StringRef(OS.str())); + OutStreamer->EmitRawText(StringRef(OS.str())); } return; } @@ -468,7 +468,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst TmpInst; TmpInst.setOpcode(AArch64::BR); TmpInst.addOperand(MCOperand::CreateReg(MI->getOperand(0).getReg())); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case AArch64::TCRETURNdi: { @@ -477,7 +477,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst TmpInst; TmpInst.setOpcode(AArch64::B); TmpInst.addOperand(Dest); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case AArch64::TLSDESC_CALLSEQ: { @@ -502,7 +502,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { Adrp.setOpcode(AArch64::ADRP); Adrp.addOperand(MCOperand::CreateReg(AArch64::X0)); Adrp.addOperand(SymTLSDesc); - EmitToStreamer(OutStreamer, Adrp); + EmitToStreamer(*OutStreamer, Adrp); MCInst Ldr; Ldr.setOpcode(AArch64::LDRXui); @@ -510,7 +510,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { Ldr.addOperand(MCOperand::CreateReg(AArch64::X0)); Ldr.addOperand(SymTLSDescLo12); Ldr.addOperand(MCOperand::CreateImm(0)); - EmitToStreamer(OutStreamer, Ldr); + EmitToStreamer(*OutStreamer, Ldr); MCInst Add; Add.setOpcode(AArch64::ADDXri); @@ -518,34 +518,34 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { Add.addOperand(MCOperand::CreateReg(AArch64::X0)); Add.addOperand(SymTLSDescLo12); Add.addOperand(MCOperand::CreateImm(AArch64_AM::getShiftValue(0))); - EmitToStreamer(OutStreamer, Add); + EmitToStreamer(*OutStreamer, Add); // Emit a relocation-annotation. This expands to no code, but requests // the following instruction gets an R_AARCH64_TLSDESC_CALL. MCInst TLSDescCall; TLSDescCall.setOpcode(AArch64::TLSDESCCALL); TLSDescCall.addOperand(Sym); - EmitToStreamer(OutStreamer, TLSDescCall); + EmitToStreamer(*OutStreamer, TLSDescCall); MCInst Blr; Blr.setOpcode(AArch64::BLR); Blr.addOperand(MCOperand::CreateReg(AArch64::X1)); - EmitToStreamer(OutStreamer, Blr); + EmitToStreamer(*OutStreamer, Blr); return; } case TargetOpcode::STACKMAP: - return LowerSTACKMAP(OutStreamer, SM, *MI); + return LowerSTACKMAP(*OutStreamer, SM, *MI); case TargetOpcode::PATCHPOINT: - return LowerPATCHPOINT(OutStreamer, SM, *MI); + return LowerPATCHPOINT(*OutStreamer, SM, *MI); } // Finally, do the automated lowerings for everything else. MCInst TmpInst; MCInstLowering.Lower(MI, TmpInst); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); } // Force static initialization. diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 1a2acf5..4d949f4 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -69,16 +69,16 @@ void ARMAsmPrinter::EmitFunctionBodyEnd() { if (!InConstantPool) return; InConstantPool = false; - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); } void ARMAsmPrinter::EmitFunctionEntryLabel() { if (AFI->isThumbFunction()) { - OutStreamer.EmitAssemblerFlag(MCAF_Code16); - OutStreamer.EmitThumbFunc(CurrentFnSym); + OutStreamer->EmitAssemblerFlag(MCAF_Code16); + OutStreamer->EmitThumbFunc(CurrentFnSym); } - OutStreamer.EmitLabel(CurrentFnSym); + OutStreamer->EmitLabel(CurrentFnSym); } void ARMAsmPrinter::EmitXXStructor(const Constant *CV) { @@ -95,7 +95,7 @@ void ARMAsmPrinter::EmitXXStructor(const Constant *CV) { : MCSymbolRefExpr::VK_None), OutContext); - OutStreamer.EmitValue(E, Size); + OutStreamer->EmitValue(E, Size); } /// runOnMachineFunction - This uses the EmitInstruction() @@ -114,10 +114,10 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) { : COFF::IMAGE_SYM_CLASS_EXTERNAL; int Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT; - OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); - OutStreamer.EmitCOFFSymbolStorageClass(Scl); - OutStreamer.EmitCOFFSymbolType(Type); - OutStreamer.EndCOFFSymbolDef(); + OutStreamer->BeginCOFFSymbolDef(CurrentFnSym); + OutStreamer->EmitCOFFSymbolStorageClass(Scl); + OutStreamer->EmitCOFFSymbolType(Type); + OutStreamer->EndCOFFSymbolDef(); } // Emit the rest of the function body. @@ -127,11 +127,11 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) { // These are created per function, rather than per TU, since it's // relatively easy to exceed the thumb branch range within a TU. if (! ThumbIndirectPads.empty()) { - OutStreamer.EmitAssemblerFlag(MCAF_Code16); + OutStreamer->EmitAssemblerFlag(MCAF_Code16); EmitAlignment(1); for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) { - OutStreamer.EmitLabel(ThumbIndirectPads[i].second); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tBX) + OutStreamer->EmitLabel(ThumbIndirectPads[i].second); + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBX) .addReg(ThumbIndirectPads[i].first) // Add predicate operands. .addImm(ARMCC::AL) @@ -429,14 +429,14 @@ void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, // the start mode, then restore the start mode. const bool WasThumb = isThumb(StartInfo); if (!EndInfo || WasThumb != isThumb(*EndInfo)) { - OutStreamer.EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32); + OutStreamer->EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32); } } void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) { Triple TT(TM.getTargetTriple()); // Use unified assembler syntax. - OutStreamer.EmitAssemblerFlag(MCAF_SyntaxUnified); + OutStreamer->EmitAssemblerFlag(MCAF_SyntaxUnified); // Emit ARM Build Attributes if (TT.isOSBinFormatELF()) @@ -450,7 +450,7 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) { TT.getSubArch() == Triple::ARMSubArch_v7m || TT.getSubArch() == Triple::ARMSubArch_v6m; if (!M.getModuleInlineAsm().empty() && isThumb) - OutStreamer.EmitAssemblerFlag(MCAF_Code16); + OutStreamer->EmitAssemblerFlag(MCAF_Code16); } static void @@ -491,26 +491,26 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) { if (!Stubs.empty()) { // Switch with ".non_lazy_symbol_pointer" directive. - OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); + OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); EmitAlignment(2); for (auto &Stub : Stubs) - emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); + emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second); Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } Stubs = MMIMacho.GetHiddenGVStubList(); if (!Stubs.empty()) { - OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); + OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); EmitAlignment(2); for (auto &Stub : Stubs) - emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); + emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second); Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } // Funny Darwin hack: This flag tells the linker that no global symbols @@ -518,7 +518,7 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) { // implementation of multiple entry points). If this doesn't occur, the // linker can safely perform dead code stripping. Since LLVM never // generates code that does this, it is always safe to set. - OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); + OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); } } @@ -557,7 +557,7 @@ static ARMBuildAttrs::CPUArch getArchForCPU(StringRef CPU, } void ARMAsmPrinter::emitAttributes() { - MCTargetStreamer &TS = *OutStreamer.getTargetStreamer(); + MCTargetStreamer &TS = *OutStreamer->getTargetStreamer(); ARMTargetStreamer &ATS = static_cast(TS); ATS.emitTextAttribute(ARMBuildAttrs::conformance, "2.09"); @@ -918,13 +918,13 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) { // We want "( - .)", but MC doesn't have a concept of the '.' // label, so just emit a local label end reference that instead. MCSymbol *DotSym = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(DotSym); + OutStreamer->EmitLabel(DotSym); const MCExpr *DotExpr = MCSymbolRefExpr::Create(DotSym, OutContext); PCRelExpr = MCBinaryExpr::CreateSub(PCRelExpr, DotExpr, OutContext); } Expr = MCBinaryExpr::CreateSub(Expr, PCRelExpr, OutContext); } - OutStreamer.EmitValue(Expr, Size); + OutStreamer->EmitValue(Expr, Size); } void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) { @@ -941,10 +941,10 @@ void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) { // Emit a label for the jump table. MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm()); - OutStreamer.EmitLabel(JTISymbol); + OutStreamer->EmitLabel(JTISymbol); // Mark the jump table as data-in-code. - OutStreamer.EmitDataRegion(MCDR_DataRegionJT32); + OutStreamer->EmitDataRegion(MCDR_DataRegionJT32); // Emit each entry of the table. const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); @@ -972,10 +972,10 @@ void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) { else if (AFI->isThumbFunction()) Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(1,OutContext), OutContext); - OutStreamer.EmitValue(Expr, 4); + OutStreamer->EmitValue(Expr, 4); } // Mark the end of jump table data-in-code region. - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); } void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) { @@ -986,7 +986,7 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) { unsigned JTI = MO1.getIndex(); MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm()); - OutStreamer.EmitLabel(JTISymbol); + OutStreamer->EmitLabel(JTISymbol); // Emit each entry of the table. const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); @@ -996,11 +996,11 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) { if (MI->getOpcode() == ARM::t2TBB_JT) { OffsetWidth = 1; // Mark the jump table as data-in-code. - OutStreamer.EmitDataRegion(MCDR_DataRegionJT8); + OutStreamer->EmitDataRegion(MCDR_DataRegionJT8); } else if (MI->getOpcode() == ARM::t2TBH_JT) { OffsetWidth = 2; // Mark the jump table as data-in-code. - OutStreamer.EmitDataRegion(MCDR_DataRegionJT16); + OutStreamer->EmitDataRegion(MCDR_DataRegionJT16); } for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) { @@ -1009,7 +1009,7 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) { OutContext); // If this isn't a TBB or TBH, the entries are direct branch instructions. if (OffsetWidth == 4) { - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::t2B) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2B) .addExpr(MBBSymbolExpr) .addImm(ARMCC::AL) .addReg(0)); @@ -1030,20 +1030,20 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) { OutContext); Expr = MCBinaryExpr::CreateDiv(Expr, MCConstantExpr::Create(2, OutContext), OutContext); - OutStreamer.EmitValue(Expr, OffsetWidth); + OutStreamer->EmitValue(Expr, OffsetWidth); } // Mark the end of jump table data-in-code region. 32-bit offsets use // actual branch instructions here, so we don't mark those as a data-region // at all. if (OffsetWidth != 4) - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); } void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) { assert(MI->getFlag(MachineInstr::FrameSetup) && "Only instruction which are involved into frame setup code are allowed"); - MCTargetStreamer &TS = *OutStreamer.getTargetStreamer(); + MCTargetStreamer &TS = *OutStreamer->getTargetStreamer(); ARMTargetStreamer &ATS = static_cast(TS); const MachineFunction &MF = *MI->getParent()->getParent(); const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo(); @@ -1188,7 +1188,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // If we just ended a constant pool, mark it as such. if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) { - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); InConstantPool = false; } @@ -1198,7 +1198,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { EmitUnwindingInstruction(MI); // Do any auto-generated pseudo lowerings. - if (emitPseudoExpansionLowering(OutStreamer, MI)) + if (emitPseudoExpansionLowering(*OutStreamer, MI)) return; assert(!convertAddSubFlagsOpcode(MI->getOpcode()) && @@ -1214,8 +1214,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { case ARM::t2LEApcrel: { // FIXME: Need to also handle globals and externals MCSymbol *CPISymbol = GetCPISymbol(MI->getOperand(1).getIndex()); - EmitToStreamer(OutStreamer, MCInstBuilder(MI->getOpcode() == - ARM::t2LEApcrel ? ARM::t2ADR + EmitToStreamer(*OutStreamer, MCInstBuilder(MI->getOpcode() == + ARM::t2LEApcrel ? ARM::t2ADR : (MI->getOpcode() == ARM::tLEApcrel ? ARM::tADR : ARM::ADR)) .addReg(MI->getOperand(0).getReg()) @@ -1231,8 +1231,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbol *JTIPICSymbol = GetARMJTIPICJumpTableLabel2(MI->getOperand(1).getIndex(), MI->getOperand(2).getImm()); - EmitToStreamer(OutStreamer, MCInstBuilder(MI->getOpcode() == - ARM::t2LEApcrelJT ? ARM::t2ADR + EmitToStreamer(*OutStreamer, MCInstBuilder(MI->getOpcode() == + ARM::t2LEApcrelJT ? ARM::t2ADR : (MI->getOpcode() == ARM::tLEApcrelJT ? ARM::tADR : ARM::ADR)) .addReg(MI->getOperand(0).getReg()) @@ -1245,7 +1245,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // Darwin call instructions are just normal call instructions with different // clobber semantics (they clobber R9). case ARM::BX_CALL: { - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr) .addReg(ARM::LR) .addReg(ARM::PC) // Add predicate operands. @@ -1254,7 +1254,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // Add 's' bit operand (always reg0 for this) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::BX) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::BX) .addReg(MI->getOperand(0).getReg())); return; } @@ -1283,14 +1283,14 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { } // Create a link-saving branch to the Reg Indirect Jump Pad. - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tBL) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBL) // Predicate comes first here. .addImm(ARMCC::AL).addReg(0) .addExpr(MCSymbolRefExpr::Create(TRegSym, OutContext))); return; } case ARM::BMOVPCRX_CALL: { - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr) .addReg(ARM::LR) .addReg(ARM::PC) // Add predicate operands. @@ -1299,7 +1299,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // Add 's' bit operand (always reg0 for this) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr) .addReg(ARM::PC) .addReg(MI->getOperand(0).getReg()) // Add predicate operands. @@ -1310,7 +1310,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { return; } case ARM::BMOVPCB_CALL: { - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr) .addReg(ARM::LR) .addReg(ARM::PC) // Add predicate operands. @@ -1324,7 +1324,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { const unsigned TF = Op.getTargetFlags(); MCSymbol *GVSym = GetARMGVSymbol(GV, TF); const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::Bcc) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::Bcc) .addExpr(GVSymExpr) // Add predicate operands. .addImm(ARMCC::AL) @@ -1359,7 +1359,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { TmpInst.addOperand(MCOperand::CreateReg(0)); // Add 's' bit operand (always reg0 for this) TmpInst.addOperand(MCOperand::CreateReg(0)); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case ARM::MOVTi16_ga_pcrel: @@ -1391,7 +1391,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { TmpInst.addOperand(MCOperand::CreateReg(0)); // Add 's' bit operand (always reg0 for this) TmpInst.addOperand(MCOperand::CreateReg(0)); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case ARM::tPICADD: { @@ -1401,12 +1401,13 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // This adds the address of LPC0 to r0. // Emit the label. - OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), - getFunctionNumber(), MI->getOperand(2).getImm(), - OutContext)); + OutStreamer->EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), + getFunctionNumber(), + MI->getOperand(2).getImm(), + OutContext)); // Form and emit the add. - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tADDhirr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDhirr) .addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg()) .addReg(ARM::PC) @@ -1422,12 +1423,13 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // This adds the address of LPC0 to r0. // Emit the label. - OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), - getFunctionNumber(), MI->getOperand(2).getImm(), - OutContext)); + OutStreamer->EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), + getFunctionNumber(), + MI->getOperand(2).getImm(), + OutContext)); // Form and emit the add. - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDrr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDrr) .addReg(MI->getOperand(0).getReg()) .addReg(ARM::PC) .addReg(MI->getOperand(1).getReg()) @@ -1453,9 +1455,10 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // a PC-relative address at the ldr instruction. // Emit the label. - OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), - getFunctionNumber(), MI->getOperand(2).getImm(), - OutContext)); + OutStreamer->EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), + getFunctionNumber(), + MI->getOperand(2).getImm(), + OutContext)); // Form and emit the load unsigned Opcode; @@ -1471,7 +1474,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { case ARM::PICLDRSB: Opcode = ARM::LDRSB; break; case ARM::PICLDRSH: Opcode = ARM::LDRSH; break; } - EmitToStreamer(OutStreamer, MCInstBuilder(Opcode) + EmitToStreamer(*OutStreamer, MCInstBuilder(Opcode) .addReg(MI->getOperand(0).getReg()) .addReg(ARM::PC) .addReg(MI->getOperand(1).getReg()) @@ -1493,11 +1496,11 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // If this is the first entry of the pool, mark it. if (!InConstantPool) { - OutStreamer.EmitDataRegion(MCDR_DataRegion); + OutStreamer->EmitDataRegion(MCDR_DataRegion); InConstantPool = true; } - OutStreamer.EmitLabel(GetCPISymbol(LabelId)); + OutStreamer->EmitLabel(GetCPISymbol(LabelId)); const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx]; if (MCPE.isMachineConstantPoolEntry()) @@ -1508,7 +1511,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { } case ARM::t2BR_JT: { // Lower and emit the instruction itself, then the jump table following it. - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr) .addReg(ARM::PC) .addReg(MI->getOperand(0).getReg()) // Add predicate operands. @@ -1521,7 +1524,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { } case ARM::t2TBB_JT: { // Lower and emit the instruction itself, then the jump table following it. - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::t2TBB) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2TBB) .addReg(ARM::PC) .addReg(MI->getOperand(0).getReg()) // Add predicate operands. @@ -1536,7 +1539,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { } case ARM::t2TBH_JT: { // Lower and emit the instruction itself, then the jump table following it. - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::t2TBH) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2TBH) .addReg(ARM::PC) .addReg(MI->getOperand(0).getReg()) // Add predicate operands. @@ -1563,7 +1566,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // Add 's' bit operand (always reg0 for this) if (Opc == ARM::MOVr) TmpInst.addOperand(MCOperand::CreateReg(0)); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); // Make sure the Thumb jump table is 4-byte aligned. if (Opc == ARM::tMOVr) @@ -1593,7 +1596,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // Add predicate operands. TmpInst.addOperand(MCOperand::CreateImm(ARMCC::AL)); TmpInst.addOperand(MCOperand::CreateReg(0)); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); // Output the data for the jump table itself EmitJumpTable(MI); @@ -1602,7 +1605,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { case ARM::BR_JTadd: { // Lower and emit the instruction itself, then the jump table following it. // add pc, target, idx - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDrr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDrr) .addReg(ARM::PC) .addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(1).getReg()) @@ -1617,7 +1620,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { return; } case ARM::SPACE: - OutStreamer.EmitZeros(MI->getOperand(1).getImm()); + OutStreamer->EmitZeros(MI->getOperand(1).getImm()); return; case ARM::TRAP: { // Non-Darwin binutils don't yet support the "trap" mnemonic. @@ -1625,8 +1628,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { if (!Subtarget->isTargetMachO()) { //.long 0xe7ffdefe @ trap uint32_t Val = 0xe7ffdefeUL; - OutStreamer.AddComment("trap"); - OutStreamer.EmitIntValue(Val, 4); + OutStreamer->AddComment("trap"); + OutStreamer->EmitIntValue(Val, 4); return; } break; @@ -1634,8 +1637,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { case ARM::TRAPNaCl: { //.long 0xe7fedef0 @ trap uint32_t Val = 0xe7fedef0UL; - OutStreamer.AddComment("trap"); - OutStreamer.EmitIntValue(Val, 4); + OutStreamer->AddComment("trap"); + OutStreamer->EmitIntValue(Val, 4); return; } case ARM::tTRAP: { @@ -1644,8 +1647,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { if (!Subtarget->isTargetMachO()) { //.short 57086 @ trap uint16_t Val = 0xdefe; - OutStreamer.AddComment("trap"); - OutStreamer.EmitIntValue(Val, 2); + OutStreamer->AddComment("trap"); + OutStreamer->EmitIntValue(Val, 2); return; } break; @@ -1664,15 +1667,15 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { unsigned SrcReg = MI->getOperand(0).getReg(); unsigned ValReg = MI->getOperand(1).getReg(); MCSymbol *Label = GetARMSJLJEHLabel(); - OutStreamer.AddComment("eh_setjmp begin"); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVr) + OutStreamer->AddComment("eh_setjmp begin"); + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr) .addReg(ValReg) .addReg(ARM::PC) // Predicate. .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tADDi3) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDi3) .addReg(ValReg) // 's' bit operand .addReg(ARM::CPSR) @@ -1682,7 +1685,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tSTRi) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tSTRi) .addReg(ValReg) .addReg(SrcReg) // The offset immediate is #4. The operand value is scaled by 4 for the @@ -1692,7 +1695,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVi8) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVi8) .addReg(ARM::R0) .addReg(ARM::CPSR) .addImm(0) @@ -1701,13 +1704,13 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addReg(0)); const MCExpr *SymbolExpr = MCSymbolRefExpr::Create(Label, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tB) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tB) .addExpr(SymbolExpr) .addImm(ARMCC::AL) .addReg(0)); - OutStreamer.AddComment("eh_setjmp end"); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVi8) + OutStreamer->AddComment("eh_setjmp end"); + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVi8) .addReg(ARM::R0) .addReg(ARM::CPSR) .addImm(1) @@ -1715,7 +1718,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - OutStreamer.EmitLabel(Label); + OutStreamer->EmitLabel(Label); return; } @@ -1730,8 +1733,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { unsigned SrcReg = MI->getOperand(0).getReg(); unsigned ValReg = MI->getOperand(1).getReg(); - OutStreamer.AddComment("eh_setjmp begin"); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDri) + OutStreamer->AddComment("eh_setjmp begin"); + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDri) .addReg(ValReg) .addReg(ARM::PC) .addImm(8) @@ -1741,7 +1744,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // 's' bit operand (always reg0 for this). .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::STRi12) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::STRi12) .addReg(ValReg) .addReg(SrcReg) .addImm(4) @@ -1749,7 +1752,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVi) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVi) .addReg(ARM::R0) .addImm(0) // Predicate. @@ -1758,7 +1761,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // 's' bit operand (always reg0 for this). .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDri) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDri) .addReg(ARM::PC) .addReg(ARM::PC) .addImm(0) @@ -1768,8 +1771,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // 's' bit operand (always reg0 for this). .addReg(0)); - OutStreamer.AddComment("eh_setjmp end"); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVi) + OutStreamer->AddComment("eh_setjmp end"); + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVi) .addReg(ARM::R0) .addImm(1) // Predicate. @@ -1786,7 +1789,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // bx $scratch unsigned SrcReg = MI->getOperand(0).getReg(); unsigned ScratchReg = MI->getOperand(1).getReg(); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::LDRi12) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12) .addReg(ARM::SP) .addReg(SrcReg) .addImm(8) @@ -1794,7 +1797,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::LDRi12) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12) .addReg(ScratchReg) .addReg(SrcReg) .addImm(4) @@ -1802,7 +1805,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::LDRi12) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12) .addReg(ARM::R7) .addReg(SrcReg) .addImm(0) @@ -1810,7 +1813,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::BX) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::BX) .addReg(ScratchReg) // Predicate. .addImm(ARMCC::AL) @@ -1825,7 +1828,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { // bx $scratch unsigned SrcReg = MI->getOperand(0).getReg(); unsigned ScratchReg = MI->getOperand(1).getReg(); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tLDRi) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi) .addReg(ScratchReg) .addReg(SrcReg) // The offset immediate is #8. The operand value is scaled by 4 for the @@ -1835,14 +1838,14 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVr) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr) .addReg(ARM::SP) .addReg(ScratchReg) // Predicate. .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tLDRi) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi) .addReg(ScratchReg) .addReg(SrcReg) .addImm(1) @@ -1850,7 +1853,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tLDRi) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi) .addReg(ARM::R7) .addReg(SrcReg) .addImm(0) @@ -1858,7 +1861,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tBX) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBX) .addReg(ScratchReg) // Predicate. .addImm(ARMCC::AL) @@ -1870,7 +1873,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst TmpInst; LowerARMMachineInstrToMCInst(MI, TmpInst, *this); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp b/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp index f0c81e0..e9491ba 100644 --- a/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp +++ b/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp @@ -205,7 +205,7 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) { HexagonMCInstrInfo::AppendImplicitOperands(MCI); HexagonMCInstrInfo::setPacketBegin(MCI, Index == 0); HexagonMCInstrInfo::setPacketEnd(MCI, Index == (Size - 1)); - EmitToStreamer(OutStreamer, MCI); + EmitToStreamer(*OutStreamer, MCI); } } else { @@ -216,7 +216,7 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) { HexagonMCInstrInfo::setPacketBegin(MCI, true); HexagonMCInstrInfo::setPacketEnd(MCI, true); } - EmitToStreamer(OutStreamer, MCI); + EmitToStreamer(*OutStreamer, MCI); } return; diff --git a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp index fb7823e..a99c9a3 100644 --- a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -152,7 +152,7 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst TmpInst; MCInstLowering.Lower(MI, TmpInst); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); } // Force static initialization. diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index 9024f21..de15e63 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -55,7 +55,7 @@ using namespace llvm; #define DEBUG_TYPE "mips-asm-printer" MipsTargetStreamer &MipsAsmPrinter::getTargetStreamer() const { - return static_cast(*OutStreamer.getTargetStreamer()); + return static_cast(*OutStreamer->getTargetStreamer()); } bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) { @@ -144,7 +144,7 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) { // If we just ended a constant pool, mark it as such. if (InConstantPool && MI->getOpcode() != Mips::CONSTPOOL_ENTRY) { - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); InConstantPool = false; } if (MI->getOpcode() == Mips::CONSTPOOL_ENTRY) { @@ -160,11 +160,11 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) { // If this is the first entry of the pool, mark it. if (!InConstantPool) { - OutStreamer.EmitDataRegion(MCDR_DataRegion); + OutStreamer->EmitDataRegion(MCDR_DataRegion); InConstantPool = true; } - OutStreamer.EmitLabel(GetCPISymbol(LabelId)); + OutStreamer->EmitLabel(GetCPISymbol(LabelId)); const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx]; if (MCPE.isMachineConstantPoolEntry()) @@ -180,14 +180,14 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) { do { // Do any auto-generated pseudo lowerings. - if (emitPseudoExpansionLowering(OutStreamer, &*I)) + if (emitPseudoExpansionLowering(*OutStreamer, &*I)) continue; if (I->getOpcode() == Mips::PseudoReturn || I->getOpcode() == Mips::PseudoReturn64 || I->getOpcode() == Mips::PseudoIndirectBranch || I->getOpcode() == Mips::PseudoIndirectBranch64) { - emitPseudoIndirectBranch(OutStreamer, &*I); + emitPseudoIndirectBranch(*OutStreamer, &*I); continue; } @@ -204,7 +204,7 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst TmpInst0; MCInstLowering.Lower(I, TmpInst0); - EmitToStreamer(OutStreamer, TmpInst0); + EmitToStreamer(*OutStreamer, TmpInst0); } while ((++I != E) && I->isInsideBundle()); // Delay slot check } @@ -338,7 +338,7 @@ void MipsAsmPrinter::EmitFunctionEntryLabel() { TS.emitDirectiveSetNoMips16(); TS.emitDirectiveEnt(*CurrentFnSym); - OutStreamer.EmitLabel(CurrentFnSym); + OutStreamer->EmitLabel(CurrentFnSym); } /// EmitFunctionBodyStart - Targets can override this to emit stuff before @@ -381,7 +381,7 @@ void MipsAsmPrinter::EmitFunctionBodyEnd() { if (!InConstantPool) return; InConstantPool = false; - OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); + OutStreamer->EmitDataRegion(MCDR_DataRegionEnd); } /// isBlockOnlyReachableByFallthough - Return true if the basic block has @@ -711,7 +711,7 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) { // Tell the assembler which ABI we are using std::string SectionName = std::string(".mdebug.") + getCurrentABIString(); - OutStreamer.SwitchSection( + OutStreamer->SwitchSection( OutContext.getELFSection(SectionName, ELF::SHT_PROGBITS, 0)); // NaN: At the moment we only support: @@ -724,11 +724,11 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) { if (ABI.IsEABI()) { if (STI.isGP32bit()) - OutStreamer.SwitchSection(OutContext.getELFSection(".gcc_compiled_long32", - ELF::SHT_PROGBITS, 0)); + OutStreamer->SwitchSection(OutContext.getELFSection(".gcc_compiled_long32", + ELF::SHT_PROGBITS, 0)); else - OutStreamer.SwitchSection(OutContext.getELFSection(".gcc_compiled_long64", - ELF::SHT_PROGBITS, 0)); + OutStreamer->SwitchSection(OutContext.getELFSection(".gcc_compiled_long64", + ELF::SHT_PROGBITS, 0)); } getTargetStreamer().updateABIInfo(STI); @@ -760,12 +760,12 @@ void MipsAsmPrinter::emitInlineAsmStart() const { TS.emitDirectiveSetAt(); TS.emitDirectiveSetMacro(); TS.emitDirectiveSetReorder(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } void MipsAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, const MCSubtargetInfo *EndInfo) const { - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); getTargetStreamer().emitDirectiveSetPop(); } @@ -774,7 +774,7 @@ void MipsAsmPrinter::EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol) { I.setOpcode(Mips::JAL); I.addOperand( MCOperand::CreateExpr(MCSymbolRefExpr::Create(Symbol, OutContext))); - OutStreamer.EmitInstruction(I, STI); + OutStreamer->EmitInstruction(I, STI); } void MipsAsmPrinter::EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, @@ -782,7 +782,7 @@ void MipsAsmPrinter::EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, MCInst I; I.setOpcode(Opcode); I.addOperand(MCOperand::CreateReg(Reg)); - OutStreamer.EmitInstruction(I, STI); + OutStreamer->EmitInstruction(I, STI); } void MipsAsmPrinter::EmitInstrRegReg(const MCSubtargetInfo &STI, @@ -802,7 +802,7 @@ void MipsAsmPrinter::EmitInstrRegReg(const MCSubtargetInfo &STI, I.setOpcode(Opcode); I.addOperand(MCOperand::CreateReg(Reg1)); I.addOperand(MCOperand::CreateReg(Reg2)); - OutStreamer.EmitInstruction(I, STI); + OutStreamer->EmitInstruction(I, STI); } void MipsAsmPrinter::EmitInstrRegRegReg(const MCSubtargetInfo &STI, @@ -813,7 +813,7 @@ void MipsAsmPrinter::EmitInstrRegRegReg(const MCSubtargetInfo &STI, I.addOperand(MCOperand::CreateReg(Reg1)); I.addOperand(MCOperand::CreateReg(Reg2)); I.addOperand(MCOperand::CreateReg(Reg3)); - OutStreamer.EmitInstruction(I, STI); + OutStreamer->EmitInstruction(I, STI); } void MipsAsmPrinter::EmitMovFPIntPair(const MCSubtargetInfo &STI, @@ -900,7 +900,7 @@ void MipsAsmPrinter::EmitFPCallStub( // // .global xxxx // - OutStreamer.EmitSymbolAttribute(MSymbol, MCSA_Global); + OutStreamer->EmitSymbolAttribute(MSymbol, MCSA_Global); const char *RetType; // // make the comment field identifying the return and parameter @@ -948,23 +948,23 @@ void MipsAsmPrinter::EmitFPCallStub( Parms = ""; break; } - OutStreamer.AddComment("\t# Stub function to call " + Twine(RetType) + " " + - Twine(Symbol) + " (" + Twine(Parms) + ")"); + OutStreamer->AddComment("\t# Stub function to call " + Twine(RetType) + " " + + Twine(Symbol) + " (" + Twine(Parms) + ")"); // // probably not necessary but we save and restore the current section state // - OutStreamer.PushSection(); + OutStreamer->PushSection(); // // .section mips16.call.fpxxxx,"ax",@progbits // const MCSectionELF *M = OutContext.getELFSection( ".mips16.call.fp." + std::string(Symbol), ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_EXECINSTR); - OutStreamer.SwitchSection(M, nullptr); + OutStreamer->SwitchSection(M, nullptr); // // .align 2 // - OutStreamer.EmitValueToAlignment(4); + OutStreamer->EmitValueToAlignment(4); MipsTargetStreamer &TS = getTargetStreamer(); // // .set nomips16 @@ -982,8 +982,8 @@ void MipsAsmPrinter::EmitFPCallStub( TS.emitDirectiveEnt(*Stub); MCSymbol *MType = OutContext.GetOrCreateSymbol("__call_stub_fp_" + Twine(Symbol)); - OutStreamer.EmitSymbolAttribute(MType, MCSA_ELF_TypeFunction); - OutStreamer.EmitLabel(Stub); + OutStreamer->EmitSymbolAttribute(MType, MCSA_ELF_TypeFunction); + OutStreamer->EmitLabel(Stub); // Only handle non-pic for now. assert(TM.getRelocationModel() != Reloc::PIC_ && @@ -1022,13 +1022,13 @@ void MipsAsmPrinter::EmitFPCallStub( EmitInstrReg(*STI, Mips::JR, Mips::S2); MCSymbol *Tmp = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(Tmp); + OutStreamer->EmitLabel(Tmp); const MCSymbolRefExpr *E = MCSymbolRefExpr::Create(Stub, OutContext); const MCSymbolRefExpr *T = MCSymbolRefExpr::Create(Tmp, OutContext); const MCExpr *T_min_E = MCBinaryExpr::CreateSub(T, E, OutContext); - OutStreamer.EmitELFSize(Stub, T_min_E); + OutStreamer->EmitELFSize(Stub, T_min_E); TS.emitDirectiveEnd(x); - OutStreamer.PopSection(); + OutStreamer->PopSection(); } void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) { @@ -1044,7 +1044,7 @@ void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) { EmitFPCallStub(Symbol, Signature); } // return to the text section - OutStreamer.SwitchSection(OutContext.getObjectFileInfo()->getTextSection()); + OutStreamer->SwitchSection(OutContext.getObjectFileInfo()->getTextSection()); } void MipsAsmPrinter::PrintDebugValueComment(const MachineInstr *MI, diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 12170a6..3beee65 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -151,7 +151,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) { std::stringstream temp; temp << "\t.loc " << filenameMap[fileName] << " " << curLoc.getLine() << " " << curLoc.getCol(); - OutStreamer.EmitRawText(temp.str()); + OutStreamer->EmitRawText(temp.str()); } void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) { @@ -162,7 +162,7 @@ void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCInst Inst; lowerToMCInst(MI, Inst); - EmitToStreamer(OutStreamer, Inst); + EmitToStreamer(*OutStreamer, Inst); } // Handle symbol backtracking for targets that do not support image handles @@ -444,7 +444,7 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll( void NVPTXAsmPrinter::EmitBasicBlockStart(const MachineBasicBlock &MBB) const { AsmPrinter::EmitBasicBlockStart(MBB); if (isLoopHeaderOfNoUnroll(MBB)) - OutStreamer.EmitRawText(StringRef("\t.pragma \"nounroll\";\n")); + OutStreamer->EmitRawText(StringRef("\t.pragma \"nounroll\";\n")); } void NVPTXAsmPrinter::EmitFunctionEntryLabel() { @@ -474,37 +474,37 @@ void NVPTXAsmPrinter::EmitFunctionEntryLabel() { if (llvm::isKernelFunction(*F)) emitKernelFunctionDirectives(*F, O); - OutStreamer.EmitRawText(O.str()); + OutStreamer->EmitRawText(O.str()); prevDebugLoc = DebugLoc(); } void NVPTXAsmPrinter::EmitFunctionBodyStart() { VRegMapping.clear(); - OutStreamer.EmitRawText(StringRef("{\n")); + OutStreamer->EmitRawText(StringRef("{\n")); setAndEmitFunctionVirtualRegisters(*MF); SmallString<128> Str; raw_svector_ostream O(Str); emitDemotedVars(MF->getFunction(), O); - OutStreamer.EmitRawText(O.str()); + OutStreamer->EmitRawText(O.str()); } void NVPTXAsmPrinter::EmitFunctionBodyEnd() { - OutStreamer.EmitRawText(StringRef("}\n")); + OutStreamer->EmitRawText(StringRef("}\n")); VRegMapping.clear(); } void NVPTXAsmPrinter::emitImplicitDef(const MachineInstr *MI) const { unsigned RegNo = MI->getOperand(0).getReg(); if (TargetRegisterInfo::isVirtualRegister(RegNo)) { - OutStreamer.AddComment(Twine("implicit-def: ") + - getVirtualRegisterName(RegNo)); + OutStreamer->AddComment(Twine("implicit-def: ") + + getVirtualRegisterName(RegNo)); } else { - OutStreamer.AddComment(Twine("implicit-def: ") + - nvptxSubtarget->getRegisterInfo()->getName(RegNo)); + OutStreamer->AddComment(Twine("implicit-def: ") + + nvptxSubtarget->getRegisterInfo()->getName(RegNo)); } - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, @@ -784,7 +784,7 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) { if (filenameMap.find(Filename) != filenameMap.end()) continue; filenameMap[Filename] = i; - OutStreamer.EmitDwarfFileDirective(i, "", Filename); + OutStreamer->EmitDwarfFileDirective(i, "", Filename); ++i; } @@ -830,19 +830,19 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) { // Emit header before any dwarf directives are emitted below. emitHeader(M, OS1, STI); - OutStreamer.EmitRawText(OS1.str()); + OutStreamer->EmitRawText(OS1.str()); // Already commented out //bool Result = AsmPrinter::doInitialization(M); // Emit module-level inline asm if it exists. if (!M.getModuleInlineAsm().empty()) { - OutStreamer.AddComment("Start of file scope inline assembly"); - OutStreamer.AddBlankLine(); - OutStreamer.EmitRawText(StringRef(M.getModuleInlineAsm())); - OutStreamer.AddBlankLine(); - OutStreamer.AddComment("End of file scope inline assembly"); - OutStreamer.AddBlankLine(); + OutStreamer->AddComment("Start of file scope inline assembly"); + OutStreamer->AddBlankLine(); + OutStreamer->EmitRawText(StringRef(M.getModuleInlineAsm())); + OutStreamer->AddBlankLine(); + OutStreamer->AddComment("End of file scope inline assembly"); + OutStreamer->AddBlankLine(); } // If we're not NVCL we're CUDA, go ahead and emit filenames. @@ -884,7 +884,7 @@ void NVPTXAsmPrinter::emitGlobals(const Module &M) { OS2 << '\n'; - OutStreamer.EmitRawText(OS2.str()); + OutStreamer->EmitRawText(OS2.str()); } void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O, @@ -1666,7 +1666,7 @@ void NVPTXAsmPrinter::setAndEmitFunctionVirtualRegisters( } } - OutStreamer.EmitRawText(O.str()); + OutStreamer->EmitRawText(O.str()); } void NVPTXAsmPrinter::printFPConstant(const ConstantFP *Fp, raw_ostream &O) { @@ -2087,7 +2087,7 @@ void NVPTXAsmPrinter::emitSrcInText(StringRef filename, unsigned line) { temp << " "; temp << reader->readLine(line); temp << "\n"; - this->OutStreamer.EmitRawText(temp.str()); + this->OutStreamer->EmitRawText(temp.str()); } LineReader *NVPTXAsmPrinter::getReader(std::string filename) { diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp index 383a1e2..8a848e3 100644 --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -427,7 +427,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI, const GlobalValue *GValue = MO.getGlobal(); MCSymbol *MOSymbol = getSymbol(GValue); const MCExpr *SymVar = MCSymbolRefExpr::Create(MOSymbol, VK, OutContext); - EmitToStreamer(OutStreamer, + EmitToStreamer(*OutStreamer, MCInstBuilder(Subtarget->isPPC64() ? PPC::BL8_NOP_TLS : PPC::BL_TLS) .addExpr(TlsRef) @@ -450,9 +450,9 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { case TargetOpcode::DBG_VALUE: llvm_unreachable("Should be handled target independently"); case TargetOpcode::STACKMAP: - return LowerSTACKMAP(OutStreamer, SM, *MI); + return LowerSTACKMAP(*OutStreamer, SM, *MI); case TargetOpcode::PATCHPOINT: - return LowerPATCHPOINT(OutStreamer, SM, *MI); + return LowerPATCHPOINT(*OutStreamer, SM, *MI); case PPC::MoveGOTtoLR: { // Transform %LR = MoveGOTtoLR @@ -471,7 +471,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { OutContext); // Emit the 'bl'. - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr)); return; } case PPC::MovePCtoLR: @@ -483,13 +483,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbol *PICBase = MF->getPICBaseSymbol(); // Emit the 'bl'. - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BL) + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL) // FIXME: We would like an efficient form for this, so we don't have to do // a lot of extra uniquing. .addExpr(MCSymbolRefExpr::Create(PICBase, OutContext))); // Emit the label. - OutStreamer.EmitLabel(PICBase); + OutStreamer->EmitLabel(PICBase); return; } case PPC::UpdateGBR: { @@ -515,13 +515,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCOperand::CreateExpr(MCBinaryExpr::CreateSub(Exp, PB, OutContext)); TmpInst.getOperand(0) = TR; TmpInst.getOperand(2) = PICR; - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); TmpInst.setOpcode(PPC::ADD4); TmpInst.getOperand(0) = PICR; TmpInst.getOperand(1) = TR; TmpInst.getOperand(2) = PICR; - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case PPC::LWZtoc: { @@ -562,7 +562,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { Exp = MCBinaryExpr::CreateSub(Exp, PB, OutContext); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); } - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case PPC::LDtocJTI: @@ -595,7 +595,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbolRefExpr::Create(TOCEntry, MCSymbolRefExpr::VK_PPC_TOC, OutContext); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } @@ -642,7 +642,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_HA, OutContext); TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case PPC::LDtocL: { @@ -684,7 +684,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO, OutContext); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case PPC::ADDItocL: { @@ -718,7 +718,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO, OutContext); TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } case PPC::ADDISgotTprelHA: { @@ -731,10 +731,10 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { const MCExpr *SymGotTprel = MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8) - .addReg(MI->getOperand(0).getReg()) - .addReg(MI->getOperand(1).getReg()) - .addExpr(SymGotTprel)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8) + .addReg(MI->getOperand(0).getReg()) + .addReg(MI->getOperand(1).getReg()) + .addExpr(SymGotTprel)); return; } case PPC::LDgotTprelL: @@ -751,7 +751,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO, OutContext); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); return; } @@ -760,7 +760,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbol *GOTRef = OutContext.CreateTempSymbol(); MCSymbol *NextInstr = OutContext.CreateTempSymbol(); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BL) + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL) // FIXME: We would like an efficient form for this, so we don't have to do // a lot of extra uniquing. .addExpr(MCSymbolRefExpr::Create(NextInstr, OutContext))); @@ -768,19 +768,19 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(GOTSymbol, OutContext), MCSymbolRefExpr::Create(GOTRef, OutContext), OutContext); - OutStreamer.EmitLabel(GOTRef); - OutStreamer.EmitValue(OffsExpr, 4); - OutStreamer.EmitLabel(NextInstr); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MFLR) - .addReg(MI->getOperand(0).getReg())); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::LWZ) - .addReg(MI->getOperand(1).getReg()) - .addImm(0) - .addReg(MI->getOperand(0).getReg())); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADD4) - .addReg(MI->getOperand(0).getReg()) - .addReg(MI->getOperand(1).getReg()) - .addReg(MI->getOperand(0).getReg())); + OutStreamer->EmitLabel(GOTRef); + OutStreamer->EmitValue(OffsExpr, 4); + OutStreamer->EmitLabel(NextInstr); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR) + .addReg(MI->getOperand(0).getReg())); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LWZ) + .addReg(MI->getOperand(1).getReg()) + .addImm(0) + .addReg(MI->getOperand(0).getReg())); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD4) + .addReg(MI->getOperand(0).getReg()) + .addReg(MI->getOperand(1).getReg()) + .addReg(MI->getOperand(0).getReg())); return; } case PPC::PPC32GOT: { @@ -791,13 +791,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { const MCExpr *SymGotTlsHA = MCSymbolRefExpr::Create(GOTSymbol, MCSymbolRefExpr::VK_PPC_HA, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::LI) - .addReg(MI->getOperand(0).getReg()) - .addExpr(SymGotTlsL)); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS) - .addReg(MI->getOperand(0).getReg()) - .addReg(MI->getOperand(0).getReg()) - .addExpr(SymGotTlsHA)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI) + .addReg(MI->getOperand(0).getReg()) + .addExpr(SymGotTlsL)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS) + .addReg(MI->getOperand(0).getReg()) + .addReg(MI->getOperand(0).getReg()) + .addExpr(SymGotTlsHA)); return; } case PPC::ADDIStlsgdHA: { @@ -810,10 +810,10 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { const MCExpr *SymGotTlsGD = MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8) - .addReg(MI->getOperand(0).getReg()) - .addReg(MI->getOperand(1).getReg()) - .addExpr(SymGotTlsGD)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8) + .addReg(MI->getOperand(0).getReg()) + .addReg(MI->getOperand(1).getReg()) + .addExpr(SymGotTlsGD)); return; } case PPC::ADDItlsgdL: @@ -829,7 +829,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MOSymbol, Subtarget->isPPC64() ? MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO : MCSymbolRefExpr::VK_PPC_GOT_TLSGD, OutContext); - EmitToStreamer(OutStreamer, + EmitToStreamer(*OutStreamer, MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI) .addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(1).getReg()) @@ -855,10 +855,10 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { const MCExpr *SymGotTlsLD = MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8) - .addReg(MI->getOperand(0).getReg()) - .addReg(MI->getOperand(1).getReg()) - .addExpr(SymGotTlsLD)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8) + .addReg(MI->getOperand(0).getReg()) + .addReg(MI->getOperand(1).getReg()) + .addExpr(SymGotTlsLD)); return; } case PPC::ADDItlsldL: @@ -874,7 +874,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MOSymbol, Subtarget->isPPC64() ? MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO : MCSymbolRefExpr::VK_PPC_GOT_TLSLD, OutContext); - EmitToStreamer(OutStreamer, + EmitToStreamer(*OutStreamer, MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI) .addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(1).getReg()) @@ -903,7 +903,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_HA, OutContext); EmitToStreamer( - OutStreamer, + *OutStreamer, MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDIS8 : PPC::ADDIS) .addReg(MI->getOperand(0).getReg()) .addReg(Subtarget->isPPC64() ? PPC::X3 : PPC::R3) @@ -922,7 +922,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { const MCExpr *SymDtprel = MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_LO, OutContext); - EmitToStreamer(OutStreamer, + EmitToStreamer(*OutStreamer, MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI) .addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(1).getReg()) @@ -936,9 +936,9 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { // Into: %R3 = MFCR ;; cr7 unsigned NewOpcode = MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8; - OutStreamer.AddComment(PPCInstPrinter:: - getRegisterName(MI->getOperand(1).getReg())); - EmitToStreamer(OutStreamer, MCInstBuilder(NewOpcode) + OutStreamer->AddComment(PPCInstPrinter:: + getRegisterName(MI->getOperand(1).getReg())); + EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode) .addReg(MI->getOperand(0).getReg())); return; } @@ -952,11 +952,11 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8; unsigned Mask = 0x80 >> OutContext.getRegisterInfo() ->getEncodingValue(MI->getOperand(0).getReg()); - OutStreamer.AddComment(PPCInstPrinter:: - getRegisterName(MI->getOperand(0).getReg())); - EmitToStreamer(OutStreamer, MCInstBuilder(NewOpcode) - .addImm(Mask) - .addReg(MI->getOperand(1).getReg())); + OutStreamer->AddComment(PPCInstPrinter:: + getRegisterName(MI->getOperand(0).getReg())); + EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode) + .addImm(Mask) + .addReg(MI->getOperand(1).getReg())); return; } break; @@ -982,13 +982,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { } LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, isDarwin); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); } void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) { if (static_cast(TM).isELFv2ABI()) { PPCTargetStreamer *TS = - static_cast(OutStreamer.getTargetStreamer()); + static_cast(OutStreamer->getTargetStreamer()); if (TS) TS->emitAbiVersion(2); @@ -1001,13 +1001,13 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) { if (M.getPICLevel() == PICLevel::Small) return AsmPrinter::EmitStartOfAsmFile(M); - OutStreamer.SwitchSection(OutContext.getELFSection( + OutStreamer->SwitchSection(OutContext.getELFSection( ".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC)); MCSymbol *TOCSym = OutContext.GetOrCreateSymbol(Twine(".LTOC")); MCSymbol *CurrentPos = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(CurrentPos); + OutStreamer->EmitLabel(CurrentPos); // The GOT pointer points to the middle of the GOT, in order to reference the // entire 64kB range. 0x8000 is the midpoint. @@ -1016,9 +1016,9 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) { MCConstantExpr::Create(0x8000, OutContext), OutContext); - OutStreamer.EmitAssignment(TOCSym, tocExpr); + OutStreamer->EmitAssignment(TOCSym, tocExpr); - OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); + OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); } void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { @@ -1033,7 +1033,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { if (PPCFI->usesPICBase()) { MCSymbol *RelocSymbol = PPCFI->getPICOffsetSymbol(); MCSymbol *PICBase = MF->getPICBaseSymbol(); - OutStreamer.EmitLabel(RelocSymbol); + OutStreamer->EmitLabel(RelocSymbol); const MCExpr *OffsExpr = MCBinaryExpr::CreateSub( @@ -1041,8 +1041,8 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { OutContext), MCSymbolRefExpr::Create(PICBase, OutContext), OutContext); - OutStreamer.EmitValue(OffsExpr, 4); - OutStreamer.EmitLabel(CurrentFnSym); + OutStreamer->EmitValue(OffsExpr, 4); + OutStreamer->EmitLabel(CurrentFnSym); return; } else return AsmPrinter::EmitFunctionEntryLabel(); @@ -1053,25 +1053,25 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { return AsmPrinter::EmitFunctionEntryLabel(); // Emit an official procedure descriptor. - MCSectionSubPair Current = OutStreamer.getCurrentSection(); - const MCSectionELF *Section = OutStreamer.getContext().getELFSection( + MCSectionSubPair Current = OutStreamer->getCurrentSection(); + const MCSectionELF *Section = OutStreamer->getContext().getELFSection( ".opd", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); - OutStreamer.SwitchSection(Section); - OutStreamer.EmitLabel(CurrentFnSym); - OutStreamer.EmitValueToAlignment(8); + OutStreamer->SwitchSection(Section); + OutStreamer->EmitLabel(CurrentFnSym); + OutStreamer->EmitValueToAlignment(8); MCSymbol *Symbol1 = CurrentFnSymForSize; // Generates a R_PPC64_ADDR64 (from FK_DATA_8) relocation for the function // entry point. - OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext), - 8 /*size*/); + OutStreamer->EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext), + 8 /*size*/); MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC.")); // Generates a R_PPC64_TOC relocation for TOC base insertion. - OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol2, - MCSymbolRefExpr::VK_PPC_TOCBASE, OutContext), - 8/*size*/); + OutStreamer->EmitValue( + MCSymbolRefExpr::Create(Symbol2, MCSymbolRefExpr::VK_PPC_TOCBASE, OutContext), + 8/*size*/); // Emit a null environment pointer. - OutStreamer.EmitIntValue(0, 8 /* size */); - OutStreamer.SwitchSection(Current.first, Current.second); + OutStreamer->EmitIntValue(0, 8 /* size */); + OutStreamer->SwitchSection(Current.first, Current.second); } @@ -1081,27 +1081,27 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) { bool isPPC64 = TD->getPointerSizeInBits() == 64; PPCTargetStreamer &TS = - static_cast(*OutStreamer.getTargetStreamer()); + static_cast(*OutStreamer->getTargetStreamer()); if (!TOC.empty()) { const MCSectionELF *Section; if (isPPC64) - Section = OutStreamer.getContext().getELFSection( + Section = OutStreamer->getContext().getELFSection( ".toc", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); else - Section = OutStreamer.getContext().getELFSection( + Section = OutStreamer->getContext().getELFSection( ".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); - OutStreamer.SwitchSection(Section); + OutStreamer->SwitchSection(Section); for (MapVector::iterator I = TOC.begin(), E = TOC.end(); I != E; ++I) { - OutStreamer.EmitLabel(I->second); + OutStreamer->EmitLabel(I->second); MCSymbol *S = I->first; if (isPPC64) TS.emitTCEntry(*S); else - OutStreamer.EmitSymbolValue(S, 4); + OutStreamer->EmitSymbolValue(S, 4); } } @@ -1131,7 +1131,7 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() { && !MF->getRegInfo().use_empty(PPC::X2)) { MCSymbol *GlobalEntryLabel = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(GlobalEntryLabel); + OutStreamer->EmitLabel(GlobalEntryLabel); const MCSymbolRefExpr *GlobalEntryLabelExp = MCSymbolRefExpr::Create(GlobalEntryLabel, OutContext); @@ -1142,20 +1142,20 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() { const MCExpr *TOCDeltaHi = PPCMCExpr::CreateHa(TOCDeltaExpr, false, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS) - .addReg(PPC::X2) - .addReg(PPC::X12) - .addExpr(TOCDeltaHi)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS) + .addReg(PPC::X2) + .addReg(PPC::X12) + .addExpr(TOCDeltaHi)); const MCExpr *TOCDeltaLo = PPCMCExpr::CreateLo(TOCDeltaExpr, false, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDI) - .addReg(PPC::X2) - .addReg(PPC::X2) - .addExpr(TOCDeltaLo)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDI) + .addReg(PPC::X2) + .addReg(PPC::X2) + .addExpr(TOCDeltaLo)); MCSymbol *LocalEntryLabel = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(LocalEntryLabel); + OutStreamer->EmitLabel(LocalEntryLabel); const MCSymbolRefExpr *LocalEntryLabelExp = MCSymbolRefExpr::Create(LocalEntryLabel, OutContext); const MCExpr *LocalOffsetExp = @@ -1163,7 +1163,7 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() { GlobalEntryLabelExp, OutContext); PPCTargetStreamer *TS = - static_cast(OutStreamer.getTargetStreamer()); + static_cast(OutStreamer->getTargetStreamer()); if (TS) TS->emitLocalEntry(CurrentFnSym, LocalOffsetExp); @@ -1182,8 +1182,8 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyEnd() { // the PPC64 ELF ABI (this is a low-priority item because GDB does not // currently make use of these fields). if (Subtarget->isPPC64()) { - OutStreamer.EmitIntValue(0, 4/*size*/); - OutStreamer.EmitIntValue(0, 8/*size*/); + OutStreamer->EmitIntValue(0, 4/*size*/); + OutStreamer->EmitIntValue(0, 8/*size*/); } } @@ -1232,28 +1232,28 @@ void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) { assert(Directive < array_lengthof(CPUDirectives) && "CPUDirectives[] might not be up-to-date!"); PPCTargetStreamer &TStreamer = - *static_cast(OutStreamer.getTargetStreamer()); + *static_cast(OutStreamer->getTargetStreamer()); TStreamer.emitMachine(CPUDirectives[Directive]); // Prime text sections so they are adjacent. This reduces the likelihood a // large data or debug section causes a branch to exceed 16M limit. const TargetLoweringObjectFileMachO &TLOFMacho = static_cast(getObjFileLowering()); - OutStreamer.SwitchSection(TLOFMacho.getTextCoalSection()); + OutStreamer->SwitchSection(TLOFMacho.getTextCoalSection()); if (TM.getRelocationModel() == Reloc::PIC_) { - OutStreamer.SwitchSection( + OutStreamer->SwitchSection( OutContext.getMachOSection("__TEXT", "__picsymbolstub1", MachO::S_SYMBOL_STUBS | MachO::S_ATTR_PURE_INSTRUCTIONS, 32, SectionKind::getText())); } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) { - OutStreamer.SwitchSection( + OutStreamer->SwitchSection( OutContext.getMachOSection("__TEXT","__symbol_stub1", MachO::S_SYMBOL_STUBS | MachO::S_ATTR_PURE_INSTRUCTIONS, 16, SectionKind::getText())); } - OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); + OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); } static MCSymbol *GetLazyPtr(MCSymbol *Sym, MCContext &Ctx) { @@ -1295,7 +1295,7 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { MachO::S_ATTR_PURE_INSTRUCTIONS, 32, SectionKind::getText()); for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { - OutStreamer.SwitchSection(StubSection); + OutStreamer->SwitchSection(StubSection); EmitAlignment(4); MCSymbol *Stub = Stubs[i].first; @@ -1303,8 +1303,8 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext); MCSymbol *AnonSymbol = GetAnonSym(Stub, OutContext); - OutStreamer.EmitLabel(Stub); - OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); + OutStreamer->EmitLabel(Stub); + OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); const MCExpr *Anon = MCSymbolRefExpr::Create(AnonSymbol, OutContext); const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext); @@ -1312,48 +1312,48 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { MCBinaryExpr::CreateSub(LazyPtrExpr, Anon, OutContext); // mflr r0 - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R0)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R0)); // bcl 20, 31, AnonSymbol - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BCLalways).addExpr(Anon)); - OutStreamer.EmitLabel(AnonSymbol); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCLalways).addExpr(Anon)); + OutStreamer->EmitLabel(AnonSymbol); // mflr r11 - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R11)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R11)); // addis r11, r11, ha16(LazyPtr - AnonSymbol) const MCExpr *SubHa16 = PPCMCExpr::CreateHa(Sub, true, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS) + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS) .addReg(PPC::R11) .addReg(PPC::R11) .addExpr(SubHa16)); // mtlr r0 - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MTLR).addReg(PPC::R0)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR).addReg(PPC::R0)); // ldu r12, lo16(LazyPtr - AnonSymbol)(r11) // lwzu r12, lo16(LazyPtr - AnonSymbol)(r11) const MCExpr *SubLo16 = PPCMCExpr::CreateLo(Sub, true, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU) + EmitToStreamer(*OutStreamer, MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU) .addReg(PPC::R12) .addExpr(SubLo16).addExpr(SubLo16) .addReg(PPC::R11)); // mtctr r12 - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12)); // bctr - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BCTR)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTR)); - OutStreamer.SwitchSection(LSPSection); - OutStreamer.EmitLabel(LazyPtr); - OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); + OutStreamer->SwitchSection(LSPSection); + OutStreamer->EmitLabel(LazyPtr); + OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); MCSymbol *DyldStubBindingHelper = OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper")); if (isPPC64) { // .quad dyld_stub_binding_helper - OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 8); + OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 8); } else { // .long dyld_stub_binding_helper - OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 4); + OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 4); } } - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); return; } @@ -1368,15 +1368,15 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext); const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext); - OutStreamer.SwitchSection(StubSection); + OutStreamer->SwitchSection(StubSection); EmitAlignment(4); - OutStreamer.EmitLabel(Stub); - OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); + OutStreamer->EmitLabel(Stub); + OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); // lis r11, ha16(LazyPtr) const MCExpr *LazyPtrHa16 = PPCMCExpr::CreateHa(LazyPtrExpr, true, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::LIS) + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LIS) .addReg(PPC::R11) .addExpr(LazyPtrHa16)); @@ -1384,32 +1384,32 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) { // lwzu r12, lo16(LazyPtr)(r11) const MCExpr *LazyPtrLo16 = PPCMCExpr::CreateLo(LazyPtrExpr, true, OutContext); - EmitToStreamer(OutStreamer, MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU) + EmitToStreamer(*OutStreamer, MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU) .addReg(PPC::R12) .addExpr(LazyPtrLo16).addExpr(LazyPtrLo16) .addReg(PPC::R11)); // mtctr r12 - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12)); // bctr - EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BCTR)); + EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTR)); - OutStreamer.SwitchSection(LSPSection); - OutStreamer.EmitLabel(LazyPtr); - OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); + OutStreamer->SwitchSection(LSPSection); + OutStreamer->EmitLabel(LazyPtr); + OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); MCSymbol *DyldStubBindingHelper = OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper")); if (isPPC64) { // .quad dyld_stub_binding_helper - OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 8); + OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 8); } else { // .long dyld_stub_binding_helper - OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 4); + OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 4); } } - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } @@ -1447,19 +1447,19 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { // Output macho stubs for external and common global variables. if (!Stubs.empty()) { // Switch with ".non_lazy_symbol_pointer" directive. - OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); + OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); EmitAlignment(isPPC64 ? 3 : 2); for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { // L_foo$stub: - OutStreamer.EmitLabel(Stubs[i].first); + OutStreamer->EmitLabel(Stubs[i].first); // .indirect_symbol _foo MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second; - OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol); + OutStreamer->EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol); if (MCSym.getInt()) // External to current translation unit. - OutStreamer.EmitIntValue(0, isPPC64 ? 8 : 4/*size*/); + OutStreamer->EmitIntValue(0, isPPC64 ? 8 : 4/*size*/); else // Internal to current translation unit. // @@ -1467,32 +1467,32 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { // need to be indirect and pc-rel. We accomplish this by using NLPs. // However, sometimes the types are local to the file. So we need to // fill in the value for the NLP in those cases. - OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(), - OutContext), + OutStreamer->EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(), + OutContext), isPPC64 ? 8 : 4/*size*/); } Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } Stubs = MMIMacho.GetHiddenGVStubList(); if (!Stubs.empty()) { - OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); + OutStreamer->SwitchSection(getObjFileLowering().getDataSection()); EmitAlignment(isPPC64 ? 3 : 2); for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { // L_foo$stub: - OutStreamer.EmitLabel(Stubs[i].first); + OutStreamer->EmitLabel(Stubs[i].first); // .long _foo - OutStreamer.EmitValue(MCSymbolRefExpr:: - Create(Stubs[i].second.getPointer(), - OutContext), - isPPC64 ? 8 : 4/*size*/); + OutStreamer->EmitValue(MCSymbolRefExpr:: + Create(Stubs[i].second.getPointer(), + OutContext), + isPPC64 ? 8 : 4/*size*/); } Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } // Funny Darwin hack: This flag tells the linker that no global symbols @@ -1500,7 +1500,7 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) { // implementation of multiple entry points). If this doesn't occur, the // linker can safely perform dead code stripping. Since LLVM never generates // code that does this, it is always safe to set. - OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); + OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); return AsmPrinter::doFinalization(M); } diff --git a/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp index b3480b4..a1dca69 100644 --- a/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp @@ -93,10 +93,10 @@ void AMDGPUAsmPrinter::EmitEndOfAsmFile(Module &M) { // This label is used to mark the end of the .text section. const TargetLoweringObjectFile &TLOF = getObjFileLowering(); - OutStreamer.SwitchSection(TLOF.getTextSection()); + OutStreamer->SwitchSection(TLOF.getTextSection()); MCSymbol *EndOfTextLabel = OutContext.GetOrCreateSymbol(StringRef(END_OF_TEXT_LABEL_NAME)); - OutStreamer.EmitLabel(EndOfTextLabel); + OutStreamer->EmitLabel(EndOfTextLabel); } bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { @@ -109,14 +109,14 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { MCContext &Context = getObjFileLowering().getContext(); const MCSectionELF *ConfigSection = Context.getELFSection(".AMDGPU.config", ELF::SHT_PROGBITS, 0); - OutStreamer.SwitchSection(ConfigSection); + OutStreamer->SwitchSection(ConfigSection); const AMDGPUSubtarget &STM = MF.getSubtarget(); SIProgramInfo KernelInfo; if (STM.isAmdHsaOS()) { getSIProgramInfo(KernelInfo, MF); EmitAmdKernelCodeT(MF, KernelInfo); - OutStreamer.EmitCodeAlignment(2 << (MF.getAlignment() - 1)); + OutStreamer->EmitCodeAlignment(2 << (MF.getAlignment() - 1)); } else if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) { getSIProgramInfo(KernelInfo, MF); EmitProgramInfoSI(MF, KernelInfo); @@ -133,40 +133,40 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { if (isVerbose()) { const MCSectionELF *CommentSection = Context.getELFSection(".AMDGPU.csdata", ELF::SHT_PROGBITS, 0); - OutStreamer.SwitchSection(CommentSection); + OutStreamer->SwitchSection(CommentSection); if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) { - OutStreamer.emitRawComment(" Kernel info:", false); - OutStreamer.emitRawComment(" codeLenInByte = " + Twine(KernelInfo.CodeLen), - false); - OutStreamer.emitRawComment(" NumSgprs: " + Twine(KernelInfo.NumSGPR), - false); - OutStreamer.emitRawComment(" NumVgprs: " + Twine(KernelInfo.NumVGPR), - false); - OutStreamer.emitRawComment(" FloatMode: " + Twine(KernelInfo.FloatMode), - false); - OutStreamer.emitRawComment(" IeeeMode: " + Twine(KernelInfo.IEEEMode), - false); - OutStreamer.emitRawComment(" ScratchSize: " + Twine(KernelInfo.ScratchSize), - false); + OutStreamer->emitRawComment(" Kernel info:", false); + OutStreamer->emitRawComment(" codeLenInByte = " + Twine(KernelInfo.CodeLen), + false); + OutStreamer->emitRawComment(" NumSgprs: " + Twine(KernelInfo.NumSGPR), + false); + OutStreamer->emitRawComment(" NumVgprs: " + Twine(KernelInfo.NumVGPR), + false); + OutStreamer->emitRawComment(" FloatMode: " + Twine(KernelInfo.FloatMode), + false); + OutStreamer->emitRawComment(" IeeeMode: " + Twine(KernelInfo.IEEEMode), + false); + OutStreamer->emitRawComment(" ScratchSize: " + Twine(KernelInfo.ScratchSize), + false); } else { R600MachineFunctionInfo *MFI = MF.getInfo(); - OutStreamer.emitRawComment( + OutStreamer->emitRawComment( Twine("SQ_PGM_RESOURCES:STACK_SIZE = " + Twine(MFI->StackSize))); } } if (STM.dumpCode()) { - OutStreamer.SwitchSection( + OutStreamer->SwitchSection( Context.getELFSection(".AMDGPU.disasm", ELF::SHT_NOTE, 0)); for (size_t i = 0; i < DisasmLines.size(); ++i) { std::string Comment(DisasmLineMaxLen - DisasmLines[i].size(), ' '); Comment += " ; " + HexLines[i] + "\n"; - OutStreamer.EmitBytes(StringRef(DisasmLines[i])); - OutStreamer.EmitBytes(StringRef(Comment)); + OutStreamer->EmitBytes(StringRef(DisasmLines[i])); + OutStreamer->EmitBytes(StringRef(Comment)); } } @@ -221,15 +221,15 @@ void AMDGPUAsmPrinter::EmitProgramInfoR600(const MachineFunction &MF) { } } - OutStreamer.EmitIntValue(RsrcReg, 4); - OutStreamer.EmitIntValue(S_NUM_GPRS(MaxGPR + 1) | + OutStreamer->EmitIntValue(RsrcReg, 4); + OutStreamer->EmitIntValue(S_NUM_GPRS(MaxGPR + 1) | S_STACK_SIZE(MFI->StackSize), 4); - OutStreamer.EmitIntValue(R_02880C_DB_SHADER_CONTROL, 4); - OutStreamer.EmitIntValue(S_02880C_KILL_ENABLE(killPixel), 4); + OutStreamer->EmitIntValue(R_02880C_DB_SHADER_CONTROL, 4); + OutStreamer->EmitIntValue(S_02880C_KILL_ENABLE(killPixel), 4); if (MFI->getShaderType() == ShaderType::COMPUTE) { - OutStreamer.EmitIntValue(R_0288E8_SQ_LDS_ALLOC, 4); - OutStreamer.EmitIntValue(RoundUpToAlignment(MFI->LDSSize, 4) >> 2, 4); + OutStreamer->EmitIntValue(R_0288E8_SQ_LDS_ALLOC, 4); + OutStreamer->EmitIntValue(RoundUpToAlignment(MFI->LDSSize, 4) >> 2, 4); } } @@ -426,33 +426,33 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const MachineFunction &MF, unsigned RsrcReg = getRsrcReg(MFI->getShaderType()); if (MFI->getShaderType() == ShaderType::COMPUTE) { - OutStreamer.EmitIntValue(R_00B848_COMPUTE_PGM_RSRC1, 4); + OutStreamer->EmitIntValue(R_00B848_COMPUTE_PGM_RSRC1, 4); - OutStreamer.EmitIntValue(KernelInfo.ComputePGMRSrc1, 4); + OutStreamer->EmitIntValue(KernelInfo.ComputePGMRSrc1, 4); - OutStreamer.EmitIntValue(R_00B84C_COMPUTE_PGM_RSRC2, 4); - OutStreamer.EmitIntValue(KernelInfo.ComputePGMRSrc2, 4); + OutStreamer->EmitIntValue(R_00B84C_COMPUTE_PGM_RSRC2, 4); + OutStreamer->EmitIntValue(KernelInfo.ComputePGMRSrc2, 4); - OutStreamer.EmitIntValue(R_00B860_COMPUTE_TMPRING_SIZE, 4); - OutStreamer.EmitIntValue(S_00B860_WAVESIZE(KernelInfo.ScratchBlocks), 4); + OutStreamer->EmitIntValue(R_00B860_COMPUTE_TMPRING_SIZE, 4); + OutStreamer->EmitIntValue(S_00B860_WAVESIZE(KernelInfo.ScratchBlocks), 4); // TODO: Should probably note flat usage somewhere. SC emits a "FlatPtr32 = // 0" comment but I don't see a corresponding field in the register spec. } else { - OutStreamer.EmitIntValue(RsrcReg, 4); - OutStreamer.EmitIntValue(S_00B028_VGPRS(KernelInfo.VGPRBlocks) | - S_00B028_SGPRS(KernelInfo.SGPRBlocks), 4); + OutStreamer->EmitIntValue(RsrcReg, 4); + OutStreamer->EmitIntValue(S_00B028_VGPRS(KernelInfo.VGPRBlocks) | + S_00B028_SGPRS(KernelInfo.SGPRBlocks), 4); if (STM.isVGPRSpillingEnabled(MFI)) { - OutStreamer.EmitIntValue(R_0286E8_SPI_TMPRING_SIZE, 4); - OutStreamer.EmitIntValue(S_0286E8_WAVESIZE(KernelInfo.ScratchBlocks), 4); + OutStreamer->EmitIntValue(R_0286E8_SPI_TMPRING_SIZE, 4); + OutStreamer->EmitIntValue(S_0286E8_WAVESIZE(KernelInfo.ScratchBlocks), 4); } } if (MFI->getShaderType() == ShaderType::PIXEL) { - OutStreamer.EmitIntValue(R_00B02C_SPI_SHADER_PGM_RSRC2_PS, 4); - OutStreamer.EmitIntValue(S_00B02C_EXTRA_LDS_SIZE(KernelInfo.LDSBlocks), 4); - OutStreamer.EmitIntValue(R_0286CC_SPI_PS_INPUT_ENA, 4); - OutStreamer.EmitIntValue(MFI->PSInputAddr, 4); + OutStreamer->EmitIntValue(R_00B02C_SPI_SHADER_PGM_RSRC2_PS, 4); + OutStreamer->EmitIntValue(S_00B02C_EXTRA_LDS_SIZE(KernelInfo.LDSBlocks), 4); + OutStreamer->EmitIntValue(R_0286CC_SPI_PS_INPUT_ENA, 4); + OutStreamer->EmitIntValue(MFI->PSInputAddr, 4); } } @@ -511,69 +511,71 @@ void AMDGPUAsmPrinter::EmitAmdKernelCodeT(const MachineFunction &MF, const MCSectionELF *VersionSection = OutContext.getELFSection(".hsa.version", ELF::SHT_PROGBITS, 0); - OutStreamer.SwitchSection(VersionSection); - OutStreamer.EmitBytes(Twine("HSA Code Unit:" + - Twine(header.hsail_version_major) + "." + - Twine(header.hsail_version_minor) + ":" + - "AMD:" + - Twine(header.amd_code_version_major) + "." + - Twine(header.amd_code_version_minor) + ":" + - "GFX8.1:0").str()); + OutStreamer->SwitchSection(VersionSection); + OutStreamer->EmitBytes(Twine("HSA Code Unit:" + + Twine(header.hsail_version_major) + "." + + Twine(header.hsail_version_minor) + ":" + + "AMD:" + + Twine(header.amd_code_version_major) + "." + + Twine(header.amd_code_version_minor) + ":" + + "GFX8.1:0").str()); - OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); + OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); if (isVerbose()) { - OutStreamer.emitRawComment("amd_code_version_major = " + - Twine(header.amd_code_version_major), false); - OutStreamer.emitRawComment("amd_code_version_minor = " + - Twine(header.amd_code_version_minor), false); - OutStreamer.emitRawComment("struct_byte_size = " + - Twine(header.struct_byte_size), false); - OutStreamer.emitRawComment("target_chip = " + - Twine(header.target_chip), false); - OutStreamer.emitRawComment(" compute_pgm_rsrc1: " + - Twine::utohexstr(KernelInfo.ComputePGMRSrc1), false); - OutStreamer.emitRawComment(" compute_pgm_rsrc2: " + - Twine::utohexstr(KernelInfo.ComputePGMRSrc2), false); - OutStreamer.emitRawComment("enable_sgpr_private_segment_buffer = " + + OutStreamer->emitRawComment("amd_code_version_major = " + + Twine(header.amd_code_version_major), false); + OutStreamer->emitRawComment("amd_code_version_minor = " + + Twine(header.amd_code_version_minor), false); + OutStreamer->emitRawComment("struct_byte_size = " + + Twine(header.struct_byte_size), false); + OutStreamer->emitRawComment("target_chip = " + + Twine(header.target_chip), false); + OutStreamer->emitRawComment(" compute_pgm_rsrc1: " + + Twine::utohexstr(KernelInfo.ComputePGMRSrc1), + false); + OutStreamer->emitRawComment(" compute_pgm_rsrc2: " + + Twine::utohexstr(KernelInfo.ComputePGMRSrc2), + false); + OutStreamer->emitRawComment("enable_sgpr_private_segment_buffer = " + Twine((bool)(header.code_properties & AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE)), false); - OutStreamer.emitRawComment("enable_sgpr_kernarg_segment_ptr = " + + OutStreamer->emitRawComment("enable_sgpr_kernarg_segment_ptr = " + Twine((bool)(header.code_properties & AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR)), false); - OutStreamer.emitRawComment("private_element_size = 2 ", false); - OutStreamer.emitRawComment("is_ptr64 = " + + OutStreamer->emitRawComment("private_element_size = 2 ", false); + OutStreamer->emitRawComment("is_ptr64 = " + Twine((bool)(header.code_properties & AMD_CODE_PROPERTY_IS_PTR64)), false); - OutStreamer.emitRawComment("workitem_private_segment_byte_size = " + - Twine(header.workitem_private_segment_byte_size), - false); - OutStreamer.emitRawComment("workgroup_group_segment_byte_size = " + - Twine(header.workgroup_group_segment_byte_size), - false); - OutStreamer.emitRawComment("gds_segment_byte_size = " + - Twine(header.gds_segment_byte_size), false); - OutStreamer.emitRawComment("kernarg_segment_byte_size = " + - Twine(header.kernarg_segment_byte_size), false); - OutStreamer.emitRawComment("wavefront_sgpr_count = " + - Twine(header.wavefront_sgpr_count), false); - OutStreamer.emitRawComment("workitem_vgpr_count = " + - Twine(header.workitem_vgpr_count), false); - OutStreamer.emitRawComment("code_type = " + Twine(header.code_type), false); - OutStreamer.emitRawComment("wavefront_size = " + - Twine((int)header.wavefront_size), false); - OutStreamer.emitRawComment("optimization_level = " + - Twine(header.optimization_level), false); - OutStreamer.emitRawComment("hsail_profile = " + - Twine(header.hsail_profile), false); - OutStreamer.emitRawComment("hsail_machine_model = " + - Twine(header.hsail_machine_model), false); - OutStreamer.emitRawComment("hsail_version_major = " + - Twine(header.hsail_version_major), false); - OutStreamer.emitRawComment("hsail_version_minor = " + - Twine(header.hsail_version_minor), false); + OutStreamer->emitRawComment("workitem_private_segment_byte_size = " + + Twine(header.workitem_private_segment_byte_size), + false); + OutStreamer->emitRawComment("workgroup_group_segment_byte_size = " + + Twine(header.workgroup_group_segment_byte_size), + false); + OutStreamer->emitRawComment("gds_segment_byte_size = " + + Twine(header.gds_segment_byte_size), false); + OutStreamer->emitRawComment("kernarg_segment_byte_size = " + + Twine(header.kernarg_segment_byte_size), false); + OutStreamer->emitRawComment("wavefront_sgpr_count = " + + Twine(header.wavefront_sgpr_count), false); + OutStreamer->emitRawComment("workitem_vgpr_count = " + + Twine(header.workitem_vgpr_count), false); + OutStreamer->emitRawComment("code_type = " + Twine(header.code_type), false); + OutStreamer->emitRawComment("wavefront_size = " + + Twine((int)header.wavefront_size), false); + OutStreamer->emitRawComment("optimization_level = " + + Twine(header.optimization_level), false); + OutStreamer->emitRawComment("hsail_profile = " + + Twine(header.hsail_profile), false); + OutStreamer->emitRawComment("hsail_machine_model = " + + Twine(header.hsail_machine_model), false); + OutStreamer->emitRawComment("hsail_version_major = " + + Twine(header.hsail_version_major), false); + OutStreamer->emitRawComment("hsail_version_minor = " + + Twine(header.hsail_version_minor), false); } - OutStreamer.EmitBytes(StringRef((char*)&header, sizeof(header))); + OutStreamer->EmitBytes(StringRef((char*)&header, sizeof(header))); } bool AMDGPUAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, diff --git a/llvm/lib/Target/R600/AMDGPUMCInstLower.cpp b/llvm/lib/Target/R600/AMDGPUMCInstLower.cpp index 7e274a9..b00bd8d 100644 --- a/llvm/lib/Target/R600/AMDGPUMCInstLower.cpp +++ b/llvm/lib/Target/R600/AMDGPUMCInstLower.cpp @@ -113,7 +113,7 @@ void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) { } else { MCInst TmpInst; MCInstLowering.lower(MI, TmpInst); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); if (STI.dumpCode()) { // Disassemble instruction/operands to text. diff --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp index 56290e2..a976e10 100644 --- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp +++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp @@ -40,7 +40,7 @@ namespace { class SparcAsmPrinter : public AsmPrinter { SparcTargetStreamer &getTargetStreamer() { return static_cast( - *OutStreamer.getTargetStreamer()); + *OutStreamer->getTargetStreamer()); } public: explicit SparcAsmPrinter(TargetMachine &TM, @@ -191,35 +191,35 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI, default: llvm_unreachable("Unsupported absolute code model"); case CodeModel::Small: - EmitHiLo(OutStreamer, GOTLabel, + EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO, MCRegOP, OutContext, STI); break; case CodeModel::Medium: { - EmitHiLo(OutStreamer, GOTLabel, + EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_Sparc_H44, SparcMCExpr::VK_Sparc_M44, MCRegOP, OutContext, STI); MCOperand imm = MCOperand::CreateExpr(MCConstantExpr::Create(12, OutContext)); - EmitSHL(OutStreamer, MCRegOP, imm, MCRegOP, STI); + EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI); MCOperand lo = createSparcMCOperand(SparcMCExpr::VK_Sparc_L44, GOTLabel, OutContext); - EmitOR(OutStreamer, MCRegOP, lo, MCRegOP, STI); + EmitOR(*OutStreamer, MCRegOP, lo, MCRegOP, STI); break; } case CodeModel::Large: { - EmitHiLo(OutStreamer, GOTLabel, + EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_Sparc_HH, SparcMCExpr::VK_Sparc_HM, MCRegOP, OutContext, STI); MCOperand imm = MCOperand::CreateExpr(MCConstantExpr::Create(32, OutContext)); - EmitSHL(OutStreamer, MCRegOP, imm, MCRegOP, STI); + EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI); // Use register %o7 to load the lower 32 bits. MCOperand RegO7 = MCOperand::CreateReg(SP::O7); - EmitHiLo(OutStreamer, GOTLabel, + EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO, RegO7, OutContext, STI); - EmitADD(OutStreamer, MCRegOP, RegO7, MCRegOP, STI); + EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI); } } return; @@ -239,20 +239,20 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI, // or , %lo(_GLOBAL_OFFSET_TABLE_+(-))), // add , %o7, - OutStreamer.EmitLabel(StartLabel); + OutStreamer->EmitLabel(StartLabel); MCOperand Callee = createPCXCallOP(EndLabel, OutContext); - EmitCall(OutStreamer, Callee, STI); - OutStreamer.EmitLabel(SethiLabel); + EmitCall(*OutStreamer, Callee, STI); + OutStreamer->EmitLabel(SethiLabel); MCOperand hiImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC22, GOTLabel, StartLabel, SethiLabel, OutContext); - EmitSETHI(OutStreamer, hiImm, MCRegOP, STI); - OutStreamer.EmitLabel(EndLabel); + EmitSETHI(*OutStreamer, hiImm, MCRegOP, STI); + OutStreamer->EmitLabel(EndLabel); MCOperand loImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC10, GOTLabel, StartLabel, EndLabel, OutContext); - EmitOR(OutStreamer, MCRegOP, loImm, MCRegOP, STI); - EmitADD(OutStreamer, MCRegOP, RegO7, MCRegOP, STI); + EmitOR(*OutStreamer, MCRegOP, loImm, MCRegOP, STI); + EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI); } void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI) @@ -272,7 +272,7 @@ void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI) do { MCInst TmpInst; LowerSparcMachineInstrToMCInst(I, TmpInst, *this); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); } while ((++I != E) && I->isInsideBundle()); // Delay slot check. } diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp index 2524733..c83a3d0 100644 --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -198,7 +198,7 @@ void SystemZAsmPrinter::EmitInstruction(const MachineInstr *MI) { Lower.lower(MI, LoweredMI); break; } - EmitToStreamer(OutStreamer, LoweredMI); + EmitToStreamer(*OutStreamer, LoweredMI); } // Convert a SystemZ-specific constant pool modifier into the associated @@ -224,7 +224,7 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) { OutContext); uint64_t Size = TM.getDataLayout()->getTypeAllocSize(ZCPV->getType()); - OutStreamer.EmitValue(Expr, Size); + OutStreamer->EmitValue(Expr, Size); } bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index 2ed4975..ab933fe 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -55,12 +55,12 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) { if (Subtarget->isTargetCOFF()) { bool Intrn = MF.getFunction()->hasInternalLinkage(); - OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); - OutStreamer.EmitCOFFSymbolStorageClass(Intrn ? COFF::IMAGE_SYM_CLASS_STATIC - : COFF::IMAGE_SYM_CLASS_EXTERNAL); - OutStreamer.EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION + OutStreamer->BeginCOFFSymbolDef(CurrentFnSym); + OutStreamer->EmitCOFFSymbolStorageClass(Intrn ? COFF::IMAGE_SYM_CLASS_STATIC + : COFF::IMAGE_SYM_CLASS_EXTERNAL); + OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT); - OutStreamer.EndCOFFSymbolDef(); + OutStreamer->EndCOFFSymbolDef(); } // Emit the rest of the function body. @@ -507,24 +507,24 @@ void X86AsmPrinter::EmitStartOfAsmFile(Module &M) { Triple TT(TM.getTargetTriple()); if (TT.isOSBinFormatMachO()) - OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); + OutStreamer->SwitchSection(getObjFileLowering().getTextSection()); if (TT.isOSBinFormatCOFF()) { // Emit an absolute @feat.00 symbol. This appears to be some kind of // compiler features bitfield read by link.exe. if (TT.getArch() == Triple::x86) { MCSymbol *S = MMI->getContext().GetOrCreateSymbol(StringRef("@feat.00")); - OutStreamer.BeginCOFFSymbolDef(S); - OutStreamer.EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC); - OutStreamer.EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL); - OutStreamer.EndCOFFSymbolDef(); + OutStreamer->BeginCOFFSymbolDef(S); + OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC); + OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL); + OutStreamer->EndCOFFSymbolDef(); // According to the PE-COFF spec, the LSB of this value marks the object // for "registered SEH". This means that all SEH handler entry points // must be registered in .sxdata. Use of any unregistered handlers will // cause the process to terminate immediately. LLVM does not know how to // register any SEH handlers, so its object files should be safe. - OutStreamer.EmitSymbolAttribute(S, MCSA_Global); - OutStreamer.EmitAssignment( + OutStreamer->EmitSymbolAttribute(S, MCSA_Global); + OutStreamer->EmitAssignment( S, MCConstantExpr::Create(int64_t(1), MMI->getContext())); } } @@ -564,7 +564,7 @@ MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const { getObjFileLowering().getSectionForConstant(Kind, C))) { if (MCSymbol *Sym = S->getCOMDATSymbol()) { if (Sym->isUndefined()) - OutStreamer.EmitSymbolAttribute(Sym, MCSA_Global); + OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global); return Sym; } } @@ -599,7 +599,7 @@ void X86AsmPrinter::GenerateExportDirective(const MCSymbol *Sym, bool IsData) { } OS.flush(); - OutStreamer.EmitBytes(Directive); + OutStreamer->EmitBytes(Directive); } void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { @@ -621,21 +621,21 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { MachO::S_ATTR_SELF_MODIFYING_CODE | MachO::S_ATTR_PURE_INSTRUCTIONS, 5, SectionKind::getMetadata()); - OutStreamer.SwitchSection(TheSection); + OutStreamer->SwitchSection(TheSection); for (const auto &Stub : Stubs) { // L_foo$stub: - OutStreamer.EmitLabel(Stub.first); + OutStreamer->EmitLabel(Stub.first); // .indirect_symbol _foo - OutStreamer.EmitSymbolAttribute(Stub.second.getPointer(), - MCSA_IndirectSymbol); + OutStreamer->EmitSymbolAttribute(Stub.second.getPointer(), + MCSA_IndirectSymbol); // hlt; hlt; hlt; hlt; hlt hlt = 0xf4. const char HltInsts[] = "\xf4\xf4\xf4\xf4\xf4"; - OutStreamer.EmitBytes(StringRef(HltInsts, 5)); + OutStreamer->EmitBytes(StringRef(HltInsts, 5)); } Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } // Output stubs for external and common global variables. @@ -645,13 +645,13 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { OutContext.getMachOSection("__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS, SectionKind::getMetadata()); - OutStreamer.SwitchSection(TheSection); + OutStreamer->SwitchSection(TheSection); for (auto &Stub : Stubs) - emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); + emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second); Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } Stubs = MMIMacho.GetHiddenGVStubList(); @@ -660,13 +660,13 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { OutContext.getMachOSection("__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS, SectionKind::getMetadata()); - OutStreamer.SwitchSection(TheSection); + OutStreamer->SwitchSection(TheSection); for (auto &Stub : Stubs) - emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); + emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second); Stubs.clear(); - OutStreamer.AddBlankLine(); + OutStreamer->AddBlankLine(); } SM.serializeToStackMapSection(); @@ -676,14 +676,14 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { // implementation of multiple entry points). If this doesn't occur, the // linker can safely perform dead code stripping. Since LLVM never // generates code that does this, it is always safe to set. - OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); + OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); } if (TT.isKnownWindowsMSVCEnvironment() && MMI->usesVAFloatArgument()) { StringRef SymbolName = (TT.getArch() == Triple::x86_64) ? "_fltused" : "__fltused"; MCSymbol *S = MMI->getContext().GetOrCreateSymbol(SymbolName); - OutStreamer.EmitSymbolAttribute(S, MCSA_Global); + OutStreamer->EmitSymbolAttribute(S, MCSA_Global); } if (TT.isOSBinFormatCOFF()) { @@ -713,7 +713,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { const TargetLoweringObjectFileCOFF &TLOFCOFF = static_cast(getObjFileLowering()); - OutStreamer.SwitchSection(TLOFCOFF.getDrectveSection()); + OutStreamer->SwitchSection(TLOFCOFF.getDrectveSection()); for (auto & Symbol : DLLExportedGlobals) GenerateExportDirective(Symbol, /*IsData=*/true); diff --git a/llvm/lib/Target/X86/X86AsmPrinter.h b/llvm/lib/Target/X86/X86AsmPrinter.h index 9c6c683..b8aa177 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.h +++ b/llvm/lib/Target/X86/X86AsmPrinter.h @@ -103,7 +103,7 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter { void EmitInstruction(const MachineInstr *MI) override; void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override { - SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); + SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo()); } bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp index 98dc376..7eabff6 100644 --- a/llvm/lib/Target/X86/X86MCInstLower.cpp +++ b/llvm/lib/Target/X86/X86MCInstLower.cpp @@ -105,7 +105,7 @@ namespace llvm { } void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) { - OutStreamer.EmitInstruction(Inst, getSubtargetInfo()); + OutStreamer->EmitInstruction(Inst, getSubtargetInfo()); SMShadowTracker.count(Inst, getSubtargetInfo()); } } // end llvm namespace @@ -271,7 +271,7 @@ MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO, // local labels. This is only safe when the symbols are in the same // section so we are restricting it to jumptable references. MCSymbol *Label = Ctx.CreateTempSymbol(); - AsmPrinter.OutStreamer.EmitAssignment(Label, Expr); + AsmPrinter.OutStreamer->EmitAssignment(Label, Expr); Expr = MCSymbolRefExpr::Create(Label, Ctx); } break; @@ -683,7 +683,7 @@ void X86AsmPrinter::LowerTlsAddr(X86MCInstLower &MCInstLowering, bool needsPadding = MI.getOpcode() == X86::TLS_addr64; - MCContext &context = OutStreamer.getContext(); + MCContext &context = OutStreamer->getContext(); if (needsPadding) EmitAndCountInstruction(MCInstBuilder(X86::DATA16_PREFIX)); @@ -859,7 +859,7 @@ static void LowerSTATEPOINT(MCStreamer &OS, StackMaps &SM, // Lower a stackmap of the form: // , , ... void X86AsmPrinter::LowerSTACKMAP(const MachineInstr &MI) { - SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); + SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo()); SM.recordStackMap(MI); unsigned NumShadowBytes = MI.getOperand(1).getImm(); SMShadowTracker.reset(NumShadowBytes); @@ -871,7 +871,7 @@ void X86AsmPrinter::LowerPATCHPOINT(const MachineInstr &MI, X86MCInstLower &MCIL) { assert(Subtarget->is64Bit() && "Patchpoint currently only supports X86-64"); - SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); + SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo()); SM.recordPatchPoint(MI); @@ -919,7 +919,7 @@ void X86AsmPrinter::LowerPATCHPOINT(const MachineInstr &MI, assert(NumBytes >= EncodedBytes && "Patchpoint can't request size less than the length of a call."); - EmitNops(OutStreamer, NumBytes - EncodedBytes, Subtarget->is64Bit(), + EmitNops(*OutStreamer, NumBytes - EncodedBytes, Subtarget->is64Bit(), getSubtargetInfo()); } @@ -1021,7 +1021,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { // Emit nothing here but a comment if we can. case X86::Int_MemBarrier: - OutStreamer.emitRawComment("MEMBARRIER"); + OutStreamer->emitRawComment("MEMBARRIER"); return; @@ -1029,8 +1029,8 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { case X86::EH_RETURN64: { // Lower these as normal, but add some comments. unsigned Reg = MI->getOperand(0).getReg(); - OutStreamer.AddComment(StringRef("eh_return, addr: %") + - X86ATTInstPrinter::getRegisterName(Reg)); + OutStreamer->AddComment(StringRef("eh_return, addr: %") + + X86ATTInstPrinter::getRegisterName(Reg)); break; } case X86::TAILJMPr: @@ -1043,7 +1043,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { case X86::TAILJMPm64_REX: case X86::TAILJMPd64_REX: // Lower these as normal, but add some comments. - OutStreamer.AddComment("TAILCALL"); + OutStreamer->AddComment("TAILCALL"); break; case X86::TLS_addr32: @@ -1067,7 +1067,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { .addExpr(MCSymbolRefExpr::Create(PICBase, OutContext))); // Emit the label. - OutStreamer.EmitLabel(PICBase); + OutStreamer->EmitLabel(PICBase); // popl $reg EmitAndCountInstruction(MCInstBuilder(X86::POP32r) @@ -1088,7 +1088,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { // However, we can't generate a ".", so just emit a new label here and refer // to it. MCSymbol *DotSym = OutContext.CreateTempSymbol(); - OutStreamer.EmitLabel(DotSym); + OutStreamer->EmitLabel(DotSym); // Now that we have emitted the label, lower the complex operand expression. MCSymbol *OpSym = MCInstLowering.GetSymbolFromOperand(MI->getOperand(2)); @@ -1108,7 +1108,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { return; } case TargetOpcode::STATEPOINT: - return LowerSTATEPOINT(OutStreamer, SM, *MI, Subtarget->is64Bit(), TM, + return LowerSTATEPOINT(*OutStreamer, SM, *MI, Subtarget->is64Bit(), TM, getSubtargetInfo(), MCInstLowering); case TargetOpcode::STACKMAP: @@ -1130,34 +1130,34 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { return; case X86::SEH_PushReg: - OutStreamer.EmitWinCFIPushReg(RI->getSEHRegNum(MI->getOperand(0).getImm())); + OutStreamer->EmitWinCFIPushReg(RI->getSEHRegNum(MI->getOperand(0).getImm())); return; case X86::SEH_SaveReg: - OutStreamer.EmitWinCFISaveReg(RI->getSEHRegNum(MI->getOperand(0).getImm()), - MI->getOperand(1).getImm()); + OutStreamer->EmitWinCFISaveReg(RI->getSEHRegNum(MI->getOperand(0).getImm()), + MI->getOperand(1).getImm()); return; case X86::SEH_SaveXMM: - OutStreamer.EmitWinCFISaveXMM(RI->getSEHRegNum(MI->getOperand(0).getImm()), - MI->getOperand(1).getImm()); + OutStreamer->EmitWinCFISaveXMM(RI->getSEHRegNum(MI->getOperand(0).getImm()), + MI->getOperand(1).getImm()); return; case X86::SEH_StackAlloc: - OutStreamer.EmitWinCFIAllocStack(MI->getOperand(0).getImm()); + OutStreamer->EmitWinCFIAllocStack(MI->getOperand(0).getImm()); return; case X86::SEH_SetFrame: - OutStreamer.EmitWinCFISetFrame(RI->getSEHRegNum(MI->getOperand(0).getImm()), - MI->getOperand(1).getImm()); + OutStreamer->EmitWinCFISetFrame(RI->getSEHRegNum(MI->getOperand(0).getImm()), + MI->getOperand(1).getImm()); return; case X86::SEH_PushFrame: - OutStreamer.EmitWinCFIPushFrame(MI->getOperand(0).getImm()); + OutStreamer->EmitWinCFIPushFrame(MI->getOperand(0).getImm()); return; case X86::SEH_EndPrologue: - OutStreamer.EmitWinCFIEndProlog(); + OutStreamer->EmitWinCFIEndProlog(); return; case X86::SEH_Epilogue: { @@ -1181,7 +1181,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { case X86::PSHUFBrm: case X86::VPSHUFBrm: case X86::VPSHUFBYrm: { - if (!OutStreamer.isVerboseAsm()) + if (!OutStreamer->isVerboseAsm()) break; assert(MI->getNumOperands() > 5 && "We should always have at least 5 operands!"); @@ -1193,7 +1193,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { SmallVector Mask; DecodePSHUFBMask(C, Mask); if (!Mask.empty()) - OutStreamer.AddComment(getShuffleComment(DstOp, SrcOp, Mask)); + OutStreamer->AddComment(getShuffleComment(DstOp, SrcOp, Mask)); } break; } @@ -1201,7 +1201,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { case X86::VPERMILPDrm: case X86::VPERMILPSYrm: case X86::VPERMILPDYrm: { - if (!OutStreamer.isVerboseAsm()) + if (!OutStreamer->isVerboseAsm()) break; assert(MI->getNumOperands() > 5 && "We should always have at least 5 operands!"); @@ -1213,7 +1213,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { SmallVector Mask; DecodeVPERMILPMask(C, Mask); if (!Mask.empty()) - OutStreamer.AddComment(getShuffleComment(DstOp, SrcOp, Mask)); + OutStreamer->AddComment(getShuffleComment(DstOp, SrcOp, Mask)); } break; } @@ -1238,7 +1238,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { case X86::MOVDQUrm: case X86::VMOVDQUrm: case X86::VMOVDQUYrm: - if (!OutStreamer.isVerboseAsm()) + if (!OutStreamer->isVerboseAsm()) break; if (MI->getNumOperands() > 4) if (auto *C = getConstantFromPool(*MI, MI->getOperand(4))) { @@ -1261,7 +1261,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { CS << "?"; } CS << "]"; - OutStreamer.AddComment(CS.str()); + OutStreamer->AddComment(CS.str()); } else if (auto *CV = dyn_cast(C)) { CS << "<"; for (int i = 0, NumOperands = CV->getNumOperands(); i < NumOperands; ++i) { @@ -1281,7 +1281,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { } } CS << ">"; - OutStreamer.AddComment(CS.str()); + OutStreamer->AddComment(CS.str()); } } break; @@ -1299,9 +1299,9 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { SMShadowTracker.count(TmpInst, getSubtargetInfo()); // Then flush the shadow so that we fill with nops before the call, not // after it. - SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); + SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo()); // Then emit the call - OutStreamer.EmitInstruction(TmpInst, getSubtargetInfo()); + OutStreamer->EmitInstruction(TmpInst, getSubtargetInfo()); return; } diff --git a/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp b/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp index 4f7a7e9..2c04769 100644 --- a/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -86,7 +86,7 @@ namespace { } // end of anonymous namespace XCoreTargetStreamer &XCoreAsmPrinter::getTargetStreamer() { - return static_cast(*OutStreamer.getTargetStreamer()); + return static_cast(*OutStreamer->getTargetStreamer()); } void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) { @@ -98,13 +98,13 @@ void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) { MCSymbol *SymGlob = OutContext.GetOrCreateSymbol( Twine(Sym->getName() + StringRef(".globound"))); - OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Global); - OutStreamer.EmitAssignment(SymGlob, - MCConstantExpr::Create(ATy->getNumElements(), - OutContext)); + OutStreamer->EmitSymbolAttribute(SymGlob, MCSA_Global); + OutStreamer->EmitAssignment(SymGlob, + MCConstantExpr::Create(ATy->getNumElements(), + OutContext)); if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()) { - OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Weak); + OutStreamer->EmitSymbolAttribute(SymGlob, MCSA_Weak); } } } @@ -116,7 +116,7 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { return; const DataLayout *TD = TM.getDataLayout(); - OutStreamer.SwitchSection( + OutStreamer->SwitchSection( getObjFileLowering().SectionForGlobal(GV, *Mang, TM)); MCSymbol *GVSym = getSymbol(GV); @@ -136,11 +136,11 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { case GlobalValue::ExternalLinkage: case GlobalValue::CommonLinkage: emitArrayBound(GVSym, GV); - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global); if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()) - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Weak); // FALL THROUGH case GlobalValue::InternalLinkage: case GlobalValue::PrivateLinkage: @@ -156,16 +156,16 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) { } unsigned Size = TD->getTypeAllocSize(C->getType()); if (MAI->hasDotTypeDotSizeDirective()) { - OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); - OutStreamer.EmitELFSize(GVSym, MCConstantExpr::Create(Size, OutContext)); + OutStreamer->EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); + OutStreamer->EmitELFSize(GVSym, MCConstantExpr::Create(Size, OutContext)); } - OutStreamer.EmitLabel(GVSym); + OutStreamer->EmitLabel(GVSym); EmitGlobalConstant(C); // The ABI requires that unsigned scalar types smaller than 32 bits // are padded to 32 bits. if (Size < 4) - OutStreamer.EmitZeros(4 - Size); + OutStreamer->EmitZeros(4 - Size); // Mark the end of the global getTargetStreamer().emitCCBottomData(GVSym->getName()); @@ -185,7 +185,7 @@ void XCoreAsmPrinter::EmitFunctionBodyEnd() { void XCoreAsmPrinter::EmitFunctionEntryLabel() { // Mark the start of the function getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName()); - OutStreamer.EmitLabel(CurrentFnSym); + OutStreamer->EmitLabel(CurrentFnSym); } void XCoreAsmPrinter:: @@ -275,7 +275,7 @@ void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) { O << "\tmov " << XCoreInstPrinter::getRegisterName(MI->getOperand(0).getReg()) << ", " << XCoreInstPrinter::getRegisterName(MI->getOperand(1).getReg()); - OutStreamer.EmitRawText(O.str()); + OutStreamer->EmitRawText(O.str()); return; } break; @@ -288,14 +288,14 @@ void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) { else printInlineJT32(MI, 0, O); O << '\n'; - OutStreamer.EmitRawText(O.str()); + OutStreamer->EmitRawText(O.str()); return; } MCInst TmpInst; MCInstLowering.Lower(MI, TmpInst); - EmitToStreamer(OutStreamer, TmpInst); + EmitToStreamer(*OutStreamer, TmpInst); } // Force static initialization. diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index c9c05cd..75c10bc 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -584,10 +584,10 @@ void DwarfStreamer::emitDIE(DIE &Die) { /// \brief Emit the debug_str section stored in \p Pool. void DwarfStreamer::emitStrings(const NonRelocatableStringpool &Pool) { - Asm->OutStreamer.SwitchSection(MOFI->getDwarfStrSection()); + Asm->OutStreamer->SwitchSection(MOFI->getDwarfStrSection()); for (auto *Entry = Pool.getFirstEntry(); Entry; Entry = Pool.getNextEntry(Entry)) - Asm->OutStreamer.EmitBytes( + Asm->OutStreamer->EmitBytes( StringRef(Entry->getKey().data(), Entry->getKey().size() + 1)); } @@ -668,13 +668,13 @@ void DwarfStreamer::emitUnitRangesEntries(CompileUnit &Unit, unsigned Padding = OffsetToAlignment(HeaderSize, TupleSize); Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Arange length - Asm->OutStreamer.EmitLabel(BeginLabel); + Asm->OutStreamer->EmitLabel(BeginLabel); Asm->EmitInt16(dwarf::DW_ARANGES_VERSION); // Version number Asm->EmitInt32(Unit.getStartOffset()); // Corresponding unit's offset Asm->EmitInt8(AddressSize); // Address size Asm->EmitInt8(0); // Segment size - Asm->OutStreamer.EmitFill(Padding, 0x0); + Asm->OutStreamer->EmitFill(Padding, 0x0); for (auto Range = Ranges.begin(), End = Ranges.end(); Range != End; ++Range) { @@ -686,9 +686,9 @@ void DwarfStreamer::emitUnitRangesEntries(CompileUnit &Unit, } // Emit terminator - Asm->OutStreamer.EmitIntValue(0, AddressSize); - Asm->OutStreamer.EmitIntValue(0, AddressSize); - Asm->OutStreamer.EmitLabel(EndLabel); + Asm->OutStreamer->EmitIntValue(0, AddressSize); + Asm->OutStreamer->EmitIntValue(0, AddressSize); + Asm->OutStreamer->EmitLabel(EndLabel); } if (!DoDebugRanges) @@ -746,16 +746,16 @@ void DwarfStreamer::emitLocationsForUnit(const CompileUnit &Unit, uint64_t High = Data.getUnsigned(&Offset, AddressSize); LocSectionSize += 2 * AddressSize; if (Low == 0 && High == 0) { - Asm->OutStreamer.EmitIntValue(0, AddressSize); - Asm->OutStreamer.EmitIntValue(0, AddressSize); + Asm->OutStreamer->EmitIntValue(0, AddressSize); + Asm->OutStreamer->EmitIntValue(0, AddressSize); break; } - Asm->OutStreamer.EmitIntValue(Low + LocPcOffset, AddressSize); - Asm->OutStreamer.EmitIntValue(High + LocPcOffset, AddressSize); + Asm->OutStreamer->EmitIntValue(Low + LocPcOffset, AddressSize); + Asm->OutStreamer->EmitIntValue(High + LocPcOffset, AddressSize); uint64_t Length = Data.getU16(&Offset); - Asm->OutStreamer.EmitIntValue(Length, 2); + Asm->OutStreamer->EmitIntValue(Length, 2); // Just copy the bytes over. - Asm->OutStreamer.EmitBytes( + Asm->OutStreamer->EmitBytes( StringRef(InputSec.Data.substr(Offset, Length))); Offset += Length; LocSectionSize += Length + 2; @@ -775,7 +775,7 @@ void DwarfStreamer::emitLineTableForUnit(StringRef PrologueBytes, // The first 4 bytes is the total length of the information for this // compilation unit (not including these 4 bytes for the length). Asm->EmitLabelDifference(LineEndSym, LineStartSym, 4); - Asm->OutStreamer.EmitLabel(LineStartSym); + Asm->OutStreamer->EmitLabel(LineStartSym); // Copy Prologue. MS->EmitBytes(PrologueBytes); LineSectionSize += PrologueBytes.size() + 4; @@ -918,7 +918,7 @@ void DwarfStreamer::emitPubSectionForUnit( return; // Start the dwarf pubnames section. - Asm->OutStreamer.SwitchSection(Sec); + Asm->OutStreamer->SwitchSection(Sec); MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + SecName + "_begin"); MCSymbol *EndLabel = Asm->createTempSymbol("pub" + SecName + "_end"); @@ -931,21 +931,21 @@ void DwarfStreamer::emitPubSectionForUnit( if (!HeaderEmitted) { // Emit the header. Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Length - Asm->OutStreamer.EmitLabel(BeginLabel); + Asm->OutStreamer->EmitLabel(BeginLabel); Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION); // Version Asm->EmitInt32(Unit.getStartOffset()); // Unit offset Asm->EmitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset()); // Size HeaderEmitted = true; } Asm->EmitInt32(Name.Die->getOffset()); - Asm->OutStreamer.EmitBytes( + Asm->OutStreamer->EmitBytes( StringRef(Name.Name.data(), Name.Name.size() + 1)); } if (!HeaderEmitted) return; Asm->EmitInt32(0); // End marker. - Asm->OutStreamer.EmitLabel(EndLabel); + Asm->OutStreamer->EmitLabel(EndLabel); } /// \brief Emit .debug_pubnames for \p Unit.