[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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames
2015-04-24 19:11:51 +00:00
parent b5365eec18
commit 579cebfb15
37 changed files with 986 additions and 981 deletions

View File

@ -78,7 +78,7 @@ public:
/// This is the MCStreamer object for the file we are generating. This /// This is the MCStreamer object for the file we are generating. This
/// contains the transient state for the current translation unit that we are /// contains the transient state for the current translation unit that we are
/// generating (such as the current section etc). /// generating (such as the current section etc).
MCStreamer &OutStreamer; std::unique_ptr<MCStreamer> OutStreamer;
/// The current machine function. /// The current machine function.
const MachineFunction *MF; const MachineFunction *MF;

View File

@ -41,7 +41,7 @@ ARMException::ARMException(AsmPrinter *A) : DwarfCFIExceptionBase(A) {}
ARMException::~ARMException() {} ARMException::~ARMException() {}
ARMTargetStreamer &ARMException::getTargetStreamer() { ARMTargetStreamer &ARMException::getTargetStreamer() {
MCTargetStreamer &TS = *Asm->OutStreamer.getTargetStreamer(); MCTargetStreamer &TS = *Asm->OutStreamer->getTargetStreamer();
return static_cast<ARMTargetStreamer &>(TS); return static_cast<ARMTargetStreamer &>(TS);
} }
@ -49,7 +49,7 @@ ARMTargetStreamer &ARMException::getTargetStreamer() {
/// content. /// content.
void ARMException::endModule() { void ARMException::endModule() {
if (shouldEmitCFI) if (shouldEmitCFI)
Asm->OutStreamer.EmitCFISections(false, true); Asm->OutStreamer->EmitCFISections(false, true);
} }
void ARMException::beginFunction(const MachineFunction *MF) { 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"); "non-EH CFI not yet supported in prologue with EHABI lowering");
if (MoveType == AsmPrinter::CFI_M_Debug) { if (MoveType == AsmPrinter::CFI_M_Debug) {
shouldEmitCFI = true; shouldEmitCFI = true;
Asm->OutStreamer.EmitCFIStartProc(false); Asm->OutStreamer->EmitCFIStartProc(false);
} }
} }
@ -77,7 +77,7 @@ void ARMException::endFunction(const MachineFunction *MF) {
// Emit references to personality. // Emit references to personality.
if (const Function *Personality = MMI->getPersonality()) { if (const Function *Personality = MMI->getPersonality()) {
MCSymbol *PerSym = Asm->getSymbol(Personality); MCSymbol *PerSym = Asm->getSymbol(Personality);
Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global); Asm->OutStreamer->EmitSymbolAttribute(PerSym, MCSA_Global);
ATS.emitPersonality(PerSym); ATS.emitPersonality(PerSym);
} }
@ -97,13 +97,13 @@ void ARMException::emitTypeInfos(unsigned TTypeEncoding) {
const std::vector<const GlobalValue *> &TypeInfos = MMI->getTypeInfos(); const std::vector<const GlobalValue *> &TypeInfos = MMI->getTypeInfos();
const std::vector<unsigned> &FilterIds = MMI->getFilterIds(); const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
bool VerboseAsm = Asm->OutStreamer.isVerboseAsm(); bool VerboseAsm = Asm->OutStreamer->isVerboseAsm();
int Entry = 0; int Entry = 0;
// Emit the Catch TypeInfos. // Emit the Catch TypeInfos.
if (VerboseAsm && !TypeInfos.empty()) { if (VerboseAsm && !TypeInfos.empty()) {
Asm->OutStreamer.AddComment(">> Catch TypeInfos <<"); Asm->OutStreamer->AddComment(">> Catch TypeInfos <<");
Asm->OutStreamer.AddBlankLine(); Asm->OutStreamer->AddBlankLine();
Entry = TypeInfos.size(); Entry = TypeInfos.size();
} }
@ -111,14 +111,14 @@ void ARMException::emitTypeInfos(unsigned TTypeEncoding) {
I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) { I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) {
const GlobalValue *GV = *I; const GlobalValue *GV = *I;
if (VerboseAsm) if (VerboseAsm)
Asm->OutStreamer.AddComment("TypeInfo " + Twine(Entry--)); Asm->OutStreamer->AddComment("TypeInfo " + Twine(Entry--));
Asm->EmitTTypeReference(GV, TTypeEncoding); Asm->EmitTTypeReference(GV, TTypeEncoding);
} }
// Emit the Exception Specifications. // Emit the Exception Specifications.
if (VerboseAsm && !FilterIds.empty()) { if (VerboseAsm && !FilterIds.empty()) {
Asm->OutStreamer.AddComment(">> Filter TypeInfos <<"); Asm->OutStreamer->AddComment(">> Filter TypeInfos <<");
Asm->OutStreamer.AddBlankLine(); Asm->OutStreamer->AddBlankLine();
Entry = 0; Entry = 0;
} }
for (std::vector<unsigned>::const_iterator for (std::vector<unsigned>::const_iterator
@ -127,7 +127,7 @@ void ARMException::emitTypeInfos(unsigned TTypeEncoding) {
if (VerboseAsm) { if (VerboseAsm) {
--Entry; --Entry;
if (TypeID != 0) if (TypeID != 0)
Asm->OutStreamer.AddComment("FilterInfo " + Twine(Entry)); Asm->OutStreamer->AddComment("FilterInfo " + Twine(Entry));
} }
Asm->EmitTTypeReference((TypeID == 0 ? nullptr : TypeInfos[TypeID - 1]), Asm->EmitTTypeReference((TypeID == 0 ? nullptr : TypeInfos[TypeID - 1]),

View File

@ -29,7 +29,7 @@ void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) {
return; return;
// Start the dwarf addr section. // Start the dwarf addr section.
Asm.OutStreamer.SwitchSection(AddrSection); Asm.OutStreamer->SwitchSection(AddrSection);
// Order the address pool entries by ID // Order the address pool entries by ID
SmallVector<const MCExpr *, 64> Entries(Pool.size()); SmallVector<const MCExpr *, 64> Entries(Pool.size());
@ -41,5 +41,5 @@ void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) {
: MCSymbolRefExpr::Create(I.first, Asm.OutContext); : MCSymbolRefExpr::Create(I.first, Asm.OutContext);
for (const MCExpr *Entry : Entries) for (const MCExpr *Entry : Entries)
Asm.OutStreamer.EmitValue(Entry, Asm.getDataLayout().getPointerSize()); Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize());
} }

View File

@ -102,7 +102,7 @@ static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &DL,
AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer) AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
: MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()), : 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) { LastMI(nullptr), LastFn(0), Counter(~0U) {
DD = nullptr; DD = nullptr;
MMI = nullptr; MMI = nullptr;
@ -112,7 +112,7 @@ AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
CurrentFnBegin = nullptr; CurrentFnBegin = nullptr;
CurrentFnEnd = nullptr; CurrentFnEnd = nullptr;
GCMetadataPrinters = nullptr; GCMetadataPrinters = nullptr;
VerboseAsm = OutStreamer.isVerboseAsm(); VerboseAsm = OutStreamer->isVerboseAsm();
} }
AsmPrinter::~AsmPrinter() { AsmPrinter::~AsmPrinter() {
@ -124,8 +124,6 @@ AsmPrinter::~AsmPrinter() {
delete &GCMap; delete &GCMap;
GCMetadataPrinters = nullptr; GCMetadataPrinters = nullptr;
} }
delete &OutStreamer;
} }
/// getFunctionNumber - Return a unique ID for the current function. /// 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. /// getCurrentSection() - Return the current section we are emitting to.
const MCSection *AsmPrinter::getCurrentSection() const { const MCSection *AsmPrinter::getCurrentSection() const {
return OutStreamer.getCurrentSection().first; return OutStreamer->getCurrentSection().first;
} }
@ -180,7 +178,7 @@ bool AsmPrinter::doInitialization(Module &M) {
const_cast<TargetLoweringObjectFile&>(getObjFileLowering()) const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
.Initialize(OutContext, TM); .Initialize(OutContext, TM);
OutStreamer.InitSections(false); OutStreamer->InitSections(false);
Mang = new Mangler(TM.getDataLayout()); Mang = new Mangler(TM.getDataLayout());
@ -198,7 +196,7 @@ bool AsmPrinter::doInitialization(Module &M) {
TT.getOSVersion(Major, Minor, Update); TT.getOSVersion(Major, Minor, Update);
// If there is a version specified, Major will be non-zero. // If there is a version specified, Major will be non-zero.
if (Major) if (Major)
OutStreamer.EmitVersionMin((TT.isMacOSX() ? OutStreamer->EmitVersionMin((TT.isMacOSX() ?
MCVM_OSXVersionMin : MCVM_IOSVersionMin), MCVM_OSXVersionMin : MCVM_IOSVersionMin),
Major, Minor, Update); Major, Minor, Update);
} }
@ -210,7 +208,7 @@ bool AsmPrinter::doInitialization(Module &M) {
// don't, this at least helps the user find where a global came from. // don't, this at least helps the user find where a global came from.
if (MAI->hasSingleParameterDotFile()) { if (MAI->hasSingleParameterDotFile()) {
// .file "foo.c" // .file "foo.c"
OutStreamer.EmitFileDirective(M.getModuleIdentifier()); OutStreamer->EmitFileDirective(M.getModuleIdentifier());
} }
GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
@ -225,11 +223,11 @@ bool AsmPrinter::doInitialization(Module &M) {
// and target triple. // and target triple.
std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo( std::unique_ptr<MCSubtargetInfo> STI(TM.getTarget().createMCSubtargetInfo(
TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString()));
OutStreamer.AddComment("Start of file scope inline assembly"); OutStreamer->AddComment("Start of file scope inline assembly");
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
EmitInlineAsm(M.getModuleInlineAsm()+"\n", *STI); EmitInlineAsm(M.getModuleInlineAsm()+"\n", *STI);
OutStreamer.AddComment("End of file scope inline assembly"); OutStreamer->AddComment("End of file scope inline assembly");
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
if (MAI->doesSupportDebugInformation()) { if (MAI->doesSupportDebugInformation()) {
@ -296,20 +294,20 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
case GlobalValue::WeakODRLinkage: case GlobalValue::WeakODRLinkage:
if (MAI->hasWeakDefDirective()) { if (MAI->hasWeakDefDirective()) {
// .globl _foo // .globl _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global);
if (!canBeHidden(GV, *MAI)) if (!canBeHidden(GV, *MAI))
// .weak_definition _foo // .weak_definition _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_WeakDefinition); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_WeakDefinition);
else else
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_WeakDefAutoPrivate); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_WeakDefAutoPrivate);
} else if (MAI->hasLinkOnceDirective()) { } else if (MAI->hasLinkOnceDirective()) {
// .globl _foo // .globl _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global);
//NOTE: linkonce is handled by the section the symbol was assigned to. //NOTE: linkonce is handled by the section the symbol was assigned to.
} else { } else {
// .weak _foo // .weak _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Weak);
} }
return; return;
case GlobalValue::AppendingLinkage: case GlobalValue::AppendingLinkage:
@ -318,7 +316,7 @@ void AsmPrinter::EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
// If external or appending, declare as a global symbol. // If external or appending, declare as a global symbol.
// .globl _foo // .globl _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global);
return; return;
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
@ -353,9 +351,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
return; return;
if (isVerbose()) { if (isVerbose()) {
GV->printAsOperand(OutStreamer.GetCommentOS(), GV->printAsOperand(OutStreamer->GetCommentOS(),
/*PrintType=*/false, GV->getParent()); /*PrintType=*/false, GV->getParent());
OutStreamer.GetCommentOS() << '\n'; OutStreamer->GetCommentOS() << '\n';
} }
} }
@ -371,7 +369,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
"' is already defined"); "' is already defined");
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective())
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject);
SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM); SectionKind GVKind = TargetLoweringObjectFile::getKindForGlobal(GV, TM);
@ -399,7 +397,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
Align = 0; Align = 0;
// .comm _foo, 42, 4 // .comm _foo, 42, 4
OutStreamer.EmitCommonSymbol(GVSym, Size, Align); OutStreamer->EmitCommonSymbol(GVSym, Size, Align);
return; return;
} }
@ -408,7 +406,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
const MCSection *TheSection = const MCSection *TheSection =
getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM); getObjFileLowering().SectionForGlobal(GV, GVKind, *Mang, TM);
// .zerofill __DATA, __bss, _foo, 400, 5 // .zerofill __DATA, __bss, _foo, 400, 5
OutStreamer.EmitZerofill(TheSection, GVSym, Size, Align); OutStreamer->EmitZerofill(TheSection, GVSym, Size, Align);
return; return;
} }
@ -420,7 +418,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
// Prefer to simply fall back to .local / .comm in this case. // Prefer to simply fall back to .local / .comm in this case.
if (MAI->getLCOMMDirectiveAlignmentType() != LCOMM::NoAlignment) { if (MAI->getLCOMMDirectiveAlignmentType() != LCOMM::NoAlignment) {
// .lcomm _foo, 42 // .lcomm _foo, 42
OutStreamer.EmitLocalCommonSymbol(GVSym, Size, Align); OutStreamer->EmitLocalCommonSymbol(GVSym, Size, Align);
return; return;
} }
@ -428,9 +426,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
Align = 0; Align = 0;
// .local _foo // .local _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Local); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Local);
// .comm _foo, 42, 4 // .comm _foo, 42, 4
OutStreamer.EmitCommonSymbol(GVSym, Size, Align); OutStreamer->EmitCommonSymbol(GVSym, Size, Align);
return; return;
} }
@ -443,9 +441,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
if (Size == 0) Size = 1; // zerofill of 0 bytes is undefined. if (Size == 0) Size = 1; // zerofill of 0 bytes is undefined.
// .globl _foo // .globl _foo
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global);
// .zerofill __DATA, __common, _foo, 400, 5 // .zerofill __DATA, __common, _foo, 400, 5
OutStreamer.EmitZerofill(TheSection, GVSym, Size, 1 << AlignLog); OutStreamer->EmitZerofill(TheSection, GVSym, Size, 1 << AlignLog);
return; return;
} }
@ -466,55 +464,55 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
if (GVKind.isThreadBSS()) { if (GVKind.isThreadBSS()) {
TheSection = getObjFileLowering().getTLSBSSSection(); TheSection = getObjFileLowering().getTLSBSSSection();
OutStreamer.EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog); OutStreamer->EmitTBSSSymbol(TheSection, MangSym, Size, 1 << AlignLog);
} else if (GVKind.isThreadData()) { } else if (GVKind.isThreadData()) {
OutStreamer.SwitchSection(TheSection); OutStreamer->SwitchSection(TheSection);
EmitAlignment(AlignLog, GV); EmitAlignment(AlignLog, GV);
OutStreamer.EmitLabel(MangSym); OutStreamer->EmitLabel(MangSym);
EmitGlobalConstant(GV->getInitializer()); EmitGlobalConstant(GV->getInitializer());
} }
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
// Emit the variable struct for the runtime. // Emit the variable struct for the runtime.
const MCSection *TLVSect const MCSection *TLVSect
= getObjFileLowering().getTLSExtraDataSection(); = getObjFileLowering().getTLSExtraDataSection();
OutStreamer.SwitchSection(TLVSect); OutStreamer->SwitchSection(TLVSect);
// Emit the linkage here. // Emit the linkage here.
EmitLinkage(GV, GVSym); EmitLinkage(GV, GVSym);
OutStreamer.EmitLabel(GVSym); OutStreamer->EmitLabel(GVSym);
// Three pointers in size: // Three pointers in size:
// - __tlv_bootstrap - used to make sure support exists // - __tlv_bootstrap - used to make sure support exists
// - spare pointer, used when mapped by the runtime // - spare pointer, used when mapped by the runtime
// - pointer to mangled symbol above with initializer // - pointer to mangled symbol above with initializer
unsigned PtrSize = DL->getPointerTypeSize(GV->getType()); unsigned PtrSize = DL->getPointerTypeSize(GV->getType());
OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"), OutStreamer->EmitSymbolValue(GetExternalSymbolSymbol("_tlv_bootstrap"),
PtrSize); PtrSize);
OutStreamer.EmitIntValue(0, PtrSize); OutStreamer->EmitIntValue(0, PtrSize);
OutStreamer.EmitSymbolValue(MangSym, PtrSize); OutStreamer->EmitSymbolValue(MangSym, PtrSize);
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
return; return;
} }
OutStreamer.SwitchSection(TheSection); OutStreamer->SwitchSection(TheSection);
EmitLinkage(GV, GVSym); EmitLinkage(GV, GVSym);
EmitAlignment(AlignLog, GV); EmitAlignment(AlignLog, GV);
OutStreamer.EmitLabel(GVSym); OutStreamer->EmitLabel(GVSym);
EmitGlobalConstant(GV->getInitializer()); EmitGlobalConstant(GV->getInitializer());
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective())
// .size foo, 42 // .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 /// EmitFunctionHeader - This method emits the header for the current
@ -526,7 +524,7 @@ void AsmPrinter::EmitFunctionHeader() {
// Print the 'header' of function. // Print the 'header' of function.
const Function *F = MF->getFunction(); const Function *F = MF->getFunction();
OutStreamer.SwitchSection( OutStreamer->SwitchSection(
getObjFileLowering().SectionForGlobal(F, *Mang, TM)); getObjFileLowering().SectionForGlobal(F, *Mang, TM));
EmitVisibility(CurrentFnSym, F->getVisibility()); EmitVisibility(CurrentFnSym, F->getVisibility());
@ -535,12 +533,12 @@ void AsmPrinter::EmitFunctionHeader() {
EmitAlignment(MF->getAlignment(), F); EmitAlignment(MF->getAlignment(), F);
if (MAI->hasDotTypeDotSizeDirective()) if (MAI->hasDotTypeDotSizeDirective())
OutStreamer.EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction); OutStreamer->EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
if (isVerbose()) { if (isVerbose()) {
F->printAsOperand(OutStreamer.GetCommentOS(), F->printAsOperand(OutStreamer->GetCommentOS(),
/*PrintType=*/false, F->getParent()); /*PrintType=*/false, F->getParent());
OutStreamer.GetCommentOS() << '\n'; OutStreamer->GetCommentOS() << '\n';
} }
// Emit the prefix data. // Emit the prefix data.
@ -557,18 +555,18 @@ void AsmPrinter::EmitFunctionHeader() {
std::vector<MCSymbol*> DeadBlockSyms; std::vector<MCSymbol*> DeadBlockSyms;
MMI->takeDeletedSymbolsForFunction(F, DeadBlockSyms); MMI->takeDeletedSymbolsForFunction(F, DeadBlockSyms);
for (unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) { for (unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) {
OutStreamer.AddComment("Address taken block that was later removed"); OutStreamer->AddComment("Address taken block that was later removed");
OutStreamer.EmitLabel(DeadBlockSyms[i]); OutStreamer->EmitLabel(DeadBlockSyms[i]);
} }
if (CurrentFnBegin) { if (CurrentFnBegin) {
if (MAI->useAssignmentForEHBegin()) { if (MAI->useAssignmentForEHBegin()) {
MCSymbol *CurPos = OutContext.CreateTempSymbol(); MCSymbol *CurPos = OutContext.CreateTempSymbol();
OutStreamer.EmitLabel(CurPos); OutStreamer->EmitLabel(CurPos);
OutStreamer.EmitAssignment(CurrentFnBegin, OutStreamer->EmitAssignment(CurrentFnBegin,
MCSymbolRefExpr::Create(CurPos, OutContext)); MCSymbolRefExpr::Create(CurPos, OutContext));
} else { } else {
OutStreamer.EmitLabel(CurrentFnBegin); OutStreamer->EmitLabel(CurrentFnBegin);
} }
} }
@ -597,7 +595,7 @@ void AsmPrinter::EmitFunctionEntryLabel() {
report_fatal_error("'" + Twine(CurrentFnSym->getName()) + report_fatal_error("'" + Twine(CurrentFnSym->getName()) +
"' label emitted multiple times to assembly file"); "' label emitted multiple times to assembly file");
return OutStreamer.EmitLabel(CurrentFnSym); return OutStreamer->EmitLabel(CurrentFnSym);
} }
/// emitComments - Pretty-print comments for instructions. /// emitComments - Pretty-print comments for instructions.
@ -640,9 +638,9 @@ static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS) {
/// that is an implicit def. /// that is an implicit def.
void AsmPrinter::emitImplicitDef(const MachineInstr *MI) const { void AsmPrinter::emitImplicitDef(const MachineInstr *MI) const {
unsigned RegNo = MI->getOperand(0).getReg(); unsigned RegNo = MI->getOperand(0).getReg();
OutStreamer.AddComment(Twine("implicit-def: ") + OutStreamer->AddComment(Twine("implicit-def: ") +
MMI->getContext().getRegisterInfo()->getName(RegNo)); MMI->getContext().getRegisterInfo()->getName(RegNo));
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
static void emitKill(const MachineInstr *MI, AsmPrinter &AP) { 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 += AP.MMI->getContext().getRegisterInfo()->getName(Op.getReg());
Str += (Op.isDef() ? "<def>" : "<kill>"); Str += (Op.isDef() ? "<def>" : "<kill>");
} }
AP.OutStreamer.AddComment(Str); AP.OutStreamer->AddComment(Str);
AP.OutStreamer.AddBlankLine(); AP.OutStreamer->AddBlankLine();
} }
/// emitDebugValueComment - This method handles the target-independent form /// 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. // Suppress offset, it is not meaningful here.
OS << "undef"; OS << "undef";
// NOTE: Want this comment at start of line, don't emit with AddComment. // 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; return true;
} }
if (Deref) if (Deref)
@ -734,7 +732,7 @@ static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
OS << '+' << Offset << ']'; OS << '+' << Offset << ']';
// NOTE: Want this comment at start of line, don't emit with AddComment. // 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; return true;
} }
@ -775,7 +773,7 @@ void AsmPrinter::emitFrameAlloc(const MachineInstr &MI) {
int FrameOffset = MI.getOperand(1).getImm(); int FrameOffset = MI.getOperand(1).getImm();
// Emit a symbol assignment. // Emit a symbol assignment.
OutStreamer.EmitAssignment(FrameAllocSym, OutStreamer->EmitAssignment(FrameAllocSym,
MCConstantExpr::Create(FrameOffset, OutContext)); MCConstantExpr::Create(FrameOffset, OutContext));
} }
@ -812,7 +810,7 @@ void AsmPrinter::EmitFunctionBody() {
} }
if (isVerbose()) if (isVerbose())
emitComments(MI, OutStreamer.GetCommentOS()); emitComments(MI, OutStreamer->GetCommentOS());
switch (MI.getOpcode()) { switch (MI.getOpcode()) {
case TargetOpcode::CFI_INSTRUCTION: case TargetOpcode::CFI_INSTRUCTION:
@ -825,7 +823,7 @@ void AsmPrinter::EmitFunctionBody() {
case TargetOpcode::EH_LABEL: case TargetOpcode::EH_LABEL:
case TargetOpcode::GC_LABEL: case TargetOpcode::GC_LABEL:
OutStreamer.EmitLabel(MI.getOperand(0).getMCSymbol()); OutStreamer->EmitLabel(MI.getOperand(0).getMCSymbol());
break; break;
case TargetOpcode::INLINEASM: case TargetOpcode::INLINEASM:
EmitInlineAsm(&MI); EmitInlineAsm(&MI);
@ -865,12 +863,12 @@ void AsmPrinter::EmitFunctionBody() {
if ((MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode)) { if ((MAI->hasSubsectionsViaSymbols() && !HasAnyRealCode)) {
MCInst Noop; MCInst Noop;
MF->getSubtarget().getInstrInfo()->getNoopForMachoTarget(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 // Targets can opt-out of emitting the noop here by leaving the opcode
// unspecified. // unspecified.
if (Noop.getOpcode()) if (Noop.getOpcode())
OutStreamer.EmitInstruction(Noop, getSubtargetInfo()); OutStreamer->EmitInstruction(Noop, getSubtargetInfo());
} }
const Function *F = MF->getFunction(); const Function *F = MF->getFunction();
@ -880,8 +878,8 @@ void AsmPrinter::EmitFunctionBody() {
MCSymbol *Sym = GetBlockAddressSymbol(&BB); MCSymbol *Sym = GetBlockAddressSymbol(&BB);
if (Sym->isDefined()) if (Sym->isDefined())
continue; continue;
OutStreamer.AddComment("Address of block that was removed by CodeGen"); OutStreamer->AddComment("Address of block that was removed by CodeGen");
OutStreamer.EmitLabel(Sym); OutStreamer->EmitLabel(Sym);
} }
// Emit target-specific gunk after the function body. // Emit target-specific gunk after the function body.
@ -891,7 +889,7 @@ void AsmPrinter::EmitFunctionBody() {
MAI->hasDotTypeDotSizeDirective()) { MAI->hasDotTypeDotSizeDirective()) {
// Create a symbol for the end of function. // Create a symbol for the end of function.
CurrentFnEnd = createTempSymbol("func_end"); CurrentFnEnd = createTempSymbol("func_end");
OutStreamer.EmitLabel(CurrentFnEnd); OutStreamer->EmitLabel(CurrentFnEnd);
} }
// If the target wants a .size directive for the size of the function, emit // If the target wants a .size directive for the size of the function, emit
@ -904,7 +902,7 @@ void AsmPrinter::EmitFunctionBody() {
MCSymbolRefExpr::Create(CurrentFnSymForSize, MCSymbolRefExpr::Create(CurrentFnSymForSize,
OutContext), OutContext),
OutContext); OutContext);
OutStreamer.EmitELFSize(CurrentFnSym, SizeExp); OutStreamer->EmitELFSize(CurrentFnSym, SizeExp);
} }
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
@ -922,7 +920,7 @@ void AsmPrinter::EmitFunctionBody() {
} }
MMI->EndFunction(); MMI->EndFunction();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
/// \brief Compute the number of Global Variables that uses a Constant. /// \brief Compute the number of Global Variables that uses a Constant.
@ -1040,7 +1038,7 @@ bool AsmPrinter::doFinalization(Module &M) {
SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags; SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags;
M.getModuleFlagsMetadata(ModuleFlags); M.getModuleFlagsMetadata(ModuleFlags);
if (!ModuleFlags.empty()) if (!ModuleFlags.empty())
TLOF.emitModuleFlags(OutStreamer, ModuleFlags, *Mang, TM); TLOF.emitModuleFlags(*OutStreamer, ModuleFlags, *Mang, TM);
Triple TT(TM.getTargetTriple()); Triple TT(TM.getTargetTriple());
if (TT.isOSBinFormatELF()) { if (TT.isOSBinFormatELF()) {
@ -1049,19 +1047,19 @@ bool AsmPrinter::doFinalization(Module &M) {
// Output stubs for external and common global variables. // Output stubs for external and common global variables.
MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList(); MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
if (!Stubs.empty()) { if (!Stubs.empty()) {
OutStreamer.SwitchSection(TLOF.getDataRelSection()); OutStreamer->SwitchSection(TLOF.getDataRelSection());
const DataLayout *DL = TM.getDataLayout(); const DataLayout *DL = TM.getDataLayout();
for (const auto &Stub : Stubs) { for (const auto &Stub : Stubs) {
OutStreamer.EmitLabel(Stub.first); OutStreamer->EmitLabel(Stub.first);
OutStreamer.EmitSymbolValue(Stub.second.getPointer(), OutStreamer->EmitSymbolValue(Stub.second.getPointer(),
DL->getPointerSize()); DL->getPointerSize());
} }
} }
} }
// Make sure we wrote out everything we need. // Make sure we wrote out everything we need.
OutStreamer.Flush(); OutStreamer->Flush();
// Finalize debug and EH information. // Finalize debug and EH information.
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
@ -1084,31 +1082,31 @@ bool AsmPrinter::doFinalization(Module &M) {
for (const auto &G : M.globals()) { for (const auto &G : M.globals()) {
if (!G.hasExternalWeakLinkage()) if (!G.hasExternalWeakLinkage())
continue; continue;
OutStreamer.EmitSymbolAttribute(getSymbol(&G), MCSA_WeakReference); OutStreamer->EmitSymbolAttribute(getSymbol(&G), MCSA_WeakReference);
} }
for (const auto &F : M) { for (const auto &F : M) {
if (!F.hasExternalWeakLinkage()) if (!F.hasExternalWeakLinkage())
continue; continue;
OutStreamer.EmitSymbolAttribute(getSymbol(&F), MCSA_WeakReference); OutStreamer->EmitSymbolAttribute(getSymbol(&F), MCSA_WeakReference);
} }
} }
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
for (const auto &Alias : M.aliases()) { for (const auto &Alias : M.aliases()) {
MCSymbol *Name = getSymbol(&Alias); MCSymbol *Name = getSymbol(&Alias);
if (Alias.hasExternalLinkage() || !MAI->getWeakRefDirective()) if (Alias.hasExternalLinkage() || !MAI->getWeakRefDirective())
OutStreamer.EmitSymbolAttribute(Name, MCSA_Global); OutStreamer->EmitSymbolAttribute(Name, MCSA_Global);
else if (Alias.hasWeakLinkage() || Alias.hasLinkOnceLinkage()) else if (Alias.hasWeakLinkage() || Alias.hasLinkOnceLinkage())
OutStreamer.EmitSymbolAttribute(Name, MCSA_WeakReference); OutStreamer->EmitSymbolAttribute(Name, MCSA_WeakReference);
else else
assert(Alias.hasLocalLinkage() && "Invalid alias linkage"); assert(Alias.hasLocalLinkage() && "Invalid alias linkage");
EmitVisibility(Name, Alias.getVisibility()); EmitVisibility(Name, Alias.getVisibility());
// Emit the directives as assignments aka .set: // Emit the directives as assignments aka .set:
OutStreamer.EmitAssignment(Name, lowerConstant(Alias.getAliasee())); OutStreamer->EmitAssignment(Name, lowerConstant(Alias.getAliasee()));
} }
GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>(); GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
@ -1125,14 +1123,14 @@ bool AsmPrinter::doFinalization(Module &M) {
const MCSection *ReadOnlySection = const MCSection *ReadOnlySection =
getObjFileLowering().getSectionForConstant(SectionKind::getReadOnly(), getObjFileLowering().getSectionForConstant(SectionKind::getReadOnly(),
/*C=*/nullptr); /*C=*/nullptr);
OutStreamer.SwitchSection(ReadOnlySection); OutStreamer->SwitchSection(ReadOnlySection);
MCSymbol *AddrSymbol = MCSymbol *AddrSymbol =
OutContext.GetOrCreateSymbol(StringRef("__morestack_addr")); OutContext.GetOrCreateSymbol(StringRef("__morestack_addr"));
OutStreamer.EmitLabel(AddrSymbol); OutStreamer->EmitLabel(AddrSymbol);
unsigned PtrSize = TM.getDataLayout()->getPointerSize(0); unsigned PtrSize = TM.getDataLayout()->getPointerSize(0);
OutStreamer.EmitSymbolValue(GetExternalSymbolSymbol("__morestack"), OutStreamer->EmitSymbolValue(GetExternalSymbolSymbol("__morestack"),
PtrSize); PtrSize);
} }
@ -1141,7 +1139,7 @@ bool AsmPrinter::doFinalization(Module &M) {
Function *InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline"); Function *InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline");
if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty()) if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty())
if (const MCSection *S = MAI->getNonexecutableStackSection(OutContext)) 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, // Allow the target to emit any magic that it wants at the end of the file,
// after everything else has gone out. // after everything else has gone out.
@ -1150,8 +1148,8 @@ bool AsmPrinter::doFinalization(Module &M) {
delete Mang; Mang = nullptr; delete Mang; Mang = nullptr;
MMI = nullptr; MMI = nullptr;
OutStreamer.Finish(); OutStreamer->Finish();
OutStreamer.reset(); OutStreamer->reset();
return false; return false;
} }
@ -1248,7 +1246,7 @@ void AsmPrinter::EmitConstantPool() {
continue; continue;
if (CurSection != CPSections[i].S) { if (CurSection != CPSections[i].S) {
OutStreamer.SwitchSection(CPSections[i].S); OutStreamer->SwitchSection(CPSections[i].S);
EmitAlignment(Log2_32(CPSections[i].Alignment)); EmitAlignment(Log2_32(CPSections[i].Alignment));
CurSection = CPSections[i].S; CurSection = CPSections[i].S;
Offset = 0; Offset = 0;
@ -1259,13 +1257,13 @@ void AsmPrinter::EmitConstantPool() {
// Emit inter-object padding for alignment. // Emit inter-object padding for alignment.
unsigned AlignMask = CPE.getAlignment() - 1; unsigned AlignMask = CPE.getAlignment() - 1;
unsigned NewOffset = (Offset + AlignMask) & ~AlignMask; unsigned NewOffset = (Offset + AlignMask) & ~AlignMask;
OutStreamer.EmitZeros(NewOffset - Offset); OutStreamer->EmitZeros(NewOffset - Offset);
Type *Ty = CPE.getType(); Type *Ty = CPE.getType();
Offset = NewOffset + Offset = NewOffset +
TM.getDataLayout()->getTypeAllocSize(Ty); TM.getDataLayout()->getTypeAllocSize(Ty);
OutStreamer.EmitLabel(Sym); OutStreamer->EmitLabel(Sym);
if (CPE.isMachineConstantPoolEntry()) if (CPE.isMachineConstantPoolEntry())
EmitMachineConstantPoolValue(CPE.Val.MachineCPVal); EmitMachineConstantPoolValue(CPE.Val.MachineCPVal);
else else
@ -1296,7 +1294,7 @@ void AsmPrinter::EmitJumpTableInfo() {
// Drop it in the readonly section. // Drop it in the readonly section.
const MCSection *ReadOnlySection = const MCSection *ReadOnlySection =
TLOF.getSectionForJumpTable(*F, *Mang, TM); TLOF.getSectionForJumpTable(*F, *Mang, TM);
OutStreamer.SwitchSection(ReadOnlySection); OutStreamer->SwitchSection(ReadOnlySection);
} }
EmitAlignment(Log2_32( EmitAlignment(Log2_32(
@ -1305,7 +1303,7 @@ void AsmPrinter::EmitJumpTableInfo() {
// Jump tables in code sections are marked with a data_region directive // Jump tables in code sections are marked with a data_region directive
// where that's supported. // where that's supported.
if (!JTInDiffSection) if (!JTInDiffSection)
OutStreamer.EmitDataRegion(MCDR_DataRegionJT32); OutStreamer->EmitDataRegion(MCDR_DataRegionJT32);
for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) { for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs; const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
@ -1328,8 +1326,9 @@ void AsmPrinter::EmitJumpTableInfo() {
// .set LJTSet, LBB32-base // .set LJTSet, LBB32-base
const MCExpr *LHS = const MCExpr *LHS =
MCSymbolRefExpr::Create(MBB->getSymbol(), OutContext); MCSymbolRefExpr::Create(MBB->getSymbol(), OutContext);
OutStreamer.EmitAssignment(GetJTSetSymbol(JTI, MBB->getNumber()), OutStreamer->EmitAssignment(GetJTSetSymbol(JTI, MBB->getNumber()),
MCBinaryExpr::CreateSub(LHS, Base, OutContext)); MCBinaryExpr::CreateSub(LHS, Base,
OutContext));
} }
} }
@ -1340,15 +1339,15 @@ void AsmPrinter::EmitJumpTableInfo() {
if (JTInDiffSection && DL->hasLinkerPrivateGlobalPrefix()) if (JTInDiffSection && DL->hasLinkerPrivateGlobalPrefix())
// FIXME: This doesn't have to have any specific name, just any randomly // FIXME: This doesn't have to have any specific name, just any randomly
// named and numbered 'l' label would work. Simplify GetJTISymbol. // 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) for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
EmitJumpTableEntry(MJTI, JTBBs[ii], JTI); EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
} }
if (!JTInDiffSection) if (!JTInDiffSection)
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
} }
/// EmitJumpTableEntry - Emit a jump table entry for the specified MBB to the /// 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.: // with a relocation as gp-relative, e.g.:
// .gprel32 LBB123 // .gprel32 LBB123
MCSymbol *MBBSym = MBB->getSymbol(); MCSymbol *MBBSym = MBB->getSymbol();
OutStreamer.EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext)); OutStreamer->EmitGPRel32Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
return; return;
} }
@ -1384,7 +1383,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
// with a relocation as gp-relative, e.g.: // with a relocation as gp-relative, e.g.:
// .gpdword LBB123 // .gpdword LBB123
MCSymbol *MBBSym = MBB->getSymbol(); MCSymbol *MBBSym = MBB->getSymbol();
OutStreamer.EmitGPRel64Value(MCSymbolRefExpr::Create(MBBSym, OutContext)); OutStreamer->EmitGPRel64Value(MCSymbolRefExpr::Create(MBBSym, OutContext));
return; return;
} }
@ -1413,7 +1412,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
unsigned EntrySize = unsigned EntrySize =
MJTI->getEntrySize(*TM.getDataLayout()); MJTI->getEntrySize(*TM.getDataLayout());
OutStreamer.EmitValue(Value, EntrySize); OutStreamer->EmitValue(Value, EntrySize);
} }
@ -1442,7 +1441,7 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
if (TM.getRelocationModel() == Reloc::Static && if (TM.getRelocationModel() == Reloc::Static &&
MAI->hasStaticCtorDtorReferenceInStaticMode()) { MAI->hasStaticCtorDtorReferenceInStaticMode()) {
StringRef Sym(".constructors_used"); StringRef Sym(".constructors_used");
OutStreamer.EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym), OutStreamer->EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym),
MCSA_Reference); MCSA_Reference);
} }
return true; return true;
@ -1454,7 +1453,7 @@ bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
if (TM.getRelocationModel() == Reloc::Static && if (TM.getRelocationModel() == Reloc::Static &&
MAI->hasStaticCtorDtorReferenceInStaticMode()) { MAI->hasStaticCtorDtorReferenceInStaticMode()) {
StringRef Sym(".destructors_used"); StringRef Sym(".destructors_used");
OutStreamer.EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym), OutStreamer->EmitSymbolAttribute(OutContext.GetOrCreateSymbol(Sym),
MCSA_Reference); MCSA_Reference);
} }
return true; return true;
@ -1472,7 +1471,7 @@ void AsmPrinter::EmitLLVMUsedList(const ConstantArray *InitList) {
const GlobalValue *GV = const GlobalValue *GV =
dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts()); dyn_cast<GlobalValue>(InitList->getOperand(i)->stripPointerCasts());
if (GV) 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 = const MCSection *OutputSection =
(isCtor ? Obj.getStaticCtorSection(S.Priority, KeySym) (isCtor ? Obj.getStaticCtorSection(S.Priority, KeySym)
: Obj.getStaticDtorSection(S.Priority, KeySym)); : Obj.getStaticDtorSection(S.Priority, KeySym));
OutStreamer.SwitchSection(OutputSection); OutStreamer->SwitchSection(OutputSection);
if (OutStreamer.getCurrentSection() != OutStreamer.getPreviousSection()) if (OutStreamer->getCurrentSection() != OutStreamer->getPreviousSection())
EmitAlignment(Align); EmitAlignment(Align);
EmitXXStructor(S.Func); EmitXXStructor(S.Func);
} }
@ -1558,7 +1557,7 @@ void AsmPrinter::EmitModuleIdents(Module &M) {
assert(N->getNumOperands() == 1 && assert(N->getNumOperands() == 1 &&
"llvm.ident metadata entry can have only one operand"); "llvm.ident metadata entry can have only one operand");
const MDString *S = cast<MDString>(N->getOperand(0)); const MDString *S = cast<MDString>(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. /// EmitInt8 - Emit a byte directive and value.
/// ///
void AsmPrinter::EmitInt8(int Value) const { void AsmPrinter::EmitInt8(int Value) const {
OutStreamer.EmitIntValue(Value, 1); OutStreamer->EmitIntValue(Value, 1);
} }
/// EmitInt16 - Emit a short directive and value. /// EmitInt16 - Emit a short directive and value.
/// ///
void AsmPrinter::EmitInt16(int Value) const { void AsmPrinter::EmitInt16(int Value) const {
OutStreamer.EmitIntValue(Value, 2); OutStreamer->EmitIntValue(Value, 2);
} }
/// EmitInt32 - Emit a long directive and value. /// EmitInt32 - Emit a long directive and value.
/// ///
void AsmPrinter::EmitInt32(int Value) const { 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 /// 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); OutContext);
if (!MAI->doesSetDirectiveSuppressesReloc()) { if (!MAI->doesSetDirectiveSuppressesReloc()) {
OutStreamer.EmitValue(Diff, Size); OutStreamer->EmitValue(Diff, Size);
return; return;
} }
// Otherwise, emit with .set (aka assignment). // Otherwise, emit with .set (aka assignment).
MCSymbol *SetLabel = createTempSymbol("set"); MCSymbol *SetLabel = createTempSymbol("set");
OutStreamer.EmitAssignment(SetLabel, Diff); OutStreamer->EmitAssignment(SetLabel, Diff);
OutStreamer.EmitSymbolValue(SetLabel, Size); OutStreamer->EmitSymbolValue(SetLabel, Size);
} }
/// EmitLabelPlusOffset - Emit something like ".long Label+Offset" /// EmitLabelPlusOffset - Emit something like ".long Label+Offset"
@ -1614,7 +1613,7 @@ void AsmPrinter::EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
unsigned Size, unsigned Size,
bool IsSectionRelative) const { bool IsSectionRelative) const {
if (MAI->needsDwarfSectionOffsetDirective() && IsSectionRelative) { if (MAI->needsDwarfSectionOffsetDirective() && IsSectionRelative) {
OutStreamer.EmitCOFFSecRel32(Label); OutStreamer->EmitCOFFSecRel32(Label);
return; return;
} }
@ -1624,7 +1623,7 @@ void AsmPrinter::EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset,
Expr = MCBinaryExpr::CreateAdd( Expr = MCBinaryExpr::CreateAdd(
Expr, MCConstantExpr::Create(Offset, OutContext), OutContext); 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<unsigned>(std::numeric_limits<unsigned>::digits) && static_cast<unsigned>(std::numeric_limits<unsigned>::digits) &&
"undefined behavior"); "undefined behavior");
if (getCurrentSection()->getKind().isText()) if (getCurrentSection()->getKind().isText())
OutStreamer.EmitCodeAlignment(1u << NumBits); OutStreamer->EmitCodeAlignment(1u << NumBits);
else else
OutStreamer.EmitValueToAlignment(1u << NumBits); OutStreamer->EmitValueToAlignment(1u << NumBits);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -1860,21 +1859,21 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
CDS->getType()); CDS->getType());
// Don't emit a 1-byte object as a .fill. // Don't emit a 1-byte object as a .fill.
if (Bytes > 1) 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 this can be emitted with .ascii/.asciz, emit it as such.
if (CDS->isString()) if (CDS->isString())
return AP.OutStreamer.EmitBytes(CDS->getAsString()); return AP.OutStreamer->EmitBytes(CDS->getAsString());
// Otherwise, emit the values in successive locations. // Otherwise, emit the values in successive locations.
unsigned ElementByteSize = CDS->getElementByteSize(); unsigned ElementByteSize = CDS->getElementByteSize();
if (isa<IntegerType>(CDS->getElementType())) { if (isa<IntegerType>(CDS->getElementType())) {
for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) { for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
if (AP.isVerbose()) if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << format("0x%" PRIx64 "\n", AP.OutStreamer->GetCommentOS() << format("0x%" PRIx64 "\n",
CDS->getElementAsInteger(i)); CDS->getElementAsInteger(i));
AP.OutStreamer.EmitIntValue(CDS->getElementAsInteger(i), AP.OutStreamer->EmitIntValue(CDS->getElementAsInteger(i),
ElementByteSize); ElementByteSize);
} }
} else if (ElementByteSize == 4) { } else if (ElementByteSize == 4) {
@ -1889,8 +1888,8 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
F = CDS->getElementAsFloat(i); F = CDS->getElementAsFloat(i);
if (AP.isVerbose()) if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << "float " << F << '\n'; AP.OutStreamer->GetCommentOS() << "float " << F << '\n';
AP.OutStreamer.EmitIntValue(I, 4); AP.OutStreamer->EmitIntValue(I, 4);
} }
} else { } else {
assert(CDS->getElementType()->isDoubleTy()); assert(CDS->getElementType()->isDoubleTy());
@ -1902,8 +1901,8 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
F = CDS->getElementAsDouble(i); F = CDS->getElementAsDouble(i);
if (AP.isVerbose()) if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << "double " << F << '\n'; AP.OutStreamer->GetCommentOS() << "double " << F << '\n';
AP.OutStreamer.EmitIntValue(I, 8); AP.OutStreamer->EmitIntValue(I, 8);
} }
} }
@ -1912,7 +1911,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
unsigned EmittedSize = DL.getTypeAllocSize(CDS->getType()->getElementType()) * unsigned EmittedSize = DL.getTypeAllocSize(CDS->getType()->getElementType()) *
CDS->getNumElements(); CDS->getNumElements();
if (unsigned Padding = Size - EmittedSize) 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) { if (Value != -1) {
uint64_t Bytes = DL.getTypeAllocSize(CA->getType()); uint64_t Bytes = DL.getTypeAllocSize(CA->getType());
AP.OutStreamer.EmitFill(Bytes, Value); AP.OutStreamer->EmitFill(Bytes, Value);
} }
else { else {
for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i) { 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()) * unsigned EmittedSize = DL.getTypeAllocSize(CV->getType()->getElementType()) *
CV->getType()->getNumElements(); CV->getType()->getNumElements();
if (unsigned Padding = Size - EmittedSize) if (unsigned Padding = Size - EmittedSize)
AP.OutStreamer.EmitZeros(Padding); AP.OutStreamer->EmitZeros(Padding);
} }
static void emitGlobalConstantStruct(const ConstantStruct *CS, AsmPrinter &AP, 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 // 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 // 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. // 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() && assert(SizeSoFar == Layout->getSizeInBytes() &&
"Layout of constant struct may be incorrect!"); "Layout of constant struct may be incorrect!");
@ -1985,10 +1984,10 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) {
CFP->getValueAPF().toString(StrVal); CFP->getValueAPF().toString(StrVal);
if (CFP->getType()) if (CFP->getType())
CFP->getType()->print(AP.OutStreamer.GetCommentOS()); CFP->getType()->print(AP.OutStreamer->GetCommentOS());
else else
AP.OutStreamer.GetCommentOS() << "Printing <null> Type"; AP.OutStreamer->GetCommentOS() << "Printing <null> Type";
AP.OutStreamer.GetCommentOS() << ' ' << StrVal << '\n'; AP.OutStreamer->GetCommentOS() << ' ' << StrVal << '\n';
} }
// Now iterate through the APInt chunks, emitting them in endian-correct // Now iterate through the APInt chunks, emitting them in endian-correct
@ -2005,22 +2004,22 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) {
int Chunk = API.getNumWords() - 1; int Chunk = API.getNumWords() - 1;
if (TrailingBytes) if (TrailingBytes)
AP.OutStreamer.EmitIntValue(p[Chunk--], TrailingBytes); AP.OutStreamer->EmitIntValue(p[Chunk--], TrailingBytes);
for (; Chunk >= 0; --Chunk) for (; Chunk >= 0; --Chunk)
AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t)); AP.OutStreamer->EmitIntValue(p[Chunk], sizeof(uint64_t));
} else { } else {
unsigned Chunk; unsigned Chunk;
for (Chunk = 0; Chunk < NumBytes / sizeof(uint64_t); ++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) if (TrailingBytes)
AP.OutStreamer.EmitIntValue(p[Chunk], TrailingBytes); AP.OutStreamer->EmitIntValue(p[Chunk], TrailingBytes);
} }
// Emit the tail padding for the long double. // Emit the tail padding for the long double.
const DataLayout &DL = *AP.TM.getDataLayout(); const DataLayout &DL = *AP.TM.getDataLayout();
AP.OutStreamer.EmitZeros(DL.getTypeAllocSize(CFP->getType()) - AP.OutStreamer->EmitZeros(DL.getTypeAllocSize(CFP->getType()) -
DL.getTypeStoreSize(CFP->getType())); DL.getTypeStoreSize(CFP->getType()));
} }
@ -2064,7 +2063,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) {
const uint64_t *RawData = Realigned.getRawData(); const uint64_t *RawData = Realigned.getRawData();
for (unsigned i = 0, e = BitWidth / 64; i != e; ++i) { for (unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
uint64_t Val = DL->isBigEndian() ? RawData[e - i - 1] : RawData[i]; uint64_t Val = DL->isBigEndian() ? RawData[e - i - 1] : RawData[i];
AP.OutStreamer.EmitIntValue(Val, 8); AP.OutStreamer->EmitIntValue(Val, 8);
} }
if (ExtraBitsSize) { if (ExtraBitsSize) {
@ -2077,7 +2076,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) {
assert(Size && Size * 8 >= ExtraBitsSize && assert(Size && Size * 8 >= ExtraBitsSize &&
(ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize))) (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
== ExtraBits && "Directive too small for extra bits."); == 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<GlobalValue>(GV->getOperand(0)); const GlobalValue *FinalGV = dyn_cast<GlobalValue>(GV->getOperand(0));
const MCSymbol *FinalSym = AP.getSymbol(FinalGV); const MCSymbol *FinalSym = AP.getSymbol(FinalGV);
*ME = AP.getObjFileLowering().getIndirectSymViaGOTPCRel( *ME = AP.getObjFileLowering().getIndirectSymViaGOTPCRel(
FinalSym, MV, Offset, AP.MMI, AP.OutStreamer); FinalSym, MV, Offset, AP.MMI, *AP.OutStreamer);
// Update GOT equivalent usage information // Update GOT equivalent usage information
--NumUses; --NumUses;
@ -2180,7 +2179,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP,
BaseCV = dyn_cast<Constant>(CV->user_back()); BaseCV = dyn_cast<Constant>(CV->user_back());
if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV)) if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
return AP.OutStreamer.EmitZeros(Size); return AP.OutStreamer->EmitZeros(Size);
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
switch (Size) { switch (Size) {
@ -2189,9 +2188,9 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP,
case 4: case 4:
case 8: case 8:
if (AP.isVerbose()) if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << format("0x%" PRIx64 "\n", AP.OutStreamer->GetCommentOS() << format("0x%" PRIx64 "\n",
CI->getZExtValue()); CI->getZExtValue());
AP.OutStreamer.EmitIntValue(CI->getZExtValue(), Size); AP.OutStreamer->EmitIntValue(CI->getZExtValue(), Size);
return; return;
default: default:
emitGlobalConstantLargeInt(CI, AP); emitGlobalConstantLargeInt(CI, AP);
@ -2203,7 +2202,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP,
return emitGlobalConstantFP(CFP, AP); return emitGlobalConstantFP(CFP, AP);
if (isa<ConstantPointerNull>(CV)) { if (isa<ConstantPointerNull>(CV)) {
AP.OutStreamer.EmitIntValue(0, Size); AP.OutStreamer->EmitIntValue(0, Size);
return; return;
} }
@ -2245,7 +2244,7 @@ static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP,
if (AP.getObjFileLowering().supportIndirectSymViaGOTPCRel()) if (AP.getObjFileLowering().supportIndirectSymViaGOTPCRel())
handleIndirectSymViaGOTPCRel(AP, &ME, BaseCV, Offset); 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. /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
@ -2257,7 +2256,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
else if (MAI->hasSubsectionsViaSymbols()) { else if (MAI->hasSubsectionsViaSymbols()) {
// If the global has zero size, emit a single byte so that two labels don't // If the global has zero size, emit a single byte so that two labels don't
// look like they are at the same location. // look like they are at the same location.
OutStreamer.EmitIntValue(0, 1); OutStreamer->EmitIntValue(0, 1);
} }
} }
@ -2367,7 +2366,7 @@ static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB,
// If this block is not a loop header, just print out what is the loop header // If this block is not a loop header, just print out what is the loop header
// and return. // and return.
if (Header != &MBB) { if (Header != &MBB) {
AP.OutStreamer.AddComment(" in Loop: Header=BB" + AP.OutStreamer->AddComment(" in Loop: Header=BB" +
Twine(AP.getFunctionNumber())+"_" + Twine(AP.getFunctionNumber())+"_" +
Twine(Loop->getHeader()->getNumber())+ Twine(Loop->getHeader()->getNumber())+
" Depth="+Twine(Loop->getLoopDepth())); " Depth="+Twine(Loop->getLoopDepth()));
@ -2376,7 +2375,7 @@ static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB,
// Otherwise, it is a loop header. Print out information about child and // Otherwise, it is a loop header. Print out information about child and
// parent loops. // parent loops.
raw_ostream &OS = AP.OutStreamer.GetCommentOS(); raw_ostream &OS = AP.OutStreamer->GetCommentOS();
PrintParentLoopComment(OS, Loop->getParentLoop(), AP.getFunctionNumber()); PrintParentLoopComment(OS, Loop->getParentLoop(), AP.getFunctionNumber());
@ -2407,18 +2406,18 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock &MBB) const {
if (MBB.hasAddressTaken()) { if (MBB.hasAddressTaken()) {
const BasicBlock *BB = MBB.getBasicBlock(); const BasicBlock *BB = MBB.getBasicBlock();
if (isVerbose()) if (isVerbose())
OutStreamer.AddComment("Block address taken"); OutStreamer->AddComment("Block address taken");
std::vector<MCSymbol*> Symbols = MMI->getAddrLabelSymbolToEmit(BB); std::vector<MCSymbol*> Symbols = MMI->getAddrLabelSymbolToEmit(BB);
for (auto *Sym : Symbols) for (auto *Sym : Symbols)
OutStreamer.EmitLabel(Sym); OutStreamer->EmitLabel(Sym);
} }
// Print some verbose block comments. // Print some verbose block comments.
if (isVerbose()) { if (isVerbose()) {
if (const BasicBlock *BB = MBB.getBasicBlock()) if (const BasicBlock *BB = MBB.getBasicBlock())
if (BB->hasName()) if (BB->hasName())
OutStreamer.AddComment("%" + BB->getName()); OutStreamer->AddComment("%" + BB->getName());
emitBasicBlockLoopComments(MBB, LI, *this); emitBasicBlockLoopComments(MBB, LI, *this);
} }
@ -2426,10 +2425,10 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock &MBB) const {
if (MBB.pred_empty() || isBlockOnlyReachableByFallthrough(&MBB)) { if (MBB.pred_empty() || isBlockOnlyReachableByFallthrough(&MBB)) {
if (isVerbose()) { if (isVerbose()) {
// NOTE: Want this comment at start of line, don't emit with AddComment. // 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 { } else {
OutStreamer.EmitLabel(MBB.getSymbol()); OutStreamer->EmitLabel(MBB.getSymbol());
} }
} }
@ -2451,7 +2450,7 @@ void AsmPrinter::EmitVisibility(MCSymbol *Sym, unsigned Visibility,
} }
if (Attr != MCSA_Invalid) if (Attr != MCSA_Invalid)
OutStreamer.EmitSymbolAttribute(Sym, Attr); OutStreamer->EmitSymbolAttribute(Sym, Attr);
} }
/// isBlockOnlyReachableByFallthough - Return true if the basic block has /// isBlockOnlyReachableByFallthough - Return true if the basic block has

View File

@ -42,30 +42,30 @@ using namespace llvm;
/// EmitSLEB128 - emit the specified signed leb128 value. /// EmitSLEB128 - emit the specified signed leb128 value.
void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const { void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const {
if (isVerbose() && Desc) if (isVerbose() && Desc)
OutStreamer.AddComment(Desc); OutStreamer->AddComment(Desc);
OutStreamer.EmitSLEB128IntValue(Value); OutStreamer->EmitSLEB128IntValue(Value);
} }
/// EmitULEB128 - emit the specified signed leb128 value. /// EmitULEB128 - emit the specified signed leb128 value.
void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc, void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc,
unsigned PadTo) const { unsigned PadTo) const {
if (isVerbose() && Desc) 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. /// EmitCFAByte - Emit a .byte 42 directive for a DW_CFA_xxx value.
void AsmPrinter::EmitCFAByte(unsigned Val) const { void AsmPrinter::EmitCFAByte(unsigned Val) const {
if (isVerbose()) { if (isVerbose()) {
if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset + 64) if (Val >= dwarf::DW_CFA_offset && Val < dwarf::DW_CFA_offset + 64)
OutStreamer.AddComment("DW_CFA_offset + Reg (" + OutStreamer->AddComment("DW_CFA_offset + Reg (" +
Twine(Val - dwarf::DW_CFA_offset) + ")"); Twine(Val - dwarf::DW_CFA_offset) + ")");
else 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) { 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 { void AsmPrinter::EmitEncodingByte(unsigned Val, const char *Desc) const {
if (isVerbose()) { if (isVerbose()) {
if (Desc) if (Desc)
OutStreamer.AddComment(Twine(Desc) + " Encoding = " + OutStreamer->AddComment(Twine(Desc) + " Encoding = " +
Twine(DecodeDWARFEncoding(Val))); Twine(DecodeDWARFEncoding(Val)));
else 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. /// GetSizeOfEncodedValue - Return the size of the encoding in bytes.
@ -150,10 +150,11 @@ void AsmPrinter::EmitTTypeReference(const GlobalValue *GV,
const TargetLoweringObjectFile &TLOF = getObjFileLowering(); const TargetLoweringObjectFile &TLOF = getObjFileLowering();
const MCExpr *Exp = const MCExpr *Exp =
TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI, OutStreamer); TLOF.getTTypeGlobalReference(GV, Encoding, *Mang, TM, MMI,
OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding)); *OutStreamer);
OutStreamer->EmitValue(Exp, GetSizeOfEncodedValue(Encoding));
} else } else
OutStreamer.EmitIntValue(0, GetSizeOfEncodedValue(Encoding)); OutStreamer->EmitIntValue(0, GetSizeOfEncodedValue(Encoding));
} }
/// EmitSectionOffset - Emit the 4-byte offset of Label from the start of its /// 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 { void AsmPrinter::emitSectionOffset(const MCSymbol *Label) const {
// On COFF targets, we have to emit the special .secrel32 directive. // On COFF targets, we have to emit the special .secrel32 directive.
if (MAI->needsDwarfSectionOffsetDirective()) { if (MAI->needsDwarfSectionOffsetDirective()) {
OutStreamer.EmitCOFFSecRel32(Label); OutStreamer->EmitCOFFSecRel32(Label);
return; return;
} }
// If the format uses relocations with dwarf, refer to the symbol directly. // If the format uses relocations with dwarf, refer to the symbol directly.
if (MAI->doesDwarfUseRelocationsAcrossSections()) { if (MAI->doesDwarfUseRelocationsAcrossSections()) {
OutStreamer.EmitSymbolValue(Label, 4); OutStreamer->EmitSymbolValue(Label, 4);
return; return;
} }
@ -219,25 +220,25 @@ void AsmPrinter::emitCFIInstruction(const MCCFIInstruction &Inst) const {
default: default:
llvm_unreachable("Unexpected instruction"); llvm_unreachable("Unexpected instruction");
case MCCFIInstruction::OpDefCfaOffset: case MCCFIInstruction::OpDefCfaOffset:
OutStreamer.EmitCFIDefCfaOffset(Inst.getOffset()); OutStreamer->EmitCFIDefCfaOffset(Inst.getOffset());
break; break;
case MCCFIInstruction::OpDefCfa: case MCCFIInstruction::OpDefCfa:
OutStreamer.EmitCFIDefCfa(Inst.getRegister(), Inst.getOffset()); OutStreamer->EmitCFIDefCfa(Inst.getRegister(), Inst.getOffset());
break; break;
case MCCFIInstruction::OpDefCfaRegister: case MCCFIInstruction::OpDefCfaRegister:
OutStreamer.EmitCFIDefCfaRegister(Inst.getRegister()); OutStreamer->EmitCFIDefCfaRegister(Inst.getRegister());
break; break;
case MCCFIInstruction::OpOffset: case MCCFIInstruction::OpOffset:
OutStreamer.EmitCFIOffset(Inst.getRegister(), Inst.getOffset()); OutStreamer->EmitCFIOffset(Inst.getRegister(), Inst.getOffset());
break; break;
case MCCFIInstruction::OpRegister: case MCCFIInstruction::OpRegister:
OutStreamer.EmitCFIRegister(Inst.getRegister(), Inst.getRegister2()); OutStreamer->EmitCFIRegister(Inst.getRegister(), Inst.getRegister2());
break; break;
case MCCFIInstruction::OpWindowSave: case MCCFIInstruction::OpWindowSave:
OutStreamer.EmitCFIWindowSave(); OutStreamer->EmitCFIWindowSave();
break; break;
case MCCFIInstruction::OpSameValue: case MCCFIInstruction::OpSameValue:
OutStreamer.EmitCFISameValue(Inst.getRegister()); OutStreamer->EmitCFISameValue(Inst.getRegister());
break; break;
} }
} }
@ -248,7 +249,7 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
// Emit the code (index) for the abbreviation. // Emit the code (index) for the abbreviation.
if (isVerbose()) if (isVerbose())
OutStreamer.AddComment("Abbrev [" + Twine(Abbrev.getNumber()) + OutStreamer->AddComment("Abbrev [" + Twine(Abbrev.getNumber()) +
"] 0x" + Twine::utohexstr(Die.getOffset()) + "] 0x" + Twine::utohexstr(Die.getOffset()) +
":0x" + Twine::utohexstr(Die.getSize()) + " " + ":0x" + Twine::utohexstr(Die.getSize()) + " " +
dwarf::TagString(Abbrev.getTag())); dwarf::TagString(Abbrev.getTag()));
@ -264,9 +265,9 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
assert(Form && "Too many attributes for DIE (check abbreviation)"); assert(Form && "Too many attributes for DIE (check abbreviation)");
if (isVerbose()) { if (isVerbose()) {
OutStreamer.AddComment(dwarf::AttributeString(Attr)); OutStreamer->AddComment(dwarf::AttributeString(Attr));
if (Attr == dwarf::DW_AT_accessibility) if (Attr == dwarf::DW_AT_accessibility)
OutStreamer.AddComment(dwarf::AccessibilityString( OutStreamer->AddComment(dwarf::AccessibilityString(
cast<DIEInteger>(Values[i])->getValue())); cast<DIEInteger>(Values[i])->getValue()));
} }
@ -279,7 +280,7 @@ void AsmPrinter::emitDwarfDIE(const DIE &Die) const {
for (auto &Child : Die.getChildren()) for (auto &Child : Die.getChildren())
emitDwarfDIE(*Child); emitDwarfDIE(*Child);
OutStreamer.AddComment("End Of Children Mark"); OutStreamer->AddComment("End Of Children Mark");
EmitInt8(0); EmitInt8(0);
} }
} }

View File

@ -91,9 +91,9 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
const MCAsmInfo *MCAI = TM.getMCAsmInfo(); const MCAsmInfo *MCAI = TM.getMCAsmInfo();
assert(MCAI && "No MCAsmInfo"); assert(MCAI && "No MCAsmInfo");
if (!MCAI->useIntegratedAssembler() && if (!MCAI->useIntegratedAssembler() &&
!OutStreamer.isIntegratedAssemblerRequired()) { !OutStreamer->isIntegratedAssemblerRequired()) {
emitInlineAsmStart(); emitInlineAsmStart();
OutStreamer.EmitRawText(Str); OutStreamer->EmitRawText(Str);
emitInlineAsmEnd(STI, nullptr); emitInlineAsmEnd(STI, nullptr);
return; return;
} }
@ -124,7 +124,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MCSubtargetInfo &STI,
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc()); SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
std::unique_ptr<MCAsmParser> Parser( std::unique_ptr<MCAsmParser> Parser(
createMCAsmParser(SrcMgr, OutContext, OutStreamer, *MAI)); createMCAsmParser(SrcMgr, OutContext, *OutStreamer, *MAI));
// Create a temporary copy of the original STI because the parser may modify // 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 // 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. // If this asmstr is empty, just print the #APP/#NOAPP markers.
// These are useful to see where empty asm's wound up. // These are useful to see where empty asm's wound up.
if (AsmStr[0] == 0) { if (AsmStr[0] == 0) {
OutStreamer.emitRawComment(MAI->getInlineAsmStart()); OutStreamer->emitRawComment(MAI->getInlineAsmStart());
OutStreamer.emitRawComment(MAI->getInlineAsmEnd()); OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
return; return;
} }
// Emit the #APP start marker. This has to happen even if verbose-asm isn't // Emit the #APP start marker. This has to happen even if verbose-asm isn't
// enabled, so we use emitRawComment. // 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 // Get the !srcloc metadata node if we have it, and decode the loc cookie from
// it. // 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 // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't
// enabled, so we use emitRawComment. // enabled, so we use emitRawComment.
OutStreamer.emitRawComment(MAI->getInlineAsmEnd()); OutStreamer->emitRawComment(MAI->getInlineAsmEnd());
} }

View File

@ -40,15 +40,15 @@ private:
public: public:
APByteStreamer(AsmPrinter &Asm) : AP(Asm) {} APByteStreamer(AsmPrinter &Asm) : AP(Asm) {}
void EmitInt8(uint8_t Byte, const Twine &Comment) override { void EmitInt8(uint8_t Byte, const Twine &Comment) override {
AP.OutStreamer.AddComment(Comment); AP.OutStreamer->AddComment(Comment);
AP.EmitInt8(Byte); AP.EmitInt8(Byte);
} }
void EmitSLEB128(uint64_t DWord, const Twine &Comment) override { void EmitSLEB128(uint64_t DWord, const Twine &Comment) override {
AP.OutStreamer.AddComment(Comment); AP.OutStreamer->AddComment(Comment);
AP.EmitSLEB128(DWord); AP.EmitSLEB128(DWord);
} }
void EmitULEB128(uint64_t DWord, const Twine &Comment) override { void EmitULEB128(uint64_t DWord, const Twine &Comment) override {
AP.OutStreamer.AddComment(Comment); AP.OutStreamer->AddComment(Comment);
AP.EmitULEB128(DWord); AP.EmitULEB128(DWord);
} }
}; };

View File

@ -211,7 +211,7 @@ void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
case dwarf::DW_FORM_flag_present: case dwarf::DW_FORM_flag_present:
// Emit something to keep the lines and comments in sync. // Emit something to keep the lines and comments in sync.
// FIXME: Is there a better way to do this? // FIXME: Is there a better way to do this?
Asm->OutStreamer.AddBlankLine(); Asm->OutStreamer->AddBlankLine();
return; return;
case dwarf::DW_FORM_flag: // Fall thru case dwarf::DW_FORM_flag: // Fall thru
case dwarf::DW_FORM_ref1: // Fall thru case dwarf::DW_FORM_ref1: // Fall thru
@ -236,7 +236,7 @@ void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
break; break;
default: llvm_unreachable("DIE Value form not supported yet"); 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. /// 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_sdata: return getSLEB128Size(Integer);
case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize(); case dwarf::DW_FORM_addr: return AP->getDataLayout().getPointerSize();
case dwarf::DW_FORM_ref_addr: case dwarf::DW_FORM_ref_addr:
if (AP->OutStreamer.getContext().getDwarfVersion() == 2) if (AP->OutStreamer->getContext().getDwarfVersion() == 2)
return AP->getDataLayout().getPointerSize(); return AP->getDataLayout().getPointerSize();
return sizeof(int32_t); return sizeof(int32_t);
default: llvm_unreachable("DIE Value form not supported yet"); default: llvm_unreachable("DIE Value form not supported yet");
@ -283,7 +283,7 @@ void DIEInteger::print(raw_ostream &O) const {
/// EmitValue - Emit expression value. /// EmitValue - Emit expression value.
/// ///
void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const { 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. /// 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, AP->EmitLabelPlusOffset(CU->getSectionSym(), Addr,
DIEEntry::getRefAddrSize(AP)); DIEEntry::getRefAddrSize(AP));
else else
AP->OutStreamer.EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP)); AP->OutStreamer->EmitIntValue(Addr, DIEEntry::getRefAddrSize(AP));
} else } else
AP->EmitInt32(Entry.getOffset()); 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 { void DIETypeSignature::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
assert(Form == dwarf::DW_FORM_ref_sig8); assert(Form == dwarf::DW_FORM_ref_sig8);
Asm->OutStreamer.EmitIntValue(Unit.getTypeSignature(), 8); Asm->OutStreamer->EmitIntValue(Unit.getTypeSignature(), 8);
} }
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -111,27 +111,27 @@ void DwarfAccelTable::FinalizeTable(AsmPrinter *Asm, StringRef Prefix) {
// Emits the header for the table via the AsmPrinter. // Emits the header for the table via the AsmPrinter.
void DwarfAccelTable::EmitHeader(AsmPrinter *Asm) { void DwarfAccelTable::EmitHeader(AsmPrinter *Asm) {
Asm->OutStreamer.AddComment("Header Magic"); Asm->OutStreamer->AddComment("Header Magic");
Asm->EmitInt32(Header.magic); Asm->EmitInt32(Header.magic);
Asm->OutStreamer.AddComment("Header Version"); Asm->OutStreamer->AddComment("Header Version");
Asm->EmitInt16(Header.version); Asm->EmitInt16(Header.version);
Asm->OutStreamer.AddComment("Header Hash Function"); Asm->OutStreamer->AddComment("Header Hash Function");
Asm->EmitInt16(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->EmitInt32(Header.bucket_count);
Asm->OutStreamer.AddComment("Header Hash Count"); Asm->OutStreamer->AddComment("Header Hash Count");
Asm->EmitInt32(Header.hashes_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->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->EmitInt32(HeaderData.die_offset_base);
Asm->OutStreamer.AddComment("HeaderData Atom Count"); Asm->OutStreamer->AddComment("HeaderData Atom Count");
Asm->EmitInt32(HeaderData.Atoms.size()); Asm->EmitInt32(HeaderData.Atoms.size());
for (size_t i = 0; i < HeaderData.Atoms.size(); i++) { for (size_t i = 0; i < HeaderData.Atoms.size(); i++) {
Atom A = HeaderData.Atoms[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->EmitInt16(A.type);
Asm->OutStreamer.AddComment(dwarf::FormEncodingString(A.form)); Asm->OutStreamer->AddComment(dwarf::FormEncodingString(A.form));
Asm->EmitInt16(A.form); Asm->EmitInt16(A.form);
} }
} }
@ -141,7 +141,7 @@ void DwarfAccelTable::EmitHeader(AsmPrinter *Asm) {
void DwarfAccelTable::EmitBuckets(AsmPrinter *Asm) { void DwarfAccelTable::EmitBuckets(AsmPrinter *Asm) {
unsigned index = 0; unsigned index = 0;
for (size_t i = 0, e = Buckets.size(); i < e; ++i) { 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) if (Buckets[i].size() != 0)
Asm->EmitInt32(index); Asm->EmitInt32(index);
else else
@ -169,7 +169,7 @@ void DwarfAccelTable::EmitHashes(AsmPrinter *Asm) {
uint32_t HashValue = (*HI)->HashValue; uint32_t HashValue = (*HI)->HashValue;
if (PrevHash == HashValue) if (PrevHash == HashValue)
continue; continue;
Asm->OutStreamer.AddComment("Hash in Bucket " + Twine(i)); Asm->OutStreamer->AddComment("Hash in Bucket " + Twine(i));
Asm->EmitInt32(HashValue); Asm->EmitInt32(HashValue);
PrevHash = HashValue; PrevHash = HashValue;
} }
@ -190,12 +190,12 @@ void DwarfAccelTable::emitOffsets(AsmPrinter *Asm, const MCSymbol *SecBegin) {
if (PrevHash == HashValue) if (PrevHash == HashValue)
continue; continue;
PrevHash = HashValue; PrevHash = HashValue;
Asm->OutStreamer.AddComment("Offset in Bucket " + Twine(i)); Asm->OutStreamer->AddComment("Offset in Bucket " + Twine(i));
MCContext &Context = Asm->OutStreamer.getContext(); MCContext &Context = Asm->OutStreamer->getContext();
const MCExpr *Sub = MCBinaryExpr::CreateSub( const MCExpr *Sub = MCBinaryExpr::CreateSub(
MCSymbolRefExpr::Create((*HI)->Sym, Context), MCSymbolRefExpr::Create((*HI)->Sym, Context),
MCSymbolRefExpr::Create(SecBegin, Context), 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) if (PrevHash != UINT64_MAX && PrevHash != (*HI)->HashValue)
Asm->EmitInt32(0); Asm->EmitInt32(0);
// Remember to emit the label for our offset. // Remember to emit the label for our offset.
Asm->OutStreamer.EmitLabel((*HI)->Sym); Asm->OutStreamer->EmitLabel((*HI)->Sym);
Asm->OutStreamer.AddComment((*HI)->Str); Asm->OutStreamer->AddComment((*HI)->Str);
Asm->emitSectionOffset((*HI)->Data.StrSym); Asm->emitSectionOffset((*HI)->Data.StrSym);
Asm->OutStreamer.AddComment("Num DIEs"); Asm->OutStreamer->AddComment("Num DIEs");
Asm->EmitInt32((*HI)->Data.Values.size()); Asm->EmitInt32((*HI)->Data.Values.size());
for (HashDataContents *HD : (*HI)->Data.Values) { for (HashDataContents *HD : (*HI)->Data.Values) {
// Emit the DIE offset // Emit the DIE offset

View File

@ -44,7 +44,7 @@ DwarfCFIExceptionBase::DwarfCFIExceptionBase(AsmPrinter *A)
void DwarfCFIExceptionBase::markFunctionEnd() { void DwarfCFIExceptionBase::markFunctionEnd() {
if (shouldEmitCFI) if (shouldEmitCFI)
Asm->OutStreamer.EmitCFIEndProc(); Asm->OutStreamer->EmitCFIEndProc();
if (MMI->getLandingPads().empty()) if (MMI->getLandingPads().empty())
return; return;
@ -64,7 +64,7 @@ DwarfCFIException::~DwarfCFIException() {}
/// content. /// content.
void DwarfCFIException::endModule() { void DwarfCFIException::endModule() {
if (moveTypeModule == AsmPrinter::CFI_M_Debug) 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. // SjLj uses this pass and it doesn't need this info.
if (!Asm->MAI->usesCFIForEH()) if (!Asm->MAI->usesCFIForEH())
@ -83,7 +83,7 @@ void DwarfCFIException::endModule() {
if (!Personalities[i]) if (!Personalities[i])
continue; continue;
MCSymbol *Sym = Asm->getSymbol(Personalities[i]); 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) if (!shouldEmitCFI)
return; return;
Asm->OutStreamer.EmitCFIStartProc(/*IsSimple=*/false); Asm->OutStreamer->EmitCFIStartProc(/*IsSimple=*/false);
// Indicate personality routine, if any. // Indicate personality routine, if any.
if (!shouldEmitPersonality) if (!shouldEmitPersonality)
@ -125,13 +125,13 @@ void DwarfCFIException::beginFunction(const MachineFunction *MF) {
const MCSymbol *Sym = const MCSymbol *Sym =
TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI); TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI);
Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); Asm->OutStreamer->EmitCFIPersonality(Sym, PerEncoding);
// Provide LSDA information. // Provide LSDA information.
if (!shouldEmitLSDA) if (!shouldEmitLSDA)
return; return;
Asm->OutStreamer.EmitCFILsda(Asm->getCurExceptionSym(), LSDAEncoding); Asm->OutStreamer->EmitCFILsda(Asm->getCurExceptionSym(), LSDAEncoding);
} }
/// endFunction - Gather and emit post-function exception information. /// endFunction - Gather and emit post-function exception information.

View File

@ -64,9 +64,9 @@ unsigned DwarfCompileUnit::getOrCreateSourceID(StringRef FileName,
// FIXME: add a better feature test than hasRawTextSupport. Even better, // FIXME: add a better feature test than hasRawTextSupport. Even better,
// extend .file to support this. // extend .file to support this.
return Asm->OutStreamer.EmitDwarfFileDirective( return Asm->OutStreamer->EmitDwarfFileDirective(
0, DirName, FileName, 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 // 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() { void DwarfCompileUnit::initStmtList() {
// Define start line table label for each Compile Unit. // Define start line table label for each Compile Unit.
MCSymbol *LineTableStartSym = MCSymbol *LineTableStartSym =
Asm->OutStreamer.getDwarfLineTableSymbol(getUniqueID()); Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID());
stmtListIndex = UnitDie.getValues().size(); 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. // Don't bother labeling the .dwo unit, as its offset isn't used.
if (!Skeleton) { if (!Skeleton) {
LabelBegin = Asm->createTempSymbol("cu_begin"); LabelBegin = Asm->createTempSymbol("cu_begin");
Asm->OutStreamer.EmitLabel(LabelBegin); Asm->OutStreamer->EmitLabel(LabelBegin);
} }
DwarfUnit::emitHeader(UseOffsets); DwarfUnit::emitHeader(UseOffsets);

View File

@ -234,7 +234,7 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M)
// Everybody else uses GNU's. // Everybody else uses GNU's.
UseGNUTLSOpcode = !(IsDarwin || IsPS4) || DwarfVersion < 3; UseGNUTLSOpcode = !(IsDarwin || IsPS4) || DwarfVersion < 3;
Asm->OutStreamer.getContext().setDwarfVersion(DwarfVersion); Asm->OutStreamer->getContext().setDwarfVersion(DwarfVersion);
{ {
NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); 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 // To avoid the compilation directory being ambiguous, let the line table
// explicitly describe the directory of all files, never relying on the // explicitly describe the directory of all files, never relying on the
// compilation directory. // compilation directory.
if (!Asm->OutStreamer.hasRawTextSupport() || SingleCU) if (!Asm->OutStreamer->hasRawTextSupport() || SingleCU)
Asm->OutStreamer.getContext().setMCLineTableCompilationDir( Asm->OutStreamer->getContext().setMCLineTableCompilationDir(
NewCU.getUniqueID(), CompilationDir); NewCU.getUniqueID(), CompilationDir);
NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit->getProducer()); NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit->getProducer());
@ -972,7 +972,7 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
Flags |= DWARF2_FLAG_IS_STMT; Flags |= DWARF2_FLAG_IS_STMT;
} }
if (DL.getLine() != if (DL.getLine() !=
Asm->OutStreamer.getContext().getCurrentDwarfLoc().getLine()) Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine())
Flags |= DWARF2_FLAG_IS_STMT; Flags |= DWARF2_FLAG_IS_STMT;
const MDNode *Scope = DL.getScope(); const MDNode *Scope = DL.getScope();
@ -998,7 +998,7 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
if (!PrevLabel) { if (!PrevLabel) {
PrevLabel = MMI->getContext().CreateTempSymbol(); PrevLabel = MMI->getContext().CreateTempSymbol();
Asm->OutStreamer.EmitLabel(PrevLabel); Asm->OutStreamer->EmitLabel(PrevLabel);
} }
I->second = PrevLabel; I->second = PrevLabel;
} }
@ -1026,7 +1026,7 @@ void DwarfDebug::endInstruction() {
// We need a label after this instruction. // We need a label after this instruction.
if (!PrevLabel) { if (!PrevLabel) {
PrevLabel = MMI->getContext().CreateTempSymbol(); PrevLabel = MMI->getContext().CreateTempSymbol();
Asm->OutStreamer.EmitLabel(PrevLabel); Asm->OutStreamer->EmitLabel(PrevLabel);
} }
I->second = PrevLabel; I->second = PrevLabel;
} }
@ -1110,11 +1110,11 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
// is absolute (such as an <> lookup header))) // is absolute (such as an <> lookup header)))
DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode()); DwarfCompileUnit *TheCU = SPMap.lookup(FnScope->getScopeNode());
assert(TheCU && "Unable to find compile unit!"); 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. // Use a single line table if we are generating assembly.
Asm->OutStreamer.getContext().setDwarfCompileUnitID(0); Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
else else
Asm->OutStreamer.getContext().setDwarfCompileUnitID(TheCU->getUniqueID()); Asm->OutStreamer->getContext().setDwarfCompileUnitID(TheCU->getUniqueID());
// Calculate history for local variables. // Calculate history for local variables.
calculateDbgValueHistory(MF, Asm->MF->getSubtarget().getRegisterInfo(), calculateDbgValueHistory(MF, Asm->MF->getSubtarget().getRegisterInfo(),
@ -1183,7 +1183,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
} }
// Set DwarfDwarfCompileUnitID in MCContext to default value. // Set DwarfDwarfCompileUnitID in MCContext to default value.
Asm->OutStreamer.getContext().setDwarfCompileUnitID(0); Asm->OutStreamer->getContext().setDwarfCompileUnitID(0);
LexicalScope *FnScope = LScopes.getCurrentFunctionScope(); LexicalScope *FnScope = LScopes.getCurrentFunctionScope();
auto *SP = cast<MDSubprogram>(FnScope->getScopeNode()); auto *SP = cast<MDSubprogram>(FnScope->getScopeNode());
@ -1260,11 +1260,11 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
if (auto *LBF = dyn_cast<MDLexicalBlockFile>(Scope)) if (auto *LBF = dyn_cast<MDLexicalBlockFile>(Scope))
Discriminator = LBF->getDiscriminator(); Discriminator = LBF->getDiscriminator();
unsigned CUID = Asm->OutStreamer.getContext().getDwarfCompileUnitID(); unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID();
Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID]) Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID])
.getOrCreateSourceID(Fn, Dir); .getOrCreateSourceID(Fn, Dir);
} }
Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, Flags, 0, Asm->OutStreamer->EmitDwarfLocDirective(Src, Line, Col, Flags, 0,
Discriminator, Fn); Discriminator, Fn);
} }
@ -1288,7 +1288,7 @@ void DwarfDebug::emitAbbreviations() {
void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section, void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
StringRef TableName) { StringRef TableName) {
Accel.FinalizeTable(Asm, TableName); Accel.FinalizeTable(Asm, TableName);
Asm->OutStreamer.SwitchSection(Section); Asm->OutStreamer->SwitchSection(Section);
// Emit the full data. // Emit the full data.
Accel.emit(Asm, Section->getBeginSymbol(), this); Accel.emit(Asm, Section->getBeginSymbol(), this);
@ -1402,23 +1402,23 @@ void DwarfDebug::emitDebugPubSection(
TheU = Skeleton; TheU = Skeleton;
// Start the dwarf pubnames section. // Start the dwarf pubnames section.
Asm->OutStreamer.SwitchSection(PSec); Asm->OutStreamer->SwitchSection(PSec);
// Emit the header. // 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 *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin");
MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end"); MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end");
Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); 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->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->emitSectionOffset(TheU->getLabelBegin());
Asm->OutStreamer.AddComment("Compilation Unit Length"); Asm->OutStreamer->AddComment("Compilation Unit Length");
Asm->EmitInt32(TheU->getLength()); Asm->EmitInt32(TheU->getLength());
// Emit the pubnames for this compilation unit. // Emit the pubnames for this compilation unit.
@ -1426,24 +1426,24 @@ void DwarfDebug::emitDebugPubSection(
const char *Name = GI.getKeyData(); const char *Name = GI.getKeyData();
const DIE *Entity = GI.second; const DIE *Entity = GI.second;
Asm->OutStreamer.AddComment("DIE offset"); Asm->OutStreamer->AddComment("DIE offset");
Asm->EmitInt32(Entity->getOffset()); Asm->EmitInt32(Entity->getOffset());
if (GnuStyle) { if (GnuStyle) {
dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity); dwarf::PubIndexEntryDescriptor Desc = computeIndexValue(TheU, Entity);
Asm->OutStreamer.AddComment( Asm->OutStreamer->AddComment(
Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " + Twine("Kind: ") + dwarf::GDBIndexEntryKindString(Desc.Kind) + ", " +
dwarf::GDBIndexEntryLinkageString(Desc.Linkage)); dwarf::GDBIndexEntryLinkageString(Desc.Linkage));
Asm->EmitInt8(Desc.toBits()); Asm->EmitInt8(Desc.toBits());
} }
Asm->OutStreamer.AddComment("External Name"); Asm->OutStreamer->AddComment("External Name");
Asm->OutStreamer.EmitBytes(StringRef(Name, GI.getKeyLength() + 1)); Asm->OutStreamer->EmitBytes(StringRef(Name, GI.getKeyLength() + 1));
} }
Asm->OutStreamer.AddComment("End Mark"); Asm->OutStreamer->AddComment("End Mark");
Asm->EmitInt32(0); 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) { void DwarfDebug::emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry) {
Asm->OutStreamer.AddComment("Loc expr size"); Asm->OutStreamer->AddComment("Loc expr size");
MCSymbol *begin = Asm->OutStreamer.getContext().CreateTempSymbol(); MCSymbol *begin = Asm->OutStreamer->getContext().CreateTempSymbol();
MCSymbol *end = Asm->OutStreamer.getContext().CreateTempSymbol(); MCSymbol *end = Asm->OutStreamer->getContext().CreateTempSymbol();
Asm->EmitLabelDifference(end, begin, 2); Asm->EmitLabelDifference(end, begin, 2);
Asm->OutStreamer.EmitLabel(begin); Asm->OutStreamer->EmitLabel(begin);
// Emit the entry. // Emit the entry.
APByteStreamer Streamer(*Asm); APByteStreamer Streamer(*Asm);
emitDebugLocEntry(Streamer, Entry); emitDebugLocEntry(Streamer, Entry);
// Close the range. // Close the range.
Asm->OutStreamer.EmitLabel(end); Asm->OutStreamer->EmitLabel(end);
} }
// Emit locations into the debug loc section. // Emit locations into the debug loc section.
void DwarfDebug::emitDebugLoc() { void DwarfDebug::emitDebugLoc() {
// Start the dwarf loc section. // Start the dwarf loc section.
Asm->OutStreamer.SwitchSection( Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfLocSection()); Asm->getObjFileLowering().getDwarfLocSection());
unsigned char Size = Asm->getDataLayout().getPointerSize(); unsigned char Size = Asm->getDataLayout().getPointerSize();
for (const auto &List : DebugLocs.getLists()) { for (const auto &List : DebugLocs.getLists()) {
Asm->OutStreamer.EmitLabel(List.Label); Asm->OutStreamer->EmitLabel(List.Label);
const DwarfCompileUnit *CU = List.CU; const DwarfCompileUnit *CU = List.CU;
for (const auto &Entry : DebugLocs.getEntries(List)) { for (const auto &Entry : DebugLocs.getEntries(List)) {
// Set up the range. This range is relative to the entry point of the // 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.BeginSym, Base, Size);
Asm->EmitLabelDifference(Entry.EndSym, Base, Size); Asm->EmitLabelDifference(Entry.EndSym, Base, Size);
} else { } else {
Asm->OutStreamer.EmitSymbolValue(Entry.BeginSym, Size); Asm->OutStreamer->EmitSymbolValue(Entry.BeginSym, Size);
Asm->OutStreamer.EmitSymbolValue(Entry.EndSym, Size); Asm->OutStreamer->EmitSymbolValue(Entry.EndSym, Size);
} }
emitDebugLocEntryLocation(Entry); 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() { void DwarfDebug::emitDebugLocDWO() {
Asm->OutStreamer.SwitchSection( Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfLocDWOSection()); Asm->getObjFileLowering().getDwarfLocDWOSection());
for (const auto &List : DebugLocs.getLists()) { for (const auto &List : DebugLocs.getLists()) {
Asm->OutStreamer.EmitLabel(List.Label); Asm->OutStreamer->EmitLabel(List.Label);
for (const auto &Entry : DebugLocs.getEntries(List)) { for (const auto &Entry : DebugLocs.getEntries(List)) {
// Just always use start_length for now - at least that's one address // 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 // rather than two. We could get fancier and try to, say, reuse an
@ -1637,7 +1637,7 @@ void DwarfDebug::emitDebugARanges() {
MCSymbol *Sym = nullptr; MCSymbol *Sym = nullptr;
if (Section) if (Section)
Sym = Asm->OutStreamer.endSection(Section); Sym = Asm->OutStreamer->endSection(Section);
// Insert a final terminator. // Insert a final terminator.
SectionMap[Section].push_back(SymbolCU(nullptr, Sym)); SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
@ -1667,8 +1667,8 @@ void DwarfDebug::emitDebugARanges() {
// Sort the symbols by offset within the section. // Sort the symbols by offset within the section.
std::sort(List.begin(), List.end(), std::sort(List.begin(), List.end(),
[&](const SymbolCU &A, const SymbolCU &B) { [&](const SymbolCU &A, const SymbolCU &B) {
unsigned IA = A.Sym ? Asm->OutStreamer.GetSymbolOrder(A.Sym) : 0; unsigned IA = A.Sym ? Asm->OutStreamer->GetSymbolOrder(A.Sym) : 0;
unsigned IB = B.Sym ? Asm->OutStreamer.GetSymbolOrder(B.Sym) : 0; unsigned IB = B.Sym ? Asm->OutStreamer->GetSymbolOrder(B.Sym) : 0;
// Symbols with no order assigned should be placed at the end. // Symbols with no order assigned should be placed at the end.
// (e.g. section end labels) // (e.g. section end labels)
@ -1697,7 +1697,7 @@ void DwarfDebug::emitDebugARanges() {
} }
// Start the dwarf aranges section. // Start the dwarf aranges section.
Asm->OutStreamer.SwitchSection( Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfARangesSection()); Asm->getObjFileLowering().getDwarfARangesSection());
unsigned PtrSize = Asm->getDataLayout().getPointerSize(); unsigned PtrSize = Asm->getDataLayout().getPointerSize();
@ -1739,18 +1739,18 @@ void DwarfDebug::emitDebugARanges() {
ContentSize += (List.size() + 1) * TupleSize; ContentSize += (List.size() + 1) * TupleSize;
// For each compile unit, write the list of spans it covers. // 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->EmitInt32(ContentSize);
Asm->OutStreamer.AddComment("DWARF Arange version number"); Asm->OutStreamer->AddComment("DWARF Arange version number");
Asm->EmitInt16(dwarf::DW_ARANGES_VERSION); 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->emitSectionOffset(CU->getLabelBegin());
Asm->OutStreamer.AddComment("Address Size (in bytes)"); Asm->OutStreamer->AddComment("Address Size (in bytes)");
Asm->EmitInt8(PtrSize); Asm->EmitInt8(PtrSize);
Asm->OutStreamer.AddComment("Segment Size (in bytes)"); Asm->OutStreamer->AddComment("Segment Size (in bytes)");
Asm->EmitInt8(0); Asm->EmitInt8(0);
Asm->OutStreamer.EmitFill(Padding, 0xff); Asm->OutStreamer->EmitFill(Padding, 0xff);
for (const ArangeSpan &Span : List) { for (const ArangeSpan &Span : List) {
Asm->EmitLabelReference(Span.Start, PtrSize); Asm->EmitLabelReference(Span.Start, PtrSize);
@ -1765,20 +1765,20 @@ void DwarfDebug::emitDebugARanges() {
if (Size == 0) if (Size == 0)
Size = 1; Size = 1;
Asm->OutStreamer.EmitIntValue(Size, PtrSize); Asm->OutStreamer->EmitIntValue(Size, PtrSize);
} }
} }
Asm->OutStreamer.AddComment("ARange terminator"); Asm->OutStreamer->AddComment("ARange terminator");
Asm->OutStreamer.EmitIntValue(0, PtrSize); Asm->OutStreamer->EmitIntValue(0, PtrSize);
Asm->OutStreamer.EmitIntValue(0, PtrSize); Asm->OutStreamer->EmitIntValue(0, PtrSize);
} }
} }
// Emit visible names into a debug ranges section. // Emit visible names into a debug ranges section.
void DwarfDebug::emitDebugRanges() { void DwarfDebug::emitDebugRanges() {
// Start the dwarf ranges section. // Start the dwarf ranges section.
Asm->OutStreamer.SwitchSection( Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfRangesSection()); Asm->getObjFileLowering().getDwarfRangesSection());
// Size for our labels. // Size for our labels.
@ -1794,7 +1794,7 @@ void DwarfDebug::emitDebugRanges() {
// Iterate over the misc ranges for the compile units in the module. // Iterate over the misc ranges for the compile units in the module.
for (const RangeSpanList &List : TheCU->getRangeLists()) { for (const RangeSpanList &List : TheCU->getRangeLists()) {
// Emit our symbol so we can find the beginning of the range. // 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()) { for (const RangeSpan &Range : List.getRanges()) {
const MCSymbol *Begin = Range.getStart(); const MCSymbol *Begin = Range.getStart();
@ -1805,14 +1805,14 @@ void DwarfDebug::emitDebugRanges() {
Asm->EmitLabelDifference(Begin, Base, Size); Asm->EmitLabelDifference(Begin, Base, Size);
Asm->EmitLabelDifference(End, Base, Size); Asm->EmitLabelDifference(End, Base, Size);
} else { } else {
Asm->OutStreamer.EmitSymbolValue(Begin, Size); Asm->OutStreamer->EmitSymbolValue(Begin, Size);
Asm->OutStreamer.EmitSymbolValue(End, Size); Asm->OutStreamer->EmitSymbolValue(End, Size);
} }
} }
// And terminate the list with two 0 values. // 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() { void DwarfDebug::emitDebugLineDWO() {
assert(useSplitDwarf() && "No split dwarf?"); assert(useSplitDwarf() && "No split dwarf?");
Asm->OutStreamer.SwitchSection( Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfLineDWOSection()); Asm->getObjFileLowering().getDwarfLineDWOSection());
SplitTypeUnitFileTable.Emit(Asm->OutStreamer); SplitTypeUnitFileTable.Emit(*Asm->OutStreamer);
} }
// Emit the .debug_str.dwo section for separated dwarf. This contains the // Emit the .debug_str.dwo section for separated dwarf. This contains the

View File

@ -51,7 +51,7 @@ void DwarfFile::emitUnits(bool UseOffsets) {
for (const auto &TheU : CUs) { for (const auto &TheU : CUs) {
DIE &Die = TheU->getUnitDie(); DIE &Die = TheU->getUnitDie();
const MCSection *USection = TheU->getSection(); const MCSection *USection = TheU->getSection();
Asm->OutStreamer.SwitchSection(USection); Asm->OutStreamer->SwitchSection(USection);
TheU->emitHeader(UseOffsets); TheU->emitHeader(UseOffsets);
@ -124,7 +124,7 @@ void DwarfFile::emitAbbrevs(const MCSection *Section) {
// Check to see if it is worth the effort. // Check to see if it is worth the effort.
if (!Abbreviations.empty()) { if (!Abbreviations.empty()) {
// Start the debug abbrev section. // Start the debug abbrev section.
Asm->OutStreamer.SwitchSection(Section); Asm->OutStreamer->SwitchSection(Section);
Asm->emitDwarfAbbrevs(Abbreviations); Asm->emitDwarfAbbrevs(Abbreviations);
} }
} }

View File

@ -38,7 +38,7 @@ void DwarfStringPool::emit(AsmPrinter &Asm, const MCSection *StrSection,
return; return;
// Start the dwarf str section. // 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 // Get all of the string pool entries and put them in an array by their ID so
// we can sort them. // we can sort them.
@ -50,20 +50,20 @@ void DwarfStringPool::emit(AsmPrinter &Asm, const MCSection *StrSection,
for (const auto &Entry : Entries) { for (const auto &Entry : Entries) {
// Emit a label for reference from debug information 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. // Emit the string itself with a terminating null byte.
Asm.OutStreamer.EmitBytes( Asm.OutStreamer->EmitBytes(
StringRef(Entry->getKeyData(), Entry->getKeyLength() + 1)); StringRef(Entry->getKeyData(), Entry->getKeyLength() + 1));
} }
// If we've got an offset section go ahead and emit that now as well. // If we've got an offset section go ahead and emit that now as well.
if (OffsetSection) { if (OffsetSection) {
Asm.OutStreamer.SwitchSection(OffsetSection); Asm.OutStreamer->SwitchSection(OffsetSection);
unsigned offset = 0; unsigned offset = 0;
unsigned size = 4; // FIXME: DWARF64 is 8. unsigned size = 4; // FIXME: DWARF64 is 8.
for (const auto &Entry : Entries) { for (const auto &Entry : Entries) {
Asm.OutStreamer.EmitIntValue(offset, size); Asm.OutStreamer->EmitIntValue(offset, size);
offset += Entry->getKeyLength() + 1; offset += Entry->getKeyLength() + 1;
} }
} }

View File

@ -1494,12 +1494,12 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const MDDerivedType *DT) {
void DwarfUnit::emitHeader(bool UseOffsets) { void DwarfUnit::emitHeader(bool UseOffsets) {
// Emit size of content not including length itself // 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->EmitInt32(getHeaderSize() + UnitDie.getSize());
Asm->OutStreamer.AddComment("DWARF version number"); Asm->OutStreamer->AddComment("DWARF version number");
Asm->EmitInt16(DD->getDwarfVersion()); 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 // 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 // start of the section. Use a relocatable offset where needed to ensure
@ -1510,7 +1510,7 @@ void DwarfUnit::emitHeader(bool UseOffsets) {
else else
Asm->EmitInt32(0); Asm->EmitInt32(0);
Asm->OutStreamer.AddComment("Address Size (in bytes)"); Asm->OutStreamer->AddComment("Address Size (in bytes)");
Asm->EmitInt8(Asm->getDataLayout().getPointerSize()); Asm->EmitInt8(Asm->getDataLayout().getPointerSize());
} }
@ -1521,11 +1521,11 @@ void DwarfUnit::initSection(const MCSection *Section) {
void DwarfTypeUnit::emitHeader(bool UseOffsets) { void DwarfTypeUnit::emitHeader(bool UseOffsets) {
DwarfUnit::emitHeader(UseOffsets); DwarfUnit::emitHeader(UseOffsets);
Asm->OutStreamer.AddComment("Type Signature"); Asm->OutStreamer->AddComment("Type Signature");
Asm->OutStreamer.EmitIntValue(TypeSignature, sizeof(TypeSignature)); Asm->OutStreamer->EmitIntValue(TypeSignature, sizeof(TypeSignature));
Asm->OutStreamer.AddComment("Type DIE Offset"); Asm->OutStreamer->AddComment("Type DIE Offset");
// In a skeleton type unit there is no type DIE so emit a zero offset. // In a skeleton type unit there is no type DIE so emit a zero offset.
Asm->OutStreamer.EmitIntValue(Ty ? Ty->getOffset() : 0, Asm->OutStreamer->EmitIntValue(Ty ? Ty->getOffset() : 0,
sizeof(Ty->getOffset())); sizeof(Ty->getOffset()));
} }

View File

@ -434,15 +434,15 @@ void EHStreamer::emitExceptionTable() {
// Sometimes we want not to emit the data into separate section (e.g. ARM // Sometimes we want not to emit the data into separate section (e.g. ARM
// EHABI). In this case LSDASection will be NULL. // EHABI). In this case LSDASection will be NULL.
if (LSDASection) if (LSDASection)
Asm->OutStreamer.SwitchSection(LSDASection); Asm->OutStreamer->SwitchSection(LSDASection);
Asm->EmitAlignment(2); Asm->EmitAlignment(2);
// Emit the LSDA. // Emit the LSDA.
MCSymbol *GCCETSym = MCSymbol *GCCETSym =
Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+ Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
Twine(Asm->getFunctionNumber())); Twine(Asm->getFunctionNumber()));
Asm->OutStreamer.EmitLabel(GCCETSym); Asm->OutStreamer->EmitLabel(GCCETSym);
Asm->OutStreamer.EmitLabel(Asm->getCurExceptionSym()); Asm->OutStreamer->EmitLabel(Asm->getCurExceptionSym());
// Emit the LSDA header. // Emit the LSDA header.
Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart"); Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
@ -486,7 +486,7 @@ void EHStreamer::emitExceptionTable() {
SizeAlign = 0; SizeAlign = 0;
} }
bool VerboseAsm = Asm->OutStreamer.isVerboseAsm(); bool VerboseAsm = Asm->OutStreamer->isVerboseAsm();
// SjLj Exception handling // SjLj Exception handling
if (IsSJLJ) { if (IsSJLJ) {
@ -504,8 +504,8 @@ void EHStreamer::emitExceptionTable() {
// Offset of the landing pad, counted in 16-byte bundles relative to the // Offset of the landing pad, counted in 16-byte bundles relative to the
// @LPStart address. // @LPStart address.
if (VerboseAsm) { if (VerboseAsm) {
Asm->OutStreamer.AddComment(">> Call Site " + Twine(idx) + " <<"); Asm->OutStreamer->AddComment(">> Call Site " + Twine(idx) + " <<");
Asm->OutStreamer.AddComment(" On exception at call site "+Twine(idx)); Asm->OutStreamer->AddComment(" On exception at call site "+Twine(idx));
} }
Asm->EmitULEB128(idx); Asm->EmitULEB128(idx);
@ -514,9 +514,9 @@ void EHStreamer::emitExceptionTable() {
// the action table), and 0 indicates that there are no actions. // the action table), and 0 indicates that there are no actions.
if (VerboseAsm) { if (VerboseAsm) {
if (S.Action == 0) if (S.Action == 0)
Asm->OutStreamer.AddComment(" Action: cleanup"); Asm->OutStreamer->AddComment(" Action: cleanup");
else else
Asm->OutStreamer.AddComment(" Action: " + Asm->OutStreamer->AddComment(" Action: " +
Twine((S.Action - 1) / 2 + 1)); Twine((S.Action - 1) / 2 + 1));
} }
Asm->EmitULEB128(S.Action); Asm->EmitULEB128(S.Action);
@ -566,10 +566,10 @@ void EHStreamer::emitExceptionTable() {
// number of 16-byte bundles. The first call site is counted relative to // number of 16-byte bundles. The first call site is counted relative to
// the start of the procedure fragment. // the start of the procedure fragment.
if (VerboseAsm) if (VerboseAsm)
Asm->OutStreamer.AddComment(">> Call Site " + Twine(++Entry) + " <<"); Asm->OutStreamer->AddComment(">> Call Site " + Twine(++Entry) + " <<");
Asm->EmitLabelDifference(BeginLabel, EHFuncBeginSym, 4); Asm->EmitLabelDifference(BeginLabel, EHFuncBeginSym, 4);
if (VerboseAsm) if (VerboseAsm)
Asm->OutStreamer.AddComment(Twine(" Call between ") + Asm->OutStreamer->AddComment(Twine(" Call between ") +
BeginLabel->getName() + " and " + BeginLabel->getName() + " and " +
EndLabel->getName()); EndLabel->getName());
Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
@ -578,11 +578,11 @@ void EHStreamer::emitExceptionTable() {
// @LPStart address. // @LPStart address.
if (!S.LPad) { if (!S.LPad) {
if (VerboseAsm) if (VerboseAsm)
Asm->OutStreamer.AddComment(" has no landing pad"); Asm->OutStreamer->AddComment(" has no landing pad");
Asm->OutStreamer.EmitIntValue(0, 4/*size*/); Asm->OutStreamer->EmitIntValue(0, 4/*size*/);
} else { } else {
if (VerboseAsm) if (VerboseAsm)
Asm->OutStreamer.AddComment(Twine(" jumps to ") + Asm->OutStreamer->AddComment(Twine(" jumps to ") +
S.LPad->LandingPadLabel->getName()); S.LPad->LandingPadLabel->getName());
Asm->EmitLabelDifference(S.LPad->LandingPadLabel, EHFuncBeginSym, 4); Asm->EmitLabelDifference(S.LPad->LandingPadLabel, EHFuncBeginSym, 4);
} }
@ -592,9 +592,9 @@ void EHStreamer::emitExceptionTable() {
// the action table), and 0 indicates that there are no actions. // the action table), and 0 indicates that there are no actions.
if (VerboseAsm) { if (VerboseAsm) {
if (S.Action == 0) if (S.Action == 0)
Asm->OutStreamer.AddComment(" On action: cleanup"); Asm->OutStreamer->AddComment(" On action: cleanup");
else else
Asm->OutStreamer.AddComment(" On action: " + Asm->OutStreamer->AddComment(" On action: " +
Twine((S.Action - 1) / 2 + 1)); Twine((S.Action - 1) / 2 + 1));
} }
Asm->EmitULEB128(S.Action); Asm->EmitULEB128(S.Action);
@ -609,7 +609,7 @@ void EHStreamer::emitExceptionTable() {
if (VerboseAsm) { if (VerboseAsm) {
// Emit comments that decode the action table. // Emit comments that decode the action table.
Asm->OutStreamer.AddComment(">> Action Record " + Twine(++Entry) + " <<"); Asm->OutStreamer->AddComment(">> Action Record " + Twine(++Entry) + " <<");
} }
// Type Filter // Type Filter
@ -618,13 +618,13 @@ void EHStreamer::emitExceptionTable() {
// type of the catch clauses or the types in the exception specification. // type of the catch clauses or the types in the exception specification.
if (VerboseAsm) { if (VerboseAsm) {
if (Action.ValueForTypeID > 0) if (Action.ValueForTypeID > 0)
Asm->OutStreamer.AddComment(" Catch TypeInfo " + Asm->OutStreamer->AddComment(" Catch TypeInfo " +
Twine(Action.ValueForTypeID)); Twine(Action.ValueForTypeID));
else if (Action.ValueForTypeID < 0) else if (Action.ValueForTypeID < 0)
Asm->OutStreamer.AddComment(" Filter TypeInfo " + Asm->OutStreamer->AddComment(" Filter TypeInfo " +
Twine(Action.ValueForTypeID)); Twine(Action.ValueForTypeID));
else else
Asm->OutStreamer.AddComment(" Cleanup"); Asm->OutStreamer->AddComment(" Cleanup");
} }
Asm->EmitSLEB128(Action.ValueForTypeID); Asm->EmitSLEB128(Action.ValueForTypeID);
@ -634,10 +634,10 @@ void EHStreamer::emitExceptionTable() {
// or 0 if there is no next action record. // or 0 if there is no next action record.
if (VerboseAsm) { if (VerboseAsm) {
if (Action.NextAction == 0) { if (Action.NextAction == 0) {
Asm->OutStreamer.AddComment(" No further actions"); Asm->OutStreamer->AddComment(" No further actions");
} else { } else {
unsigned NextAction = Entry + (Action.NextAction + 1) / 2; 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); Asm->EmitSLEB128(Action.NextAction);
@ -652,13 +652,13 @@ void EHStreamer::emitTypeInfos(unsigned TTypeEncoding) {
const std::vector<const GlobalValue *> &TypeInfos = MMI->getTypeInfos(); const std::vector<const GlobalValue *> &TypeInfos = MMI->getTypeInfos();
const std::vector<unsigned> &FilterIds = MMI->getFilterIds(); const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
bool VerboseAsm = Asm->OutStreamer.isVerboseAsm(); bool VerboseAsm = Asm->OutStreamer->isVerboseAsm();
int Entry = 0; int Entry = 0;
// Emit the Catch TypeInfos. // Emit the Catch TypeInfos.
if (VerboseAsm && !TypeInfos.empty()) { if (VerboseAsm && !TypeInfos.empty()) {
Asm->OutStreamer.AddComment(">> Catch TypeInfos <<"); Asm->OutStreamer->AddComment(">> Catch TypeInfos <<");
Asm->OutStreamer.AddBlankLine(); Asm->OutStreamer->AddBlankLine();
Entry = TypeInfos.size(); Entry = TypeInfos.size();
} }
@ -666,14 +666,14 @@ void EHStreamer::emitTypeInfos(unsigned TTypeEncoding) {
I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) { I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) {
const GlobalValue *GV = *I; const GlobalValue *GV = *I;
if (VerboseAsm) if (VerboseAsm)
Asm->OutStreamer.AddComment("TypeInfo " + Twine(Entry--)); Asm->OutStreamer->AddComment("TypeInfo " + Twine(Entry--));
Asm->EmitTTypeReference(GV, TTypeEncoding); Asm->EmitTTypeReference(GV, TTypeEncoding);
} }
// Emit the Exception Specifications. // Emit the Exception Specifications.
if (VerboseAsm && !FilterIds.empty()) { if (VerboseAsm && !FilterIds.empty()) {
Asm->OutStreamer.AddComment(">> Filter TypeInfos <<"); Asm->OutStreamer->AddComment(">> Filter TypeInfos <<");
Asm->OutStreamer.AddBlankLine(); Asm->OutStreamer->AddBlankLine();
Entry = 0; Entry = 0;
} }
for (std::vector<unsigned>::const_iterator for (std::vector<unsigned>::const_iterator
@ -682,7 +682,7 @@ void EHStreamer::emitTypeInfos(unsigned TTypeEncoding) {
if (VerboseAsm) { if (VerboseAsm) {
--Entry; --Entry;
if (isFilterEHSelector(TypeID)) if (isFilterEHSelector(TypeID))
Asm->OutStreamer.AddComment("FilterInfo " + Twine(Entry)); Asm->OutStreamer->AddComment("FilterInfo " + Twine(Entry));
} }
Asm->EmitULEB128(TypeID); Asm->EmitULEB128(TypeID);

View File

@ -47,11 +47,11 @@ void llvm::linkErlangGCPrinter() {}
void ErlangGCPrinter::finishAssembly(Module &M, GCModuleInfo &Info, void ErlangGCPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
AsmPrinter &AP) { AsmPrinter &AP) {
MCStreamer &OS = AP.OutStreamer; MCStreamer &OS = *AP.OutStreamer;
unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(); unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize();
// Put this in a custom .note section. // Put this in a custom .note section.
AP.OutStreamer.SwitchSection( OS.SwitchSection(
AP.getObjFileLowering().getContext().getELFSection(".note.gc", AP.getObjFileLowering().getContext().getELFSection(".note.gc",
ELF::SHT_PROGBITS, 0)); ELF::SHT_PROGBITS, 0));

View File

@ -62,16 +62,16 @@ static void EmitCamlGlobal(const Module &M, AsmPrinter &AP, const char *Id) {
MCSymbol *Sym = AP.OutContext.GetOrCreateSymbol(TmpStr); MCSymbol *Sym = AP.OutContext.GetOrCreateSymbol(TmpStr);
AP.OutStreamer.EmitSymbolAttribute(Sym, MCSA_Global); AP.OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
AP.OutStreamer.EmitLabel(Sym); AP.OutStreamer->EmitLabel(Sym);
} }
void OcamlGCMetadataPrinter::beginAssembly(Module &M, GCModuleInfo &Info, void OcamlGCMetadataPrinter::beginAssembly(Module &M, GCModuleInfo &Info,
AsmPrinter &AP) { AsmPrinter &AP) {
AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection()); AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getTextSection());
EmitCamlGlobal(M, AP, "code_begin"); EmitCamlGlobal(M, AP, "code_begin");
AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getDataSection());
EmitCamlGlobal(M, AP, "data_begin"); EmitCamlGlobal(M, AP, "data_begin");
} }
@ -95,16 +95,16 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
AsmPrinter &AP) { AsmPrinter &AP) {
unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(); unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize();
AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection()); AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getTextSection());
EmitCamlGlobal(M, AP, "code_end"); EmitCamlGlobal(M, AP, "code_end");
AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection()); AP.OutStreamer->SwitchSection(AP.getObjFileLowering().getDataSection());
EmitCamlGlobal(M, AP, "data_end"); EmitCamlGlobal(M, AP, "data_end");
// FIXME: Why does ocaml emit this?? // 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"); EmitCamlGlobal(M, AP, "frametable");
int NumDescriptors = 0; int NumDescriptors = 0;
@ -146,9 +146,9 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
Twine(uintptr_t(&FI)) + ")"); Twine(uintptr_t(&FI)) + ")");
} }
AP.OutStreamer.AddComment("live roots for " + AP.OutStreamer->AddComment("live roots for " +
Twine(FI.getFunction().getName())); Twine(FI.getFunction().getName()));
AP.OutStreamer.AddBlankLine(); AP.OutStreamer->AddBlankLine();
for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) { for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) {
size_t LiveCount = FI.live_size(J); size_t LiveCount = FI.live_size(J);
@ -160,7 +160,7 @@ void OcamlGCMetadataPrinter::finishAssembly(Module &M, GCModuleInfo &Info,
Twine(LiveCount) + " >= 65536."); Twine(LiveCount) + " >= 65536.");
} }
AP.OutStreamer.EmitSymbolValue(J->Label, IntPtrSize); AP.OutStreamer->EmitSymbolValue(J->Label, IntPtrSize);
AP.EmitInt16(FrameSize); AP.EmitInt16(FrameSize);
AP.EmitInt16(LiveCount); AP.EmitInt16(LiveCount);

View File

@ -83,7 +83,7 @@ void Win64Exception::beginFunction(const MachineFunction *MF) {
GlobalValue::getRealLinkageName(F->getName())); GlobalValue::getRealLinkageName(F->getName()));
// Emit a symbol assignment. // Emit a symbol assignment.
Asm->OutStreamer.EmitAssignment( Asm->OutStreamer->EmitAssignment(
HandlerTypeParentFrameOffset, HandlerTypeParentFrameOffset,
MCConstantExpr::Create(I->second, Asm->OutContext)); MCConstantExpr::Create(I->second, Asm->OutContext));
} }
@ -92,14 +92,14 @@ void Win64Exception::beginFunction(const MachineFunction *MF) {
if (!shouldEmitPersonality && !shouldEmitMoves) if (!shouldEmitPersonality && !shouldEmitMoves)
return; return;
Asm->OutStreamer.EmitWinCFIStartProc(Asm->CurrentFnSym); Asm->OutStreamer->EmitWinCFIStartProc(Asm->CurrentFnSym);
if (!shouldEmitPersonality) if (!shouldEmitPersonality)
return; return;
const MCSymbol *PersHandlerSym = const MCSymbol *PersHandlerSym =
TLOF.getCFIPersonalitySymbol(Per, *Asm->Mang, Asm->TM, MMI); 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. /// endFunction - Gather and emit post-function exception information.
@ -117,10 +117,10 @@ void Win64Exception::endFunction(const MachineFunction *MF) {
MMI->TidyLandingPads(); MMI->TidyLandingPads();
if (shouldEmitPersonality) { if (shouldEmitPersonality) {
Asm->OutStreamer.PushSection(); Asm->OutStreamer->PushSection();
// Emit an UNWIND_INFO struct describing the prologue. // 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 // Emit the tables appropriate to the personality function in use. If we
// don't recognize the personality, assume it uses an Itanium-style LSDA. // don't recognize the personality, assume it uses an Itanium-style LSDA.
@ -131,9 +131,9 @@ void Win64Exception::endFunction(const MachineFunction *MF) {
else else
emitExceptionTable(); emitExceptionTable();
Asm->OutStreamer.PopSection(); Asm->OutStreamer->PopSection();
} }
Asm->OutStreamer.EmitWinCFIEndProc(); Asm->OutStreamer->EmitWinCFIEndProc();
} }
const MCExpr *Win64Exception::createImageRel32(const MCSymbol *Value) { const MCExpr *Win64Exception::createImageRel32(const MCSymbol *Value) {
@ -208,7 +208,7 @@ void Win64Exception::emitCSpecificHandlerTable() {
continue; // Ignore gaps. continue; // Ignore gaps.
NumEntries += CSE.LPad->SEHHandlers.size(); 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 there are no actions, we don't need to iterate again.
if (NumEntries == 0) if (NumEntries == 0)
@ -241,25 +241,25 @@ void Win64Exception::emitCSpecificHandlerTable() {
// Emit an entry for each action. // Emit an entry for each action.
for (SEHHandler Handler : LPad->SEHHandlers) { for (SEHHandler Handler : LPad->SEHHandlers) {
Asm->OutStreamer.EmitValue(Begin, 4); Asm->OutStreamer->EmitValue(Begin, 4);
Asm->OutStreamer.EmitValue(End, 4); Asm->OutStreamer->EmitValue(End, 4);
// Emit the filter or finally function pointer, if present. Otherwise, // Emit the filter or finally function pointer, if present. Otherwise,
// emit '1' to indicate a catch-all. // emit '1' to indicate a catch-all.
const Function *F = Handler.FilterOrFinally; const Function *F = Handler.FilterOrFinally;
if (F) if (F)
Asm->OutStreamer.EmitValue(createImageRel32(Asm->getSymbol(F)), 4); Asm->OutStreamer->EmitValue(createImageRel32(Asm->getSymbol(F)), 4);
else else
Asm->OutStreamer.EmitIntValue(1, 4); Asm->OutStreamer->EmitIntValue(1, 4);
// Emit the recovery address, if present. Otherwise, this must be a // Emit the recovery address, if present. Otherwise, this must be a
// finally. // finally.
const BlockAddress *BA = Handler.RecoverBA; const BlockAddress *BA = Handler.RecoverBA;
if (BA) if (BA)
Asm->OutStreamer.EmitValue( Asm->OutStreamer->EmitValue(
createImageRel32(Asm->GetBlockAddressSymbol(BA)), 4); createImageRel32(Asm->GetBlockAddressSymbol(BA)), 4);
else else
Asm->OutStreamer.EmitIntValue(0, 4); Asm->OutStreamer->EmitIntValue(0, 4);
} }
} }
} }
@ -267,7 +267,7 @@ void Win64Exception::emitCSpecificHandlerTable() {
void Win64Exception::emitCXXFrameHandler3Table(const MachineFunction *MF) { void Win64Exception::emitCXXFrameHandler3Table(const MachineFunction *MF) {
const Function *F = MF->getFunction(); const Function *F = MF->getFunction();
const Function *ParentF = MMI->getWinEHParent(F); const Function *ParentF = MMI->getWinEHParent(F);
auto &OS = Asm->OutStreamer; auto &OS = *Asm->OutStreamer;
WinEHFuncInfo &FuncInfo = MMI->getWinEHFuncInfo(ParentF); WinEHFuncInfo &FuncInfo = MMI->getWinEHFuncInfo(ParentF);
StringRef ParentLinkageName = StringRef ParentLinkageName =

View File

@ -95,7 +95,7 @@ void WinCodeViewLineTables::maybeRecordLocation(DebugLoc DL,
FileNameRegistry.add(Filename); FileNameRegistry.add(Filename);
MCSymbol *MCL = Asm->MMI->getContext().CreateTempSymbol(); MCSymbol *MCL = Asm->MMI->getContext().CreateTempSymbol();
Asm->OutStreamer.EmitLabel(MCL); Asm->OutStreamer->EmitLabel(MCL);
CurFn->Instrs.push_back(MCL); CurFn->Instrs.push_back(MCL);
InstrInfo[MCL] = InstrInfoTy(Filename, DL.getLine()); InstrInfo[MCL] = InstrInfoTy(Filename, DL.getLine());
} }
@ -120,7 +120,7 @@ void WinCodeViewLineTables::endModule() {
return; return;
assert(Asm != nullptr); assert(Asm != nullptr);
Asm->OutStreamer.SwitchSection( Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getCOFFDebugSymbolsSection()); Asm->getObjFileLowering().getCOFFDebugSymbolsSection());
Asm->EmitInt32(COFF::DEBUG_SECTION_MAGIC); Asm->EmitInt32(COFF::DEBUG_SECTION_MAGIC);
@ -135,7 +135,7 @@ void WinCodeViewLineTables::endModule() {
emitDebugInfoForFunction(VisitedFunctions[I]); emitDebugInfoForFunction(VisitedFunctions[I]);
// This subsection holds a file index to offset in string table table. // 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); Asm->EmitInt32(COFF::DEBUG_INDEX_SUBSECTION);
size_t NumFilenames = FileNameRegistry.Infos.size(); size_t NumFilenames = FileNameRegistry.Infos.size();
Asm->EmitInt32(8 * NumFilenames); Asm->EmitInt32(8 * NumFilenames);
@ -148,7 +148,7 @@ void WinCodeViewLineTables::endModule() {
} }
// This subsection holds the string table. // 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(COFF::DEBUG_STRING_TABLE_SUBSECTION);
Asm->EmitInt32(FileNameRegistry.LastOffset); Asm->EmitInt32(FileNameRegistry.LastOffset);
// The payload starts with a null character. // 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) { for (size_t I = 0, E = FileNameRegistry.Filenames.size(); I != E; ++I) {
// Just emit unique filenames one by one, separated by a null character. // 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); Asm->EmitInt8(0);
} }
// No more subsections. Fill with zeros to align the end of the section by 4. // 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(); clear();
} }
@ -203,39 +203,39 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) {
// Emit a symbol subsection, required by VS2012+ to find function boundaries. // Emit a symbol subsection, required by VS2012+ to find function boundaries.
MCSymbol *SymbolsBegin = Asm->MMI->getContext().CreateTempSymbol(), MCSymbol *SymbolsBegin = Asm->MMI->getContext().CreateTempSymbol(),
*SymbolsEnd = 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); Asm->EmitInt32(COFF::DEBUG_SYMBOL_SUBSECTION);
EmitLabelDiff(Asm->OutStreamer, SymbolsBegin, SymbolsEnd); EmitLabelDiff(*Asm->OutStreamer, SymbolsBegin, SymbolsEnd);
Asm->OutStreamer.EmitLabel(SymbolsBegin); Asm->OutStreamer->EmitLabel(SymbolsBegin);
{ {
MCSymbol *ProcSegmentBegin = Asm->MMI->getContext().CreateTempSymbol(), MCSymbol *ProcSegmentBegin = Asm->MMI->getContext().CreateTempSymbol(),
*ProcSegmentEnd = Asm->MMI->getContext().CreateTempSymbol(); *ProcSegmentEnd = Asm->MMI->getContext().CreateTempSymbol();
EmitLabelDiff(Asm->OutStreamer, ProcSegmentBegin, ProcSegmentEnd, 2); EmitLabelDiff(*Asm->OutStreamer, ProcSegmentBegin, ProcSegmentEnd, 2);
Asm->OutStreamer.EmitLabel(ProcSegmentBegin); Asm->OutStreamer->EmitLabel(ProcSegmentBegin);
Asm->EmitInt16(COFF::DEBUG_SYMBOL_TYPE_PROC_START); Asm->EmitInt16(COFF::DEBUG_SYMBOL_TYPE_PROC_START);
// Some bytes of this segment don't seem to be required for basic debugging, // Some bytes of this segment don't seem to be required for basic debugging,
// so just fill them with zeroes. // 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 // This is the important bit that tells the debugger where the function
// code is located and what's its size: // code is located and what's its size:
EmitLabelDiff(Asm->OutStreamer, Fn, FI.End); EmitLabelDiff(*Asm->OutStreamer, Fn, FI.End);
Asm->OutStreamer.EmitFill(12, 0); Asm->OutStreamer->EmitFill(12, 0);
Asm->OutStreamer.EmitCOFFSecRel32(Fn); Asm->OutStreamer->EmitCOFFSecRel32(Fn);
Asm->OutStreamer.EmitCOFFSectionIndex(Fn); Asm->OutStreamer->EmitCOFFSectionIndex(Fn);
Asm->EmitInt8(0); Asm->EmitInt8(0);
// Emit the function display name as a null-terminated string. // Emit the function display name as a null-terminated string.
Asm->OutStreamer.EmitBytes(FuncName); Asm->OutStreamer->EmitBytes(FuncName);
Asm->EmitInt8(0); Asm->EmitInt8(0);
Asm->OutStreamer.EmitLabel(ProcSegmentEnd); Asm->OutStreamer->EmitLabel(ProcSegmentEnd);
// We're done with this function. // We're done with this function.
Asm->EmitInt16(0x0002); Asm->EmitInt16(0x0002);
Asm->EmitInt16(COFF::DEBUG_SYMBOL_TYPE_PROC_END); 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. // 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. // PCs/Instructions are grouped into segments sharing the same filename.
// Pre-calculate the lengths (in instructions) of these segments and store // 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; FilenameSegmentLengths[LastSegmentEnd] = FI.Instrs.size() - LastSegmentEnd;
// Emit a line table subsection, requred to do PC-to-file:line lookup. // 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); Asm->EmitInt32(COFF::DEBUG_LINE_TABLE_SUBSECTION);
MCSymbol *LineTableBegin = Asm->MMI->getContext().CreateTempSymbol(), MCSymbol *LineTableBegin = Asm->MMI->getContext().CreateTempSymbol(),
*LineTableEnd = Asm->MMI->getContext().CreateTempSymbol(); *LineTableEnd = Asm->MMI->getContext().CreateTempSymbol();
EmitLabelDiff(Asm->OutStreamer, LineTableBegin, LineTableEnd); EmitLabelDiff(*Asm->OutStreamer, LineTableBegin, LineTableEnd);
Asm->OutStreamer.EmitLabel(LineTableBegin); Asm->OutStreamer->EmitLabel(LineTableBegin);
// Identify the function this subsection is for. // Identify the function this subsection is for.
Asm->OutStreamer.EmitCOFFSecRel32(Fn); Asm->OutStreamer->EmitCOFFSecRel32(Fn);
Asm->OutStreamer.EmitCOFFSectionIndex(Fn); Asm->OutStreamer->EmitCOFFSectionIndex(Fn);
// Insert padding after a 16-bit section index. // Insert padding after a 16-bit section index.
Asm->EmitInt16(0); Asm->EmitInt16(0);
// Length of the function's code, in bytes. // 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: // PC-to-linenumber lookup table:
MCSymbol *FileSegmentEnd = nullptr; MCSymbol *FileSegmentEnd = nullptr;
@ -279,17 +279,17 @@ void WinCodeViewLineTables::emitDebugInfoForFunction(const Function *GV) {
if (FilenameSegmentLengths.count(J)) { if (FilenameSegmentLengths.count(J)) {
// We came to a beginning of a new filename segment. // We came to a beginning of a new filename segment.
if (FileSegmentEnd) if (FileSegmentEnd)
Asm->OutStreamer.EmitLabel(FileSegmentEnd); Asm->OutStreamer->EmitLabel(FileSegmentEnd);
StringRef CurFilename = InstrInfo[FI.Instrs[J]].Filename; StringRef CurFilename = InstrInfo[FI.Instrs[J]].Filename;
assert(FileNameRegistry.Infos.count(CurFilename)); assert(FileNameRegistry.Infos.count(CurFilename));
size_t IndexInStringTable = size_t IndexInStringTable =
FileNameRegistry.Infos[CurFilename].FilenameID; FileNameRegistry.Infos[CurFilename].FilenameID;
// Each segment starts with the offset of the filename // Each segment starts with the offset of the filename
// in the string table. // in the string table.
Asm->OutStreamer.AddComment( Asm->OutStreamer->AddComment(
"Segment for file '" + Twine(CurFilename) + "' begins"); "Segment for file '" + Twine(CurFilename) + "' begins");
MCSymbol *FileSegmentBegin = Asm->MMI->getContext().CreateTempSymbol(); MCSymbol *FileSegmentBegin = Asm->MMI->getContext().CreateTempSymbol();
Asm->OutStreamer.EmitLabel(FileSegmentBegin); Asm->OutStreamer->EmitLabel(FileSegmentBegin);
Asm->EmitInt32(8 * IndexInStringTable); Asm->EmitInt32(8 * IndexInStringTable);
// Number of PC records in the lookup table. // 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 // Full size of the segment for this filename, including the prev two
// records. // records.
FileSegmentEnd = Asm->MMI->getContext().CreateTempSymbol(); 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. // 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); Asm->EmitInt32(InstrInfo[Instr].LineNumber);
} }
if (FileSegmentEnd) if (FileSegmentEnd)
Asm->OutStreamer.EmitLabel(FileSegmentEnd); Asm->OutStreamer->EmitLabel(FileSegmentEnd);
Asm->OutStreamer.EmitLabel(LineTableEnd); Asm->OutStreamer->EmitLabel(LineTableEnd);
} }
void WinCodeViewLineTables::beginFunction(const MachineFunction *MF) { void WinCodeViewLineTables::beginFunction(const MachineFunction *MF) {

View File

@ -273,9 +273,9 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID,
MachineInstr::const_mop_iterator MOE, MachineInstr::const_mop_iterator MOE,
bool recordResult) { bool recordResult) {
MCContext &OutContext = AP.OutStreamer.getContext(); MCContext &OutContext = AP.OutStreamer->getContext();
MCSymbol *MILabel = OutContext.CreateTempSymbol(); MCSymbol *MILabel = OutContext.CreateTempSymbol();
AP.OutStreamer.EmitLabel(MILabel); AP.OutStreamer->EmitLabel(MILabel);
LocationVec Locations; LocationVec Locations;
LiveOutVec LiveOuts; LiveOutVec LiveOuts;
@ -521,8 +521,8 @@ void StackMaps::serializeToStackMapSection() {
if (CSInfos.empty()) if (CSInfos.empty())
return; return;
MCContext &OutContext = AP.OutStreamer.getContext(); MCContext &OutContext = AP.OutStreamer->getContext();
MCStreamer &OS = AP.OutStreamer; MCStreamer &OS = *AP.OutStreamer;
// Create the section. // Create the section.
const MCSection *StackMapSection = const MCSection *StackMapSection =

View File

@ -128,7 +128,7 @@ void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) {
// implementation of multiple entry points). If this doesn't occur, the // implementation of multiple entry points). If this doesn't occur, the
// linker can safely perform dead code stripping. Since LLVM never // linker can safely perform dead code stripping. Since LLVM never
// generates code that does this, it is always safe to set. // generates code that does this, it is always safe to set.
OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
SM.serializeToStackMapSection(); SM.serializeToStackMapSection();
} }
} }
@ -156,7 +156,7 @@ void AArch64AsmPrinter::EmitLOHs() {
"Label hasn't been inserted for LOH related instruction"); "Label hasn't been inserted for LOH related instruction");
MCArgs.push_back(LabelIt->second); MCArgs.push_back(LabelIt->second);
} }
OutStreamer.EmitLOHDirective(D.getKind(), MCArgs); OutStreamer->EmitLOHDirective(D.getKind(), MCArgs);
MCArgs.clear(); MCArgs.clear();
} }
} }
@ -436,7 +436,7 @@ void AArch64AsmPrinter::LowerPATCHPOINT(MCStreamer &OutStreamer, StackMaps &SM,
void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Do any auto-generated pseudo lowerings. // Do any auto-generated pseudo lowerings.
if (emitPseudoExpansionLowering(OutStreamer, MI)) if (emitPseudoExpansionLowering(*OutStreamer, MI))
return; return;
if (AArch64FI->getLOHRelated().count(MI)) { if (AArch64FI->getLOHRelated().count(MI)) {
@ -444,7 +444,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbol *LOHLabel = createTempSymbol("loh"); MCSymbol *LOHLabel = createTempSymbol("loh");
// Associate the instruction with the label // Associate the instruction with the label
LOHInstToLabel[MI] = LOHLabel; LOHInstToLabel[MI] = LOHLabel;
OutStreamer.EmitLabel(LOHLabel); OutStreamer->EmitLabel(LOHLabel);
} }
// Do any manual lowerings. // Do any manual lowerings.
@ -452,11 +452,11 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
default: default:
break; break;
case AArch64::DBG_VALUE: { case AArch64::DBG_VALUE: {
if (isVerbose() && OutStreamer.hasRawTextSupport()) { if (isVerbose() && OutStreamer->hasRawTextSupport()) {
SmallString<128> TmpStr; SmallString<128> TmpStr;
raw_svector_ostream OS(TmpStr); raw_svector_ostream OS(TmpStr);
PrintDebugValueComment(MI, OS); PrintDebugValueComment(MI, OS);
OutStreamer.EmitRawText(StringRef(OS.str())); OutStreamer->EmitRawText(StringRef(OS.str()));
} }
return; return;
} }
@ -468,7 +468,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst; MCInst TmpInst;
TmpInst.setOpcode(AArch64::BR); TmpInst.setOpcode(AArch64::BR);
TmpInst.addOperand(MCOperand::CreateReg(MI->getOperand(0).getReg())); TmpInst.addOperand(MCOperand::CreateReg(MI->getOperand(0).getReg()));
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case AArch64::TCRETURNdi: { case AArch64::TCRETURNdi: {
@ -477,7 +477,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst; MCInst TmpInst;
TmpInst.setOpcode(AArch64::B); TmpInst.setOpcode(AArch64::B);
TmpInst.addOperand(Dest); TmpInst.addOperand(Dest);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case AArch64::TLSDESC_CALLSEQ: { case AArch64::TLSDESC_CALLSEQ: {
@ -502,7 +502,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
Adrp.setOpcode(AArch64::ADRP); Adrp.setOpcode(AArch64::ADRP);
Adrp.addOperand(MCOperand::CreateReg(AArch64::X0)); Adrp.addOperand(MCOperand::CreateReg(AArch64::X0));
Adrp.addOperand(SymTLSDesc); Adrp.addOperand(SymTLSDesc);
EmitToStreamer(OutStreamer, Adrp); EmitToStreamer(*OutStreamer, Adrp);
MCInst Ldr; MCInst Ldr;
Ldr.setOpcode(AArch64::LDRXui); Ldr.setOpcode(AArch64::LDRXui);
@ -510,7 +510,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
Ldr.addOperand(MCOperand::CreateReg(AArch64::X0)); Ldr.addOperand(MCOperand::CreateReg(AArch64::X0));
Ldr.addOperand(SymTLSDescLo12); Ldr.addOperand(SymTLSDescLo12);
Ldr.addOperand(MCOperand::CreateImm(0)); Ldr.addOperand(MCOperand::CreateImm(0));
EmitToStreamer(OutStreamer, Ldr); EmitToStreamer(*OutStreamer, Ldr);
MCInst Add; MCInst Add;
Add.setOpcode(AArch64::ADDXri); Add.setOpcode(AArch64::ADDXri);
@ -518,34 +518,34 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {
Add.addOperand(MCOperand::CreateReg(AArch64::X0)); Add.addOperand(MCOperand::CreateReg(AArch64::X0));
Add.addOperand(SymTLSDescLo12); Add.addOperand(SymTLSDescLo12);
Add.addOperand(MCOperand::CreateImm(AArch64_AM::getShiftValue(0))); 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 // Emit a relocation-annotation. This expands to no code, but requests
// the following instruction gets an R_AARCH64_TLSDESC_CALL. // the following instruction gets an R_AARCH64_TLSDESC_CALL.
MCInst TLSDescCall; MCInst TLSDescCall;
TLSDescCall.setOpcode(AArch64::TLSDESCCALL); TLSDescCall.setOpcode(AArch64::TLSDESCCALL);
TLSDescCall.addOperand(Sym); TLSDescCall.addOperand(Sym);
EmitToStreamer(OutStreamer, TLSDescCall); EmitToStreamer(*OutStreamer, TLSDescCall);
MCInst Blr; MCInst Blr;
Blr.setOpcode(AArch64::BLR); Blr.setOpcode(AArch64::BLR);
Blr.addOperand(MCOperand::CreateReg(AArch64::X1)); Blr.addOperand(MCOperand::CreateReg(AArch64::X1));
EmitToStreamer(OutStreamer, Blr); EmitToStreamer(*OutStreamer, Blr);
return; return;
} }
case TargetOpcode::STACKMAP: case TargetOpcode::STACKMAP:
return LowerSTACKMAP(OutStreamer, SM, *MI); return LowerSTACKMAP(*OutStreamer, SM, *MI);
case TargetOpcode::PATCHPOINT: case TargetOpcode::PATCHPOINT:
return LowerPATCHPOINT(OutStreamer, SM, *MI); return LowerPATCHPOINT(*OutStreamer, SM, *MI);
} }
// Finally, do the automated lowerings for everything else. // Finally, do the automated lowerings for everything else.
MCInst TmpInst; MCInst TmpInst;
MCInstLowering.Lower(MI, TmpInst); MCInstLowering.Lower(MI, TmpInst);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
} }
// Force static initialization. // Force static initialization.

View File

@ -69,16 +69,16 @@ void ARMAsmPrinter::EmitFunctionBodyEnd() {
if (!InConstantPool) if (!InConstantPool)
return; return;
InConstantPool = false; InConstantPool = false;
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
} }
void ARMAsmPrinter::EmitFunctionEntryLabel() { void ARMAsmPrinter::EmitFunctionEntryLabel() {
if (AFI->isThumbFunction()) { if (AFI->isThumbFunction()) {
OutStreamer.EmitAssemblerFlag(MCAF_Code16); OutStreamer->EmitAssemblerFlag(MCAF_Code16);
OutStreamer.EmitThumbFunc(CurrentFnSym); OutStreamer->EmitThumbFunc(CurrentFnSym);
} }
OutStreamer.EmitLabel(CurrentFnSym); OutStreamer->EmitLabel(CurrentFnSym);
} }
void ARMAsmPrinter::EmitXXStructor(const Constant *CV) { void ARMAsmPrinter::EmitXXStructor(const Constant *CV) {
@ -95,7 +95,7 @@ void ARMAsmPrinter::EmitXXStructor(const Constant *CV) {
: MCSymbolRefExpr::VK_None), : MCSymbolRefExpr::VK_None),
OutContext); OutContext);
OutStreamer.EmitValue(E, Size); OutStreamer->EmitValue(E, Size);
} }
/// runOnMachineFunction - This uses the EmitInstruction() /// runOnMachineFunction - This uses the EmitInstruction()
@ -114,10 +114,10 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
: COFF::IMAGE_SYM_CLASS_EXTERNAL; : COFF::IMAGE_SYM_CLASS_EXTERNAL;
int Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT; int Type = COFF::IMAGE_SYM_DTYPE_FUNCTION << COFF::SCT_COMPLEX_TYPE_SHIFT;
OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
OutStreamer.EmitCOFFSymbolStorageClass(Scl); OutStreamer->EmitCOFFSymbolStorageClass(Scl);
OutStreamer.EmitCOFFSymbolType(Type); OutStreamer->EmitCOFFSymbolType(Type);
OutStreamer.EndCOFFSymbolDef(); OutStreamer->EndCOFFSymbolDef();
} }
// Emit the rest of the function body. // 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 // These are created per function, rather than per TU, since it's
// relatively easy to exceed the thumb branch range within a TU. // relatively easy to exceed the thumb branch range within a TU.
if (! ThumbIndirectPads.empty()) { if (! ThumbIndirectPads.empty()) {
OutStreamer.EmitAssemblerFlag(MCAF_Code16); OutStreamer->EmitAssemblerFlag(MCAF_Code16);
EmitAlignment(1); EmitAlignment(1);
for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) { for (unsigned i = 0, e = ThumbIndirectPads.size(); i < e; i++) {
OutStreamer.EmitLabel(ThumbIndirectPads[i].second); OutStreamer->EmitLabel(ThumbIndirectPads[i].second);
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tBX) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBX)
.addReg(ThumbIndirectPads[i].first) .addReg(ThumbIndirectPads[i].first)
// Add predicate operands. // Add predicate operands.
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
@ -429,14 +429,14 @@ void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
// the start mode, then restore the start mode. // the start mode, then restore the start mode.
const bool WasThumb = isThumb(StartInfo); const bool WasThumb = isThumb(StartInfo);
if (!EndInfo || WasThumb != isThumb(*EndInfo)) { if (!EndInfo || WasThumb != isThumb(*EndInfo)) {
OutStreamer.EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32); OutStreamer->EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
} }
} }
void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) { void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
Triple TT(TM.getTargetTriple()); Triple TT(TM.getTargetTriple());
// Use unified assembler syntax. // Use unified assembler syntax.
OutStreamer.EmitAssemblerFlag(MCAF_SyntaxUnified); OutStreamer->EmitAssemblerFlag(MCAF_SyntaxUnified);
// Emit ARM Build Attributes // Emit ARM Build Attributes
if (TT.isOSBinFormatELF()) if (TT.isOSBinFormatELF())
@ -450,7 +450,7 @@ void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
TT.getSubArch() == Triple::ARMSubArch_v7m || TT.getSubArch() == Triple::ARMSubArch_v7m ||
TT.getSubArch() == Triple::ARMSubArch_v6m; TT.getSubArch() == Triple::ARMSubArch_v6m;
if (!M.getModuleInlineAsm().empty() && isThumb) if (!M.getModuleInlineAsm().empty() && isThumb)
OutStreamer.EmitAssemblerFlag(MCAF_Code16); OutStreamer->EmitAssemblerFlag(MCAF_Code16);
} }
static void static void
@ -491,26 +491,26 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
if (!Stubs.empty()) { if (!Stubs.empty()) {
// Switch with ".non_lazy_symbol_pointer" directive. // Switch with ".non_lazy_symbol_pointer" directive.
OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
EmitAlignment(2); EmitAlignment(2);
for (auto &Stub : Stubs) for (auto &Stub : Stubs)
emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
Stubs = MMIMacho.GetHiddenGVStubList(); Stubs = MMIMacho.GetHiddenGVStubList();
if (!Stubs.empty()) { if (!Stubs.empty()) {
OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
EmitAlignment(2); EmitAlignment(2);
for (auto &Stub : Stubs) for (auto &Stub : Stubs)
emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
// Funny Darwin hack: This flag tells the linker that no global symbols // 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 // implementation of multiple entry points). If this doesn't occur, the
// linker can safely perform dead code stripping. Since LLVM never // linker can safely perform dead code stripping. Since LLVM never
// generates code that does this, it is always safe to set. // 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() { void ARMAsmPrinter::emitAttributes() {
MCTargetStreamer &TS = *OutStreamer.getTargetStreamer(); MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS); ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
ATS.emitTextAttribute(ARMBuildAttrs::conformance, "2.09"); ATS.emitTextAttribute(ARMBuildAttrs::conformance, "2.09");
@ -918,13 +918,13 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
// We want "(<expr> - .)", but MC doesn't have a concept of the '.' // We want "(<expr> - .)", but MC doesn't have a concept of the '.'
// label, so just emit a local label end reference that instead. // label, so just emit a local label end reference that instead.
MCSymbol *DotSym = OutContext.CreateTempSymbol(); MCSymbol *DotSym = OutContext.CreateTempSymbol();
OutStreamer.EmitLabel(DotSym); OutStreamer->EmitLabel(DotSym);
const MCExpr *DotExpr = MCSymbolRefExpr::Create(DotSym, OutContext); const MCExpr *DotExpr = MCSymbolRefExpr::Create(DotSym, OutContext);
PCRelExpr = MCBinaryExpr::CreateSub(PCRelExpr, DotExpr, OutContext); PCRelExpr = MCBinaryExpr::CreateSub(PCRelExpr, DotExpr, OutContext);
} }
Expr = MCBinaryExpr::CreateSub(Expr, PCRelExpr, OutContext); Expr = MCBinaryExpr::CreateSub(Expr, PCRelExpr, OutContext);
} }
OutStreamer.EmitValue(Expr, Size); OutStreamer->EmitValue(Expr, Size);
} }
void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) { void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) {
@ -941,10 +941,10 @@ void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) {
// Emit a label for the jump table. // Emit a label for the jump table.
MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm()); MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm());
OutStreamer.EmitLabel(JTISymbol); OutStreamer->EmitLabel(JTISymbol);
// Mark the jump table as data-in-code. // Mark the jump table as data-in-code.
OutStreamer.EmitDataRegion(MCDR_DataRegionJT32); OutStreamer->EmitDataRegion(MCDR_DataRegionJT32);
// Emit each entry of the table. // Emit each entry of the table.
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
@ -972,10 +972,10 @@ void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) {
else if (AFI->isThumbFunction()) else if (AFI->isThumbFunction())
Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(1,OutContext), Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(1,OutContext),
OutContext); OutContext);
OutStreamer.EmitValue(Expr, 4); OutStreamer->EmitValue(Expr, 4);
} }
// Mark the end of jump table data-in-code region. // Mark the end of jump table data-in-code region.
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
} }
void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) { void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) {
@ -986,7 +986,7 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) {
unsigned JTI = MO1.getIndex(); unsigned JTI = MO1.getIndex();
MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm()); MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm());
OutStreamer.EmitLabel(JTISymbol); OutStreamer->EmitLabel(JTISymbol);
// Emit each entry of the table. // Emit each entry of the table.
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo(); const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
@ -996,11 +996,11 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) {
if (MI->getOpcode() == ARM::t2TBB_JT) { if (MI->getOpcode() == ARM::t2TBB_JT) {
OffsetWidth = 1; OffsetWidth = 1;
// Mark the jump table as data-in-code. // Mark the jump table as data-in-code.
OutStreamer.EmitDataRegion(MCDR_DataRegionJT8); OutStreamer->EmitDataRegion(MCDR_DataRegionJT8);
} else if (MI->getOpcode() == ARM::t2TBH_JT) { } else if (MI->getOpcode() == ARM::t2TBH_JT) {
OffsetWidth = 2; OffsetWidth = 2;
// Mark the jump table as data-in-code. // 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) { for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
@ -1009,7 +1009,7 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) {
OutContext); OutContext);
// If this isn't a TBB or TBH, the entries are direct branch instructions. // If this isn't a TBB or TBH, the entries are direct branch instructions.
if (OffsetWidth == 4) { if (OffsetWidth == 4) {
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::t2B) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::t2B)
.addExpr(MBBSymbolExpr) .addExpr(MBBSymbolExpr)
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
@ -1030,20 +1030,20 @@ void ARMAsmPrinter::EmitJump2Table(const MachineInstr *MI) {
OutContext); OutContext);
Expr = MCBinaryExpr::CreateDiv(Expr, MCConstantExpr::Create(2, OutContext), Expr = MCBinaryExpr::CreateDiv(Expr, MCConstantExpr::Create(2, OutContext),
OutContext); OutContext);
OutStreamer.EmitValue(Expr, OffsetWidth); OutStreamer->EmitValue(Expr, OffsetWidth);
} }
// Mark the end of jump table data-in-code region. 32-bit offsets use // 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 // actual branch instructions here, so we don't mark those as a data-region
// at all. // at all.
if (OffsetWidth != 4) if (OffsetWidth != 4)
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
} }
void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) { void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
assert(MI->getFlag(MachineInstr::FrameSetup) && assert(MI->getFlag(MachineInstr::FrameSetup) &&
"Only instruction which are involved into frame setup code are allowed"); "Only instruction which are involved into frame setup code are allowed");
MCTargetStreamer &TS = *OutStreamer.getTargetStreamer(); MCTargetStreamer &TS = *OutStreamer->getTargetStreamer();
ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS); ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
const MachineFunction &MF = *MI->getParent()->getParent(); const MachineFunction &MF = *MI->getParent()->getParent();
const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo(); 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 we just ended a constant pool, mark it as such.
if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) { if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
InConstantPool = false; InConstantPool = false;
} }
@ -1198,7 +1198,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
EmitUnwindingInstruction(MI); EmitUnwindingInstruction(MI);
// Do any auto-generated pseudo lowerings. // Do any auto-generated pseudo lowerings.
if (emitPseudoExpansionLowering(OutStreamer, MI)) if (emitPseudoExpansionLowering(*OutStreamer, MI))
return; return;
assert(!convertAddSubFlagsOpcode(MI->getOpcode()) && assert(!convertAddSubFlagsOpcode(MI->getOpcode()) &&
@ -1214,7 +1214,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
case ARM::t2LEApcrel: { case ARM::t2LEApcrel: {
// FIXME: Need to also handle globals and externals // FIXME: Need to also handle globals and externals
MCSymbol *CPISymbol = GetCPISymbol(MI->getOperand(1).getIndex()); MCSymbol *CPISymbol = GetCPISymbol(MI->getOperand(1).getIndex());
EmitToStreamer(OutStreamer, MCInstBuilder(MI->getOpcode() == EmitToStreamer(*OutStreamer, MCInstBuilder(MI->getOpcode() ==
ARM::t2LEApcrel ? ARM::t2ADR ARM::t2LEApcrel ? ARM::t2ADR
: (MI->getOpcode() == ARM::tLEApcrel ? ARM::tADR : (MI->getOpcode() == ARM::tLEApcrel ? ARM::tADR
: ARM::ADR)) : ARM::ADR))
@ -1231,7 +1231,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbol *JTIPICSymbol = MCSymbol *JTIPICSymbol =
GetARMJTIPICJumpTableLabel2(MI->getOperand(1).getIndex(), GetARMJTIPICJumpTableLabel2(MI->getOperand(1).getIndex(),
MI->getOperand(2).getImm()); MI->getOperand(2).getImm());
EmitToStreamer(OutStreamer, MCInstBuilder(MI->getOpcode() == EmitToStreamer(*OutStreamer, MCInstBuilder(MI->getOpcode() ==
ARM::t2LEApcrelJT ? ARM::t2ADR ARM::t2LEApcrelJT ? ARM::t2ADR
: (MI->getOpcode() == ARM::tLEApcrelJT ? ARM::tADR : (MI->getOpcode() == ARM::tLEApcrelJT ? ARM::tADR
: ARM::ADR)) : ARM::ADR))
@ -1245,7 +1245,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Darwin call instructions are just normal call instructions with different // Darwin call instructions are just normal call instructions with different
// clobber semantics (they clobber R9). // clobber semantics (they clobber R9).
case ARM::BX_CALL: { case ARM::BX_CALL: {
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
.addReg(ARM::LR) .addReg(ARM::LR)
.addReg(ARM::PC) .addReg(ARM::PC)
// Add predicate operands. // Add predicate operands.
@ -1254,7 +1254,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Add 's' bit operand (always reg0 for this) // Add 's' bit operand (always reg0 for this)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::BX) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::BX)
.addReg(MI->getOperand(0).getReg())); .addReg(MI->getOperand(0).getReg()));
return; return;
} }
@ -1283,14 +1283,14 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
} }
// Create a link-saving branch to the Reg Indirect Jump Pad. // 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. // Predicate comes first here.
.addImm(ARMCC::AL).addReg(0) .addImm(ARMCC::AL).addReg(0)
.addExpr(MCSymbolRefExpr::Create(TRegSym, OutContext))); .addExpr(MCSymbolRefExpr::Create(TRegSym, OutContext)));
return; return;
} }
case ARM::BMOVPCRX_CALL: { case ARM::BMOVPCRX_CALL: {
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
.addReg(ARM::LR) .addReg(ARM::LR)
.addReg(ARM::PC) .addReg(ARM::PC)
// Add predicate operands. // Add predicate operands.
@ -1299,7 +1299,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Add 's' bit operand (always reg0 for this) // Add 's' bit operand (always reg0 for this)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
.addReg(ARM::PC) .addReg(ARM::PC)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
// Add predicate operands. // Add predicate operands.
@ -1310,7 +1310,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
return; return;
} }
case ARM::BMOVPCB_CALL: { case ARM::BMOVPCB_CALL: {
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVr)
.addReg(ARM::LR) .addReg(ARM::LR)
.addReg(ARM::PC) .addReg(ARM::PC)
// Add predicate operands. // Add predicate operands.
@ -1324,7 +1324,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const unsigned TF = Op.getTargetFlags(); const unsigned TF = Op.getTargetFlags();
MCSymbol *GVSym = GetARMGVSymbol(GV, TF); MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext); const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::Bcc) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::Bcc)
.addExpr(GVSymExpr) .addExpr(GVSymExpr)
// Add predicate operands. // Add predicate operands.
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
@ -1359,7 +1359,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
TmpInst.addOperand(MCOperand::CreateReg(0)); TmpInst.addOperand(MCOperand::CreateReg(0));
// Add 's' bit operand (always reg0 for this) // Add 's' bit operand (always reg0 for this)
TmpInst.addOperand(MCOperand::CreateReg(0)); TmpInst.addOperand(MCOperand::CreateReg(0));
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case ARM::MOVTi16_ga_pcrel: case ARM::MOVTi16_ga_pcrel:
@ -1391,7 +1391,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
TmpInst.addOperand(MCOperand::CreateReg(0)); TmpInst.addOperand(MCOperand::CreateReg(0));
// Add 's' bit operand (always reg0 for this) // Add 's' bit operand (always reg0 for this)
TmpInst.addOperand(MCOperand::CreateReg(0)); TmpInst.addOperand(MCOperand::CreateReg(0));
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case ARM::tPICADD: { case ARM::tPICADD: {
@ -1401,12 +1401,13 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// This adds the address of LPC0 to r0. // This adds the address of LPC0 to r0.
// Emit the label. // Emit the label.
OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), OutStreamer->EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(), MI->getOperand(2).getImm(), getFunctionNumber(),
MI->getOperand(2).getImm(),
OutContext)); OutContext));
// Form and emit the add. // 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(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(ARM::PC) .addReg(ARM::PC)
@ -1422,12 +1423,13 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// This adds the address of LPC0 to r0. // This adds the address of LPC0 to r0.
// Emit the label. // Emit the label.
OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), OutStreamer->EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(), MI->getOperand(2).getImm(), getFunctionNumber(),
MI->getOperand(2).getImm(),
OutContext)); OutContext));
// Form and emit the add. // Form and emit the add.
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDrr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDrr)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(ARM::PC) .addReg(ARM::PC)
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
@ -1453,8 +1455,9 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// a PC-relative address at the ldr instruction. // a PC-relative address at the ldr instruction.
// Emit the label. // Emit the label.
OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(), OutStreamer->EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(), MI->getOperand(2).getImm(), getFunctionNumber(),
MI->getOperand(2).getImm(),
OutContext)); OutContext));
// Form and emit the load // Form and emit the load
@ -1471,7 +1474,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
case ARM::PICLDRSB: Opcode = ARM::LDRSB; break; case ARM::PICLDRSB: Opcode = ARM::LDRSB; break;
case ARM::PICLDRSH: Opcode = ARM::LDRSH; break; case ARM::PICLDRSH: Opcode = ARM::LDRSH; break;
} }
EmitToStreamer(OutStreamer, MCInstBuilder(Opcode) EmitToStreamer(*OutStreamer, MCInstBuilder(Opcode)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(ARM::PC) .addReg(ARM::PC)
.addReg(MI->getOperand(1).getReg()) .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 this is the first entry of the pool, mark it.
if (!InConstantPool) { if (!InConstantPool) {
OutStreamer.EmitDataRegion(MCDR_DataRegion); OutStreamer->EmitDataRegion(MCDR_DataRegion);
InConstantPool = true; InConstantPool = true;
} }
OutStreamer.EmitLabel(GetCPISymbol(LabelId)); OutStreamer->EmitLabel(GetCPISymbol(LabelId));
const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx]; const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx];
if (MCPE.isMachineConstantPoolEntry()) if (MCPE.isMachineConstantPoolEntry())
@ -1508,7 +1511,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
} }
case ARM::t2BR_JT: { case ARM::t2BR_JT: {
// Lower and emit the instruction itself, then the jump table following it. // 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(ARM::PC)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
// Add predicate operands. // Add predicate operands.
@ -1521,7 +1524,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
} }
case ARM::t2TBB_JT: { case ARM::t2TBB_JT: {
// Lower and emit the instruction itself, then the jump table following it. // 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(ARM::PC)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
// Add predicate operands. // Add predicate operands.
@ -1536,7 +1539,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
} }
case ARM::t2TBH_JT: { case ARM::t2TBH_JT: {
// Lower and emit the instruction itself, then the jump table following it. // 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(ARM::PC)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
// Add predicate operands. // Add predicate operands.
@ -1563,7 +1566,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Add 's' bit operand (always reg0 for this) // Add 's' bit operand (always reg0 for this)
if (Opc == ARM::MOVr) if (Opc == ARM::MOVr)
TmpInst.addOperand(MCOperand::CreateReg(0)); TmpInst.addOperand(MCOperand::CreateReg(0));
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
// Make sure the Thumb jump table is 4-byte aligned. // Make sure the Thumb jump table is 4-byte aligned.
if (Opc == ARM::tMOVr) if (Opc == ARM::tMOVr)
@ -1593,7 +1596,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Add predicate operands. // Add predicate operands.
TmpInst.addOperand(MCOperand::CreateImm(ARMCC::AL)); TmpInst.addOperand(MCOperand::CreateImm(ARMCC::AL));
TmpInst.addOperand(MCOperand::CreateReg(0)); TmpInst.addOperand(MCOperand::CreateReg(0));
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
// Output the data for the jump table itself // Output the data for the jump table itself
EmitJumpTable(MI); EmitJumpTable(MI);
@ -1602,7 +1605,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
case ARM::BR_JTadd: { case ARM::BR_JTadd: {
// Lower and emit the instruction itself, then the jump table following it. // Lower and emit the instruction itself, then the jump table following it.
// add pc, target, idx // add pc, target, idx
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDrr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDrr)
.addReg(ARM::PC) .addReg(ARM::PC)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
@ -1617,7 +1620,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
return; return;
} }
case ARM::SPACE: case ARM::SPACE:
OutStreamer.EmitZeros(MI->getOperand(1).getImm()); OutStreamer->EmitZeros(MI->getOperand(1).getImm());
return; return;
case ARM::TRAP: { case ARM::TRAP: {
// Non-Darwin binutils don't yet support the "trap" mnemonic. // Non-Darwin binutils don't yet support the "trap" mnemonic.
@ -1625,8 +1628,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
if (!Subtarget->isTargetMachO()) { if (!Subtarget->isTargetMachO()) {
//.long 0xe7ffdefe @ trap //.long 0xe7ffdefe @ trap
uint32_t Val = 0xe7ffdefeUL; uint32_t Val = 0xe7ffdefeUL;
OutStreamer.AddComment("trap"); OutStreamer->AddComment("trap");
OutStreamer.EmitIntValue(Val, 4); OutStreamer->EmitIntValue(Val, 4);
return; return;
} }
break; break;
@ -1634,8 +1637,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
case ARM::TRAPNaCl: { case ARM::TRAPNaCl: {
//.long 0xe7fedef0 @ trap //.long 0xe7fedef0 @ trap
uint32_t Val = 0xe7fedef0UL; uint32_t Val = 0xe7fedef0UL;
OutStreamer.AddComment("trap"); OutStreamer->AddComment("trap");
OutStreamer.EmitIntValue(Val, 4); OutStreamer->EmitIntValue(Val, 4);
return; return;
} }
case ARM::tTRAP: { case ARM::tTRAP: {
@ -1644,8 +1647,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
if (!Subtarget->isTargetMachO()) { if (!Subtarget->isTargetMachO()) {
//.short 57086 @ trap //.short 57086 @ trap
uint16_t Val = 0xdefe; uint16_t Val = 0xdefe;
OutStreamer.AddComment("trap"); OutStreamer->AddComment("trap");
OutStreamer.EmitIntValue(Val, 2); OutStreamer->EmitIntValue(Val, 2);
return; return;
} }
break; break;
@ -1664,15 +1667,15 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
unsigned SrcReg = MI->getOperand(0).getReg(); unsigned SrcReg = MI->getOperand(0).getReg();
unsigned ValReg = MI->getOperand(1).getReg(); unsigned ValReg = MI->getOperand(1).getReg();
MCSymbol *Label = GetARMSJLJEHLabel(); MCSymbol *Label = GetARMSJLJEHLabel();
OutStreamer.AddComment("eh_setjmp begin"); OutStreamer->AddComment("eh_setjmp begin");
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr)
.addReg(ValReg) .addReg(ValReg)
.addReg(ARM::PC) .addReg(ARM::PC)
// Predicate. // Predicate.
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tADDi3) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDi3)
.addReg(ValReg) .addReg(ValReg)
// 's' bit operand // 's' bit operand
.addReg(ARM::CPSR) .addReg(ARM::CPSR)
@ -1682,7 +1685,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tSTRi) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tSTRi)
.addReg(ValReg) .addReg(ValReg)
.addReg(SrcReg) .addReg(SrcReg)
// The offset immediate is #4. The operand value is scaled by 4 for the // 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) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVi8) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVi8)
.addReg(ARM::R0) .addReg(ARM::R0)
.addReg(ARM::CPSR) .addReg(ARM::CPSR)
.addImm(0) .addImm(0)
@ -1701,13 +1704,13 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addReg(0)); .addReg(0));
const MCExpr *SymbolExpr = MCSymbolRefExpr::Create(Label, OutContext); const MCExpr *SymbolExpr = MCSymbolRefExpr::Create(Label, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tB) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tB)
.addExpr(SymbolExpr) .addExpr(SymbolExpr)
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
OutStreamer.AddComment("eh_setjmp end"); OutStreamer->AddComment("eh_setjmp end");
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVi8) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVi8)
.addReg(ARM::R0) .addReg(ARM::R0)
.addReg(ARM::CPSR) .addReg(ARM::CPSR)
.addImm(1) .addImm(1)
@ -1715,7 +1718,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
OutStreamer.EmitLabel(Label); OutStreamer->EmitLabel(Label);
return; return;
} }
@ -1730,8 +1733,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
unsigned SrcReg = MI->getOperand(0).getReg(); unsigned SrcReg = MI->getOperand(0).getReg();
unsigned ValReg = MI->getOperand(1).getReg(); unsigned ValReg = MI->getOperand(1).getReg();
OutStreamer.AddComment("eh_setjmp begin"); OutStreamer->AddComment("eh_setjmp begin");
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDri) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDri)
.addReg(ValReg) .addReg(ValReg)
.addReg(ARM::PC) .addReg(ARM::PC)
.addImm(8) .addImm(8)
@ -1741,7 +1744,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// 's' bit operand (always reg0 for this). // 's' bit operand (always reg0 for this).
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::STRi12) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::STRi12)
.addReg(ValReg) .addReg(ValReg)
.addReg(SrcReg) .addReg(SrcReg)
.addImm(4) .addImm(4)
@ -1749,7 +1752,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVi) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVi)
.addReg(ARM::R0) .addReg(ARM::R0)
.addImm(0) .addImm(0)
// Predicate. // Predicate.
@ -1758,7 +1761,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// 's' bit operand (always reg0 for this). // 's' bit operand (always reg0 for this).
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::ADDri) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::ADDri)
.addReg(ARM::PC) .addReg(ARM::PC)
.addReg(ARM::PC) .addReg(ARM::PC)
.addImm(0) .addImm(0)
@ -1768,8 +1771,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// 's' bit operand (always reg0 for this). // 's' bit operand (always reg0 for this).
.addReg(0)); .addReg(0));
OutStreamer.AddComment("eh_setjmp end"); OutStreamer->AddComment("eh_setjmp end");
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::MOVi) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::MOVi)
.addReg(ARM::R0) .addReg(ARM::R0)
.addImm(1) .addImm(1)
// Predicate. // Predicate.
@ -1786,7 +1789,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// bx $scratch // bx $scratch
unsigned SrcReg = MI->getOperand(0).getReg(); unsigned SrcReg = MI->getOperand(0).getReg();
unsigned ScratchReg = MI->getOperand(1).getReg(); unsigned ScratchReg = MI->getOperand(1).getReg();
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::LDRi12) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12)
.addReg(ARM::SP) .addReg(ARM::SP)
.addReg(SrcReg) .addReg(SrcReg)
.addImm(8) .addImm(8)
@ -1794,7 +1797,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::LDRi12) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12)
.addReg(ScratchReg) .addReg(ScratchReg)
.addReg(SrcReg) .addReg(SrcReg)
.addImm(4) .addImm(4)
@ -1802,7 +1805,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::LDRi12) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::LDRi12)
.addReg(ARM::R7) .addReg(ARM::R7)
.addReg(SrcReg) .addReg(SrcReg)
.addImm(0) .addImm(0)
@ -1810,7 +1813,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::BX) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::BX)
.addReg(ScratchReg) .addReg(ScratchReg)
// Predicate. // Predicate.
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
@ -1825,7 +1828,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// bx $scratch // bx $scratch
unsigned SrcReg = MI->getOperand(0).getReg(); unsigned SrcReg = MI->getOperand(0).getReg();
unsigned ScratchReg = MI->getOperand(1).getReg(); unsigned ScratchReg = MI->getOperand(1).getReg();
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tLDRi) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
.addReg(ScratchReg) .addReg(ScratchReg)
.addReg(SrcReg) .addReg(SrcReg)
// The offset immediate is #8. The operand value is scaled by 4 for the // 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) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tMOVr) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr)
.addReg(ARM::SP) .addReg(ARM::SP)
.addReg(ScratchReg) .addReg(ScratchReg)
// Predicate. // Predicate.
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tLDRi) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
.addReg(ScratchReg) .addReg(ScratchReg)
.addReg(SrcReg) .addReg(SrcReg)
.addImm(1) .addImm(1)
@ -1850,7 +1853,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tLDRi) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi)
.addReg(ARM::R7) .addReg(ARM::R7)
.addReg(SrcReg) .addReg(SrcReg)
.addImm(0) .addImm(0)
@ -1858,7 +1861,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
.addReg(0)); .addReg(0));
EmitToStreamer(OutStreamer, MCInstBuilder(ARM::tBX) EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tBX)
.addReg(ScratchReg) .addReg(ScratchReg)
// Predicate. // Predicate.
.addImm(ARMCC::AL) .addImm(ARMCC::AL)
@ -1870,7 +1873,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst; MCInst TmpInst;
LowerARMMachineInstrToMCInst(MI, TmpInst, *this); LowerARMMachineInstrToMCInst(MI, TmpInst, *this);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -205,7 +205,7 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) {
HexagonMCInstrInfo::AppendImplicitOperands(MCI); HexagonMCInstrInfo::AppendImplicitOperands(MCI);
HexagonMCInstrInfo::setPacketBegin(MCI, Index == 0); HexagonMCInstrInfo::setPacketBegin(MCI, Index == 0);
HexagonMCInstrInfo::setPacketEnd(MCI, Index == (Size - 1)); HexagonMCInstrInfo::setPacketEnd(MCI, Index == (Size - 1));
EmitToStreamer(OutStreamer, MCI); EmitToStreamer(*OutStreamer, MCI);
} }
} }
else { else {
@ -216,7 +216,7 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) {
HexagonMCInstrInfo::setPacketBegin(MCI, true); HexagonMCInstrInfo::setPacketBegin(MCI, true);
HexagonMCInstrInfo::setPacketEnd(MCI, true); HexagonMCInstrInfo::setPacketEnd(MCI, true);
} }
EmitToStreamer(OutStreamer, MCI); EmitToStreamer(*OutStreamer, MCI);
} }
return; return;

View File

@ -152,7 +152,7 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst; MCInst TmpInst;
MCInstLowering.Lower(MI, TmpInst); MCInstLowering.Lower(MI, TmpInst);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
} }
// Force static initialization. // Force static initialization.

View File

@ -55,7 +55,7 @@ using namespace llvm;
#define DEBUG_TYPE "mips-asm-printer" #define DEBUG_TYPE "mips-asm-printer"
MipsTargetStreamer &MipsAsmPrinter::getTargetStreamer() const { MipsTargetStreamer &MipsAsmPrinter::getTargetStreamer() const {
return static_cast<MipsTargetStreamer &>(*OutStreamer.getTargetStreamer()); return static_cast<MipsTargetStreamer &>(*OutStreamer->getTargetStreamer());
} }
bool MipsAsmPrinter::runOnMachineFunction(MachineFunction &MF) { 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 we just ended a constant pool, mark it as such.
if (InConstantPool && MI->getOpcode() != Mips::CONSTPOOL_ENTRY) { if (InConstantPool && MI->getOpcode() != Mips::CONSTPOOL_ENTRY) {
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
InConstantPool = false; InConstantPool = false;
} }
if (MI->getOpcode() == Mips::CONSTPOOL_ENTRY) { 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 this is the first entry of the pool, mark it.
if (!InConstantPool) { if (!InConstantPool) {
OutStreamer.EmitDataRegion(MCDR_DataRegion); OutStreamer->EmitDataRegion(MCDR_DataRegion);
InConstantPool = true; InConstantPool = true;
} }
OutStreamer.EmitLabel(GetCPISymbol(LabelId)); OutStreamer->EmitLabel(GetCPISymbol(LabelId));
const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx]; const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx];
if (MCPE.isMachineConstantPoolEntry()) if (MCPE.isMachineConstantPoolEntry())
@ -180,14 +180,14 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) {
do { do {
// Do any auto-generated pseudo lowerings. // Do any auto-generated pseudo lowerings.
if (emitPseudoExpansionLowering(OutStreamer, &*I)) if (emitPseudoExpansionLowering(*OutStreamer, &*I))
continue; continue;
if (I->getOpcode() == Mips::PseudoReturn || if (I->getOpcode() == Mips::PseudoReturn ||
I->getOpcode() == Mips::PseudoReturn64 || I->getOpcode() == Mips::PseudoReturn64 ||
I->getOpcode() == Mips::PseudoIndirectBranch || I->getOpcode() == Mips::PseudoIndirectBranch ||
I->getOpcode() == Mips::PseudoIndirectBranch64) { I->getOpcode() == Mips::PseudoIndirectBranch64) {
emitPseudoIndirectBranch(OutStreamer, &*I); emitPseudoIndirectBranch(*OutStreamer, &*I);
continue; continue;
} }
@ -204,7 +204,7 @@ void MipsAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst TmpInst0; MCInst TmpInst0;
MCInstLowering.Lower(I, TmpInst0); MCInstLowering.Lower(I, TmpInst0);
EmitToStreamer(OutStreamer, TmpInst0); EmitToStreamer(*OutStreamer, TmpInst0);
} while ((++I != E) && I->isInsideBundle()); // Delay slot check } while ((++I != E) && I->isInsideBundle()); // Delay slot check
} }
@ -338,7 +338,7 @@ void MipsAsmPrinter::EmitFunctionEntryLabel() {
TS.emitDirectiveSetNoMips16(); TS.emitDirectiveSetNoMips16();
TS.emitDirectiveEnt(*CurrentFnSym); TS.emitDirectiveEnt(*CurrentFnSym);
OutStreamer.EmitLabel(CurrentFnSym); OutStreamer->EmitLabel(CurrentFnSym);
} }
/// EmitFunctionBodyStart - Targets can override this to emit stuff before /// EmitFunctionBodyStart - Targets can override this to emit stuff before
@ -381,7 +381,7 @@ void MipsAsmPrinter::EmitFunctionBodyEnd() {
if (!InConstantPool) if (!InConstantPool)
return; return;
InConstantPool = false; InConstantPool = false;
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd); OutStreamer->EmitDataRegion(MCDR_DataRegionEnd);
} }
/// isBlockOnlyReachableByFallthough - Return true if the basic block has /// 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 // Tell the assembler which ABI we are using
std::string SectionName = std::string(".mdebug.") + getCurrentABIString(); std::string SectionName = std::string(".mdebug.") + getCurrentABIString();
OutStreamer.SwitchSection( OutStreamer->SwitchSection(
OutContext.getELFSection(SectionName, ELF::SHT_PROGBITS, 0)); OutContext.getELFSection(SectionName, ELF::SHT_PROGBITS, 0));
// NaN: At the moment we only support: // NaN: At the moment we only support:
@ -724,10 +724,10 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (ABI.IsEABI()) { if (ABI.IsEABI()) {
if (STI.isGP32bit()) if (STI.isGP32bit())
OutStreamer.SwitchSection(OutContext.getELFSection(".gcc_compiled_long32", OutStreamer->SwitchSection(OutContext.getELFSection(".gcc_compiled_long32",
ELF::SHT_PROGBITS, 0)); ELF::SHT_PROGBITS, 0));
else else
OutStreamer.SwitchSection(OutContext.getELFSection(".gcc_compiled_long64", OutStreamer->SwitchSection(OutContext.getELFSection(".gcc_compiled_long64",
ELF::SHT_PROGBITS, 0)); ELF::SHT_PROGBITS, 0));
} }
@ -760,12 +760,12 @@ void MipsAsmPrinter::emitInlineAsmStart() const {
TS.emitDirectiveSetAt(); TS.emitDirectiveSetAt();
TS.emitDirectiveSetMacro(); TS.emitDirectiveSetMacro();
TS.emitDirectiveSetReorder(); TS.emitDirectiveSetReorder();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
void MipsAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, void MipsAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
const MCSubtargetInfo *EndInfo) const { const MCSubtargetInfo *EndInfo) const {
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
getTargetStreamer().emitDirectiveSetPop(); getTargetStreamer().emitDirectiveSetPop();
} }
@ -774,7 +774,7 @@ void MipsAsmPrinter::EmitJal(const MCSubtargetInfo &STI, MCSymbol *Symbol) {
I.setOpcode(Mips::JAL); I.setOpcode(Mips::JAL);
I.addOperand( I.addOperand(
MCOperand::CreateExpr(MCSymbolRefExpr::Create(Symbol, OutContext))); MCOperand::CreateExpr(MCSymbolRefExpr::Create(Symbol, OutContext)));
OutStreamer.EmitInstruction(I, STI); OutStreamer->EmitInstruction(I, STI);
} }
void MipsAsmPrinter::EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode, void MipsAsmPrinter::EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode,
@ -782,7 +782,7 @@ void MipsAsmPrinter::EmitInstrReg(const MCSubtargetInfo &STI, unsigned Opcode,
MCInst I; MCInst I;
I.setOpcode(Opcode); I.setOpcode(Opcode);
I.addOperand(MCOperand::CreateReg(Reg)); I.addOperand(MCOperand::CreateReg(Reg));
OutStreamer.EmitInstruction(I, STI); OutStreamer->EmitInstruction(I, STI);
} }
void MipsAsmPrinter::EmitInstrRegReg(const MCSubtargetInfo &STI, void MipsAsmPrinter::EmitInstrRegReg(const MCSubtargetInfo &STI,
@ -802,7 +802,7 @@ void MipsAsmPrinter::EmitInstrRegReg(const MCSubtargetInfo &STI,
I.setOpcode(Opcode); I.setOpcode(Opcode);
I.addOperand(MCOperand::CreateReg(Reg1)); I.addOperand(MCOperand::CreateReg(Reg1));
I.addOperand(MCOperand::CreateReg(Reg2)); I.addOperand(MCOperand::CreateReg(Reg2));
OutStreamer.EmitInstruction(I, STI); OutStreamer->EmitInstruction(I, STI);
} }
void MipsAsmPrinter::EmitInstrRegRegReg(const MCSubtargetInfo &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(Reg1));
I.addOperand(MCOperand::CreateReg(Reg2)); I.addOperand(MCOperand::CreateReg(Reg2));
I.addOperand(MCOperand::CreateReg(Reg3)); I.addOperand(MCOperand::CreateReg(Reg3));
OutStreamer.EmitInstruction(I, STI); OutStreamer->EmitInstruction(I, STI);
} }
void MipsAsmPrinter::EmitMovFPIntPair(const MCSubtargetInfo &STI, void MipsAsmPrinter::EmitMovFPIntPair(const MCSubtargetInfo &STI,
@ -900,7 +900,7 @@ void MipsAsmPrinter::EmitFPCallStub(
// //
// .global xxxx // .global xxxx
// //
OutStreamer.EmitSymbolAttribute(MSymbol, MCSA_Global); OutStreamer->EmitSymbolAttribute(MSymbol, MCSA_Global);
const char *RetType; const char *RetType;
// //
// make the comment field identifying the return and parameter // make the comment field identifying the return and parameter
@ -948,23 +948,23 @@ void MipsAsmPrinter::EmitFPCallStub(
Parms = ""; Parms = "";
break; break;
} }
OutStreamer.AddComment("\t# Stub function to call " + Twine(RetType) + " " + OutStreamer->AddComment("\t# Stub function to call " + Twine(RetType) + " " +
Twine(Symbol) + " (" + Twine(Parms) + ")"); Twine(Symbol) + " (" + Twine(Parms) + ")");
// //
// probably not necessary but we save and restore the current section state // probably not necessary but we save and restore the current section state
// //
OutStreamer.PushSection(); OutStreamer->PushSection();
// //
// .section mips16.call.fpxxxx,"ax",@progbits // .section mips16.call.fpxxxx,"ax",@progbits
// //
const MCSectionELF *M = OutContext.getELFSection( const MCSectionELF *M = OutContext.getELFSection(
".mips16.call.fp." + std::string(Symbol), ELF::SHT_PROGBITS, ".mips16.call.fp." + std::string(Symbol), ELF::SHT_PROGBITS,
ELF::SHF_ALLOC | ELF::SHF_EXECINSTR); ELF::SHF_ALLOC | ELF::SHF_EXECINSTR);
OutStreamer.SwitchSection(M, nullptr); OutStreamer->SwitchSection(M, nullptr);
// //
// .align 2 // .align 2
// //
OutStreamer.EmitValueToAlignment(4); OutStreamer->EmitValueToAlignment(4);
MipsTargetStreamer &TS = getTargetStreamer(); MipsTargetStreamer &TS = getTargetStreamer();
// //
// .set nomips16 // .set nomips16
@ -982,8 +982,8 @@ void MipsAsmPrinter::EmitFPCallStub(
TS.emitDirectiveEnt(*Stub); TS.emitDirectiveEnt(*Stub);
MCSymbol *MType = MCSymbol *MType =
OutContext.GetOrCreateSymbol("__call_stub_fp_" + Twine(Symbol)); OutContext.GetOrCreateSymbol("__call_stub_fp_" + Twine(Symbol));
OutStreamer.EmitSymbolAttribute(MType, MCSA_ELF_TypeFunction); OutStreamer->EmitSymbolAttribute(MType, MCSA_ELF_TypeFunction);
OutStreamer.EmitLabel(Stub); OutStreamer->EmitLabel(Stub);
// Only handle non-pic for now. // Only handle non-pic for now.
assert(TM.getRelocationModel() != Reloc::PIC_ && assert(TM.getRelocationModel() != Reloc::PIC_ &&
@ -1022,13 +1022,13 @@ void MipsAsmPrinter::EmitFPCallStub(
EmitInstrReg(*STI, Mips::JR, Mips::S2); EmitInstrReg(*STI, Mips::JR, Mips::S2);
MCSymbol *Tmp = OutContext.CreateTempSymbol(); MCSymbol *Tmp = OutContext.CreateTempSymbol();
OutStreamer.EmitLabel(Tmp); OutStreamer->EmitLabel(Tmp);
const MCSymbolRefExpr *E = MCSymbolRefExpr::Create(Stub, OutContext); const MCSymbolRefExpr *E = MCSymbolRefExpr::Create(Stub, OutContext);
const MCSymbolRefExpr *T = MCSymbolRefExpr::Create(Tmp, OutContext); const MCSymbolRefExpr *T = MCSymbolRefExpr::Create(Tmp, OutContext);
const MCExpr *T_min_E = MCBinaryExpr::CreateSub(T, E, 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); TS.emitDirectiveEnd(x);
OutStreamer.PopSection(); OutStreamer->PopSection();
} }
void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) { void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) {
@ -1044,7 +1044,7 @@ void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) {
EmitFPCallStub(Symbol, Signature); EmitFPCallStub(Symbol, Signature);
} }
// return to the text section // return to the text section
OutStreamer.SwitchSection(OutContext.getObjectFileInfo()->getTextSection()); OutStreamer->SwitchSection(OutContext.getObjectFileInfo()->getTextSection());
} }
void MipsAsmPrinter::PrintDebugValueComment(const MachineInstr *MI, void MipsAsmPrinter::PrintDebugValueComment(const MachineInstr *MI,

View File

@ -151,7 +151,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) {
std::stringstream temp; std::stringstream temp;
temp << "\t.loc " << filenameMap[fileName] << " " << curLoc.getLine() temp << "\t.loc " << filenameMap[fileName] << " " << curLoc.getLine()
<< " " << curLoc.getCol(); << " " << curLoc.getCol();
OutStreamer.EmitRawText(temp.str()); OutStreamer->EmitRawText(temp.str());
} }
void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) { void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) {
@ -162,7 +162,7 @@ void NVPTXAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCInst Inst; MCInst Inst;
lowerToMCInst(MI, Inst); lowerToMCInst(MI, Inst);
EmitToStreamer(OutStreamer, Inst); EmitToStreamer(*OutStreamer, Inst);
} }
// Handle symbol backtracking for targets that do not support image handles // 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 { void NVPTXAsmPrinter::EmitBasicBlockStart(const MachineBasicBlock &MBB) const {
AsmPrinter::EmitBasicBlockStart(MBB); AsmPrinter::EmitBasicBlockStart(MBB);
if (isLoopHeaderOfNoUnroll(MBB)) if (isLoopHeaderOfNoUnroll(MBB))
OutStreamer.EmitRawText(StringRef("\t.pragma \"nounroll\";\n")); OutStreamer->EmitRawText(StringRef("\t.pragma \"nounroll\";\n"));
} }
void NVPTXAsmPrinter::EmitFunctionEntryLabel() { void NVPTXAsmPrinter::EmitFunctionEntryLabel() {
@ -474,37 +474,37 @@ void NVPTXAsmPrinter::EmitFunctionEntryLabel() {
if (llvm::isKernelFunction(*F)) if (llvm::isKernelFunction(*F))
emitKernelFunctionDirectives(*F, O); emitKernelFunctionDirectives(*F, O);
OutStreamer.EmitRawText(O.str()); OutStreamer->EmitRawText(O.str());
prevDebugLoc = DebugLoc(); prevDebugLoc = DebugLoc();
} }
void NVPTXAsmPrinter::EmitFunctionBodyStart() { void NVPTXAsmPrinter::EmitFunctionBodyStart() {
VRegMapping.clear(); VRegMapping.clear();
OutStreamer.EmitRawText(StringRef("{\n")); OutStreamer->EmitRawText(StringRef("{\n"));
setAndEmitFunctionVirtualRegisters(*MF); setAndEmitFunctionVirtualRegisters(*MF);
SmallString<128> Str; SmallString<128> Str;
raw_svector_ostream O(Str); raw_svector_ostream O(Str);
emitDemotedVars(MF->getFunction(), O); emitDemotedVars(MF->getFunction(), O);
OutStreamer.EmitRawText(O.str()); OutStreamer->EmitRawText(O.str());
} }
void NVPTXAsmPrinter::EmitFunctionBodyEnd() { void NVPTXAsmPrinter::EmitFunctionBodyEnd() {
OutStreamer.EmitRawText(StringRef("}\n")); OutStreamer->EmitRawText(StringRef("}\n"));
VRegMapping.clear(); VRegMapping.clear();
} }
void NVPTXAsmPrinter::emitImplicitDef(const MachineInstr *MI) const { void NVPTXAsmPrinter::emitImplicitDef(const MachineInstr *MI) const {
unsigned RegNo = MI->getOperand(0).getReg(); unsigned RegNo = MI->getOperand(0).getReg();
if (TargetRegisterInfo::isVirtualRegister(RegNo)) { if (TargetRegisterInfo::isVirtualRegister(RegNo)) {
OutStreamer.AddComment(Twine("implicit-def: ") + OutStreamer->AddComment(Twine("implicit-def: ") +
getVirtualRegisterName(RegNo)); getVirtualRegisterName(RegNo));
} else { } else {
OutStreamer.AddComment(Twine("implicit-def: ") + OutStreamer->AddComment(Twine("implicit-def: ") +
nvptxSubtarget->getRegisterInfo()->getName(RegNo)); nvptxSubtarget->getRegisterInfo()->getName(RegNo));
} }
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F, void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F,
@ -784,7 +784,7 @@ void NVPTXAsmPrinter::recordAndEmitFilenames(Module &M) {
if (filenameMap.find(Filename) != filenameMap.end()) if (filenameMap.find(Filename) != filenameMap.end())
continue; continue;
filenameMap[Filename] = i; filenameMap[Filename] = i;
OutStreamer.EmitDwarfFileDirective(i, "", Filename); OutStreamer->EmitDwarfFileDirective(i, "", Filename);
++i; ++i;
} }
@ -830,19 +830,19 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) {
// Emit header before any dwarf directives are emitted below. // Emit header before any dwarf directives are emitted below.
emitHeader(M, OS1, STI); emitHeader(M, OS1, STI);
OutStreamer.EmitRawText(OS1.str()); OutStreamer->EmitRawText(OS1.str());
// Already commented out // Already commented out
//bool Result = AsmPrinter::doInitialization(M); //bool Result = AsmPrinter::doInitialization(M);
// Emit module-level inline asm if it exists. // Emit module-level inline asm if it exists.
if (!M.getModuleInlineAsm().empty()) { if (!M.getModuleInlineAsm().empty()) {
OutStreamer.AddComment("Start of file scope inline assembly"); OutStreamer->AddComment("Start of file scope inline assembly");
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
OutStreamer.EmitRawText(StringRef(M.getModuleInlineAsm())); OutStreamer->EmitRawText(StringRef(M.getModuleInlineAsm()));
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
OutStreamer.AddComment("End of file scope inline assembly"); OutStreamer->AddComment("End of file scope inline assembly");
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
// If we're not NVCL we're CUDA, go ahead and emit filenames. // 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'; OS2 << '\n';
OutStreamer.EmitRawText(OS2.str()); OutStreamer->EmitRawText(OS2.str());
} }
void NVPTXAsmPrinter::emitHeader(Module &M, raw_ostream &O, 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) { void NVPTXAsmPrinter::printFPConstant(const ConstantFP *Fp, raw_ostream &O) {
@ -2087,7 +2087,7 @@ void NVPTXAsmPrinter::emitSrcInText(StringRef filename, unsigned line) {
temp << " "; temp << " ";
temp << reader->readLine(line); temp << reader->readLine(line);
temp << "\n"; temp << "\n";
this->OutStreamer.EmitRawText(temp.str()); this->OutStreamer->EmitRawText(temp.str());
} }
LineReader *NVPTXAsmPrinter::getReader(std::string filename) { LineReader *NVPTXAsmPrinter::getReader(std::string filename) {

View File

@ -427,7 +427,7 @@ void PPCAsmPrinter::EmitTlsCall(const MachineInstr *MI,
const GlobalValue *GValue = MO.getGlobal(); const GlobalValue *GValue = MO.getGlobal();
MCSymbol *MOSymbol = getSymbol(GValue); MCSymbol *MOSymbol = getSymbol(GValue);
const MCExpr *SymVar = MCSymbolRefExpr::Create(MOSymbol, VK, OutContext); const MCExpr *SymVar = MCSymbolRefExpr::Create(MOSymbol, VK, OutContext);
EmitToStreamer(OutStreamer, EmitToStreamer(*OutStreamer,
MCInstBuilder(Subtarget->isPPC64() ? MCInstBuilder(Subtarget->isPPC64() ?
PPC::BL8_NOP_TLS : PPC::BL_TLS) PPC::BL8_NOP_TLS : PPC::BL_TLS)
.addExpr(TlsRef) .addExpr(TlsRef)
@ -450,9 +450,9 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
case TargetOpcode::DBG_VALUE: case TargetOpcode::DBG_VALUE:
llvm_unreachable("Should be handled target independently"); llvm_unreachable("Should be handled target independently");
case TargetOpcode::STACKMAP: case TargetOpcode::STACKMAP:
return LowerSTACKMAP(OutStreamer, SM, *MI); return LowerSTACKMAP(*OutStreamer, SM, *MI);
case TargetOpcode::PATCHPOINT: case TargetOpcode::PATCHPOINT:
return LowerPATCHPOINT(OutStreamer, SM, *MI); return LowerPATCHPOINT(*OutStreamer, SM, *MI);
case PPC::MoveGOTtoLR: { case PPC::MoveGOTtoLR: {
// Transform %LR = MoveGOTtoLR // Transform %LR = MoveGOTtoLR
@ -471,7 +471,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
OutContext); OutContext);
// Emit the 'bl'. // Emit the 'bl'.
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BL).addExpr(OffsExpr));
return; return;
} }
case PPC::MovePCtoLR: case PPC::MovePCtoLR:
@ -483,13 +483,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbol *PICBase = MF->getPICBaseSymbol(); MCSymbol *PICBase = MF->getPICBaseSymbol();
// Emit the 'bl'. // 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 // FIXME: We would like an efficient form for this, so we don't have to do
// a lot of extra uniquing. // a lot of extra uniquing.
.addExpr(MCSymbolRefExpr::Create(PICBase, OutContext))); .addExpr(MCSymbolRefExpr::Create(PICBase, OutContext)));
// Emit the label. // Emit the label.
OutStreamer.EmitLabel(PICBase); OutStreamer->EmitLabel(PICBase);
return; return;
} }
case PPC::UpdateGBR: { case PPC::UpdateGBR: {
@ -515,13 +515,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCOperand::CreateExpr(MCBinaryExpr::CreateSub(Exp, PB, OutContext)); MCOperand::CreateExpr(MCBinaryExpr::CreateSub(Exp, PB, OutContext));
TmpInst.getOperand(0) = TR; TmpInst.getOperand(0) = TR;
TmpInst.getOperand(2) = PICR; TmpInst.getOperand(2) = PICR;
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
TmpInst.setOpcode(PPC::ADD4); TmpInst.setOpcode(PPC::ADD4);
TmpInst.getOperand(0) = PICR; TmpInst.getOperand(0) = PICR;
TmpInst.getOperand(1) = TR; TmpInst.getOperand(1) = TR;
TmpInst.getOperand(2) = PICR; TmpInst.getOperand(2) = PICR;
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case PPC::LWZtoc: { case PPC::LWZtoc: {
@ -562,7 +562,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
Exp = MCBinaryExpr::CreateSub(Exp, PB, OutContext); Exp = MCBinaryExpr::CreateSub(Exp, PB, OutContext);
TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
} }
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case PPC::LDtocJTI: case PPC::LDtocJTI:
@ -595,7 +595,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbolRefExpr::Create(TOCEntry, MCSymbolRefExpr::VK_PPC_TOC, MCSymbolRefExpr::Create(TOCEntry, MCSymbolRefExpr::VK_PPC_TOC,
OutContext); OutContext);
TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
@ -642,7 +642,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_HA, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_HA,
OutContext); OutContext);
TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp); TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case PPC::LDtocL: { case PPC::LDtocL: {
@ -684,7 +684,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO,
OutContext); OutContext);
TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case PPC::ADDItocL: { case PPC::ADDItocL: {
@ -718,7 +718,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_TOC_LO,
OutContext); OutContext);
TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp); TmpInst.getOperand(2) = MCOperand::CreateExpr(Exp);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
case PPC::ADDISgotTprelHA: { case PPC::ADDISgotTprelHA: {
@ -731,7 +731,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const MCExpr *SymGotTprel = const MCExpr *SymGotTprel =
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA,
OutContext); OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
.addExpr(SymGotTprel)); .addExpr(SymGotTprel));
@ -751,7 +751,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO,
OutContext); OutContext);
TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp); TmpInst.getOperand(1) = MCOperand::CreateExpr(Exp);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
return; return;
} }
@ -760,7 +760,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbol *GOTRef = OutContext.CreateTempSymbol(); MCSymbol *GOTRef = OutContext.CreateTempSymbol();
MCSymbol *NextInstr = 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 // FIXME: We would like an efficient form for this, so we don't have to do
// a lot of extra uniquing. // a lot of extra uniquing.
.addExpr(MCSymbolRefExpr::Create(NextInstr, OutContext))); .addExpr(MCSymbolRefExpr::Create(NextInstr, OutContext)));
@ -768,16 +768,16 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(GOTSymbol, OutContext), MCBinaryExpr::CreateSub(MCSymbolRefExpr::Create(GOTSymbol, OutContext),
MCSymbolRefExpr::Create(GOTRef, OutContext), MCSymbolRefExpr::Create(GOTRef, OutContext),
OutContext); OutContext);
OutStreamer.EmitLabel(GOTRef); OutStreamer->EmitLabel(GOTRef);
OutStreamer.EmitValue(OffsExpr, 4); OutStreamer->EmitValue(OffsExpr, 4);
OutStreamer.EmitLabel(NextInstr); OutStreamer->EmitLabel(NextInstr);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MFLR) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR)
.addReg(MI->getOperand(0).getReg())); .addReg(MI->getOperand(0).getReg()));
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::LWZ) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LWZ)
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
.addImm(0) .addImm(0)
.addReg(MI->getOperand(0).getReg())); .addReg(MI->getOperand(0).getReg()));
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADD4) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADD4)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
.addReg(MI->getOperand(0).getReg())); .addReg(MI->getOperand(0).getReg()));
@ -791,10 +791,10 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const MCExpr *SymGotTlsHA = const MCExpr *SymGotTlsHA =
MCSymbolRefExpr::Create(GOTSymbol, MCSymbolRefExpr::VK_PPC_HA, MCSymbolRefExpr::Create(GOTSymbol, MCSymbolRefExpr::VK_PPC_HA,
OutContext); OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::LI) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LI)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addExpr(SymGotTlsL)); .addExpr(SymGotTlsL));
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addExpr(SymGotTlsHA)); .addExpr(SymGotTlsHA));
@ -810,7 +810,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const MCExpr *SymGotTlsGD = const MCExpr *SymGotTlsGD =
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA,
OutContext); OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
.addExpr(SymGotTlsGD)); .addExpr(SymGotTlsGD));
@ -829,7 +829,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MOSymbol, Subtarget->isPPC64() ? MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO MOSymbol, Subtarget->isPPC64() ? MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO
: MCSymbolRefExpr::VK_PPC_GOT_TLSGD, : MCSymbolRefExpr::VK_PPC_GOT_TLSGD,
OutContext); OutContext);
EmitToStreamer(OutStreamer, EmitToStreamer(*OutStreamer,
MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI) MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
@ -855,7 +855,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const MCExpr *SymGotTlsLD = const MCExpr *SymGotTlsLD =
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA,
OutContext); OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS8) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS8)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
.addExpr(SymGotTlsLD)); .addExpr(SymGotTlsLD));
@ -874,7 +874,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MOSymbol, Subtarget->isPPC64() ? MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO MOSymbol, Subtarget->isPPC64() ? MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO
: MCSymbolRefExpr::VK_PPC_GOT_TLSLD, : MCSymbolRefExpr::VK_PPC_GOT_TLSLD,
OutContext); OutContext);
EmitToStreamer(OutStreamer, EmitToStreamer(*OutStreamer,
MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI) MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
@ -903,7 +903,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_HA, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_HA,
OutContext); OutContext);
EmitToStreamer( EmitToStreamer(
OutStreamer, *OutStreamer,
MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDIS8 : PPC::ADDIS) MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDIS8 : PPC::ADDIS)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(Subtarget->isPPC64() ? PPC::X3 : PPC::R3) .addReg(Subtarget->isPPC64() ? PPC::X3 : PPC::R3)
@ -922,7 +922,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
const MCExpr *SymDtprel = const MCExpr *SymDtprel =
MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_LO, MCSymbolRefExpr::Create(MOSymbol, MCSymbolRefExpr::VK_PPC_DTPREL_LO,
OutContext); OutContext);
EmitToStreamer(OutStreamer, EmitToStreamer(*OutStreamer,
MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI) MCInstBuilder(Subtarget->isPPC64() ? PPC::ADDI8 : PPC::ADDI)
.addReg(MI->getOperand(0).getReg()) .addReg(MI->getOperand(0).getReg())
.addReg(MI->getOperand(1).getReg()) .addReg(MI->getOperand(1).getReg())
@ -936,9 +936,9 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Into: %R3 = MFCR ;; cr7 // Into: %R3 = MFCR ;; cr7
unsigned NewOpcode = unsigned NewOpcode =
MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8; MI->getOpcode() == PPC::MFOCRF ? PPC::MFCR : PPC::MFCR8;
OutStreamer.AddComment(PPCInstPrinter:: OutStreamer->AddComment(PPCInstPrinter::
getRegisterName(MI->getOperand(1).getReg())); getRegisterName(MI->getOperand(1).getReg()));
EmitToStreamer(OutStreamer, MCInstBuilder(NewOpcode) EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
.addReg(MI->getOperand(0).getReg())); .addReg(MI->getOperand(0).getReg()));
return; return;
} }
@ -952,9 +952,9 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8; MI->getOpcode() == PPC::MTOCRF ? PPC::MTCRF : PPC::MTCRF8;
unsigned Mask = 0x80 >> OutContext.getRegisterInfo() unsigned Mask = 0x80 >> OutContext.getRegisterInfo()
->getEncodingValue(MI->getOperand(0).getReg()); ->getEncodingValue(MI->getOperand(0).getReg());
OutStreamer.AddComment(PPCInstPrinter:: OutStreamer->AddComment(PPCInstPrinter::
getRegisterName(MI->getOperand(0).getReg())); getRegisterName(MI->getOperand(0).getReg()));
EmitToStreamer(OutStreamer, MCInstBuilder(NewOpcode) EmitToStreamer(*OutStreamer, MCInstBuilder(NewOpcode)
.addImm(Mask) .addImm(Mask)
.addReg(MI->getOperand(1).getReg())); .addReg(MI->getOperand(1).getReg()));
return; return;
@ -982,13 +982,13 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
} }
LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, isDarwin); LowerPPCMachineInstrToMCInst(MI, TmpInst, *this, isDarwin);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
} }
void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) { void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (static_cast<const PPCTargetMachine &>(TM).isELFv2ABI()) { if (static_cast<const PPCTargetMachine &>(TM).isELFv2ABI()) {
PPCTargetStreamer *TS = PPCTargetStreamer *TS =
static_cast<PPCTargetStreamer *>(OutStreamer.getTargetStreamer()); static_cast<PPCTargetStreamer *>(OutStreamer->getTargetStreamer());
if (TS) if (TS)
TS->emitAbiVersion(2); TS->emitAbiVersion(2);
@ -1001,13 +1001,13 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (M.getPICLevel() == PICLevel::Small) if (M.getPICLevel() == PICLevel::Small)
return AsmPrinter::EmitStartOfAsmFile(M); return AsmPrinter::EmitStartOfAsmFile(M);
OutStreamer.SwitchSection(OutContext.getELFSection( OutStreamer->SwitchSection(OutContext.getELFSection(
".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC)); ".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC));
MCSymbol *TOCSym = OutContext.GetOrCreateSymbol(Twine(".LTOC")); MCSymbol *TOCSym = OutContext.GetOrCreateSymbol(Twine(".LTOC"));
MCSymbol *CurrentPos = OutContext.CreateTempSymbol(); 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 // The GOT pointer points to the middle of the GOT, in order to reference the
// entire 64kB range. 0x8000 is the midpoint. // entire 64kB range. 0x8000 is the midpoint.
@ -1016,9 +1016,9 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) {
MCConstantExpr::Create(0x8000, OutContext), MCConstantExpr::Create(0x8000, OutContext),
OutContext); OutContext);
OutStreamer.EmitAssignment(TOCSym, tocExpr); OutStreamer->EmitAssignment(TOCSym, tocExpr);
OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
} }
void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
@ -1033,7 +1033,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
if (PPCFI->usesPICBase()) { if (PPCFI->usesPICBase()) {
MCSymbol *RelocSymbol = PPCFI->getPICOffsetSymbol(); MCSymbol *RelocSymbol = PPCFI->getPICOffsetSymbol();
MCSymbol *PICBase = MF->getPICBaseSymbol(); MCSymbol *PICBase = MF->getPICBaseSymbol();
OutStreamer.EmitLabel(RelocSymbol); OutStreamer->EmitLabel(RelocSymbol);
const MCExpr *OffsExpr = const MCExpr *OffsExpr =
MCBinaryExpr::CreateSub( MCBinaryExpr::CreateSub(
@ -1041,8 +1041,8 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
OutContext), OutContext),
MCSymbolRefExpr::Create(PICBase, OutContext), MCSymbolRefExpr::Create(PICBase, OutContext),
OutContext); OutContext);
OutStreamer.EmitValue(OffsExpr, 4); OutStreamer->EmitValue(OffsExpr, 4);
OutStreamer.EmitLabel(CurrentFnSym); OutStreamer->EmitLabel(CurrentFnSym);
return; return;
} else } else
return AsmPrinter::EmitFunctionEntryLabel(); return AsmPrinter::EmitFunctionEntryLabel();
@ -1053,25 +1053,25 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
return AsmPrinter::EmitFunctionEntryLabel(); return AsmPrinter::EmitFunctionEntryLabel();
// Emit an official procedure descriptor. // Emit an official procedure descriptor.
MCSectionSubPair Current = OutStreamer.getCurrentSection(); MCSectionSubPair Current = OutStreamer->getCurrentSection();
const MCSectionELF *Section = OutStreamer.getContext().getELFSection( const MCSectionELF *Section = OutStreamer->getContext().getELFSection(
".opd", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); ".opd", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
OutStreamer.SwitchSection(Section); OutStreamer->SwitchSection(Section);
OutStreamer.EmitLabel(CurrentFnSym); OutStreamer->EmitLabel(CurrentFnSym);
OutStreamer.EmitValueToAlignment(8); OutStreamer->EmitValueToAlignment(8);
MCSymbol *Symbol1 = CurrentFnSymForSize; MCSymbol *Symbol1 = CurrentFnSymForSize;
// Generates a R_PPC64_ADDR64 (from FK_DATA_8) relocation for the function // Generates a R_PPC64_ADDR64 (from FK_DATA_8) relocation for the function
// entry point. // entry point.
OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext), OutStreamer->EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext),
8 /*size*/); 8 /*size*/);
MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC.")); MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC."));
// Generates a R_PPC64_TOC relocation for TOC base insertion. // Generates a R_PPC64_TOC relocation for TOC base insertion.
OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol2, OutStreamer->EmitValue(
MCSymbolRefExpr::VK_PPC_TOCBASE, OutContext), MCSymbolRefExpr::Create(Symbol2, MCSymbolRefExpr::VK_PPC_TOCBASE, OutContext),
8/*size*/); 8/*size*/);
// Emit a null environment pointer. // Emit a null environment pointer.
OutStreamer.EmitIntValue(0, 8 /* size */); OutStreamer->EmitIntValue(0, 8 /* size */);
OutStreamer.SwitchSection(Current.first, Current.second); OutStreamer->SwitchSection(Current.first, Current.second);
} }
@ -1081,27 +1081,27 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
bool isPPC64 = TD->getPointerSizeInBits() == 64; bool isPPC64 = TD->getPointerSizeInBits() == 64;
PPCTargetStreamer &TS = PPCTargetStreamer &TS =
static_cast<PPCTargetStreamer &>(*OutStreamer.getTargetStreamer()); static_cast<PPCTargetStreamer &>(*OutStreamer->getTargetStreamer());
if (!TOC.empty()) { if (!TOC.empty()) {
const MCSectionELF *Section; const MCSectionELF *Section;
if (isPPC64) if (isPPC64)
Section = OutStreamer.getContext().getELFSection( Section = OutStreamer->getContext().getELFSection(
".toc", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); ".toc", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
else else
Section = OutStreamer.getContext().getELFSection( Section = OutStreamer->getContext().getELFSection(
".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC); ".got2", ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
OutStreamer.SwitchSection(Section); OutStreamer->SwitchSection(Section);
for (MapVector<MCSymbol*, MCSymbol*>::iterator I = TOC.begin(), for (MapVector<MCSymbol*, MCSymbol*>::iterator I = TOC.begin(),
E = TOC.end(); I != E; ++I) { E = TOC.end(); I != E; ++I) {
OutStreamer.EmitLabel(I->second); OutStreamer->EmitLabel(I->second);
MCSymbol *S = I->first; MCSymbol *S = I->first;
if (isPPC64) if (isPPC64)
TS.emitTCEntry(*S); TS.emitTCEntry(*S);
else else
OutStreamer.EmitSymbolValue(S, 4); OutStreamer->EmitSymbolValue(S, 4);
} }
} }
@ -1131,7 +1131,7 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() {
&& !MF->getRegInfo().use_empty(PPC::X2)) { && !MF->getRegInfo().use_empty(PPC::X2)) {
MCSymbol *GlobalEntryLabel = OutContext.CreateTempSymbol(); MCSymbol *GlobalEntryLabel = OutContext.CreateTempSymbol();
OutStreamer.EmitLabel(GlobalEntryLabel); OutStreamer->EmitLabel(GlobalEntryLabel);
const MCSymbolRefExpr *GlobalEntryLabelExp = const MCSymbolRefExpr *GlobalEntryLabelExp =
MCSymbolRefExpr::Create(GlobalEntryLabel, OutContext); MCSymbolRefExpr::Create(GlobalEntryLabel, OutContext);
@ -1142,20 +1142,20 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() {
const MCExpr *TOCDeltaHi = const MCExpr *TOCDeltaHi =
PPCMCExpr::CreateHa(TOCDeltaExpr, false, OutContext); PPCMCExpr::CreateHa(TOCDeltaExpr, false, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
.addReg(PPC::X2) .addReg(PPC::X2)
.addReg(PPC::X12) .addReg(PPC::X12)
.addExpr(TOCDeltaHi)); .addExpr(TOCDeltaHi));
const MCExpr *TOCDeltaLo = const MCExpr *TOCDeltaLo =
PPCMCExpr::CreateLo(TOCDeltaExpr, false, OutContext); PPCMCExpr::CreateLo(TOCDeltaExpr, false, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDI) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDI)
.addReg(PPC::X2) .addReg(PPC::X2)
.addReg(PPC::X2) .addReg(PPC::X2)
.addExpr(TOCDeltaLo)); .addExpr(TOCDeltaLo));
MCSymbol *LocalEntryLabel = OutContext.CreateTempSymbol(); MCSymbol *LocalEntryLabel = OutContext.CreateTempSymbol();
OutStreamer.EmitLabel(LocalEntryLabel); OutStreamer->EmitLabel(LocalEntryLabel);
const MCSymbolRefExpr *LocalEntryLabelExp = const MCSymbolRefExpr *LocalEntryLabelExp =
MCSymbolRefExpr::Create(LocalEntryLabel, OutContext); MCSymbolRefExpr::Create(LocalEntryLabel, OutContext);
const MCExpr *LocalOffsetExp = const MCExpr *LocalOffsetExp =
@ -1163,7 +1163,7 @@ void PPCLinuxAsmPrinter::EmitFunctionBodyStart() {
GlobalEntryLabelExp, OutContext); GlobalEntryLabelExp, OutContext);
PPCTargetStreamer *TS = PPCTargetStreamer *TS =
static_cast<PPCTargetStreamer *>(OutStreamer.getTargetStreamer()); static_cast<PPCTargetStreamer *>(OutStreamer->getTargetStreamer());
if (TS) if (TS)
TS->emitLocalEntry(CurrentFnSym, LocalOffsetExp); 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 // the PPC64 ELF ABI (this is a low-priority item because GDB does not
// currently make use of these fields). // currently make use of these fields).
if (Subtarget->isPPC64()) { if (Subtarget->isPPC64()) {
OutStreamer.EmitIntValue(0, 4/*size*/); OutStreamer->EmitIntValue(0, 4/*size*/);
OutStreamer.EmitIntValue(0, 8/*size*/); OutStreamer->EmitIntValue(0, 8/*size*/);
} }
} }
@ -1232,28 +1232,28 @@ void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) {
assert(Directive < array_lengthof(CPUDirectives) && assert(Directive < array_lengthof(CPUDirectives) &&
"CPUDirectives[] might not be up-to-date!"); "CPUDirectives[] might not be up-to-date!");
PPCTargetStreamer &TStreamer = PPCTargetStreamer &TStreamer =
*static_cast<PPCTargetStreamer *>(OutStreamer.getTargetStreamer()); *static_cast<PPCTargetStreamer *>(OutStreamer->getTargetStreamer());
TStreamer.emitMachine(CPUDirectives[Directive]); TStreamer.emitMachine(CPUDirectives[Directive]);
// Prime text sections so they are adjacent. This reduces the likelihood a // Prime text sections so they are adjacent. This reduces the likelihood a
// large data or debug section causes a branch to exceed 16M limit. // large data or debug section causes a branch to exceed 16M limit.
const TargetLoweringObjectFileMachO &TLOFMacho = const TargetLoweringObjectFileMachO &TLOFMacho =
static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering()); static_cast<const TargetLoweringObjectFileMachO &>(getObjFileLowering());
OutStreamer.SwitchSection(TLOFMacho.getTextCoalSection()); OutStreamer->SwitchSection(TLOFMacho.getTextCoalSection());
if (TM.getRelocationModel() == Reloc::PIC_) { if (TM.getRelocationModel() == Reloc::PIC_) {
OutStreamer.SwitchSection( OutStreamer->SwitchSection(
OutContext.getMachOSection("__TEXT", "__picsymbolstub1", OutContext.getMachOSection("__TEXT", "__picsymbolstub1",
MachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
32, SectionKind::getText())); 32, SectionKind::getText()));
} else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) { } else if (TM.getRelocationModel() == Reloc::DynamicNoPIC) {
OutStreamer.SwitchSection( OutStreamer->SwitchSection(
OutContext.getMachOSection("__TEXT","__symbol_stub1", OutContext.getMachOSection("__TEXT","__symbol_stub1",
MachO::S_SYMBOL_STUBS | MachO::S_SYMBOL_STUBS |
MachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
16, SectionKind::getText())); 16, SectionKind::getText()));
} }
OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
} }
static MCSymbol *GetLazyPtr(MCSymbol *Sym, MCContext &Ctx) { static MCSymbol *GetLazyPtr(MCSymbol *Sym, MCContext &Ctx) {
@ -1295,7 +1295,7 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
MachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
32, SectionKind::getText()); 32, SectionKind::getText());
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
OutStreamer.SwitchSection(StubSection); OutStreamer->SwitchSection(StubSection);
EmitAlignment(4); EmitAlignment(4);
MCSymbol *Stub = Stubs[i].first; MCSymbol *Stub = Stubs[i].first;
@ -1303,8 +1303,8 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext); MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext);
MCSymbol *AnonSymbol = GetAnonSym(Stub, OutContext); MCSymbol *AnonSymbol = GetAnonSym(Stub, OutContext);
OutStreamer.EmitLabel(Stub); OutStreamer->EmitLabel(Stub);
OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
const MCExpr *Anon = MCSymbolRefExpr::Create(AnonSymbol, OutContext); const MCExpr *Anon = MCSymbolRefExpr::Create(AnonSymbol, OutContext);
const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext); const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext);
@ -1312,48 +1312,48 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
MCBinaryExpr::CreateSub(LazyPtrExpr, Anon, OutContext); MCBinaryExpr::CreateSub(LazyPtrExpr, Anon, OutContext);
// mflr r0 // mflr r0
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R0)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R0));
// bcl 20, 31, AnonSymbol // bcl 20, 31, AnonSymbol
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BCLalways).addExpr(Anon)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCLalways).addExpr(Anon));
OutStreamer.EmitLabel(AnonSymbol); OutStreamer->EmitLabel(AnonSymbol);
// mflr r11 // mflr r11
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R11)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MFLR).addReg(PPC::R11));
// addis r11, r11, ha16(LazyPtr - AnonSymbol) // addis r11, r11, ha16(LazyPtr - AnonSymbol)
const MCExpr *SubHa16 = PPCMCExpr::CreateHa(Sub, true, OutContext); const MCExpr *SubHa16 = PPCMCExpr::CreateHa(Sub, true, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::ADDIS) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::ADDIS)
.addReg(PPC::R11) .addReg(PPC::R11)
.addReg(PPC::R11) .addReg(PPC::R11)
.addExpr(SubHa16)); .addExpr(SubHa16));
// mtlr r0 // mtlr r0
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MTLR).addReg(PPC::R0)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTLR).addReg(PPC::R0));
// ldu r12, lo16(LazyPtr - AnonSymbol)(r11) // ldu r12, lo16(LazyPtr - AnonSymbol)(r11)
// lwzu r12, lo16(LazyPtr - AnonSymbol)(r11) // lwzu r12, lo16(LazyPtr - AnonSymbol)(r11)
const MCExpr *SubLo16 = PPCMCExpr::CreateLo(Sub, true, OutContext); 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) .addReg(PPC::R12)
.addExpr(SubLo16).addExpr(SubLo16) .addExpr(SubLo16).addExpr(SubLo16)
.addReg(PPC::R11)); .addReg(PPC::R11));
// mtctr r12 // mtctr r12
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12));
// bctr // bctr
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BCTR)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTR));
OutStreamer.SwitchSection(LSPSection); OutStreamer->SwitchSection(LSPSection);
OutStreamer.EmitLabel(LazyPtr); OutStreamer->EmitLabel(LazyPtr);
OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
MCSymbol *DyldStubBindingHelper = MCSymbol *DyldStubBindingHelper =
OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper")); OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper"));
if (isPPC64) { if (isPPC64) {
// .quad dyld_stub_binding_helper // .quad dyld_stub_binding_helper
OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 8); OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 8);
} else { } else {
// .long dyld_stub_binding_helper // .long dyld_stub_binding_helper
OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 4); OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 4);
} }
} }
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
return; return;
} }
@ -1368,15 +1368,15 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext); MCSymbol *LazyPtr = GetLazyPtr(Stub, OutContext);
const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext); const MCExpr *LazyPtrExpr = MCSymbolRefExpr::Create(LazyPtr, OutContext);
OutStreamer.SwitchSection(StubSection); OutStreamer->SwitchSection(StubSection);
EmitAlignment(4); EmitAlignment(4);
OutStreamer.EmitLabel(Stub); OutStreamer->EmitLabel(Stub);
OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
// lis r11, ha16(LazyPtr) // lis r11, ha16(LazyPtr)
const MCExpr *LazyPtrHa16 = const MCExpr *LazyPtrHa16 =
PPCMCExpr::CreateHa(LazyPtrExpr, true, OutContext); PPCMCExpr::CreateHa(LazyPtrExpr, true, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::LIS) EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::LIS)
.addReg(PPC::R11) .addReg(PPC::R11)
.addExpr(LazyPtrHa16)); .addExpr(LazyPtrHa16));
@ -1384,32 +1384,32 @@ EmitFunctionStubs(const MachineModuleInfoMachO::SymbolListTy &Stubs) {
// lwzu r12, lo16(LazyPtr)(r11) // lwzu r12, lo16(LazyPtr)(r11)
const MCExpr *LazyPtrLo16 = const MCExpr *LazyPtrLo16 =
PPCMCExpr::CreateLo(LazyPtrExpr, true, OutContext); PPCMCExpr::CreateLo(LazyPtrExpr, true, OutContext);
EmitToStreamer(OutStreamer, MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU) EmitToStreamer(*OutStreamer, MCInstBuilder(isPPC64 ? PPC::LDU : PPC::LWZU)
.addReg(PPC::R12) .addReg(PPC::R12)
.addExpr(LazyPtrLo16).addExpr(LazyPtrLo16) .addExpr(LazyPtrLo16).addExpr(LazyPtrLo16)
.addReg(PPC::R11)); .addReg(PPC::R11));
// mtctr r12 // mtctr r12
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::MTCTR).addReg(PPC::R12));
// bctr // bctr
EmitToStreamer(OutStreamer, MCInstBuilder(PPC::BCTR)); EmitToStreamer(*OutStreamer, MCInstBuilder(PPC::BCTR));
OutStreamer.SwitchSection(LSPSection); OutStreamer->SwitchSection(LSPSection);
OutStreamer.EmitLabel(LazyPtr); OutStreamer->EmitLabel(LazyPtr);
OutStreamer.EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol); OutStreamer->EmitSymbolAttribute(RawSym, MCSA_IndirectSymbol);
MCSymbol *DyldStubBindingHelper = MCSymbol *DyldStubBindingHelper =
OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper")); OutContext.GetOrCreateSymbol(StringRef("dyld_stub_binding_helper"));
if (isPPC64) { if (isPPC64) {
// .quad dyld_stub_binding_helper // .quad dyld_stub_binding_helper
OutStreamer.EmitSymbolValue(DyldStubBindingHelper, 8); OutStreamer->EmitSymbolValue(DyldStubBindingHelper, 8);
} else { } else {
// .long dyld_stub_binding_helper // .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. // Output macho stubs for external and common global variables.
if (!Stubs.empty()) { if (!Stubs.empty()) {
// Switch with ".non_lazy_symbol_pointer" directive. // Switch with ".non_lazy_symbol_pointer" directive.
OutStreamer.SwitchSection(TLOFMacho.getNonLazySymbolPointerSection()); OutStreamer->SwitchSection(TLOFMacho.getNonLazySymbolPointerSection());
EmitAlignment(isPPC64 ? 3 : 2); EmitAlignment(isPPC64 ? 3 : 2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
// L_foo$stub: // L_foo$stub:
OutStreamer.EmitLabel(Stubs[i].first); OutStreamer->EmitLabel(Stubs[i].first);
// .indirect_symbol _foo // .indirect_symbol _foo
MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second; MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol); OutStreamer->EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
if (MCSym.getInt()) if (MCSym.getInt())
// External to current translation unit. // External to current translation unit.
OutStreamer.EmitIntValue(0, isPPC64 ? 8 : 4/*size*/); OutStreamer->EmitIntValue(0, isPPC64 ? 8 : 4/*size*/);
else else
// Internal to current translation unit. // 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. // 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 // However, sometimes the types are local to the file. So we need to
// fill in the value for the NLP in those cases. // fill in the value for the NLP in those cases.
OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(), OutStreamer->EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
OutContext), OutContext),
isPPC64 ? 8 : 4/*size*/); isPPC64 ? 8 : 4/*size*/);
} }
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
Stubs = MMIMacho.GetHiddenGVStubList(); Stubs = MMIMacho.GetHiddenGVStubList();
if (!Stubs.empty()) { if (!Stubs.empty()) {
OutStreamer.SwitchSection(getObjFileLowering().getDataSection()); OutStreamer->SwitchSection(getObjFileLowering().getDataSection());
EmitAlignment(isPPC64 ? 3 : 2); EmitAlignment(isPPC64 ? 3 : 2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
// L_foo$stub: // L_foo$stub:
OutStreamer.EmitLabel(Stubs[i].first); OutStreamer->EmitLabel(Stubs[i].first);
// .long _foo // .long _foo
OutStreamer.EmitValue(MCSymbolRefExpr:: OutStreamer->EmitValue(MCSymbolRefExpr::
Create(Stubs[i].second.getPointer(), Create(Stubs[i].second.getPointer(),
OutContext), OutContext),
isPPC64 ? 8 : 4/*size*/); isPPC64 ? 8 : 4/*size*/);
} }
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
// Funny Darwin hack: This flag tells the linker that no global symbols // 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 // implementation of multiple entry points). If this doesn't occur, the
// linker can safely perform dead code stripping. Since LLVM never generates // linker can safely perform dead code stripping. Since LLVM never generates
// code that does this, it is always safe to set. // code that does this, it is always safe to set.
OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
return AsmPrinter::doFinalization(M); return AsmPrinter::doFinalization(M);
} }

View File

@ -93,10 +93,10 @@ void AMDGPUAsmPrinter::EmitEndOfAsmFile(Module &M) {
// This label is used to mark the end of the .text section. // This label is used to mark the end of the .text section.
const TargetLoweringObjectFile &TLOF = getObjFileLowering(); const TargetLoweringObjectFile &TLOF = getObjFileLowering();
OutStreamer.SwitchSection(TLOF.getTextSection()); OutStreamer->SwitchSection(TLOF.getTextSection());
MCSymbol *EndOfTextLabel = MCSymbol *EndOfTextLabel =
OutContext.GetOrCreateSymbol(StringRef(END_OF_TEXT_LABEL_NAME)); OutContext.GetOrCreateSymbol(StringRef(END_OF_TEXT_LABEL_NAME));
OutStreamer.EmitLabel(EndOfTextLabel); OutStreamer->EmitLabel(EndOfTextLabel);
} }
bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) { bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
@ -109,14 +109,14 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
MCContext &Context = getObjFileLowering().getContext(); MCContext &Context = getObjFileLowering().getContext();
const MCSectionELF *ConfigSection = const MCSectionELF *ConfigSection =
Context.getELFSection(".AMDGPU.config", ELF::SHT_PROGBITS, 0); Context.getELFSection(".AMDGPU.config", ELF::SHT_PROGBITS, 0);
OutStreamer.SwitchSection(ConfigSection); OutStreamer->SwitchSection(ConfigSection);
const AMDGPUSubtarget &STM = MF.getSubtarget<AMDGPUSubtarget>(); const AMDGPUSubtarget &STM = MF.getSubtarget<AMDGPUSubtarget>();
SIProgramInfo KernelInfo; SIProgramInfo KernelInfo;
if (STM.isAmdHsaOS()) { if (STM.isAmdHsaOS()) {
getSIProgramInfo(KernelInfo, MF); getSIProgramInfo(KernelInfo, MF);
EmitAmdKernelCodeT(MF, KernelInfo); EmitAmdKernelCodeT(MF, KernelInfo);
OutStreamer.EmitCodeAlignment(2 << (MF.getAlignment() - 1)); OutStreamer->EmitCodeAlignment(2 << (MF.getAlignment() - 1));
} else if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) { } else if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) {
getSIProgramInfo(KernelInfo, MF); getSIProgramInfo(KernelInfo, MF);
EmitProgramInfoSI(MF, KernelInfo); EmitProgramInfoSI(MF, KernelInfo);
@ -133,40 +133,40 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
if (isVerbose()) { if (isVerbose()) {
const MCSectionELF *CommentSection = const MCSectionELF *CommentSection =
Context.getELFSection(".AMDGPU.csdata", ELF::SHT_PROGBITS, 0); Context.getELFSection(".AMDGPU.csdata", ELF::SHT_PROGBITS, 0);
OutStreamer.SwitchSection(CommentSection); OutStreamer->SwitchSection(CommentSection);
if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) { if (STM.getGeneration() >= AMDGPUSubtarget::SOUTHERN_ISLANDS) {
OutStreamer.emitRawComment(" Kernel info:", false); OutStreamer->emitRawComment(" Kernel info:", false);
OutStreamer.emitRawComment(" codeLenInByte = " + Twine(KernelInfo.CodeLen), OutStreamer->emitRawComment(" codeLenInByte = " + Twine(KernelInfo.CodeLen),
false); false);
OutStreamer.emitRawComment(" NumSgprs: " + Twine(KernelInfo.NumSGPR), OutStreamer->emitRawComment(" NumSgprs: " + Twine(KernelInfo.NumSGPR),
false); false);
OutStreamer.emitRawComment(" NumVgprs: " + Twine(KernelInfo.NumVGPR), OutStreamer->emitRawComment(" NumVgprs: " + Twine(KernelInfo.NumVGPR),
false); false);
OutStreamer.emitRawComment(" FloatMode: " + Twine(KernelInfo.FloatMode), OutStreamer->emitRawComment(" FloatMode: " + Twine(KernelInfo.FloatMode),
false); false);
OutStreamer.emitRawComment(" IeeeMode: " + Twine(KernelInfo.IEEEMode), OutStreamer->emitRawComment(" IeeeMode: " + Twine(KernelInfo.IEEEMode),
false); false);
OutStreamer.emitRawComment(" ScratchSize: " + Twine(KernelInfo.ScratchSize), OutStreamer->emitRawComment(" ScratchSize: " + Twine(KernelInfo.ScratchSize),
false); false);
} else { } else {
R600MachineFunctionInfo *MFI = MF.getInfo<R600MachineFunctionInfo>(); R600MachineFunctionInfo *MFI = MF.getInfo<R600MachineFunctionInfo>();
OutStreamer.emitRawComment( OutStreamer->emitRawComment(
Twine("SQ_PGM_RESOURCES:STACK_SIZE = " + Twine(MFI->StackSize))); Twine("SQ_PGM_RESOURCES:STACK_SIZE = " + Twine(MFI->StackSize)));
} }
} }
if (STM.dumpCode()) { if (STM.dumpCode()) {
OutStreamer.SwitchSection( OutStreamer->SwitchSection(
Context.getELFSection(".AMDGPU.disasm", ELF::SHT_NOTE, 0)); Context.getELFSection(".AMDGPU.disasm", ELF::SHT_NOTE, 0));
for (size_t i = 0; i < DisasmLines.size(); ++i) { for (size_t i = 0; i < DisasmLines.size(); ++i) {
std::string Comment(DisasmLineMaxLen - DisasmLines[i].size(), ' '); std::string Comment(DisasmLineMaxLen - DisasmLines[i].size(), ' ');
Comment += " ; " + HexLines[i] + "\n"; Comment += " ; " + HexLines[i] + "\n";
OutStreamer.EmitBytes(StringRef(DisasmLines[i])); OutStreamer->EmitBytes(StringRef(DisasmLines[i]));
OutStreamer.EmitBytes(StringRef(Comment)); OutStreamer->EmitBytes(StringRef(Comment));
} }
} }
@ -221,15 +221,15 @@ void AMDGPUAsmPrinter::EmitProgramInfoR600(const MachineFunction &MF) {
} }
} }
OutStreamer.EmitIntValue(RsrcReg, 4); OutStreamer->EmitIntValue(RsrcReg, 4);
OutStreamer.EmitIntValue(S_NUM_GPRS(MaxGPR + 1) | OutStreamer->EmitIntValue(S_NUM_GPRS(MaxGPR + 1) |
S_STACK_SIZE(MFI->StackSize), 4); S_STACK_SIZE(MFI->StackSize), 4);
OutStreamer.EmitIntValue(R_02880C_DB_SHADER_CONTROL, 4); OutStreamer->EmitIntValue(R_02880C_DB_SHADER_CONTROL, 4);
OutStreamer.EmitIntValue(S_02880C_KILL_ENABLE(killPixel), 4); OutStreamer->EmitIntValue(S_02880C_KILL_ENABLE(killPixel), 4);
if (MFI->getShaderType() == ShaderType::COMPUTE) { if (MFI->getShaderType() == ShaderType::COMPUTE) {
OutStreamer.EmitIntValue(R_0288E8_SQ_LDS_ALLOC, 4); OutStreamer->EmitIntValue(R_0288E8_SQ_LDS_ALLOC, 4);
OutStreamer.EmitIntValue(RoundUpToAlignment(MFI->LDSSize, 4) >> 2, 4); OutStreamer->EmitIntValue(RoundUpToAlignment(MFI->LDSSize, 4) >> 2, 4);
} }
} }
@ -426,33 +426,33 @@ void AMDGPUAsmPrinter::EmitProgramInfoSI(const MachineFunction &MF,
unsigned RsrcReg = getRsrcReg(MFI->getShaderType()); unsigned RsrcReg = getRsrcReg(MFI->getShaderType());
if (MFI->getShaderType() == ShaderType::COMPUTE) { 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(R_00B84C_COMPUTE_PGM_RSRC2, 4);
OutStreamer.EmitIntValue(KernelInfo.ComputePGMRSrc2, 4); OutStreamer->EmitIntValue(KernelInfo.ComputePGMRSrc2, 4);
OutStreamer.EmitIntValue(R_00B860_COMPUTE_TMPRING_SIZE, 4); OutStreamer->EmitIntValue(R_00B860_COMPUTE_TMPRING_SIZE, 4);
OutStreamer.EmitIntValue(S_00B860_WAVESIZE(KernelInfo.ScratchBlocks), 4); OutStreamer->EmitIntValue(S_00B860_WAVESIZE(KernelInfo.ScratchBlocks), 4);
// TODO: Should probably note flat usage somewhere. SC emits a "FlatPtr32 = // 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. // 0" comment but I don't see a corresponding field in the register spec.
} else { } else {
OutStreamer.EmitIntValue(RsrcReg, 4); OutStreamer->EmitIntValue(RsrcReg, 4);
OutStreamer.EmitIntValue(S_00B028_VGPRS(KernelInfo.VGPRBlocks) | OutStreamer->EmitIntValue(S_00B028_VGPRS(KernelInfo.VGPRBlocks) |
S_00B028_SGPRS(KernelInfo.SGPRBlocks), 4); S_00B028_SGPRS(KernelInfo.SGPRBlocks), 4);
if (STM.isVGPRSpillingEnabled(MFI)) { if (STM.isVGPRSpillingEnabled(MFI)) {
OutStreamer.EmitIntValue(R_0286E8_SPI_TMPRING_SIZE, 4); OutStreamer->EmitIntValue(R_0286E8_SPI_TMPRING_SIZE, 4);
OutStreamer.EmitIntValue(S_0286E8_WAVESIZE(KernelInfo.ScratchBlocks), 4); OutStreamer->EmitIntValue(S_0286E8_WAVESIZE(KernelInfo.ScratchBlocks), 4);
} }
} }
if (MFI->getShaderType() == ShaderType::PIXEL) { if (MFI->getShaderType() == ShaderType::PIXEL) {
OutStreamer.EmitIntValue(R_00B02C_SPI_SHADER_PGM_RSRC2_PS, 4); OutStreamer->EmitIntValue(R_00B02C_SPI_SHADER_PGM_RSRC2_PS, 4);
OutStreamer.EmitIntValue(S_00B02C_EXTRA_LDS_SIZE(KernelInfo.LDSBlocks), 4); OutStreamer->EmitIntValue(S_00B02C_EXTRA_LDS_SIZE(KernelInfo.LDSBlocks), 4);
OutStreamer.EmitIntValue(R_0286CC_SPI_PS_INPUT_ENA, 4); OutStreamer->EmitIntValue(R_0286CC_SPI_PS_INPUT_ENA, 4);
OutStreamer.EmitIntValue(MFI->PSInputAddr, 4); OutStreamer->EmitIntValue(MFI->PSInputAddr, 4);
} }
} }
@ -511,8 +511,8 @@ void AMDGPUAsmPrinter::EmitAmdKernelCodeT(const MachineFunction &MF,
const MCSectionELF *VersionSection = const MCSectionELF *VersionSection =
OutContext.getELFSection(".hsa.version", ELF::SHT_PROGBITS, 0); OutContext.getELFSection(".hsa.version", ELF::SHT_PROGBITS, 0);
OutStreamer.SwitchSection(VersionSection); OutStreamer->SwitchSection(VersionSection);
OutStreamer.EmitBytes(Twine("HSA Code Unit:" + OutStreamer->EmitBytes(Twine("HSA Code Unit:" +
Twine(header.hsail_version_major) + "." + Twine(header.hsail_version_major) + "." +
Twine(header.hsail_version_minor) + ":" + Twine(header.hsail_version_minor) + ":" +
"AMD:" + "AMD:" +
@ -520,60 +520,62 @@ void AMDGPUAsmPrinter::EmitAmdKernelCodeT(const MachineFunction &MF,
Twine(header.amd_code_version_minor) + ":" + Twine(header.amd_code_version_minor) + ":" +
"GFX8.1:0").str()); "GFX8.1:0").str());
OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
if (isVerbose()) { if (isVerbose()) {
OutStreamer.emitRawComment("amd_code_version_major = " + OutStreamer->emitRawComment("amd_code_version_major = " +
Twine(header.amd_code_version_major), false); Twine(header.amd_code_version_major), false);
OutStreamer.emitRawComment("amd_code_version_minor = " + OutStreamer->emitRawComment("amd_code_version_minor = " +
Twine(header.amd_code_version_minor), false); Twine(header.amd_code_version_minor), false);
OutStreamer.emitRawComment("struct_byte_size = " + OutStreamer->emitRawComment("struct_byte_size = " +
Twine(header.struct_byte_size), false); Twine(header.struct_byte_size), false);
OutStreamer.emitRawComment("target_chip = " + OutStreamer->emitRawComment("target_chip = " +
Twine(header.target_chip), false); Twine(header.target_chip), false);
OutStreamer.emitRawComment(" compute_pgm_rsrc1: " + OutStreamer->emitRawComment(" compute_pgm_rsrc1: " +
Twine::utohexstr(KernelInfo.ComputePGMRSrc1), false); Twine::utohexstr(KernelInfo.ComputePGMRSrc1),
OutStreamer.emitRawComment(" compute_pgm_rsrc2: " + false);
Twine::utohexstr(KernelInfo.ComputePGMRSrc2), false); OutStreamer->emitRawComment(" compute_pgm_rsrc2: " +
OutStreamer.emitRawComment("enable_sgpr_private_segment_buffer = " + Twine::utohexstr(KernelInfo.ComputePGMRSrc2),
false);
OutStreamer->emitRawComment("enable_sgpr_private_segment_buffer = " +
Twine((bool)(header.code_properties & Twine((bool)(header.code_properties &
AMD_CODE_PROPERTY_ENABLE_SGPR_PRIVATE_SEGMENT_SIZE)), false); 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 & Twine((bool)(header.code_properties &
AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR)), false); AMD_CODE_PROPERTY_ENABLE_SGPR_KERNARG_SEGMENT_PTR)), false);
OutStreamer.emitRawComment("private_element_size = 2 ", false); OutStreamer->emitRawComment("private_element_size = 2 ", false);
OutStreamer.emitRawComment("is_ptr64 = " + OutStreamer->emitRawComment("is_ptr64 = " +
Twine((bool)(header.code_properties & AMD_CODE_PROPERTY_IS_PTR64)), false); Twine((bool)(header.code_properties & AMD_CODE_PROPERTY_IS_PTR64)), false);
OutStreamer.emitRawComment("workitem_private_segment_byte_size = " + OutStreamer->emitRawComment("workitem_private_segment_byte_size = " +
Twine(header.workitem_private_segment_byte_size), Twine(header.workitem_private_segment_byte_size),
false); false);
OutStreamer.emitRawComment("workgroup_group_segment_byte_size = " + OutStreamer->emitRawComment("workgroup_group_segment_byte_size = " +
Twine(header.workgroup_group_segment_byte_size), Twine(header.workgroup_group_segment_byte_size),
false); false);
OutStreamer.emitRawComment("gds_segment_byte_size = " + OutStreamer->emitRawComment("gds_segment_byte_size = " +
Twine(header.gds_segment_byte_size), false); Twine(header.gds_segment_byte_size), false);
OutStreamer.emitRawComment("kernarg_segment_byte_size = " + OutStreamer->emitRawComment("kernarg_segment_byte_size = " +
Twine(header.kernarg_segment_byte_size), false); Twine(header.kernarg_segment_byte_size), false);
OutStreamer.emitRawComment("wavefront_sgpr_count = " + OutStreamer->emitRawComment("wavefront_sgpr_count = " +
Twine(header.wavefront_sgpr_count), false); Twine(header.wavefront_sgpr_count), false);
OutStreamer.emitRawComment("workitem_vgpr_count = " + OutStreamer->emitRawComment("workitem_vgpr_count = " +
Twine(header.workitem_vgpr_count), false); Twine(header.workitem_vgpr_count), false);
OutStreamer.emitRawComment("code_type = " + Twine(header.code_type), false); OutStreamer->emitRawComment("code_type = " + Twine(header.code_type), false);
OutStreamer.emitRawComment("wavefront_size = " + OutStreamer->emitRawComment("wavefront_size = " +
Twine((int)header.wavefront_size), false); Twine((int)header.wavefront_size), false);
OutStreamer.emitRawComment("optimization_level = " + OutStreamer->emitRawComment("optimization_level = " +
Twine(header.optimization_level), false); Twine(header.optimization_level), false);
OutStreamer.emitRawComment("hsail_profile = " + OutStreamer->emitRawComment("hsail_profile = " +
Twine(header.hsail_profile), false); Twine(header.hsail_profile), false);
OutStreamer.emitRawComment("hsail_machine_model = " + OutStreamer->emitRawComment("hsail_machine_model = " +
Twine(header.hsail_machine_model), false); Twine(header.hsail_machine_model), false);
OutStreamer.emitRawComment("hsail_version_major = " + OutStreamer->emitRawComment("hsail_version_major = " +
Twine(header.hsail_version_major), false); Twine(header.hsail_version_major), false);
OutStreamer.emitRawComment("hsail_version_minor = " + OutStreamer->emitRawComment("hsail_version_minor = " +
Twine(header.hsail_version_minor), false); 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, bool AMDGPUAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,

View File

@ -113,7 +113,7 @@ void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
} else { } else {
MCInst TmpInst; MCInst TmpInst;
MCInstLowering.lower(MI, TmpInst); MCInstLowering.lower(MI, TmpInst);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
if (STI.dumpCode()) { if (STI.dumpCode()) {
// Disassemble instruction/operands to text. // Disassemble instruction/operands to text.

View File

@ -40,7 +40,7 @@ namespace {
class SparcAsmPrinter : public AsmPrinter { class SparcAsmPrinter : public AsmPrinter {
SparcTargetStreamer &getTargetStreamer() { SparcTargetStreamer &getTargetStreamer() {
return static_cast<SparcTargetStreamer &>( return static_cast<SparcTargetStreamer &>(
*OutStreamer.getTargetStreamer()); *OutStreamer->getTargetStreamer());
} }
public: public:
explicit SparcAsmPrinter(TargetMachine &TM, explicit SparcAsmPrinter(TargetMachine &TM,
@ -191,35 +191,35 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
default: default:
llvm_unreachable("Unsupported absolute code model"); llvm_unreachable("Unsupported absolute code model");
case CodeModel::Small: case CodeModel::Small:
EmitHiLo(OutStreamer, GOTLabel, EmitHiLo(*OutStreamer, GOTLabel,
SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO, SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO,
MCRegOP, OutContext, STI); MCRegOP, OutContext, STI);
break; break;
case CodeModel::Medium: { case CodeModel::Medium: {
EmitHiLo(OutStreamer, GOTLabel, EmitHiLo(*OutStreamer, GOTLabel,
SparcMCExpr::VK_Sparc_H44, SparcMCExpr::VK_Sparc_M44, SparcMCExpr::VK_Sparc_H44, SparcMCExpr::VK_Sparc_M44,
MCRegOP, OutContext, STI); MCRegOP, OutContext, STI);
MCOperand imm = MCOperand::CreateExpr(MCConstantExpr::Create(12, MCOperand imm = MCOperand::CreateExpr(MCConstantExpr::Create(12,
OutContext)); OutContext));
EmitSHL(OutStreamer, MCRegOP, imm, MCRegOP, STI); EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
MCOperand lo = createSparcMCOperand(SparcMCExpr::VK_Sparc_L44, MCOperand lo = createSparcMCOperand(SparcMCExpr::VK_Sparc_L44,
GOTLabel, OutContext); GOTLabel, OutContext);
EmitOR(OutStreamer, MCRegOP, lo, MCRegOP, STI); EmitOR(*OutStreamer, MCRegOP, lo, MCRegOP, STI);
break; break;
} }
case CodeModel::Large: { case CodeModel::Large: {
EmitHiLo(OutStreamer, GOTLabel, EmitHiLo(*OutStreamer, GOTLabel,
SparcMCExpr::VK_Sparc_HH, SparcMCExpr::VK_Sparc_HM, SparcMCExpr::VK_Sparc_HH, SparcMCExpr::VK_Sparc_HM,
MCRegOP, OutContext, STI); MCRegOP, OutContext, STI);
MCOperand imm = MCOperand::CreateExpr(MCConstantExpr::Create(32, MCOperand imm = MCOperand::CreateExpr(MCConstantExpr::Create(32,
OutContext)); OutContext));
EmitSHL(OutStreamer, MCRegOP, imm, MCRegOP, STI); EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
// Use register %o7 to load the lower 32 bits. // Use register %o7 to load the lower 32 bits.
MCOperand RegO7 = MCOperand::CreateReg(SP::O7); MCOperand RegO7 = MCOperand::CreateReg(SP::O7);
EmitHiLo(OutStreamer, GOTLabel, EmitHiLo(*OutStreamer, GOTLabel,
SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO, SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO,
RegO7, OutContext, STI); RegO7, OutContext, STI);
EmitADD(OutStreamer, MCRegOP, RegO7, MCRegOP, STI); EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
} }
} }
return; return;
@ -239,20 +239,20 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
// or <MO>, %lo(_GLOBAL_OFFSET_TABLE_+(<EndLabel>-<StartLabel>))), <MO> // or <MO>, %lo(_GLOBAL_OFFSET_TABLE_+(<EndLabel>-<StartLabel>))), <MO>
// add <MO>, %o7, <MO> // add <MO>, %o7, <MO>
OutStreamer.EmitLabel(StartLabel); OutStreamer->EmitLabel(StartLabel);
MCOperand Callee = createPCXCallOP(EndLabel, OutContext); MCOperand Callee = createPCXCallOP(EndLabel, OutContext);
EmitCall(OutStreamer, Callee, STI); EmitCall(*OutStreamer, Callee, STI);
OutStreamer.EmitLabel(SethiLabel); OutStreamer->EmitLabel(SethiLabel);
MCOperand hiImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC22, MCOperand hiImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC22,
GOTLabel, StartLabel, SethiLabel, GOTLabel, StartLabel, SethiLabel,
OutContext); OutContext);
EmitSETHI(OutStreamer, hiImm, MCRegOP, STI); EmitSETHI(*OutStreamer, hiImm, MCRegOP, STI);
OutStreamer.EmitLabel(EndLabel); OutStreamer->EmitLabel(EndLabel);
MCOperand loImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC10, MCOperand loImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC10,
GOTLabel, StartLabel, EndLabel, GOTLabel, StartLabel, EndLabel,
OutContext); OutContext);
EmitOR(OutStreamer, MCRegOP, loImm, MCRegOP, STI); EmitOR(*OutStreamer, MCRegOP, loImm, MCRegOP, STI);
EmitADD(OutStreamer, MCRegOP, RegO7, MCRegOP, STI); EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
} }
void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI) void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI)
@ -272,7 +272,7 @@ void SparcAsmPrinter::EmitInstruction(const MachineInstr *MI)
do { do {
MCInst TmpInst; MCInst TmpInst;
LowerSparcMachineInstrToMCInst(I, TmpInst, *this); LowerSparcMachineInstrToMCInst(I, TmpInst, *this);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
} while ((++I != E) && I->isInsideBundle()); // Delay slot check. } while ((++I != E) && I->isInsideBundle()); // Delay slot check.
} }

View File

@ -198,7 +198,7 @@ void SystemZAsmPrinter::EmitInstruction(const MachineInstr *MI) {
Lower.lower(MI, LoweredMI); Lower.lower(MI, LoweredMI);
break; break;
} }
EmitToStreamer(OutStreamer, LoweredMI); EmitToStreamer(*OutStreamer, LoweredMI);
} }
// Convert a SystemZ-specific constant pool modifier into the associated // Convert a SystemZ-specific constant pool modifier into the associated
@ -224,7 +224,7 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
OutContext); OutContext);
uint64_t Size = TM.getDataLayout()->getTypeAllocSize(ZCPV->getType()); uint64_t Size = TM.getDataLayout()->getTypeAllocSize(ZCPV->getType());
OutStreamer.EmitValue(Expr, Size); OutStreamer->EmitValue(Expr, Size);
} }
bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI, bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI,

View File

@ -55,12 +55,12 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
if (Subtarget->isTargetCOFF()) { if (Subtarget->isTargetCOFF()) {
bool Intrn = MF.getFunction()->hasInternalLinkage(); bool Intrn = MF.getFunction()->hasInternalLinkage();
OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
OutStreamer.EmitCOFFSymbolStorageClass(Intrn ? COFF::IMAGE_SYM_CLASS_STATIC OutStreamer->EmitCOFFSymbolStorageClass(Intrn ? COFF::IMAGE_SYM_CLASS_STATIC
: COFF::IMAGE_SYM_CLASS_EXTERNAL); : COFF::IMAGE_SYM_CLASS_EXTERNAL);
OutStreamer.EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION
<< COFF::SCT_COMPLEX_TYPE_SHIFT); << COFF::SCT_COMPLEX_TYPE_SHIFT);
OutStreamer.EndCOFFSymbolDef(); OutStreamer->EndCOFFSymbolDef();
} }
// Emit the rest of the function body. // Emit the rest of the function body.
@ -507,24 +507,24 @@ void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
Triple TT(TM.getTargetTriple()); Triple TT(TM.getTargetTriple());
if (TT.isOSBinFormatMachO()) if (TT.isOSBinFormatMachO())
OutStreamer.SwitchSection(getObjFileLowering().getTextSection()); OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
if (TT.isOSBinFormatCOFF()) { if (TT.isOSBinFormatCOFF()) {
// Emit an absolute @feat.00 symbol. This appears to be some kind of // Emit an absolute @feat.00 symbol. This appears to be some kind of
// compiler features bitfield read by link.exe. // compiler features bitfield read by link.exe.
if (TT.getArch() == Triple::x86) { if (TT.getArch() == Triple::x86) {
MCSymbol *S = MMI->getContext().GetOrCreateSymbol(StringRef("@feat.00")); MCSymbol *S = MMI->getContext().GetOrCreateSymbol(StringRef("@feat.00"));
OutStreamer.BeginCOFFSymbolDef(S); OutStreamer->BeginCOFFSymbolDef(S);
OutStreamer.EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC); OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
OutStreamer.EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL); OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
OutStreamer.EndCOFFSymbolDef(); OutStreamer->EndCOFFSymbolDef();
// According to the PE-COFF spec, the LSB of this value marks the object // 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 // for "registered SEH". This means that all SEH handler entry points
// must be registered in .sxdata. Use of any unregistered handlers will // must be registered in .sxdata. Use of any unregistered handlers will
// cause the process to terminate immediately. LLVM does not know how to // cause the process to terminate immediately. LLVM does not know how to
// register any SEH handlers, so its object files should be safe. // register any SEH handlers, so its object files should be safe.
OutStreamer.EmitSymbolAttribute(S, MCSA_Global); OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
OutStreamer.EmitAssignment( OutStreamer->EmitAssignment(
S, MCConstantExpr::Create(int64_t(1), MMI->getContext())); S, MCConstantExpr::Create(int64_t(1), MMI->getContext()));
} }
} }
@ -564,7 +564,7 @@ MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const {
getObjFileLowering().getSectionForConstant(Kind, C))) { getObjFileLowering().getSectionForConstant(Kind, C))) {
if (MCSymbol *Sym = S->getCOMDATSymbol()) { if (MCSymbol *Sym = S->getCOMDATSymbol()) {
if (Sym->isUndefined()) if (Sym->isUndefined())
OutStreamer.EmitSymbolAttribute(Sym, MCSA_Global); OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
return Sym; return Sym;
} }
} }
@ -599,7 +599,7 @@ void X86AsmPrinter::GenerateExportDirective(const MCSymbol *Sym, bool IsData) {
} }
OS.flush(); OS.flush();
OutStreamer.EmitBytes(Directive); OutStreamer->EmitBytes(Directive);
} }
void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
@ -621,21 +621,21 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
MachO::S_ATTR_SELF_MODIFYING_CODE | MachO::S_ATTR_SELF_MODIFYING_CODE |
MachO::S_ATTR_PURE_INSTRUCTIONS, MachO::S_ATTR_PURE_INSTRUCTIONS,
5, SectionKind::getMetadata()); 5, SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection); OutStreamer->SwitchSection(TheSection);
for (const auto &Stub : Stubs) { for (const auto &Stub : Stubs) {
// L_foo$stub: // L_foo$stub:
OutStreamer.EmitLabel(Stub.first); OutStreamer->EmitLabel(Stub.first);
// .indirect_symbol _foo // .indirect_symbol _foo
OutStreamer.EmitSymbolAttribute(Stub.second.getPointer(), OutStreamer->EmitSymbolAttribute(Stub.second.getPointer(),
MCSA_IndirectSymbol); MCSA_IndirectSymbol);
// hlt; hlt; hlt; hlt; hlt hlt = 0xf4. // hlt; hlt; hlt; hlt; hlt hlt = 0xf4.
const char HltInsts[] = "\xf4\xf4\xf4\xf4\xf4"; const char HltInsts[] = "\xf4\xf4\xf4\xf4\xf4";
OutStreamer.EmitBytes(StringRef(HltInsts, 5)); OutStreamer->EmitBytes(StringRef(HltInsts, 5));
} }
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
// Output stubs for external and common global variables. // Output stubs for external and common global variables.
@ -645,13 +645,13 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutContext.getMachOSection("__IMPORT", "__pointers", OutContext.getMachOSection("__IMPORT", "__pointers",
MachO::S_NON_LAZY_SYMBOL_POINTERS, MachO::S_NON_LAZY_SYMBOL_POINTERS,
SectionKind::getMetadata()); SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection); OutStreamer->SwitchSection(TheSection);
for (auto &Stub : Stubs) for (auto &Stub : Stubs)
emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
Stubs = MMIMacho.GetHiddenGVStubList(); Stubs = MMIMacho.GetHiddenGVStubList();
@ -660,13 +660,13 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutContext.getMachOSection("__IMPORT", "__pointers", OutContext.getMachOSection("__IMPORT", "__pointers",
MachO::S_NON_LAZY_SYMBOL_POINTERS, MachO::S_NON_LAZY_SYMBOL_POINTERS,
SectionKind::getMetadata()); SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection); OutStreamer->SwitchSection(TheSection);
for (auto &Stub : Stubs) for (auto &Stub : Stubs)
emitNonLazySymbolPointer(OutStreamer, Stub.first, Stub.second); emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine(); OutStreamer->AddBlankLine();
} }
SM.serializeToStackMapSection(); SM.serializeToStackMapSection();
@ -676,14 +676,14 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
// implementation of multiple entry points). If this doesn't occur, the // implementation of multiple entry points). If this doesn't occur, the
// linker can safely perform dead code stripping. Since LLVM never // linker can safely perform dead code stripping. Since LLVM never
// generates code that does this, it is always safe to set. // generates code that does this, it is always safe to set.
OutStreamer.EmitAssemblerFlag(MCAF_SubsectionsViaSymbols); OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
} }
if (TT.isKnownWindowsMSVCEnvironment() && MMI->usesVAFloatArgument()) { if (TT.isKnownWindowsMSVCEnvironment() && MMI->usesVAFloatArgument()) {
StringRef SymbolName = StringRef SymbolName =
(TT.getArch() == Triple::x86_64) ? "_fltused" : "__fltused"; (TT.getArch() == Triple::x86_64) ? "_fltused" : "__fltused";
MCSymbol *S = MMI->getContext().GetOrCreateSymbol(SymbolName); MCSymbol *S = MMI->getContext().GetOrCreateSymbol(SymbolName);
OutStreamer.EmitSymbolAttribute(S, MCSA_Global); OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
} }
if (TT.isOSBinFormatCOFF()) { if (TT.isOSBinFormatCOFF()) {
@ -713,7 +713,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
const TargetLoweringObjectFileCOFF &TLOFCOFF = const TargetLoweringObjectFileCOFF &TLOFCOFF =
static_cast<const TargetLoweringObjectFileCOFF&>(getObjFileLowering()); static_cast<const TargetLoweringObjectFileCOFF&>(getObjFileLowering());
OutStreamer.SwitchSection(TLOFCOFF.getDrectveSection()); OutStreamer->SwitchSection(TLOFCOFF.getDrectveSection());
for (auto & Symbol : DLLExportedGlobals) for (auto & Symbol : DLLExportedGlobals)
GenerateExportDirective(Symbol, /*IsData=*/true); GenerateExportDirective(Symbol, /*IsData=*/true);

View File

@ -103,7 +103,7 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
void EmitInstruction(const MachineInstr *MI) override; void EmitInstruction(const MachineInstr *MI) override;
void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override { void EmitBasicBlockEnd(const MachineBasicBlock &MBB) override {
SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo());
} }
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,

View File

@ -105,7 +105,7 @@ namespace llvm {
} }
void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) { void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) {
OutStreamer.EmitInstruction(Inst, getSubtargetInfo()); OutStreamer->EmitInstruction(Inst, getSubtargetInfo());
SMShadowTracker.count(Inst, getSubtargetInfo()); SMShadowTracker.count(Inst, getSubtargetInfo());
} }
} // end llvm namespace } // 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 // local labels. This is only safe when the symbols are in the same
// section so we are restricting it to jumptable references. // section so we are restricting it to jumptable references.
MCSymbol *Label = Ctx.CreateTempSymbol(); MCSymbol *Label = Ctx.CreateTempSymbol();
AsmPrinter.OutStreamer.EmitAssignment(Label, Expr); AsmPrinter.OutStreamer->EmitAssignment(Label, Expr);
Expr = MCSymbolRefExpr::Create(Label, Ctx); Expr = MCSymbolRefExpr::Create(Label, Ctx);
} }
break; break;
@ -683,7 +683,7 @@ void X86AsmPrinter::LowerTlsAddr(X86MCInstLower &MCInstLowering,
bool needsPadding = MI.getOpcode() == X86::TLS_addr64; bool needsPadding = MI.getOpcode() == X86::TLS_addr64;
MCContext &context = OutStreamer.getContext(); MCContext &context = OutStreamer->getContext();
if (needsPadding) if (needsPadding)
EmitAndCountInstruction(MCInstBuilder(X86::DATA16_PREFIX)); EmitAndCountInstruction(MCInstBuilder(X86::DATA16_PREFIX));
@ -859,7 +859,7 @@ static void LowerSTATEPOINT(MCStreamer &OS, StackMaps &SM,
// Lower a stackmap of the form: // Lower a stackmap of the form:
// <id>, <shadowBytes>, ... // <id>, <shadowBytes>, ...
void X86AsmPrinter::LowerSTACKMAP(const MachineInstr &MI) { void X86AsmPrinter::LowerSTACKMAP(const MachineInstr &MI) {
SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo());
SM.recordStackMap(MI); SM.recordStackMap(MI);
unsigned NumShadowBytes = MI.getOperand(1).getImm(); unsigned NumShadowBytes = MI.getOperand(1).getImm();
SMShadowTracker.reset(NumShadowBytes); SMShadowTracker.reset(NumShadowBytes);
@ -871,7 +871,7 @@ void X86AsmPrinter::LowerPATCHPOINT(const MachineInstr &MI,
X86MCInstLower &MCIL) { X86MCInstLower &MCIL) {
assert(Subtarget->is64Bit() && "Patchpoint currently only supports X86-64"); assert(Subtarget->is64Bit() && "Patchpoint currently only supports X86-64");
SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo());
SM.recordPatchPoint(MI); SM.recordPatchPoint(MI);
@ -919,7 +919,7 @@ void X86AsmPrinter::LowerPATCHPOINT(const MachineInstr &MI,
assert(NumBytes >= EncodedBytes && assert(NumBytes >= EncodedBytes &&
"Patchpoint can't request size less than the length of a call."); "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()); getSubtargetInfo());
} }
@ -1021,7 +1021,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
// Emit nothing here but a comment if we can. // Emit nothing here but a comment if we can.
case X86::Int_MemBarrier: case X86::Int_MemBarrier:
OutStreamer.emitRawComment("MEMBARRIER"); OutStreamer->emitRawComment("MEMBARRIER");
return; return;
@ -1029,7 +1029,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
case X86::EH_RETURN64: { case X86::EH_RETURN64: {
// Lower these as normal, but add some comments. // Lower these as normal, but add some comments.
unsigned Reg = MI->getOperand(0).getReg(); unsigned Reg = MI->getOperand(0).getReg();
OutStreamer.AddComment(StringRef("eh_return, addr: %") + OutStreamer->AddComment(StringRef("eh_return, addr: %") +
X86ATTInstPrinter::getRegisterName(Reg)); X86ATTInstPrinter::getRegisterName(Reg));
break; break;
} }
@ -1043,7 +1043,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
case X86::TAILJMPm64_REX: case X86::TAILJMPm64_REX:
case X86::TAILJMPd64_REX: case X86::TAILJMPd64_REX:
// Lower these as normal, but add some comments. // Lower these as normal, but add some comments.
OutStreamer.AddComment("TAILCALL"); OutStreamer->AddComment("TAILCALL");
break; break;
case X86::TLS_addr32: case X86::TLS_addr32:
@ -1067,7 +1067,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
.addExpr(MCSymbolRefExpr::Create(PICBase, OutContext))); .addExpr(MCSymbolRefExpr::Create(PICBase, OutContext)));
// Emit the label. // Emit the label.
OutStreamer.EmitLabel(PICBase); OutStreamer->EmitLabel(PICBase);
// popl $reg // popl $reg
EmitAndCountInstruction(MCInstBuilder(X86::POP32r) 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 // However, we can't generate a ".", so just emit a new label here and refer
// to it. // to it.
MCSymbol *DotSym = OutContext.CreateTempSymbol(); MCSymbol *DotSym = OutContext.CreateTempSymbol();
OutStreamer.EmitLabel(DotSym); OutStreamer->EmitLabel(DotSym);
// Now that we have emitted the label, lower the complex operand expression. // Now that we have emitted the label, lower the complex operand expression.
MCSymbol *OpSym = MCInstLowering.GetSymbolFromOperand(MI->getOperand(2)); MCSymbol *OpSym = MCInstLowering.GetSymbolFromOperand(MI->getOperand(2));
@ -1108,7 +1108,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
return; return;
} }
case TargetOpcode::STATEPOINT: case TargetOpcode::STATEPOINT:
return LowerSTATEPOINT(OutStreamer, SM, *MI, Subtarget->is64Bit(), TM, return LowerSTATEPOINT(*OutStreamer, SM, *MI, Subtarget->is64Bit(), TM,
getSubtargetInfo(), MCInstLowering); getSubtargetInfo(), MCInstLowering);
case TargetOpcode::STACKMAP: case TargetOpcode::STACKMAP:
@ -1130,34 +1130,34 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
return; return;
case X86::SEH_PushReg: case X86::SEH_PushReg:
OutStreamer.EmitWinCFIPushReg(RI->getSEHRegNum(MI->getOperand(0).getImm())); OutStreamer->EmitWinCFIPushReg(RI->getSEHRegNum(MI->getOperand(0).getImm()));
return; return;
case X86::SEH_SaveReg: case X86::SEH_SaveReg:
OutStreamer.EmitWinCFISaveReg(RI->getSEHRegNum(MI->getOperand(0).getImm()), OutStreamer->EmitWinCFISaveReg(RI->getSEHRegNum(MI->getOperand(0).getImm()),
MI->getOperand(1).getImm()); MI->getOperand(1).getImm());
return; return;
case X86::SEH_SaveXMM: case X86::SEH_SaveXMM:
OutStreamer.EmitWinCFISaveXMM(RI->getSEHRegNum(MI->getOperand(0).getImm()), OutStreamer->EmitWinCFISaveXMM(RI->getSEHRegNum(MI->getOperand(0).getImm()),
MI->getOperand(1).getImm()); MI->getOperand(1).getImm());
return; return;
case X86::SEH_StackAlloc: case X86::SEH_StackAlloc:
OutStreamer.EmitWinCFIAllocStack(MI->getOperand(0).getImm()); OutStreamer->EmitWinCFIAllocStack(MI->getOperand(0).getImm());
return; return;
case X86::SEH_SetFrame: case X86::SEH_SetFrame:
OutStreamer.EmitWinCFISetFrame(RI->getSEHRegNum(MI->getOperand(0).getImm()), OutStreamer->EmitWinCFISetFrame(RI->getSEHRegNum(MI->getOperand(0).getImm()),
MI->getOperand(1).getImm()); MI->getOperand(1).getImm());
return; return;
case X86::SEH_PushFrame: case X86::SEH_PushFrame:
OutStreamer.EmitWinCFIPushFrame(MI->getOperand(0).getImm()); OutStreamer->EmitWinCFIPushFrame(MI->getOperand(0).getImm());
return; return;
case X86::SEH_EndPrologue: case X86::SEH_EndPrologue:
OutStreamer.EmitWinCFIEndProlog(); OutStreamer->EmitWinCFIEndProlog();
return; return;
case X86::SEH_Epilogue: { case X86::SEH_Epilogue: {
@ -1181,7 +1181,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
case X86::PSHUFBrm: case X86::PSHUFBrm:
case X86::VPSHUFBrm: case X86::VPSHUFBrm:
case X86::VPSHUFBYrm: { case X86::VPSHUFBYrm: {
if (!OutStreamer.isVerboseAsm()) if (!OutStreamer->isVerboseAsm())
break; break;
assert(MI->getNumOperands() > 5 && assert(MI->getNumOperands() > 5 &&
"We should always have at least 5 operands!"); "We should always have at least 5 operands!");
@ -1193,7 +1193,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
SmallVector<int, 16> Mask; SmallVector<int, 16> Mask;
DecodePSHUFBMask(C, Mask); DecodePSHUFBMask(C, Mask);
if (!Mask.empty()) if (!Mask.empty())
OutStreamer.AddComment(getShuffleComment(DstOp, SrcOp, Mask)); OutStreamer->AddComment(getShuffleComment(DstOp, SrcOp, Mask));
} }
break; break;
} }
@ -1201,7 +1201,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
case X86::VPERMILPDrm: case X86::VPERMILPDrm:
case X86::VPERMILPSYrm: case X86::VPERMILPSYrm:
case X86::VPERMILPDYrm: { case X86::VPERMILPDYrm: {
if (!OutStreamer.isVerboseAsm()) if (!OutStreamer->isVerboseAsm())
break; break;
assert(MI->getNumOperands() > 5 && assert(MI->getNumOperands() > 5 &&
"We should always have at least 5 operands!"); "We should always have at least 5 operands!");
@ -1213,7 +1213,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
SmallVector<int, 16> Mask; SmallVector<int, 16> Mask;
DecodeVPERMILPMask(C, Mask); DecodeVPERMILPMask(C, Mask);
if (!Mask.empty()) if (!Mask.empty())
OutStreamer.AddComment(getShuffleComment(DstOp, SrcOp, Mask)); OutStreamer->AddComment(getShuffleComment(DstOp, SrcOp, Mask));
} }
break; break;
} }
@ -1238,7 +1238,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
case X86::MOVDQUrm: case X86::MOVDQUrm:
case X86::VMOVDQUrm: case X86::VMOVDQUrm:
case X86::VMOVDQUYrm: case X86::VMOVDQUYrm:
if (!OutStreamer.isVerboseAsm()) if (!OutStreamer->isVerboseAsm())
break; break;
if (MI->getNumOperands() > 4) if (MI->getNumOperands() > 4)
if (auto *C = getConstantFromPool(*MI, MI->getOperand(4))) { if (auto *C = getConstantFromPool(*MI, MI->getOperand(4))) {
@ -1261,7 +1261,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
CS << "?"; CS << "?";
} }
CS << "]"; CS << "]";
OutStreamer.AddComment(CS.str()); OutStreamer->AddComment(CS.str());
} else if (auto *CV = dyn_cast<ConstantVector>(C)) { } else if (auto *CV = dyn_cast<ConstantVector>(C)) {
CS << "<"; CS << "<";
for (int i = 0, NumOperands = CV->getNumOperands(); i < NumOperands; ++i) { for (int i = 0, NumOperands = CV->getNumOperands(); i < NumOperands; ++i) {
@ -1281,7 +1281,7 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
} }
} }
CS << ">"; CS << ">";
OutStreamer.AddComment(CS.str()); OutStreamer->AddComment(CS.str());
} }
} }
break; break;
@ -1299,9 +1299,9 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) {
SMShadowTracker.count(TmpInst, getSubtargetInfo()); SMShadowTracker.count(TmpInst, getSubtargetInfo());
// Then flush the shadow so that we fill with nops before the call, not // Then flush the shadow so that we fill with nops before the call, not
// after it. // after it.
SMShadowTracker.emitShadowPadding(OutStreamer, getSubtargetInfo()); SMShadowTracker.emitShadowPadding(*OutStreamer, getSubtargetInfo());
// Then emit the call // Then emit the call
OutStreamer.EmitInstruction(TmpInst, getSubtargetInfo()); OutStreamer->EmitInstruction(TmpInst, getSubtargetInfo());
return; return;
} }

View File

@ -86,7 +86,7 @@ namespace {
} // end of anonymous namespace } // end of anonymous namespace
XCoreTargetStreamer &XCoreAsmPrinter::getTargetStreamer() { XCoreTargetStreamer &XCoreAsmPrinter::getTargetStreamer() {
return static_cast<XCoreTargetStreamer&>(*OutStreamer.getTargetStreamer()); return static_cast<XCoreTargetStreamer&>(*OutStreamer->getTargetStreamer());
} }
void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) { void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) {
@ -98,13 +98,13 @@ void XCoreAsmPrinter::emitArrayBound(MCSymbol *Sym, const GlobalVariable *GV) {
MCSymbol *SymGlob = OutContext.GetOrCreateSymbol( MCSymbol *SymGlob = OutContext.GetOrCreateSymbol(
Twine(Sym->getName() + StringRef(".globound"))); Twine(Sym->getName() + StringRef(".globound")));
OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Global); OutStreamer->EmitSymbolAttribute(SymGlob, MCSA_Global);
OutStreamer.EmitAssignment(SymGlob, OutStreamer->EmitAssignment(SymGlob,
MCConstantExpr::Create(ATy->getNumElements(), MCConstantExpr::Create(ATy->getNumElements(),
OutContext)); OutContext));
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
GV->hasCommonLinkage()) { GV->hasCommonLinkage()) {
OutStreamer.EmitSymbolAttribute(SymGlob, MCSA_Weak); OutStreamer->EmitSymbolAttribute(SymGlob, MCSA_Weak);
} }
} }
} }
@ -116,7 +116,7 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
return; return;
const DataLayout *TD = TM.getDataLayout(); const DataLayout *TD = TM.getDataLayout();
OutStreamer.SwitchSection( OutStreamer->SwitchSection(
getObjFileLowering().SectionForGlobal(GV, *Mang, TM)); getObjFileLowering().SectionForGlobal(GV, *Mang, TM));
MCSymbol *GVSym = getSymbol(GV); MCSymbol *GVSym = getSymbol(GV);
@ -136,11 +136,11 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
case GlobalValue::ExternalLinkage: case GlobalValue::ExternalLinkage:
case GlobalValue::CommonLinkage: case GlobalValue::CommonLinkage:
emitArrayBound(GVSym, GV); emitArrayBound(GVSym, GV);
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Global);
if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
GV->hasCommonLinkage()) GV->hasCommonLinkage())
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Weak); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_Weak);
// FALL THROUGH // FALL THROUGH
case GlobalValue::InternalLinkage: case GlobalValue::InternalLinkage:
case GlobalValue::PrivateLinkage: case GlobalValue::PrivateLinkage:
@ -156,16 +156,16 @@ void XCoreAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
} }
unsigned Size = TD->getTypeAllocSize(C->getType()); unsigned Size = TD->getTypeAllocSize(C->getType());
if (MAI->hasDotTypeDotSizeDirective()) { if (MAI->hasDotTypeDotSizeDirective()) {
OutStreamer.EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject); OutStreamer->EmitSymbolAttribute(GVSym, MCSA_ELF_TypeObject);
OutStreamer.EmitELFSize(GVSym, MCConstantExpr::Create(Size, OutContext)); OutStreamer->EmitELFSize(GVSym, MCConstantExpr::Create(Size, OutContext));
} }
OutStreamer.EmitLabel(GVSym); OutStreamer->EmitLabel(GVSym);
EmitGlobalConstant(C); EmitGlobalConstant(C);
// The ABI requires that unsigned scalar types smaller than 32 bits // The ABI requires that unsigned scalar types smaller than 32 bits
// are padded to 32 bits. // are padded to 32 bits.
if (Size < 4) if (Size < 4)
OutStreamer.EmitZeros(4 - Size); OutStreamer->EmitZeros(4 - Size);
// Mark the end of the global // Mark the end of the global
getTargetStreamer().emitCCBottomData(GVSym->getName()); getTargetStreamer().emitCCBottomData(GVSym->getName());
@ -185,7 +185,7 @@ void XCoreAsmPrinter::EmitFunctionBodyEnd() {
void XCoreAsmPrinter::EmitFunctionEntryLabel() { void XCoreAsmPrinter::EmitFunctionEntryLabel() {
// Mark the start of the function // Mark the start of the function
getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName()); getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
OutStreamer.EmitLabel(CurrentFnSym); OutStreamer->EmitLabel(CurrentFnSym);
} }
void XCoreAsmPrinter:: void XCoreAsmPrinter::
@ -275,7 +275,7 @@ void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) {
O << "\tmov " O << "\tmov "
<< XCoreInstPrinter::getRegisterName(MI->getOperand(0).getReg()) << ", " << XCoreInstPrinter::getRegisterName(MI->getOperand(0).getReg()) << ", "
<< XCoreInstPrinter::getRegisterName(MI->getOperand(1).getReg()); << XCoreInstPrinter::getRegisterName(MI->getOperand(1).getReg());
OutStreamer.EmitRawText(O.str()); OutStreamer->EmitRawText(O.str());
return; return;
} }
break; break;
@ -288,14 +288,14 @@ void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) {
else else
printInlineJT32(MI, 0, O); printInlineJT32(MI, 0, O);
O << '\n'; O << '\n';
OutStreamer.EmitRawText(O.str()); OutStreamer->EmitRawText(O.str());
return; return;
} }
MCInst TmpInst; MCInst TmpInst;
MCInstLowering.Lower(MI, TmpInst); MCInstLowering.Lower(MI, TmpInst);
EmitToStreamer(OutStreamer, TmpInst); EmitToStreamer(*OutStreamer, TmpInst);
} }
// Force static initialization. // Force static initialization.

View File

@ -584,10 +584,10 @@ void DwarfStreamer::emitDIE(DIE &Die) {
/// \brief Emit the debug_str section stored in \p Pool. /// \brief Emit the debug_str section stored in \p Pool.
void DwarfStreamer::emitStrings(const NonRelocatableStringpool &Pool) { void DwarfStreamer::emitStrings(const NonRelocatableStringpool &Pool) {
Asm->OutStreamer.SwitchSection(MOFI->getDwarfStrSection()); Asm->OutStreamer->SwitchSection(MOFI->getDwarfStrSection());
for (auto *Entry = Pool.getFirstEntry(); Entry; for (auto *Entry = Pool.getFirstEntry(); Entry;
Entry = Pool.getNextEntry(Entry)) Entry = Pool.getNextEntry(Entry))
Asm->OutStreamer.EmitBytes( Asm->OutStreamer->EmitBytes(
StringRef(Entry->getKey().data(), Entry->getKey().size() + 1)); StringRef(Entry->getKey().data(), Entry->getKey().size() + 1));
} }
@ -668,13 +668,13 @@ void DwarfStreamer::emitUnitRangesEntries(CompileUnit &Unit,
unsigned Padding = OffsetToAlignment(HeaderSize, TupleSize); unsigned Padding = OffsetToAlignment(HeaderSize, TupleSize);
Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Arange length Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Arange length
Asm->OutStreamer.EmitLabel(BeginLabel); Asm->OutStreamer->EmitLabel(BeginLabel);
Asm->EmitInt16(dwarf::DW_ARANGES_VERSION); // Version number Asm->EmitInt16(dwarf::DW_ARANGES_VERSION); // Version number
Asm->EmitInt32(Unit.getStartOffset()); // Corresponding unit's offset Asm->EmitInt32(Unit.getStartOffset()); // Corresponding unit's offset
Asm->EmitInt8(AddressSize); // Address size Asm->EmitInt8(AddressSize); // Address size
Asm->EmitInt8(0); // Segment 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; for (auto Range = Ranges.begin(), End = Ranges.end(); Range != End;
++Range) { ++Range) {
@ -686,9 +686,9 @@ void DwarfStreamer::emitUnitRangesEntries(CompileUnit &Unit,
} }
// Emit terminator // Emit terminator
Asm->OutStreamer.EmitIntValue(0, AddressSize); Asm->OutStreamer->EmitIntValue(0, AddressSize);
Asm->OutStreamer.EmitIntValue(0, AddressSize); Asm->OutStreamer->EmitIntValue(0, AddressSize);
Asm->OutStreamer.EmitLabel(EndLabel); Asm->OutStreamer->EmitLabel(EndLabel);
} }
if (!DoDebugRanges) if (!DoDebugRanges)
@ -746,16 +746,16 @@ void DwarfStreamer::emitLocationsForUnit(const CompileUnit &Unit,
uint64_t High = Data.getUnsigned(&Offset, AddressSize); uint64_t High = Data.getUnsigned(&Offset, AddressSize);
LocSectionSize += 2 * AddressSize; LocSectionSize += 2 * AddressSize;
if (Low == 0 && High == 0) { 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; break;
} }
Asm->OutStreamer.EmitIntValue(Low + LocPcOffset, AddressSize); Asm->OutStreamer->EmitIntValue(Low + LocPcOffset, AddressSize);
Asm->OutStreamer.EmitIntValue(High + LocPcOffset, AddressSize); Asm->OutStreamer->EmitIntValue(High + LocPcOffset, AddressSize);
uint64_t Length = Data.getU16(&Offset); uint64_t Length = Data.getU16(&Offset);
Asm->OutStreamer.EmitIntValue(Length, 2); Asm->OutStreamer->EmitIntValue(Length, 2);
// Just copy the bytes over. // Just copy the bytes over.
Asm->OutStreamer.EmitBytes( Asm->OutStreamer->EmitBytes(
StringRef(InputSec.Data.substr(Offset, Length))); StringRef(InputSec.Data.substr(Offset, Length)));
Offset += Length; Offset += Length;
LocSectionSize += Length + 2; 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 // The first 4 bytes is the total length of the information for this
// compilation unit (not including these 4 bytes for the length). // compilation unit (not including these 4 bytes for the length).
Asm->EmitLabelDifference(LineEndSym, LineStartSym, 4); Asm->EmitLabelDifference(LineEndSym, LineStartSym, 4);
Asm->OutStreamer.EmitLabel(LineStartSym); Asm->OutStreamer->EmitLabel(LineStartSym);
// Copy Prologue. // Copy Prologue.
MS->EmitBytes(PrologueBytes); MS->EmitBytes(PrologueBytes);
LineSectionSize += PrologueBytes.size() + 4; LineSectionSize += PrologueBytes.size() + 4;
@ -918,7 +918,7 @@ void DwarfStreamer::emitPubSectionForUnit(
return; return;
// Start the dwarf pubnames section. // Start the dwarf pubnames section.
Asm->OutStreamer.SwitchSection(Sec); Asm->OutStreamer->SwitchSection(Sec);
MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + SecName + "_begin"); MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + SecName + "_begin");
MCSymbol *EndLabel = Asm->createTempSymbol("pub" + SecName + "_end"); MCSymbol *EndLabel = Asm->createTempSymbol("pub" + SecName + "_end");
@ -931,21 +931,21 @@ void DwarfStreamer::emitPubSectionForUnit(
if (!HeaderEmitted) { if (!HeaderEmitted) {
// Emit the header. // Emit the header.
Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Length Asm->EmitLabelDifference(EndLabel, BeginLabel, 4); // Length
Asm->OutStreamer.EmitLabel(BeginLabel); Asm->OutStreamer->EmitLabel(BeginLabel);
Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION); // Version Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION); // Version
Asm->EmitInt32(Unit.getStartOffset()); // Unit offset Asm->EmitInt32(Unit.getStartOffset()); // Unit offset
Asm->EmitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset()); // Size Asm->EmitInt32(Unit.getNextUnitOffset() - Unit.getStartOffset()); // Size
HeaderEmitted = true; HeaderEmitted = true;
} }
Asm->EmitInt32(Name.Die->getOffset()); Asm->EmitInt32(Name.Die->getOffset());
Asm->OutStreamer.EmitBytes( Asm->OutStreamer->EmitBytes(
StringRef(Name.Name.data(), Name.Name.size() + 1)); StringRef(Name.Name.data(), Name.Name.size() + 1));
} }
if (!HeaderEmitted) if (!HeaderEmitted)
return; return;
Asm->EmitInt32(0); // End marker. Asm->EmitInt32(0); // End marker.
Asm->OutStreamer.EmitLabel(EndLabel); Asm->OutStreamer->EmitLabel(EndLabel);
} }
/// \brief Emit .debug_pubnames for \p Unit. /// \brief Emit .debug_pubnames for \p Unit.