From e6d1592492a3a379186bfb02bd0f4eda0669c0d5 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 20 Aug 2019 20:50:12 +0000 Subject: Vendor import of stripped llvm trunk r366426 (just before the release_90 branch point): https://llvm.org/svn/llvm-project/llvm/trunk@366426 --- lib/MC/MCAsmStreamer.cpp | 61 +++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'lib/MC/MCAsmStreamer.cpp') diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index e017103070bf..7a2b0b8a1220 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -1,9 +1,8 @@ //===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output ----------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -108,10 +107,7 @@ public: void AddComment(const Twine &T, bool EOL = true) override; /// 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); + void AddEncodingComment(const MCInst &Inst, const MCSubtargetInfo &); /// Return a raw_ostream that comments can be written to. /// Unlike AddComment, you are required to terminate comments with \n if you @@ -192,6 +188,7 @@ public: void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc()) override; void EmitIntValue(uint64_t Value, unsigned Size) override; + void EmitIntValueInHex(uint64_t Value, unsigned Size) override; void EmitULEB128Value(const MCExpr *Value) override; @@ -227,11 +224,11 @@ public: Expected tryEmitDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, - MD5::MD5Result *Checksum = 0, + Optional Checksum = None, Optional Source = None, unsigned CUID = 0) override; void emitDwarfFile0Directive(StringRef Directory, StringRef Filename, - MD5::MD5Result *Checksum, + Optional Checksum, Optional Source, unsigned CUID = 0) override; void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, @@ -312,8 +309,7 @@ public: void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count) override; - void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, - bool PrintSchedInfo) override; + void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override; void EmitBundleAlignMode(unsigned AlignPow2) override; void EmitBundleLock(bool AlignToEnd) override; @@ -546,6 +542,7 @@ static const char *getPlatformName(MachO::PlatformType Type) { case MachO::PLATFORM_TVOS: return "tvos"; case MachO::PLATFORM_WATCHOS: return "watchos"; case MachO::PLATFORM_BRIDGEOS: return "bridgeos"; + case MachO::PLATFORM_MACCATALYST: return "macCatalyst"; case MachO::PLATFORM_IOSSIMULATOR: return "iossimulator"; case MachO::PLATFORM_TVOSSIMULATOR: return "tvossimulator"; case MachO::PLATFORM_WATCHOSSIMULATOR: return "watchossimulator"; @@ -657,6 +654,9 @@ bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, // .weak_reference case MCSA_WeakReference: OS << MAI->getWeakRefDirective(); break; case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break; + case MCSA_Cold: + // Assemblers currently do not support a .cold directive. + return false; } Symbol->print(OS, MAI); @@ -924,6 +924,10 @@ void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size) { EmitValue(MCConstantExpr::create(Value, getContext()), Size); } +void MCAsmStreamer::EmitIntValueInHex(uint64_t Value, unsigned Size) { + EmitValue(MCConstantExpr::create(Value, getContext(), true), Size); +} + void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) { assert(Size <= 8 && "Invalid size"); @@ -1153,7 +1157,7 @@ void MCAsmStreamer::EmitFileDirective(StringRef Filename) { static void printDwarfFileDirective(unsigned FileNo, StringRef Directory, StringRef Filename, - MD5::MD5Result *Checksum, + Optional Checksum, Optional Source, bool UseDwarfDirectory, raw_svector_ostream &OS) { @@ -1186,13 +1190,14 @@ static void printDwarfFileDirective(unsigned FileNo, StringRef Directory, Expected MCAsmStreamer::tryEmitDwarfFileDirective( unsigned FileNo, StringRef Directory, StringRef Filename, - MD5::MD5Result *Checksum, Optional Source, unsigned CUID) { + Optional Checksum, Optional Source, unsigned CUID) { assert(CUID == 0 && "multiple CUs not supported by MCAsmStreamer"); MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID); unsigned NumFiles = Table.getMCDwarfFiles().size(); Expected FileNoOrErr = - Table.tryGetFile(Directory, Filename, Checksum, Source, FileNo); + Table.tryGetFile(Directory, Filename, Checksum, Source, + getContext().getDwarfVersion(), FileNo); if (!FileNoOrErr) return FileNoOrErr.takeError(); FileNo = FileNoOrErr.get(); @@ -1214,7 +1219,7 @@ Expected MCAsmStreamer::tryEmitDwarfFileDirective( void MCAsmStreamer::emitDwarfFile0Directive(StringRef Directory, StringRef Filename, - MD5::MD5Result *Checksum, + Optional Checksum, Optional Source, unsigned CUID) { assert(CUID == 0); @@ -1737,8 +1742,7 @@ void MCAsmStreamer::emitCGProfileEntry(const MCSymbolRefExpr *From, } void MCAsmStreamer::AddEncodingComment(const MCInst &Inst, - const MCSubtargetInfo &STI, - bool PrintSchedInfo) { + const MCSubtargetInfo &STI) { raw_ostream &OS = GetCommentOS(); SmallString<256> Code; SmallVector Fixups; @@ -1817,11 +1821,7 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst, } } } - OS << "]"; - // If we are not going to add fixup or schedule comments after this point - // then we have to end the current comment line with "\n". - if (Fixups.size() || !PrintSchedInfo) - OS << "\n"; + OS << "]\n"; for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { MCFixup &F = Fixups[i]; @@ -1833,18 +1833,15 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst, } void MCAsmStreamer::EmitInstruction(const MCInst &Inst, - const MCSubtargetInfo &STI, - bool PrintSchedInfo) { + const MCSubtargetInfo &STI) { assert(getCurrentSectionOnly() && "Cannot emit contents before setting section!"); // Show the encoding in a comment if we have a code emitter. - AddEncodingComment(Inst, STI, PrintSchedInfo); + AddEncodingComment(Inst, STI); // Show the MCInst if enabled. if (ShowInst) { - if (PrintSchedInfo) - GetCommentOS() << "\n"; Inst.dump_pretty(GetCommentOS(), InstPrinter.get(), "\n "); GetCommentOS() << "\n"; } @@ -1854,12 +1851,6 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst, else InstPrinter->printInst(&Inst, OS, "", STI); - if (PrintSchedInfo) { - std::string SI = STI.getSchedInfoStr(Inst); - if (!SI.empty()) - GetCommentOS() << SI; - } - StringRef Comments = CommentToEmit; if (Comments.size() && Comments.back() != '\n') GetCommentOS() << "\n"; @@ -1927,7 +1918,7 @@ void MCAsmStreamer::FinishImpl() { // Emit the label for the line table, if requested - since the rest of the // line table will be defined by .loc/.file directives, and not emitted // directly, the label is the only work required here. - auto &Tables = getContext().getMCDwarfLineTables(); + const auto &Tables = getContext().getMCDwarfLineTables(); if (!Tables.empty()) { assert(Tables.size() == 1 && "asm output only supports one line table"); if (auto *Label = Tables.begin()->second.getLabel()) { -- cgit v1.2.3