aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/MC/MCAsmStreamer.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-30 16:33:32 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-30 16:33:32 +0000
commit51315c45ff5643a27f9c84b816db54ee870ba29b (patch)
tree1d87443fa0e53d3e6b315ce25787e64be0906bf7 /contrib/llvm/lib/MC/MCAsmStreamer.cpp
parent6dfd050075216be8538ae375a22d30db72916f7e (diff)
parenteb11fae6d08f479c0799db45860a98af528fa6e7 (diff)
Merge llvm trunk r338150, and resolve conflicts.
Notes
Notes: svn path=/projects/clang700-import/; revision=336916
Diffstat (limited to 'contrib/llvm/lib/MC/MCAsmStreamer.cpp')
-rw-r--r--contrib/llvm/lib/MC/MCAsmStreamer.cpp329
1 files changed, 221 insertions, 108 deletions
diff --git a/contrib/llvm/lib/MC/MCAsmStreamer.cpp b/contrib/llvm/lib/MC/MCAsmStreamer.cpp
index 6f045a4b10ba..92f615180561 100644
--- a/contrib/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/contrib/llvm/lib/MC/MCAsmStreamer.cpp
@@ -7,12 +7,14 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCContext.h"
@@ -21,6 +23,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCObjectFileInfo.h"
+#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h"
@@ -30,6 +33,7 @@
#include "llvm/Support/LEB128.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/TargetRegistry.h"
#include <cctype>
using namespace llvm;
@@ -41,12 +45,12 @@ class MCAsmStreamer final : public MCStreamer {
formatted_raw_ostream &OS;
const MCAsmInfo *MAI;
std::unique_ptr<MCInstPrinter> InstPrinter;
- std::unique_ptr<MCCodeEmitter> Emitter;
- std::unique_ptr<MCAsmBackend> AsmBackend;
+ std::unique_ptr<MCAssembler> Assembler;
SmallString<128> ExplicitCommentToEmit;
SmallString<128> CommentToEmit;
raw_svector_ostream CommentStream;
+ raw_null_ostream NullStream;
unsigned IsVerboseAsm : 1;
unsigned ShowInst : 1;
@@ -59,18 +63,24 @@ class MCAsmStreamer final : public MCStreamer {
public:
MCAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os,
bool isVerboseAsm, bool useDwarfDirectory,
- MCInstPrinter *printer, MCCodeEmitter *emitter,
- MCAsmBackend *asmbackend, bool showInst)
+ MCInstPrinter *printer, std::unique_ptr<MCCodeEmitter> emitter,
+ std::unique_ptr<MCAsmBackend> asmbackend, bool showInst)
: MCStreamer(Context), OSOwner(std::move(os)), OS(*OSOwner),
- MAI(Context.getAsmInfo()), InstPrinter(printer), Emitter(emitter),
- AsmBackend(asmbackend), CommentStream(CommentToEmit),
- IsVerboseAsm(isVerboseAsm), ShowInst(showInst),
- UseDwarfDirectory(useDwarfDirectory) {
+ MAI(Context.getAsmInfo()), InstPrinter(printer),
+ Assembler(llvm::make_unique<MCAssembler>(
+ Context, std::move(asmbackend), std::move(emitter),
+ (asmbackend) ? asmbackend->createObjectWriter(NullStream)
+ : nullptr)),
+ CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm),
+ ShowInst(showInst), UseDwarfDirectory(useDwarfDirectory) {
assert(InstPrinter);
if (IsVerboseAsm)
InstPrinter->setCommentStream(CommentStream);
}
+ MCAssembler &getAssembler() { return *Assembler; }
+ MCAssembler *getAssemblerPtr() override { return nullptr; }
+
inline void EmitEOL() {
// Dump Explicit Comments here.
emitExplicitComments();
@@ -86,26 +96,24 @@ public:
void EmitCommentsAndEOL();
- /// isVerboseAsm - Return true if this streamer supports verbose assembly at
- /// all.
+ /// Return true if this streamer supports verbose assembly at all.
bool isVerboseAsm() const override { return IsVerboseAsm; }
- /// hasRawTextSupport - We support EmitRawText.
+ /// Do we support EmitRawText?
bool hasRawTextSupport() const override { return true; }
- /// AddComment - Add a comment that can be emitted to the generated .s
- /// file if applicable as a QoI issue to make the output of the compiler
- /// more readable. This only affects the MCAsmStreamer, and only when
- /// verbose assembly output is enabled.
+ /// Add a comment that can be emitted to the generated .s file to make the
+ /// output of the compiler more readable. This only affects the MCAsmStreamer
+ /// and only when verbose assembly output is enabled.
void AddComment(const Twine &T, bool EOL = true) override;
- /// AddEncodingComment - Add a comment showing the encoding of an instruction.
- /// If PrintSchedInfo - is true then the comment sched:[x:y] should
- // be added to output if it's being supported by target
+ /// Add a comment showing the encoding of an instruction.
+ /// If PrintSchedInfo is true, then the comment sched:[x:y] will be added to
+ /// the output if supported by the target.
void AddEncodingComment(const MCInst &Inst, const MCSubtargetInfo &,
bool PrintSchedInfo);
- /// GetCommentOS - Return a raw_ostream that comments can be written to.
+ /// Return a raw_ostream that comments can be written to.
/// Unlike AddComment, you are required to terminate comments with \n if you
/// use this method.
raw_ostream &GetCommentOS() override {
@@ -119,7 +127,7 @@ public:
void addExplicitComment(const Twine &T) override;
void emitExplicitComments() override;
- /// AddBlankLine - Emit a blank line to a .s file to pretty it up.
+ /// Emit a blank line to a .s file to pretty it up.
void AddBlankLine() override {
EmitEOL();
}
@@ -154,13 +162,15 @@ public:
void EmitCOFFSymbolType(int Type) override;
void EndCOFFSymbolDef() override;
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
+ void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override;
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
+ void EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override;
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) override;
- /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
+ /// Emit a local common (.lcomm) symbol.
///
/// @param Symbol - The common symbol to emit.
/// @param Size - The size of the common symbol.
@@ -169,7 +179,8 @@ public:
unsigned ByteAlignment) override;
void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
- uint64_t Size = 0, unsigned ByteAlignment = 0) override;
+ uint64_t Size = 0, unsigned ByteAlignment = 0,
+ SMLoc Loc = SMLoc()) override;
void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment = 0) override;
@@ -198,8 +209,6 @@ public:
void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
SMLoc Loc = SMLoc()) override;
- void emitFill(uint64_t NumValues, int64_t Size, int64_t Expr) override;
-
void emitFill(const MCExpr &NumValues, int64_t Size, int64_t Expr,
SMLoc Loc = SMLoc()) override;
@@ -215,9 +224,16 @@ public:
SMLoc Loc) override;
void EmitFileDirective(StringRef Filename) override;
- unsigned EmitDwarfFileDirective(unsigned FileNo, StringRef Directory,
- StringRef Filename,
- unsigned CUID = 0) override;
+ Expected<unsigned> tryEmitDwarfFileDirective(unsigned FileNo,
+ StringRef Directory,
+ StringRef Filename,
+ MD5::MD5Result *Checksum = 0,
+ Optional<StringRef> Source = None,
+ unsigned CUID = 0) override;
+ void emitDwarfFile0Directive(StringRef Directory, StringRef Filename,
+ MD5::MD5Result *Checksum,
+ Optional<StringRef> Source,
+ unsigned CUID = 0) override;
void EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator,
@@ -290,6 +306,9 @@ public:
SMLoc Loc) override;
void EmitWinEHHandlerData(SMLoc Loc) override;
+ void emitCGProfileEntry(const MCSymbolRefExpr *From,
+ const MCSymbolRefExpr *To, uint64_t Count) override;
+
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
bool PrintSchedInfo) override;
@@ -298,11 +317,15 @@ public:
void EmitBundleUnlock() override;
bool EmitRelocDirective(const MCExpr &Offset, StringRef Name,
- const MCExpr *Expr, SMLoc Loc) override;
+ const MCExpr *Expr, SMLoc Loc,
+ const MCSubtargetInfo &STI) override;
+
+ void EmitAddrsig() override;
+ void EmitAddrsigSym(const MCSymbol *Sym) override;
- /// EmitRawText - If this file is backed by an assembly streamer, this dumps
- /// the specified string in the output .s file. This capability is
- /// indicated by the hasRawTextSupport() predicate.
+ /// If this file is backed by an assembly streamer, this dumps the specified
+ /// string in the output .s file. This capability is indicated by the
+ /// hasRawTextSupport() predicate.
void EmitRawTextImpl(StringRef String) override;
void FinishImpl() override;
@@ -310,11 +333,6 @@ public:
} // end anonymous namespace.
-/// AddComment - Add a comment that can be emitted to the generated .s
-/// file if applicable as a QoI issue to make the output of the compiler
-/// more readable. This only affects the MCAsmStreamer, and only when
-/// verbose assembly output is enabled.
-/// By deafult EOL is set to true so that each comment goes on its own line.
void MCAsmStreamer::AddComment(const Twine &T, bool EOL) {
if (!IsVerboseAsm) return;
@@ -536,11 +554,19 @@ void MCAsmStreamer::EmitThumbFunc(MCSymbol *Func) {
}
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
- Symbol->print(OS, MAI);
- OS << " = ";
- Value->print(OS, MAI);
+ // Do not emit a .set on inlined target assignments.
+ bool EmitSet = true;
+ if (auto *E = dyn_cast<MCTargetExpr>(Value))
+ if (E->inlineAssignedExpr())
+ EmitSet = false;
+ if (EmitSet) {
+ OS << ".set ";
+ Symbol->print(OS, MAI);
+ OS << ", ";
+ Value->print(OS, MAI);
- EmitEOL();
+ EmitEOL();
+ }
MCStreamer::EmitAssignment(Symbol, Value);
}
@@ -576,7 +602,7 @@ bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
case MCSA_ELF_TypeObject: OS << "object"; break;
case MCSA_ELF_TypeTLS: OS << "tls_object"; break;
case MCSA_ELF_TypeCommon: OS << "common"; break;
- case MCSA_ELF_TypeNoType: OS << "no_type"; break;
+ case MCSA_ELF_TypeNoType: OS << "notype"; break;
case MCSA_ELF_TypeGnuUniqueObject: OS << "gnu_unique_object"; break;
}
EmitEOL();
@@ -661,6 +687,12 @@ void MCAsmStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
EmitEOL();
}
+void MCAsmStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {
+ OS << "\t.symidx\t";
+ Symbol->print(OS, MAI);
+ EmitEOL();
+}
+
void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
OS << "\t.secidx\t";
Symbol->print(OS, MAI);
@@ -675,6 +707,16 @@ void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {
EmitEOL();
}
+void MCAsmStreamer::EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) {
+ OS << "\t.rva\t";
+ Symbol->print(OS, MAI);
+ if (Offset > 0)
+ OS << '+' << Offset;
+ else if (Offset < 0)
+ OS << '-' << -Offset;
+ EmitEOL();
+}
+
void MCAsmStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
assert(MAI->hasDotTypeDotSizeDirective());
OS << "\t.size\t";
@@ -699,10 +741,6 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
EmitEOL();
}
-/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
-///
-/// @param Symbol - The common symbol to emit.
-/// @param Size - The size of the common symbol.
void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlign) {
OS << "\t.lcomm\t";
@@ -726,14 +764,18 @@ void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
}
void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
- uint64_t Size, unsigned ByteAlignment) {
+ uint64_t Size, unsigned ByteAlignment,
+ SMLoc Loc) {
if (Symbol)
AssignFragment(Symbol, &Section->getDummyFragment());
// Note: a .zerofill directive does not switch sections.
OS << ".zerofill ";
+ assert(Section->getVariant() == MCSection::SV_MachO &&
+ ".zerofill is a Mach-O specific directive");
// This is a mach-o specific directive.
+
const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
@@ -756,7 +798,11 @@ void MCAsmStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
assert(Symbol && "Symbol shouldn't be NULL!");
// Instead of using the Section we'll just use the shortcut.
+
+ assert(Section->getVariant() == MCSection::SV_MachO &&
+ ".zerofill is a Mach-O specific directive");
// This is a mach-o specific directive and section.
+
OS << ".tbss ";
Symbol->print(OS, MAI);
OS << ", " << Size;
@@ -780,7 +826,7 @@ static void PrintQuotedString(StringRef Data, raw_ostream &OS) {
continue;
}
- if (isprint((unsigned char)C)) {
+ if (isPrint((unsigned char)C)) {
OS << (char)C;
continue;
}
@@ -915,7 +961,7 @@ void MCAsmStreamer::EmitULEB128Value(const MCExpr *Value) {
EmitULEB128IntValue(IntValue);
return;
}
- OS << ".uleb128 ";
+ OS << "\t.uleb128 ";
Value->print(OS, MAI);
EmitEOL();
}
@@ -926,7 +972,7 @@ void MCAsmStreamer::EmitSLEB128Value(const MCExpr *Value) {
EmitSLEB128IntValue(IntValue);
return;
}
- OS << ".sleb128 ";
+ OS << "\t.sleb128 ";
Value->print(OS, MAI);
EmitEOL();
}
@@ -992,14 +1038,6 @@ void MCAsmStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
MCStreamer::emitFill(NumBytes, FillValue);
}
-void MCAsmStreamer::emitFill(uint64_t NumValues, int64_t Size, int64_t Expr) {
- if (NumValues == 0)
- return;
-
- const MCExpr *E = MCConstantExpr::create(NumValues, getContext());
- emitFill(*E, Size, Expr);
-}
-
void MCAsmStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
int64_t Expr, SMLoc Loc) {
// FIXME: Emit location directives
@@ -1086,20 +1124,12 @@ void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
EmitEOL();
}
-unsigned MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
- StringRef Directory,
- StringRef Filename,
- unsigned CUID) {
- assert(CUID == 0);
-
- MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
- unsigned NumFiles = Table.getMCDwarfFiles().size();
- FileNo = Table.getFile(Directory, Filename, FileNo);
- if (FileNo == 0)
- return 0;
- if (NumFiles == Table.getMCDwarfFiles().size())
- return FileNo;
-
+static void printDwarfFileDirective(unsigned FileNo, StringRef Directory,
+ StringRef Filename,
+ MD5::MD5Result *Checksum,
+ Optional<StringRef> Source,
+ bool UseDwarfDirectory,
+ raw_svector_ostream &OS) {
SmallString<128> FullPathName;
if (!UseDwarfDirectory && !Directory.empty()) {
@@ -1113,51 +1143,102 @@ unsigned MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo,
}
}
- SmallString<128> Str;
- raw_svector_ostream OS1(Str);
- OS1 << "\t.file\t" << FileNo << ' ';
+ OS << "\t.file\t" << FileNo << ' ';
if (!Directory.empty()) {
- PrintQuotedString(Directory, OS1);
- OS1 << ' ';
+ PrintQuotedString(Directory, OS);
+ OS << ' ';
}
- PrintQuotedString(Filename, OS1);
- if (MCTargetStreamer *TS = getTargetStreamer()) {
+ PrintQuotedString(Filename, OS);
+ if (Checksum)
+ OS << " md5 0x" << Checksum->digest();
+ if (Source) {
+ OS << " source ";
+ PrintQuotedString(*Source, OS);
+ }
+}
+
+Expected<unsigned> MCAsmStreamer::tryEmitDwarfFileDirective(
+ unsigned FileNo, StringRef Directory, StringRef Filename,
+ MD5::MD5Result *Checksum, Optional<StringRef> Source, unsigned CUID) {
+ assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer");
+
+ MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID);
+ unsigned NumFiles = Table.getMCDwarfFiles().size();
+ Expected<unsigned> FileNoOrErr =
+ Table.tryGetFile(Directory, Filename, Checksum, Source, FileNo);
+ if (!FileNoOrErr)
+ return FileNoOrErr.takeError();
+ FileNo = FileNoOrErr.get();
+ if (NumFiles == Table.getMCDwarfFiles().size())
+ return FileNo;
+
+ SmallString<128> Str;
+ raw_svector_ostream OS1(Str);
+ printDwarfFileDirective(FileNo, Directory, Filename, Checksum, Source,
+ UseDwarfDirectory, OS1);
+
+ if (MCTargetStreamer *TS = getTargetStreamer())
TS->emitDwarfFileDirective(OS1.str());
- } else {
+ else
EmitRawText(OS1.str());
- }
return FileNo;
}
+void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory,
+ StringRef Filename,
+ MD5::MD5Result *Checksum,
+ Optional<StringRef> Source,
+ unsigned CUID) {
+ assert(CUID == 0);
+ // .file 0 is new for DWARF v5.
+ if (getContext().getDwarfVersion() < 5)
+ return;
+ // Inform MCDwarf about the root file.
+ getContext().setMCLineTableRootFile(CUID, Directory, Filename, Checksum,
+ Source);
+
+ SmallString<128> Str;
+ raw_svector_ostream OS1(Str);
+ printDwarfFileDirective(0, Directory, Filename, Checksum, Source,
+ UseDwarfDirectory, OS1);
+
+ if (MCTargetStreamer *TS = getTargetStreamer())
+ TS->emitDwarfFileDirective(OS1.str());
+ else
+ EmitRawText(OS1.str());
+}
+
void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
unsigned Column, unsigned Flags,
unsigned Isa,
unsigned Discriminator,
StringRef FileName) {
OS << "\t.loc\t" << FileNo << " " << Line << " " << Column;
- if (Flags & DWARF2_FLAG_BASIC_BLOCK)
- OS << " basic_block";
- if (Flags & DWARF2_FLAG_PROLOGUE_END)
- OS << " prologue_end";
- if (Flags & DWARF2_FLAG_EPILOGUE_BEGIN)
- OS << " epilogue_begin";
-
- unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
- if ((Flags & DWARF2_FLAG_IS_STMT) != (OldFlags & DWARF2_FLAG_IS_STMT)) {
- OS << " is_stmt ";
+ if (MAI->supportsExtendedDwarfLocDirective()) {
+ if (Flags & DWARF2_FLAG_BASIC_BLOCK)
+ OS << " basic_block";
+ if (Flags & DWARF2_FLAG_PROLOGUE_END)
+ OS << " prologue_end";
+ if (Flags & DWARF2_FLAG_EPILOGUE_BEGIN)
+ OS << " epilogue_begin";
+
+ unsigned OldFlags = getContext().getCurrentDwarfLoc().getFlags();
+ if ((Flags & DWARF2_FLAG_IS_STMT) != (OldFlags & DWARF2_FLAG_IS_STMT)) {
+ OS << " is_stmt ";
+
+ if (Flags & DWARF2_FLAG_IS_STMT)
+ OS << "1";
+ else
+ OS << "0";
+ }
- if (Flags & DWARF2_FLAG_IS_STMT)
- OS << "1";
- else
- OS << "0";
+ if (Isa)
+ OS << " isa " << Isa;
+ if (Discriminator)
+ OS << " discriminator " << Discriminator;
}
- if (Isa)
- OS << " isa " << Isa;
- if (Discriminator)
- OS << " discriminator " << Discriminator;
-
if (IsVerboseAsm) {
OS.PadToColumn(MAI->getCommentColumn());
OS << MAI->getCommentString() << ' ' << FileName << ':'
@@ -1606,6 +1687,17 @@ void MCAsmStreamer::EmitWinCFIEndProlog(SMLoc Loc) {
EmitEOL();
}
+void MCAsmStreamer::emitCGProfileEntry(const MCSymbolRefExpr *From,
+ const MCSymbolRefExpr *To,
+ uint64_t Count) {
+ OS << "\t.cg_profile ";
+ From->getSymbol().print(OS, MAI);
+ OS << ", ";
+ To->getSymbol().print(OS, MAI);
+ OS << ", " << Count;
+ EmitEOL();
+}
+
void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
const MCSubtargetInfo &STI,
bool PrintSchedInfo) {
@@ -1613,7 +1705,12 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
SmallString<256> Code;
SmallVector<MCFixup, 4> Fixups;
raw_svector_ostream VecOS(Code);
- Emitter->encodeInstruction(Inst, VecOS, Fixups, STI);
+
+ // If we have no code emitter, don't emit code.
+ if (!getAssembler().getEmitterPtr())
+ return;
+
+ getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
// If we are showing fixups, create symbolic markers in the encoded
// representation. We do this by making a per-bit map to the fixup item index,
@@ -1625,7 +1722,8 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
MCFixup &F = Fixups[i];
- const MCFixupKindInfo &Info = AsmBackend->getFixupKindInfo(F.getKind());
+ const MCFixupKindInfo &Info =
+ getAssembler().getBackend().getFixupKindInfo(F.getKind());
for (unsigned j = 0; j != Info.TargetSize; ++j) {
unsigned Index = F.getOffset() * 8 + Info.TargetOffset + j;
assert(Index < Code.size() * 8 && "Invalid offset in fixup!");
@@ -1689,7 +1787,8 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
MCFixup &F = Fixups[i];
- const MCFixupKindInfo &Info = AsmBackend->getFixupKindInfo(F.getKind());
+ const MCFixupKindInfo &Info =
+ getAssembler().getBackend().getFixupKindInfo(F.getKind());
OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
<< ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
}
@@ -1702,8 +1801,7 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst,
"Cannot emit contents before setting section!");
// Show the encoding in a comment if we have a code emitter.
- if (Emitter)
- AddEncodingComment(Inst, STI, PrintSchedInfo);
+ AddEncodingComment(Inst, STI, PrintSchedInfo);
// Show the MCInst if enabled.
if (ShowInst) {
@@ -1749,7 +1847,8 @@ void MCAsmStreamer::EmitBundleUnlock() {
}
bool MCAsmStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name,
- const MCExpr *Expr, SMLoc) {
+ const MCExpr *Expr, SMLoc,
+ const MCSubtargetInfo &STI) {
OS << "\t.reloc ";
Offset.print(OS, MAI);
OS << ", " << Name;
@@ -1761,6 +1860,17 @@ bool MCAsmStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name,
return false;
}
+void MCAsmStreamer::EmitAddrsig() {
+ OS << "\t.addrsig";
+ EmitEOL();
+}
+
+void MCAsmStreamer::EmitAddrsigSym(const MCSymbol *Sym) {
+ OS << "\t.addrsig_sym ";
+ Sym->print(OS, MAI);
+ EmitEOL();
+}
+
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
/// the specified string in the output .s file. This capability is
/// indicated by the hasRawTextSupport() predicate.
@@ -1792,8 +1902,11 @@ void MCAsmStreamer::FinishImpl() {
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
std::unique_ptr<formatted_raw_ostream> OS,
bool isVerboseAsm, bool useDwarfDirectory,
- MCInstPrinter *IP, MCCodeEmitter *CE,
- MCAsmBackend *MAB, bool ShowInst) {
+ MCInstPrinter *IP,
+ std::unique_ptr<MCCodeEmitter> &&CE,
+ std::unique_ptr<MCAsmBackend> &&MAB,
+ bool ShowInst) {
return new MCAsmStreamer(Context, std::move(OS), isVerboseAsm,
- useDwarfDirectory, IP, CE, MAB, ShowInst);
+ useDwarfDirectory, IP, std::move(CE), std::move(MAB),
+ ShowInst);
}