2009-06-24 01:03:06 +00:00
|
|
|
//===- lib/MC/MCAsmStreamer.cpp - Text Assembly Output --------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2009-08-31 08:08:38 +00:00
|
|
|
#include "llvm/MC/MCAsmInfo.h"
|
2009-08-27 00:51:57 +00:00
|
|
|
#include "llvm/MC/MCCodeEmitter.h"
|
2009-06-24 01:03:06 +00:00
|
|
|
#include "llvm/MC/MCContext.h"
|
2009-08-31 08:08:38 +00:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
2009-07-01 06:35:03 +00:00
|
|
|
#include "llvm/MC/MCInst.h"
|
2009-09-14 03:02:37 +00:00
|
|
|
#include "llvm/MC/MCInstPrinter.h"
|
2009-08-10 18:15:01 +00:00
|
|
|
#include "llvm/MC/MCSectionMachO.h"
|
2009-06-24 01:03:06 +00:00
|
|
|
#include "llvm/MC/MCSymbol.h"
|
2010-03-19 05:48:53 +00:00
|
|
|
#include "llvm/ADT/OwningPtr.h"
|
2010-01-22 07:29:22 +00:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
|
|
|
#include "llvm/ADT/Twine.h"
|
2009-07-11 20:10:48 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2009-08-19 06:12:02 +00:00
|
|
|
#include "llvm/Support/MathExtras.h"
|
2009-08-27 00:51:57 +00:00
|
|
|
#include "llvm/Support/Format.h"
|
2010-01-22 07:29:22 +00:00
|
|
|
#include "llvm/Support/FormattedStream.h"
|
2009-06-24 01:03:06 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
class MCAsmStreamer : public MCStreamer {
|
2010-01-22 07:29:22 +00:00
|
|
|
formatted_raw_ostream &OS;
|
2009-08-22 21:43:10 +00:00
|
|
|
const MCAsmInfo &MAI;
|
2010-03-19 05:48:53 +00:00
|
|
|
OwningPtr<MCInstPrinter> InstPrinter;
|
2009-08-27 00:51:57 +00:00
|
|
|
MCCodeEmitter *Emitter;
|
2010-01-22 07:29:22 +00:00
|
|
|
|
|
|
|
SmallString<128> CommentToEmit;
|
2010-01-22 19:17:48 +00:00
|
|
|
raw_svector_ostream CommentStream;
|
2010-02-03 18:18:30 +00:00
|
|
|
|
|
|
|
unsigned IsLittleEndian : 1;
|
|
|
|
unsigned IsVerboseAsm : 1;
|
|
|
|
unsigned ShowInst : 1;
|
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
public:
|
2010-01-22 07:29:22 +00:00
|
|
|
MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os,
|
2010-01-22 07:06:15 +00:00
|
|
|
bool isLittleEndian, bool isVerboseAsm, MCInstPrinter *printer,
|
2010-02-10 01:41:14 +00:00
|
|
|
MCCodeEmitter *emitter, bool showInst)
|
2010-03-12 18:28:53 +00:00
|
|
|
: MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()),
|
|
|
|
InstPrinter(printer), Emitter(emitter), CommentStream(CommentToEmit),
|
2010-02-03 18:18:30 +00:00
|
|
|
IsLittleEndian(isLittleEndian), IsVerboseAsm(isVerboseAsm),
|
2010-02-10 01:41:14 +00:00
|
|
|
ShowInst(showInst) {
|
2010-02-10 00:10:18 +00:00
|
|
|
if (InstPrinter && IsVerboseAsm)
|
|
|
|
InstPrinter->setCommentStream(CommentStream);
|
|
|
|
}
|
2009-08-17 04:17:34 +00:00
|
|
|
~MCAsmStreamer() {}
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2010-01-20 06:39:07 +00:00
|
|
|
bool isLittleEndian() const { return IsLittleEndian; }
|
2010-02-09 23:00:14 +00:00
|
|
|
|
2010-01-22 07:29:22 +00:00
|
|
|
inline void EmitEOL() {
|
2010-01-22 19:17:48 +00:00
|
|
|
// If we don't have any comments, just emit a \n.
|
|
|
|
if (!IsVerboseAsm) {
|
2010-01-22 07:29:22 +00:00
|
|
|
OS << '\n';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EmitCommentsAndEOL();
|
|
|
|
}
|
|
|
|
void EmitCommentsAndEOL();
|
2010-02-02 23:37:42 +00:00
|
|
|
|
|
|
|
/// isVerboseAsm - Return true if this streamer supports verbose assembly at
|
|
|
|
/// all.
|
|
|
|
virtual bool isVerboseAsm() const { return IsVerboseAsm; }
|
2010-04-03 21:35:55 +00:00
|
|
|
|
|
|
|
/// hasRawTextSupport - We support EmitRawText.
|
|
|
|
virtual bool hasRawTextSupport() const { return true; }
|
2010-02-09 23:00:14 +00:00
|
|
|
|
2010-01-22 18:21:35 +00:00
|
|
|
/// AddComment - Add a comment that can be emitted to the generated .s
|
2010-01-22 07:29:22 +00:00
|
|
|
/// 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.
|
2010-01-22 18:21:35 +00:00
|
|
|
virtual void AddComment(const Twine &T);
|
2010-02-09 23:00:14 +00:00
|
|
|
|
|
|
|
/// AddEncodingComment - Add a comment showing the encoding of an instruction.
|
|
|
|
virtual void AddEncodingComment(const MCInst &Inst);
|
|
|
|
|
2010-01-22 19:17:48 +00:00
|
|
|
/// GetCommentOS - 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.
|
|
|
|
virtual raw_ostream &GetCommentOS() {
|
|
|
|
if (!IsVerboseAsm)
|
|
|
|
return nulls(); // Discard comments unless in verbose asm mode.
|
|
|
|
return CommentStream;
|
|
|
|
}
|
2010-02-09 23:00:14 +00:00
|
|
|
|
2010-01-22 19:52:01 +00:00
|
|
|
/// AddBlankLine - Emit a blank line to a .s file to pretty it up.
|
|
|
|
virtual void AddBlankLine() {
|
|
|
|
EmitEOL();
|
|
|
|
}
|
2010-02-09 23:00:14 +00:00
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
/// @name MCStreamer Interface
|
|
|
|
/// @{
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2009-08-17 05:49:08 +00:00
|
|
|
virtual void SwitchSection(const MCSection *Section);
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
virtual void EmitLabel(MCSymbol *Symbol);
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2010-01-23 06:39:22 +00:00
|
|
|
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2009-08-31 08:09:28 +00:00
|
|
|
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2010-01-23 06:39:22 +00:00
|
|
|
virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute);
|
2009-07-13 21:03:15 +00:00
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
|
2010-05-08 19:54:22 +00:00
|
|
|
virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
|
|
|
|
virtual void EmitCOFFSymbolStorageClass(int StorageClass);
|
|
|
|
virtual void EmitCOFFSymbolType(int Type);
|
|
|
|
virtual void EndCOFFSymbolDef();
|
2010-01-25 07:52:13 +00:00
|
|
|
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value);
|
2010-01-23 07:47:02 +00:00
|
|
|
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
2009-08-30 06:17:16 +00:00
|
|
|
unsigned ByteAlignment);
|
2009-07-14 18:17:10 +00:00
|
|
|
|
2010-01-23 07:47:02 +00:00
|
|
|
/// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol.
|
|
|
|
///
|
|
|
|
/// @param Symbol - The common symbol to emit.
|
|
|
|
/// @param Size - The size of the common symbol.
|
|
|
|
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size);
|
|
|
|
|
2009-08-28 05:48:22 +00:00
|
|
|
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
|
2009-08-30 06:17:16 +00:00
|
|
|
unsigned Size = 0, unsigned ByteAlignment = 0);
|
2009-07-14 21:35:03 +00:00
|
|
|
|
2010-05-18 21:16:04 +00:00
|
|
|
virtual void EmitTBSSSymbol (const MCSection *Section, MCSymbol *Symbol,
|
|
|
|
uint64_t Size, unsigned ByteAlignment = 0);
|
2010-05-14 01:50:28 +00:00
|
|
|
|
2010-01-19 19:46:13 +00:00
|
|
|
virtual void EmitBytes(StringRef Data, unsigned AddrSpace);
|
2009-07-07 20:30:46 +00:00
|
|
|
|
2010-01-19 19:46:13 +00:00
|
|
|
virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace);
|
2010-01-19 22:03:38 +00:00
|
|
|
virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace);
|
2010-01-25 21:28:50 +00:00
|
|
|
virtual void EmitGPRel32Value(const MCExpr *Value);
|
|
|
|
|
2010-01-19 22:03:38 +00:00
|
|
|
|
2010-01-19 19:46:13 +00:00
|
|
|
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
|
|
|
|
unsigned AddrSpace);
|
2009-07-10 22:20:30 +00:00
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
|
|
|
|
unsigned ValueSize = 1,
|
|
|
|
unsigned MaxBytesToEmit = 0);
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2010-02-23 18:26:34 +00:00
|
|
|
virtual void EmitCodeAlignment(unsigned ByteAlignment,
|
|
|
|
unsigned MaxBytesToEmit = 0);
|
|
|
|
|
2009-08-31 08:09:28 +00:00
|
|
|
virtual void EmitValueToOffset(const MCExpr *Offset,
|
2009-08-17 04:17:34 +00:00
|
|
|
unsigned char Value = 0);
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2010-01-25 18:58:59 +00:00
|
|
|
virtual void EmitFileDirective(StringRef Filename);
|
|
|
|
virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename);
|
|
|
|
|
|
|
|
virtual void EmitInstruction(const MCInst &Inst);
|
|
|
|
|
2010-04-03 21:35:55 +00:00
|
|
|
/// EmitRawText - If this file is backed by a assembly streamer, this dumps
|
|
|
|
/// the specified string in the output .s file. This capability is
|
|
|
|
/// indicated by the hasRawTextSupport() predicate.
|
|
|
|
virtual void EmitRawText(StringRef String);
|
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
virtual void Finish();
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
};
|
2009-06-24 19:25:34 +00:00
|
|
|
|
2009-08-17 04:17:34 +00:00
|
|
|
} // end anonymous namespace.
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2010-01-22 18:21:35 +00:00
|
|
|
/// AddComment - Add a comment that can be emitted to the generated .s
|
2010-01-22 07:29:22 +00:00
|
|
|
/// 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.
|
2010-01-22 18:21:35 +00:00
|
|
|
void MCAsmStreamer::AddComment(const Twine &T) {
|
2010-01-22 07:29:22 +00:00
|
|
|
if (!IsVerboseAsm) return;
|
2010-01-22 19:17:48 +00:00
|
|
|
|
|
|
|
// Make sure that CommentStream is flushed.
|
|
|
|
CommentStream.flush();
|
|
|
|
|
2010-01-22 07:29:22 +00:00
|
|
|
T.toVector(CommentToEmit);
|
2010-01-22 19:17:48 +00:00
|
|
|
// Each comment goes on its own line.
|
|
|
|
CommentToEmit.push_back('\n');
|
2010-01-22 21:16:10 +00:00
|
|
|
|
|
|
|
// Tell the comment stream that the vector changed underneath it.
|
|
|
|
CommentStream.resync();
|
2010-01-22 07:29:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EmitCommentsAndEOL() {
|
2010-01-22 19:17:48 +00:00
|
|
|
if (CommentToEmit.empty() && CommentStream.GetNumBytesInBuffer() == 0) {
|
|
|
|
OS << '\n';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CommentStream.flush();
|
2010-01-22 07:29:22 +00:00
|
|
|
StringRef Comments = CommentToEmit.str();
|
2010-01-22 19:17:48 +00:00
|
|
|
|
|
|
|
assert(Comments.back() == '\n' &&
|
|
|
|
"Comment array not newline terminated");
|
|
|
|
do {
|
2010-01-22 07:29:22 +00:00
|
|
|
// Emit a line of comments.
|
|
|
|
OS.PadToColumn(MAI.getCommentColumn());
|
|
|
|
size_t Position = Comments.find('\n');
|
|
|
|
OS << MAI.getCommentString() << ' ' << Comments.substr(0, Position) << '\n';
|
|
|
|
|
|
|
|
Comments = Comments.substr(Position+1);
|
2010-01-22 19:17:48 +00:00
|
|
|
} while (!Comments.empty());
|
2010-01-22 07:29:22 +00:00
|
|
|
|
2010-01-22 21:16:10 +00:00
|
|
|
CommentToEmit.clear();
|
|
|
|
// Tell the comment stream that the vector changed underneath it.
|
|
|
|
CommentStream.resync();
|
2010-01-22 07:29:22 +00:00
|
|
|
}
|
|
|
|
|
2009-06-25 21:03:18 +00:00
|
|
|
static inline int64_t truncateToSize(int64_t Value, unsigned Bytes) {
|
|
|
|
assert(Bytes && "Invalid size!");
|
|
|
|
return Value & ((uint64_t) (int64_t) -1 >> (64 - Bytes * 8));
|
|
|
|
}
|
|
|
|
|
2009-08-17 05:49:08 +00:00
|
|
|
void MCAsmStreamer::SwitchSection(const MCSection *Section) {
|
2009-08-19 05:49:37 +00:00
|
|
|
assert(Section && "Cannot switch to a null section!");
|
2009-06-24 01:03:06 +00:00
|
|
|
if (Section != CurSection) {
|
|
|
|
CurSection = Section;
|
2009-08-22 21:43:10 +00:00
|
|
|
Section->PrintSwitchToSection(MAI, OS);
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
|
2009-08-22 07:22:36 +00:00
|
|
|
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
2010-05-05 19:01:00 +00:00
|
|
|
assert(!Symbol->isVariable() && "Cannot emit a variable symbol!");
|
2009-06-24 17:00:42 +00:00
|
|
|
assert(CurSection && "Cannot emit before setting section!");
|
|
|
|
|
2010-01-22 07:36:39 +00:00
|
|
|
OS << *Symbol << ":";
|
|
|
|
EmitEOL();
|
2009-08-22 07:22:36 +00:00
|
|
|
Symbol->setSection(*CurSection);
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2010-01-23 06:39:22 +00:00
|
|
|
void MCAsmStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
|
2009-07-16 17:56:39 +00:00
|
|
|
switch (Flag) {
|
2009-08-13 23:36:34 +00:00
|
|
|
default: assert(0 && "Invalid flag!");
|
2010-01-23 06:39:22 +00:00
|
|
|
case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
|
2009-07-16 17:56:39 +00:00
|
|
|
}
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2009-07-13 21:03:15 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 08:09:28 +00:00
|
|
|
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
2010-01-22 07:36:39 +00:00
|
|
|
OS << *Symbol << " = " << *Value;
|
|
|
|
EmitEOL();
|
2009-10-16 01:34:54 +00:00
|
|
|
|
|
|
|
// FIXME: Lift context changes into super class.
|
2010-05-05 17:41:00 +00:00
|
|
|
Symbol->setVariableValue(Value);
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 01:34:54 +00:00
|
|
|
void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
2010-01-23 06:39:22 +00:00
|
|
|
MCSymbolAttr Attribute) {
|
2009-06-24 01:03:06 +00:00
|
|
|
switch (Attribute) {
|
2010-01-23 06:39:22 +00:00
|
|
|
case MCSA_Invalid: assert(0 && "Invalid symbol attribute");
|
2010-01-25 18:30:45 +00:00
|
|
|
case MCSA_ELF_TypeFunction: /// .type _foo, STT_FUNC # aka @function
|
|
|
|
case MCSA_ELF_TypeIndFunction: /// .type _foo, STT_GNU_IFUNC
|
|
|
|
case MCSA_ELF_TypeObject: /// .type _foo, STT_OBJECT # aka @object
|
|
|
|
case MCSA_ELF_TypeTLS: /// .type _foo, STT_TLS # aka @tls_object
|
|
|
|
case MCSA_ELF_TypeCommon: /// .type _foo, STT_COMMON # aka @common
|
|
|
|
case MCSA_ELF_TypeNoType: /// .type _foo, STT_NOTYPE # aka @notype
|
|
|
|
assert(MAI.hasDotTypeDotSizeDirective() && "Symbol Attr not supported");
|
2010-02-04 01:42:13 +00:00
|
|
|
OS << "\t.type\t" << *Symbol << ','
|
2010-01-25 18:30:45 +00:00
|
|
|
<< ((MAI.getCommentString()[0] != '@') ? '@' : '%');
|
|
|
|
switch (Attribute) {
|
|
|
|
default: assert(0 && "Unknown ELF .type");
|
|
|
|
case MCSA_ELF_TypeFunction: OS << "function"; break;
|
|
|
|
case MCSA_ELF_TypeIndFunction: OS << "gnu_indirect_function"; break;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
EmitEOL();
|
|
|
|
return;
|
|
|
|
case MCSA_Global: // .globl/.global
|
|
|
|
OS << MAI.getGlobalDirective();
|
|
|
|
break;
|
2010-06-21 20:35:01 +00:00
|
|
|
case MCSA_Hidden: OS << "\t.hidden\t"; break;
|
|
|
|
case MCSA_IndirectSymbol: OS << "\t.indirect_symbol\t"; break;
|
|
|
|
case MCSA_Internal: OS << "\t.internal\t"; break;
|
|
|
|
case MCSA_LazyReference: OS << "\t.lazy_reference\t"; break;
|
|
|
|
case MCSA_Local: OS << "\t.local\t"; break;
|
|
|
|
case MCSA_NoDeadStrip: OS << "\t.no_dead_strip\t"; break;
|
|
|
|
case MCSA_PrivateExtern: OS << "\t.private_extern\t"; break;
|
|
|
|
case MCSA_Protected: OS << "\t.protected\t"; break;
|
|
|
|
case MCSA_Reference: OS << "\t.reference\t"; break;
|
|
|
|
case MCSA_Weak: OS << "\t.weak\t"; break;
|
|
|
|
case MCSA_WeakDefinition: OS << "\t.weak_definition\t"; break;
|
2010-01-23 06:39:22 +00:00
|
|
|
// .weak_reference
|
|
|
|
case MCSA_WeakReference: OS << MAI.getWeakRefDirective(); break;
|
2010-07-08 17:22:42 +00:00
|
|
|
case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break;
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2010-01-22 07:36:39 +00:00
|
|
|
OS << *Symbol;
|
|
|
|
EmitEOL();
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2009-07-14 18:17:10 +00:00
|
|
|
void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
2010-01-22 07:36:39 +00:00
|
|
|
OS << ".desc" << ' ' << *Symbol << ',' << DescValue;
|
|
|
|
EmitEOL();
|
2009-07-14 18:17:10 +00:00
|
|
|
}
|
|
|
|
|
2010-05-08 19:54:22 +00:00
|
|
|
void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
|
|
|
|
OS << "\t.def\t " << *Symbol << ';';
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EmitCOFFSymbolStorageClass (int StorageClass) {
|
|
|
|
OS << "\t.scl\t" << StorageClass << ';';
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EmitCOFFSymbolType (int Type) {
|
|
|
|
OS << "\t.type\t" << Type << ';';
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EndCOFFSymbolDef() {
|
|
|
|
OS << "\t.endef";
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:52:13 +00:00
|
|
|
void MCAsmStreamer::EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {
|
|
|
|
assert(MAI.hasDotTypeDotSizeDirective());
|
|
|
|
OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
|
|
|
|
}
|
|
|
|
|
2010-01-23 07:47:02 +00:00
|
|
|
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
2009-08-30 06:17:16 +00:00
|
|
|
unsigned ByteAlignment) {
|
2010-01-23 07:47:02 +00:00
|
|
|
OS << "\t.comm\t" << *Symbol << ',' << Size;
|
2010-01-25 07:29:13 +00:00
|
|
|
if (ByteAlignment != 0) {
|
2010-01-26 20:21:43 +00:00
|
|
|
if (MAI.getCOMMDirectiveAlignmentIsInBytes())
|
2010-01-19 06:01:04 +00:00
|
|
|
OS << ',' << ByteAlignment;
|
|
|
|
else
|
|
|
|
OS << ',' << Log2_32(ByteAlignment);
|
|
|
|
}
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2009-07-07 20:30:46 +00:00
|
|
|
}
|
|
|
|
|
2010-01-23 07:47:02 +00:00
|
|
|
/// 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) {
|
|
|
|
assert(MAI.hasLCOMMDirective() && "Doesn't have .lcomm, can't emit it!");
|
|
|
|
OS << "\t.lcomm\t" << *Symbol << ',' << Size;
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
2009-08-28 05:48:22 +00:00
|
|
|
void MCAsmStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
|
2009-08-30 06:17:16 +00:00
|
|
|
unsigned Size, unsigned ByteAlignment) {
|
2009-08-13 23:36:34 +00:00
|
|
|
// Note: a .zerofill directive does not switch sections.
|
2009-08-08 23:39:42 +00:00
|
|
|
OS << ".zerofill ";
|
|
|
|
|
|
|
|
// This is a mach-o specific directive.
|
2009-08-10 01:39:42 +00:00
|
|
|
const MCSectionMachO *MOSection = ((const MCSectionMachO*)Section);
|
2009-08-14 18:51:45 +00:00
|
|
|
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
|
2009-08-08 23:39:42 +00:00
|
|
|
|
2009-07-10 22:20:30 +00:00
|
|
|
if (Symbol != NULL) {
|
2010-01-17 21:43:43 +00:00
|
|
|
OS << ',' << *Symbol << ',' << Size;
|
2009-08-30 06:17:16 +00:00
|
|
|
if (ByteAlignment != 0)
|
|
|
|
OS << ',' << Log2_32(ByteAlignment);
|
2009-07-10 22:20:30 +00:00
|
|
|
}
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2009-07-10 22:20:30 +00:00
|
|
|
}
|
|
|
|
|
2010-05-17 02:13:02 +00:00
|
|
|
// .tbss sym, size, align
|
|
|
|
// This depends that the symbol has already been mangled from the original,
|
|
|
|
// e.g. _a.
|
2010-05-18 21:16:04 +00:00
|
|
|
void MCAsmStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
|
|
|
|
uint64_t Size, unsigned ByteAlignment) {
|
2010-05-14 01:50:28 +00:00
|
|
|
assert(Symbol != NULL && "Symbol shouldn't be NULL!");
|
2010-05-18 21:16:04 +00:00
|
|
|
// Instead of using the Section we'll just use the shortcut.
|
|
|
|
// This is a mach-o specific directive and section.
|
2010-05-17 02:13:02 +00:00
|
|
|
OS << ".tbss " << *Symbol << ", " << Size;
|
2010-05-14 01:50:28 +00:00
|
|
|
|
2010-05-18 21:16:04 +00:00
|
|
|
// Output align if we have it. We default to 1 so don't bother printing
|
|
|
|
// that.
|
|
|
|
if (ByteAlignment > 1) OS << ", " << Log2_32(ByteAlignment);
|
2010-05-14 01:50:28 +00:00
|
|
|
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
2010-01-23 00:15:00 +00:00
|
|
|
static inline char toOctal(int X) { return (X&7)+'0'; }
|
|
|
|
|
2010-01-25 18:58:59 +00:00
|
|
|
static void PrintQuotedString(StringRef Data, raw_ostream &OS) {
|
|
|
|
OS << '"';
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = Data.size(); i != e; ++i) {
|
|
|
|
unsigned char C = Data[i];
|
|
|
|
if (C == '"' || C == '\\') {
|
|
|
|
OS << '\\' << (char)C;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isprint((unsigned char)C)) {
|
|
|
|
OS << (char)C;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (C) {
|
|
|
|
case '\b': OS << "\\b"; break;
|
|
|
|
case '\f': OS << "\\f"; break;
|
|
|
|
case '\n': OS << "\\n"; break;
|
|
|
|
case '\r': OS << "\\r"; break;
|
|
|
|
case '\t': OS << "\\t"; break;
|
|
|
|
default:
|
|
|
|
OS << '\\';
|
|
|
|
OS << toOctal(C >> 6);
|
|
|
|
OS << toOctal(C >> 3);
|
|
|
|
OS << toOctal(C >> 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << '"';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-19 19:46:13 +00:00
|
|
|
void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
|
2009-06-24 17:00:42 +00:00
|
|
|
assert(CurSection && "Cannot emit contents before setting section!");
|
2010-01-23 00:15:00 +00:00
|
|
|
if (Data.empty()) return;
|
|
|
|
|
|
|
|
if (Data.size() == 1) {
|
|
|
|
OS << MAI.getData8bitsDirective(AddrSpace);
|
|
|
|
OS << (unsigned)(unsigned char)Data[0];
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2010-01-23 00:15:00 +00:00
|
|
|
return;
|
2010-01-22 07:36:39 +00:00
|
|
|
}
|
2010-01-23 00:15:00 +00:00
|
|
|
|
|
|
|
// If the data ends with 0 and the target supports .asciz, use it, otherwise
|
|
|
|
// use .ascii
|
|
|
|
if (MAI.getAscizDirective() && Data.back() == 0) {
|
|
|
|
OS << MAI.getAscizDirective();
|
|
|
|
Data = Data.substr(0, Data.size()-1);
|
|
|
|
} else {
|
|
|
|
OS << MAI.getAsciiDirective();
|
|
|
|
}
|
|
|
|
|
2010-01-25 18:58:59 +00:00
|
|
|
OS << ' ';
|
|
|
|
PrintQuotedString(Data, OS);
|
2010-01-23 00:15:00 +00:00
|
|
|
EmitEOL();
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2010-01-19 22:03:38 +00:00
|
|
|
/// EmitIntValue - Special case of EmitValue that avoids the client having
|
|
|
|
/// to pass in a MCExpr for constant integers.
|
|
|
|
void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size,
|
|
|
|
unsigned AddrSpace) {
|
|
|
|
assert(CurSection && "Cannot emit contents before setting section!");
|
|
|
|
const char *Directive = 0;
|
|
|
|
switch (Size) {
|
|
|
|
default: break;
|
|
|
|
case 1: Directive = MAI.getData8bitsDirective(AddrSpace); break;
|
|
|
|
case 2: Directive = MAI.getData16bitsDirective(AddrSpace); break;
|
|
|
|
case 4: Directive = MAI.getData32bitsDirective(AddrSpace); break;
|
2010-01-20 06:45:39 +00:00
|
|
|
case 8:
|
|
|
|
Directive = MAI.getData64bitsDirective(AddrSpace);
|
|
|
|
// If the target doesn't support 64-bit data, emit as two 32-bit halves.
|
|
|
|
if (Directive) break;
|
|
|
|
if (isLittleEndian()) {
|
|
|
|
EmitIntValue((uint32_t)(Value >> 0 ), 4, AddrSpace);
|
|
|
|
EmitIntValue((uint32_t)(Value >> 32), 4, AddrSpace);
|
|
|
|
} else {
|
|
|
|
EmitIntValue((uint32_t)(Value >> 32), 4, AddrSpace);
|
|
|
|
EmitIntValue((uint32_t)(Value >> 0 ), 4, AddrSpace);
|
|
|
|
}
|
|
|
|
return;
|
2010-01-19 22:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
assert(Directive && "Invalid size for machine code value!");
|
2010-01-22 07:29:22 +00:00
|
|
|
OS << Directive << truncateToSize(Value, Size);
|
|
|
|
EmitEOL();
|
2010-01-19 22:03:38 +00:00
|
|
|
}
|
|
|
|
|
2010-01-19 19:46:13 +00:00
|
|
|
void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size,
|
|
|
|
unsigned AddrSpace) {
|
2009-06-24 17:00:42 +00:00
|
|
|
assert(CurSection && "Cannot emit contents before setting section!");
|
2010-01-19 22:03:38 +00:00
|
|
|
const char *Directive = 0;
|
2009-06-24 01:03:06 +00:00
|
|
|
switch (Size) {
|
2010-01-19 22:03:38 +00:00
|
|
|
default: break;
|
|
|
|
case 1: Directive = MAI.getData8bitsDirective(AddrSpace); break;
|
|
|
|
case 2: Directive = MAI.getData16bitsDirective(AddrSpace); break;
|
|
|
|
case 4: Directive = MAI.getData32bitsDirective(AddrSpace); break;
|
|
|
|
case 8: Directive = MAI.getData64bitsDirective(AddrSpace); break;
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
2010-01-19 19:46:13 +00:00
|
|
|
|
2010-01-19 22:03:38 +00:00
|
|
|
assert(Directive && "Invalid size for machine code value!");
|
2010-01-25 21:28:50 +00:00
|
|
|
OS << Directive << *Value;
|
2010-01-22 07:29:22 +00:00
|
|
|
EmitEOL();
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2010-01-25 21:28:50 +00:00
|
|
|
void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
|
|
|
|
assert(MAI.getGPRel32Directive() != 0);
|
|
|
|
OS << MAI.getGPRel32Directive() << *Value;
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-19 18:52:28 +00:00
|
|
|
/// EmitFill - Emit NumBytes bytes worth of the value specified by
|
|
|
|
/// FillValue. This implements directives such as '.space'.
|
2010-01-19 19:46:13 +00:00
|
|
|
void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
|
|
|
|
unsigned AddrSpace) {
|
2010-01-19 18:58:52 +00:00
|
|
|
if (NumBytes == 0) return;
|
|
|
|
|
2010-01-19 19:46:13 +00:00
|
|
|
if (AddrSpace == 0)
|
|
|
|
if (const char *ZeroDirective = MAI.getZeroDirective()) {
|
|
|
|
OS << ZeroDirective << NumBytes;
|
|
|
|
if (FillValue != 0)
|
|
|
|
OS << ',' << (int)FillValue;
|
2010-01-22 07:29:22 +00:00
|
|
|
EmitEOL();
|
2010-01-19 19:46:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit a byte at a time.
|
|
|
|
MCStreamer::EmitFill(NumBytes, FillValue, AddrSpace);
|
2010-01-19 18:52:28 +00:00
|
|
|
}
|
|
|
|
|
2009-06-24 19:25:34 +00:00
|
|
|
void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
|
|
|
|
unsigned ValueSize,
|
|
|
|
unsigned MaxBytesToEmit) {
|
2009-08-19 06:12:02 +00:00
|
|
|
// Some assemblers don't support non-power of two alignments, so we always
|
|
|
|
// emit alignments as a power of two if possible.
|
|
|
|
if (isPowerOf2_32(ByteAlignment)) {
|
2009-08-19 06:35:36 +00:00
|
|
|
switch (ValueSize) {
|
|
|
|
default: llvm_unreachable("Invalid size for machine code value!");
|
2009-08-22 21:43:10 +00:00
|
|
|
case 1: OS << MAI.getAlignDirective(); break;
|
|
|
|
// FIXME: use MAI for this!
|
2009-08-19 06:35:36 +00:00
|
|
|
case 2: OS << ".p2alignw "; break;
|
|
|
|
case 4: OS << ".p2alignl "; break;
|
|
|
|
case 8: llvm_unreachable("Unsupported alignment size!");
|
|
|
|
}
|
2009-08-19 06:12:02 +00:00
|
|
|
|
2009-08-22 21:43:10 +00:00
|
|
|
if (MAI.getAlignmentIsInBytes())
|
2009-08-19 06:12:02 +00:00
|
|
|
OS << ByteAlignment;
|
|
|
|
else
|
|
|
|
OS << Log2_32(ByteAlignment);
|
|
|
|
|
|
|
|
if (Value || MaxBytesToEmit) {
|
2009-09-03 04:01:10 +00:00
|
|
|
OS << ", 0x";
|
|
|
|
OS.write_hex(truncateToSize(Value, ValueSize));
|
2009-06-24 19:25:34 +00:00
|
|
|
|
2009-08-19 06:12:02 +00:00
|
|
|
if (MaxBytesToEmit)
|
|
|
|
OS << ", " << MaxBytesToEmit;
|
|
|
|
}
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2009-08-19 06:12:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Non-power of two alignment. This is not widely supported by assemblers.
|
2009-08-22 21:43:10 +00:00
|
|
|
// FIXME: Parameterize this based on MAI.
|
2009-06-24 19:25:34 +00:00
|
|
|
switch (ValueSize) {
|
2009-08-19 06:12:02 +00:00
|
|
|
default: llvm_unreachable("Invalid size for machine code value!");
|
|
|
|
case 1: OS << ".balign"; break;
|
|
|
|
case 2: OS << ".balignw"; break;
|
|
|
|
case 4: OS << ".balignl"; break;
|
|
|
|
case 8: llvm_unreachable("Unsupported alignment size!");
|
2009-06-24 19:25:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-19 06:12:02 +00:00
|
|
|
OS << ' ' << ByteAlignment;
|
2009-06-25 21:03:18 +00:00
|
|
|
OS << ", " << truncateToSize(Value, ValueSize);
|
2009-06-24 19:25:34 +00:00
|
|
|
if (MaxBytesToEmit)
|
|
|
|
OS << ", " << MaxBytesToEmit;
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2009-06-24 19:25:34 +00:00
|
|
|
}
|
|
|
|
|
2010-02-23 18:26:34 +00:00
|
|
|
void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment,
|
|
|
|
unsigned MaxBytesToEmit) {
|
2010-02-23 18:44:31 +00:00
|
|
|
// Emit with a text fill value.
|
|
|
|
EmitValueToAlignment(ByteAlignment, MAI.getTextAlignFillValue(),
|
|
|
|
1, MaxBytesToEmit);
|
2010-02-23 18:26:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 08:09:28 +00:00
|
|
|
void MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
|
2009-06-24 19:25:34 +00:00
|
|
|
unsigned char Value) {
|
|
|
|
// FIXME: Verify that Offset is associated with the current section.
|
2010-01-22 07:36:39 +00:00
|
|
|
OS << ".org " << *Offset << ", " << (unsigned) Value;
|
|
|
|
EmitEOL();
|
2009-06-24 19:25:34 +00:00
|
|
|
}
|
|
|
|
|
2010-01-25 18:58:59 +00:00
|
|
|
|
|
|
|
void MCAsmStreamer::EmitFileDirective(StringRef Filename) {
|
|
|
|
assert(MAI.hasSingleParameterDotFile());
|
|
|
|
OS << "\t.file\t";
|
|
|
|
PrintQuotedString(Filename, OS);
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
|
|
|
|
OS << "\t.file\t" << FileNo << ' ';
|
|
|
|
PrintQuotedString(Filename, OS);
|
|
|
|
EmitEOL();
|
|
|
|
}
|
|
|
|
|
2010-02-09 23:00:14 +00:00
|
|
|
void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
|
|
|
|
raw_ostream &OS = GetCommentOS();
|
|
|
|
SmallString<256> Code;
|
|
|
|
SmallVector<MCFixup, 4> Fixups;
|
|
|
|
raw_svector_ostream VecOS(Code);
|
|
|
|
Emitter->EncodeInstruction(Inst, VecOS, Fixups);
|
|
|
|
VecOS.flush();
|
2010-01-25 18:58:59 +00:00
|
|
|
|
2010-02-09 23:00:14 +00:00
|
|
|
// 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,
|
|
|
|
// then trying to display it as nicely as possible.
|
2010-02-10 01:41:14 +00:00
|
|
|
SmallVector<uint8_t, 64> FixupMap;
|
|
|
|
FixupMap.resize(Code.size() * 8);
|
2010-02-09 23:00:14 +00:00
|
|
|
for (unsigned i = 0, e = Code.size() * 8; i != e; ++i)
|
|
|
|
FixupMap[i] = 0;
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
|
|
|
|
MCFixup &F = Fixups[i];
|
2010-02-11 21:27:18 +00:00
|
|
|
const MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
|
2010-02-09 23:00:14 +00:00
|
|
|
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!");
|
|
|
|
FixupMap[Index] = 1 + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << "encoding: [";
|
|
|
|
for (unsigned i = 0, e = Code.size(); i != e; ++i) {
|
|
|
|
if (i)
|
|
|
|
OS << ',';
|
|
|
|
|
|
|
|
// See if all bits are the same map entry.
|
|
|
|
uint8_t MapEntry = FixupMap[i * 8 + 0];
|
|
|
|
for (unsigned j = 1; j != 8; ++j) {
|
|
|
|
if (FixupMap[i * 8 + j] == MapEntry)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
MapEntry = uint8_t(~0U);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (MapEntry != uint8_t(~0U)) {
|
|
|
|
if (MapEntry == 0) {
|
|
|
|
OS << format("0x%02x", uint8_t(Code[i]));
|
|
|
|
} else {
|
|
|
|
assert(Code[i] == 0 && "Encoder wrote into fixed up bit!");
|
|
|
|
OS << char('A' + MapEntry - 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Otherwise, write out in binary.
|
|
|
|
OS << "0b";
|
|
|
|
for (unsigned j = 8; j--;) {
|
|
|
|
unsigned Bit = (Code[i] >> j) & 1;
|
|
|
|
if (uint8_t MapEntry = FixupMap[i * 8 + j]) {
|
|
|
|
assert(Bit == 0 && "Encoder wrote into fixed up bit!");
|
|
|
|
OS << char('A' + MapEntry - 1);
|
|
|
|
} else
|
|
|
|
OS << Bit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OS << "]\n";
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
|
|
|
|
MCFixup &F = Fixups[i];
|
2010-02-11 21:27:18 +00:00
|
|
|
const MCFixupKindInfo &Info = Emitter->getFixupKindInfo(F.getKind());
|
2010-02-09 23:00:14 +00:00
|
|
|
OS << " fixup " << char('A' + i) << " - " << "offset: " << F.getOffset()
|
2010-02-10 04:47:08 +00:00
|
|
|
<< ", value: " << *F.getValue() << ", kind: " << Info.Name << "\n";
|
2010-02-09 23:00:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
|
|
|
|
assert(CurSection && "Cannot emit contents before setting section!");
|
|
|
|
|
|
|
|
// Show the encoding in a comment if we have a code emitter.
|
|
|
|
if (Emitter)
|
|
|
|
AddEncodingComment(Inst);
|
|
|
|
|
2010-02-09 00:54:51 +00:00
|
|
|
// Show the MCInst if enabled.
|
2010-05-26 15:18:13 +00:00
|
|
|
if (ShowInst) {
|
2010-03-22 21:49:34 +00:00
|
|
|
Inst.dump_pretty(GetCommentOS(), &MAI, InstPrinter.get(), "\n ");
|
2010-05-26 15:18:13 +00:00
|
|
|
GetCommentOS() << "\n";
|
|
|
|
}
|
|
|
|
|
2010-03-22 21:49:34 +00:00
|
|
|
// If we have an AsmPrinter, use that to print, otherwise print the MCInst.
|
2010-02-03 18:18:30 +00:00
|
|
|
if (InstPrinter)
|
2010-04-04 05:04:31 +00:00
|
|
|
InstPrinter->printInst(&Inst, OS);
|
2010-02-03 18:18:30 +00:00
|
|
|
else
|
|
|
|
Inst.print(OS, &MAI);
|
2010-01-22 07:36:39 +00:00
|
|
|
EmitEOL();
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|
|
|
|
|
2010-04-03 21:35:55 +00:00
|
|
|
/// EmitRawText - If this file is backed by a assembly streamer, this dumps
|
|
|
|
/// the specified string in the output .s file. This capability is
|
|
|
|
/// indicated by the hasRawTextSupport() predicate.
|
|
|
|
void MCAsmStreamer::EmitRawText(StringRef String) {
|
2010-04-03 22:06:56 +00:00
|
|
|
if (!String.empty() && String.back() == '\n')
|
|
|
|
String = String.substr(0, String.size()-1);
|
2010-04-03 21:35:55 +00:00
|
|
|
OS << String;
|
2010-04-03 22:06:56 +00:00
|
|
|
EmitEOL();
|
2010-04-03 21:35:55 +00:00
|
|
|
}
|
|
|
|
|
2009-06-24 01:03:06 +00:00
|
|
|
void MCAsmStreamer::Finish() {
|
|
|
|
}
|
2010-02-03 18:18:30 +00:00
|
|
|
|
2010-01-22 07:29:22 +00:00
|
|
|
MCStreamer *llvm::createAsmStreamer(MCContext &Context,
|
|
|
|
formatted_raw_ostream &OS,
|
2010-03-12 18:28:53 +00:00
|
|
|
bool isLittleEndian,
|
2010-01-22 07:06:15 +00:00
|
|
|
bool isVerboseAsm, MCInstPrinter *IP,
|
2010-02-10 01:41:14 +00:00
|
|
|
MCCodeEmitter *CE, bool ShowInst) {
|
2010-03-12 18:28:53 +00:00
|
|
|
return new MCAsmStreamer(Context, OS, isLittleEndian, isVerboseAsm,
|
2010-02-10 01:41:14 +00:00
|
|
|
IP, CE, ShowInst);
|
2009-06-24 01:03:06 +00:00
|
|
|
}
|