1 //===- lib/MC/MCStreamer.cpp - Streaming Machine Code Output --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCStreamer.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/Support/raw_ostream.h"
13 #include "llvm/ADT/SmallString.h"
14 #include "llvm/ADT/Twine.h"
18 MCStreamer::MCStreamer(MCContext &_Context) : Context(_Context), CurSection(0) {
21 MCStreamer::~MCStreamer() {
24 raw_ostream &MCStreamer::GetCommentOS() {
25 // By default, discard comments.
30 /// EmitIntValue - Special case of EmitValue that avoids the client having to
31 /// pass in a MCExpr for constant integers.
32 void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
34 EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace);
37 void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
39 EmitValue(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace);
42 /// EmitFill - Emit NumBytes bytes worth of the value specified by
43 /// FillValue. This implements directives such as '.space'.
44 void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
46 const MCExpr *E = MCConstantExpr::Create(FillValue, getContext());
47 for (uint64_t i = 0, e = NumBytes; i != e; ++i)
48 EmitValue(E, 1, AddrSpace);
51 /// EmitRawText - If this file is backed by an assembly streamer, this dumps
52 /// the specified string in the output .s file. This capability is
53 /// indicated by the hasRawTextSupport() predicate.
54 void MCStreamer::EmitRawText(StringRef String) {
55 errs() << "EmitRawText called on an MCStreamer that doesn't support it, "
56 " something must not be fully mc'ized\n";
60 void MCStreamer::EmitRawText(const Twine &T) {
63 EmitRawText(Str.str());