LLVM  3.7.0
MCObjectStreamer.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCObjectStreamer.cpp - Object File MCStreamer Interface -----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/MC/MCAsmBackend.h"
13 #include "llvm/MC/MCAsmInfo.h"
14 #include "llvm/MC/MCAssembler.h"
15 #include "llvm/MC/MCCodeEmitter.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCDwarf.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCObjectWriter.h"
20 #include "llvm/MC/MCSection.h"
21 #include "llvm/MC/MCSymbol.h"
24 using namespace llvm;
25 
28  MCCodeEmitter *Emitter_)
29  : MCStreamer(Context),
30  Assembler(new MCAssembler(Context, TAB, *Emitter_,
31  *TAB.createObjectWriter(OS), OS)),
32  EmitEHFrame(true), EmitDebugFrame(false) {}
33 
35  delete &Assembler->getBackend();
36  delete &Assembler->getEmitter();
37  delete &Assembler->getWriter();
38  delete Assembler;
39 }
40 
42  if (PendingLabels.size()) {
43  if (!F) {
44  F = new MCDataFragment();
45  MCSection *CurSection = getCurrentSectionOnly();
46  CurSection->getFragmentList().insert(CurInsertionPoint, F);
47  F->setParent(CurSection);
48  }
49  for (MCSymbol *Sym : PendingLabels) {
50  Sym->setFragment(F);
51  Sym->setOffset(FOffset);
52  }
53  PendingLabels.clear();
54  }
55 }
56 
58  const MCSymbol *Lo,
59  unsigned Size) {
60  // If not assigned to the same (valid) fragment, fallback.
61  if (!Hi->getFragment() || Hi->getFragment() != Lo->getFragment()) {
63  return;
64  }
65 
66  assert(Hi->getOffset() >= Lo->getOffset() &&
67  "Expected Hi to be greater than Lo");
68  EmitIntValue(Hi->getOffset() - Lo->getOffset(), Size);
69 }
70 
72  if (Assembler)
73  Assembler->reset();
74  CurInsertionPoint = MCSection::iterator();
75  EmitEHFrame = true;
76  EmitDebugFrame = false;
77  PendingLabels.clear();
79 }
80 
82  if (!getNumFrameInfos())
83  return;
84 
85  if (EmitEHFrame)
86  MCDwarfFrameEmitter::Emit(*this, MAB, true);
87 
88  if (EmitDebugFrame)
89  MCDwarfFrameEmitter::Emit(*this, MAB, false);
90 }
91 
93  assert(getCurrentSectionOnly() && "No current section!");
94 
95  if (CurInsertionPoint != getCurrentSectionOnly()->getFragmentList().begin())
96  return std::prev(CurInsertionPoint);
97 
98  return nullptr;
99 }
100 
102  MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
103  // When bundling is enabled, we don't want to add data to a fragment that
104  // already has instructions (see MCELFStreamer::EmitInstToData for details)
105  if (!F || (Assembler->isBundlingEnabled() && !Assembler->getRelaxAll() &&
106  F->hasInstructions())) {
107  F = new MCDataFragment();
108  insert(F);
109  }
110  return F;
111 }
112 
114  Assembler->registerSymbol(Sym);
115 }
116 
118  MCStreamer::EmitCFISections(EH, Debug);
119  EmitEHFrame = EH;
120  EmitDebugFrame = Debug;
121 }
122 
123 void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
124  const SMLoc &Loc) {
125  MCStreamer::EmitValueImpl(Value, Size, Loc);
127  flushPendingLabels(DF, DF->getContents().size());
128 
129  MCLineEntry::Make(this, getCurrentSection().first);
130 
131  // Avoid fixups when possible.
132  int64_t AbsValue;
133  if (Value->evaluateAsAbsolute(AbsValue, getAssembler())) {
134  EmitIntValue(AbsValue, Size);
135  return;
136  }
137  DF->getFixups().push_back(
138  MCFixup::create(DF->getContents().size(), Value,
139  MCFixup::getKindForSize(Size, false), Loc));
140  DF->getContents().resize(DF->getContents().size() + Size, 0);
141 }
142 
143 void MCObjectStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
144  // We need to create a local symbol to avoid relocations.
145  Frame.Begin = getContext().createTempSymbol();
146  EmitLabel(Frame.Begin);
147 }
148 
149 void MCObjectStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
150  Frame.End = getContext().createTempSymbol();
151  EmitLabel(Frame.End);
152 }
153 
155  MCStreamer::EmitLabel(Symbol);
156 
157  getAssembler().registerSymbol(*Symbol);
158  assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
159 
160  // If there is a current fragment, mark the symbol as pointing into it.
161  // Otherwise queue the label and set its fragment pointer when we emit the
162  // next fragment.
163  auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
164  if (F && !(getAssembler().isBundlingEnabled() &&
165  getAssembler().getRelaxAll())) {
166  Symbol->setFragment(F);
167  Symbol->setOffset(F->getContents().size());
168  } else {
169  PendingLabels.push_back(Symbol);
170  }
171 }
172 
174  int64_t IntValue;
175  if (Value->evaluateAsAbsolute(IntValue, getAssembler())) {
176  EmitULEB128IntValue(IntValue);
177  return;
178  }
179  insert(new MCLEBFragment(*Value, false));
180 }
181 
183  int64_t IntValue;
184  if (Value->evaluateAsAbsolute(IntValue, getAssembler())) {
185  EmitSLEB128IntValue(IntValue);
186  return;
187  }
188  insert(new MCLEBFragment(*Value, true));
189 }
190 
192  const MCSymbol *Symbol) {
193  report_fatal_error("This file format doesn't support weak aliases.");
194 }
195 
197  const MCExpr *Subsection) {
198  changeSectionImpl(Section, Subsection);
199 }
200 
202  const MCExpr *Subsection) {
203  assert(Section && "Cannot switch to a null section!");
204  flushPendingLabels(nullptr);
205 
206  bool Created = getAssembler().registerSection(*Section);
207 
208  int64_t IntSubsection = 0;
209  if (Subsection &&
210  !Subsection->evaluateAsAbsolute(IntSubsection, getAssembler()))
211  report_fatal_error("Cannot evaluate subsection number");
212  if (IntSubsection < 0 || IntSubsection > 8192)
213  report_fatal_error("Subsection number out of range");
214  CurInsertionPoint =
215  Section->getSubsectionInsertionPoint(unsigned(IntSubsection));
216  return Created;
217 }
218 
220  getAssembler().registerSymbol(*Symbol);
221  MCStreamer::EmitAssignment(Symbol, Value);
222 }
223 
225  return Sec.hasInstructions();
226 }
227 
229  const MCSubtargetInfo &STI) {
230  MCStreamer::EmitInstruction(Inst, STI);
231 
233  Sec->setHasInstructions(true);
234 
235  // Now that a machine instruction has been assembled into this section, make
236  // a line entry for any .loc directive that has been seen.
237  MCLineEntry::Make(this, getCurrentSection().first);
238 
239  // If this instruction doesn't need relaxation, just emit it as data.
240  MCAssembler &Assembler = getAssembler();
241  if (!Assembler.getBackend().mayNeedRelaxation(Inst)) {
242  EmitInstToData(Inst, STI);
243  return;
244  }
245 
246  // Otherwise, relax and emit it as data if either:
247  // - The RelaxAll flag was passed
248  // - Bundling is enabled and this instruction is inside a bundle-locked
249  // group. We want to emit all such instructions into the same data
250  // fragment.
251  if (Assembler.getRelaxAll() ||
252  (Assembler.isBundlingEnabled() && Sec->isBundleLocked())) {
253  MCInst Relaxed;
254  getAssembler().getBackend().relaxInstruction(Inst, Relaxed);
255  while (getAssembler().getBackend().mayNeedRelaxation(Relaxed))
256  getAssembler().getBackend().relaxInstruction(Relaxed, Relaxed);
257  EmitInstToData(Relaxed, STI);
258  return;
259  }
260 
261  // Otherwise emit to a separate fragment.
262  EmitInstToFragment(Inst, STI);
263 }
264 
266  const MCSubtargetInfo &STI) {
267  if (getAssembler().getRelaxAll() && getAssembler().isBundlingEnabled())
268  llvm_unreachable("All instructions should have already been relaxed");
269 
270  // Always create a new, separate fragment here, because its size can change
271  // during relaxation.
272  MCRelaxableFragment *IF = new MCRelaxableFragment(Inst, STI);
273  insert(IF);
274 
276  raw_svector_ostream VecOS(Code);
277  getAssembler().getEmitter().encodeInstruction(Inst, VecOS, IF->getFixups(),
278  STI);
279  VecOS.flush();
280  IF->getContents().append(Code.begin(), Code.end());
281 }
282 
283 #ifndef NDEBUG
284 static const char *const BundlingNotImplementedMsg =
285  "Aligned bundling is not implemented for this object format";
286 #endif
287 
288 void MCObjectStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
290 }
291 
292 void MCObjectStreamer::EmitBundleLock(bool AlignToEnd) {
294 }
295 
298 }
299 
300 void MCObjectStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
301  unsigned Column, unsigned Flags,
302  unsigned Isa,
303  unsigned Discriminator,
304  StringRef FileName) {
305  // In case we see two .loc directives in a row, make sure the
306  // first one gets a line entry.
307  MCLineEntry::Make(this, getCurrentSection().first);
308 
309  this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,
310  Isa, Discriminator, FileName);
311 }
312 
314  const MCSymbol *B) {
315  MCContext &Context = OS.getContext();
317  const MCExpr *ARef = MCSymbolRefExpr::create(A, Variant, Context);
318  const MCExpr *BRef = MCSymbolRefExpr::create(B, Variant, Context);
319  const MCExpr *AddrDelta =
320  MCBinaryExpr::create(MCBinaryExpr::Sub, ARef, BRef, Context);
321  return AddrDelta;
322 }
323 
324 static void emitDwarfSetLineAddr(MCObjectStreamer &OS, int64_t LineDelta,
325  const MCSymbol *Label, int PointerSize) {
326  // emit the sequence to set the address
328  OS.EmitULEB128IntValue(PointerSize + 1);
330  OS.EmitSymbolValue(Label, PointerSize);
331 
332  // emit the sequence for the LineDelta (from 1) and a zero address delta.
333  MCDwarfLineAddr::Emit(&OS, LineDelta, 0);
334 }
335 
337  const MCSymbol *LastLabel,
338  const MCSymbol *Label,
339  unsigned PointerSize) {
340  if (!LastLabel) {
341  emitDwarfSetLineAddr(*this, LineDelta, Label, PointerSize);
342  return;
343  }
344  const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel);
345  int64_t Res;
346  if (AddrDelta->evaluateAsAbsolute(Res, getAssembler())) {
347  MCDwarfLineAddr::Emit(this, LineDelta, Res);
348  return;
349  }
350  insert(new MCDwarfLineAddrFragment(LineDelta, *AddrDelta));
351 }
352 
354  const MCSymbol *Label) {
355  const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel);
356  int64_t Res;
357  if (AddrDelta->evaluateAsAbsolute(Res, getAssembler())) {
359  return;
360  }
361  insert(new MCDwarfCallFrameFragment(*AddrDelta));
362 }
363 
365  MCLineEntry::Make(this, getCurrentSection().first);
367  flushPendingLabels(DF, DF->getContents().size());
368  DF->getContents().append(Data.begin(), Data.end());
369 }
370 
372  int64_t Value,
373  unsigned ValueSize,
374  unsigned MaxBytesToEmit) {
375  if (MaxBytesToEmit == 0)
376  MaxBytesToEmit = ByteAlignment;
377  insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit));
378 
379  // Update the maximum alignment on the current section if necessary.
380  MCSection *CurSec = getCurrentSection().first;
381  if (ByteAlignment > CurSec->getAlignment())
382  CurSec->setAlignment(ByteAlignment);
383 }
384 
386  unsigned MaxBytesToEmit) {
387  EmitValueToAlignment(ByteAlignment, 0, 1, MaxBytesToEmit);
388  cast<MCAlignFragment>(getCurrentFragment())->setEmitNops(true);
389 }
390 
392  unsigned char Value) {
393  int64_t Res;
394  if (Offset->evaluateAsAbsolute(Res, getAssembler())) {
395  insert(new MCOrgFragment(*Offset, Value));
396  return false;
397  }
398 
399  MCSymbol *CurrentPos = getContext().createTempSymbol();
400  EmitLabel(CurrentPos);
402  const MCExpr *Ref =
403  MCSymbolRefExpr::create(CurrentPos, Variant, getContext());
404  const MCExpr *Delta =
406 
407  if (!Delta->evaluateAsAbsolute(Res, getAssembler()))
408  return true;
409  EmitFill(Res, Value);
410  return false;
411 }
412 
413 // Associate GPRel32 fixup with data and resize data area
416  flushPendingLabels(DF, DF->getContents().size());
417 
418  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
419  Value, FK_GPRel_4));
420  DF->getContents().resize(DF->getContents().size() + 4, 0);
421 }
422 
423 // Associate GPRel32 fixup with data and resize data area
426  flushPendingLabels(DF, DF->getContents().size());
427 
428  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
429  Value, FK_GPRel_4));
430  DF->getContents().resize(DF->getContents().size() + 8, 0);
431 }
432 
433 void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
434  // FIXME: A MCFillFragment would be more memory efficient but MCExpr has
435  // problems evaluating expressions across multiple fragments.
437  flushPendingLabels(DF, DF->getContents().size());
438  DF->getContents().append(NumBytes, FillValue);
439 }
440 
441 void MCObjectStreamer::EmitZeros(uint64_t NumBytes) {
442  const MCSection *Sec = getCurrentSection().first;
443  assert(Sec && "need a section");
444  unsigned ItemSize = Sec->isVirtualSection() ? 0 : 1;
445  insert(new MCFillFragment(0, ItemSize, NumBytes));
446 }
447 
449  // If we are generating dwarf for assembly source files dump out the sections.
450  if (getContext().getGenDwarfForAssembly())
451  MCGenDwarfInfo::Emit(this);
452 
453  // Dump out the dwarf file & directory tables and line tables.
455 
456  flushPendingLabels(nullptr);
457  getAssembler().Finish();
458 }
virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName)
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
Definition: MCStreamer.cpp:153
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
static void Emit(MCStreamer *MCOS, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
Definition: MCDwarf.cpp:419
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
static const char *const BundlingNotImplementedMsg
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:315
void EmitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:103
bool hasInstructions() const
Definition: MCSection.h:144
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, bool IsSectionRelative=false)
Special case of EmitValue that avoids the client having to pass in a MCExpr for MCSymbols.
Definition: MCStreamer.cpp:115
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
virtual void EmitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &)
Emit an instruction to a special fragment, because this instruction can change its size during relaxa...
void setAlignment(unsigned Value)
Definition: MCSection.h:125
virtual void reset()
State management.
Definition: MCStreamer.cpp:53
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
Definition: MCDwarf.cpp:1570
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:735
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:488
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:232
static MCFixupKind getKindForSize(unsigned Size, bool isPCRel)
Return the generic fixup kind for a value with the given size.
Definition: MCFixup.h:98
F(f)
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, const SMLoc &Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition: MCStreamer.cpp:682
bool registerSection(MCSection &Section)
Definition: MCAssembler.h:859
unsigned getAlignment() const
Definition: MCSection.h:124
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:639
void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
virtual void EmitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:213
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.cpp:140
MCFragment * getCurrentFragment() const
void setHasInstructions(bool Value)
Definition: MCSection.h:145
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Definition: MCStreamer.h:274
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:279
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
void EmitFill(uint64_t NumBytes, uint8_t FillValue) override
Emit NumBytes bytes worth of the value specified by FillValue.
MCSymbol * Begin
Definition: MCDwarf.h:476
bool mayHaveInstructions(MCSection &Sec) const override
#define false
Definition: ConvertUTF.c:65
MCContext & getContext() const
Definition: MCStreamer.h:210
void EmitBundleLock(bool AlignToEnd) override
The following instructions are a bundle-locked group.
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:596
Context object for machine code objects.
Definition: MCContext.h:48
A four-byte gp relative fixup.
Definition: MCFixup.h:34
Streaming object file generation interface.
MCObjectWriter & getWriter() const
Definition: MCAssembler.h:737
SmallVectorImpl< char > & getContents()
Definition: MCAssembler.h:186
virtual void EmitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers...
Definition: MCStreamer.cpp:79
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
iterator begin() const
Definition: StringRef.h:90
void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) override
Emit the absolute difference between two symbols if possible.
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCAssembler.h:259
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCAssembler.h:129
#define true
Definition: ConvertUTF.c:66
void EmitULEB128Value(const MCExpr *Value) override
Streaming machine code generation interface.
Definition: MCStreamer.h:157
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:222
void visitUsedSymbol(const MCSymbol &Sym) override
FragmentListType::iterator iterator
Definition: MCSection.h:62
void EmitSLEB128Value(const MCExpr *Value) override
void insert(MCFragment *F)
void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
MCAssembler & getAssembler()
virtual void relaxInstruction(const MCInst &Inst, MCInst &Res) const =0
Relax the instruction in the given fragment to the next wider instruction.
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
bool getRelaxAll() const
Definition: MCAssembler.h:748
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCAssembler.h:211
virtual bool mayNeedRelaxation(const MCInst &Inst) const =0
Check whether the given instruction may need relaxation.
iterator insert(iterator where, NodeTy *New)
Definition: ilist.h:412
MCFragment * getFragment() const
Definition: MCSymbol.h:382
void EmitValueImpl(const MCExpr *Value, unsigned Size, const SMLoc &Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
void EmitFrames(MCAsmBackend *MAB)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:416
void setOffset(uint64_t Value)
Definition: MCSymbol.h:325
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
Definition: MCFixup.h:78
static void emitDwarfSetLineAddr(MCObjectStreamer &OS, int64_t LineDelta, const MCSymbol *Label, int PointerSize)
void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
void setFragment(MCFragment *Value) const
Definition: MCSymbol.h:385
static const MCExpr * buildSymbolDiff(MCObjectStreamer &OS, const MCSymbol *A, const MCSymbol *B)
void EmitCFISections(bool EH, bool Debug) override
void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, const MCSymbol *Label)
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:203
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
Definition: MCStreamer.cpp:647
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
bool isBundlingEnabled() const
Definition: MCAssembler.h:751
void flushPendingLabels(MCFragment *F, uint64_t FOffset=0)
If any labels have been emitted but not assigned fragments, ensure that they get assigned, either to F if possible or to a new data fragment.
void EmitBundleAlignMode(unsigned AlignPow2) override
Set the bundle alignment mode from now on in the section.
static void Emit(MCStreamer *MCOS)
Definition: MCDwarf.cpp:836
unsigned getNumFrameInfos()
Definition: MCStreamer.h:216
void EmitZeros(uint64_t NumBytes) override
Emit NumBytes worth of zeros.
void EmitBundleUnlock() override
Ends a bundle-locked group.
bool EmitValueToOffset(const MCExpr *Offset, unsigned char Value) override
Emit some number of copies of Value until the byte offset Offset is reached.
void FinishImpl() override
Streamer specific finalization.
uint64_t getOffset() const
Definition: MCSymbol.h:319
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void reset() override
state management
MCAsmBackend & getBackend() const
Definition: MCAssembler.h:733
MCSubtargetInfo - Generic base class for all target subtargets.
static void Make(MCObjectStreamer *MCOS, MCSection *Section)
Definition: MCDwarf.cpp:67
void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName) override
This implements the DWARF2 '.loc fileno lineno ...' assembler directive.
void EmitULEB128IntValue(uint64_t Value, unsigned Padding=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:94
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:321
void reset()
Reuse an assembler instance.
Fragment for data and encoded instructions.
Definition: MCAssembler.h:228
MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection)
Definition: MCSection.cpp:57
LLVM Value Representation.
Definition: Value.h:69
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:34
bool isBundleLocked() const
Definition: MCSection.h:135
static cl::opt< bool, true > Debug("debug", cl::desc("Enable debug output"), cl::Hidden, cl::location(DebugFlag))
void EmitGPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
iterator end() const
Definition: StringRef.h:92
Subtraction.
Definition: MCExpr.h:429
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
Definition: MCDwarf.cpp:1493
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
Represents a location in source code.
Definition: SMLoc.h:23
void setParent(MCSection *Value)
Definition: MCAssembler.h:119
void Finish()
Finish - Do final processing and write the object to the output stream.
MCSection::FragmentListType & getFragmentList()
Definition: MCSection.h:150
void EmitGPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
MCDataFragment * getOrCreateDataFragment()
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment...
MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter)
void resize(size_type N)
Definition: SmallVector.h:376
static void Emit(MCObjectStreamer *MCOS)
Definition: MCDwarf.cpp:200