LLVM  4.0.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/MCCodeView.h"
17 #include "llvm/MC/MCContext.h"
18 #include "llvm/MC/MCDwarf.h"
19 #include "llvm/MC/MCExpr.h"
20 #include "llvm/MC/MCObjectWriter.h"
21 #include "llvm/MC/MCSection.h"
22 #include "llvm/MC/MCSymbol.h"
24 #include "llvm/Support/SourceMgr.h"
26 using namespace llvm;
27 
30  MCCodeEmitter *Emitter_)
31  : MCStreamer(Context),
32  Assembler(new MCAssembler(Context, TAB, *Emitter_,
33  *TAB.createObjectWriter(OS))),
34  EmitEHFrame(true), EmitDebugFrame(false) {}
35 
37  delete &Assembler->getBackend();
38  delete &Assembler->getEmitter();
39  delete &Assembler->getWriter();
40  delete Assembler;
41 }
42 
44  if (PendingLabels.empty())
45  return;
46  if (!F) {
47  F = new MCDataFragment();
48  MCSection *CurSection = getCurrentSectionOnly();
49  CurSection->getFragmentList().insert(CurInsertionPoint, F);
50  F->setParent(CurSection);
51  }
52  for (MCSymbol *Sym : PendingLabels) {
53  Sym->setFragment(F);
54  Sym->setOffset(FOffset);
55  }
56  PendingLabels.clear();
57 }
58 
60  const MCSymbol *Lo,
61  unsigned Size) {
62  // If not assigned to the same (valid) fragment, fallback.
63  if (!Hi->getFragment() || Hi->getFragment() != Lo->getFragment() ||
64  Hi->isVariable() || Lo->isVariable()) {
66  return;
67  }
68 
69  EmitIntValue(Hi->getOffset() - Lo->getOffset(), Size);
70 }
71 
73  if (Assembler)
74  Assembler->reset();
75  CurInsertionPoint = MCSection::iterator();
76  EmitEHFrame = true;
77  EmitDebugFrame = false;
78  PendingLabels.clear();
80 }
81 
83  if (!getNumFrameInfos())
84  return;
85 
86  if (EmitEHFrame)
87  MCDwarfFrameEmitter::Emit(*this, MAB, true);
88 
89  if (EmitDebugFrame)
90  MCDwarfFrameEmitter::Emit(*this, MAB, false);
91 }
92 
94  assert(getCurrentSectionOnly() && "No current section!");
95 
96  if (CurInsertionPoint != getCurrentSectionOnly()->getFragmentList().begin())
97  return &*std::prev(CurInsertionPoint);
98 
99  return nullptr;
100 }
101 
103  MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
104  // When bundling is enabled, we don't want to add data to a fragment that
105  // already has instructions (see MCELFStreamer::EmitInstToData for details)
106  if (!F || (Assembler->isBundlingEnabled() && !Assembler->getRelaxAll() &&
107  F->hasInstructions())) {
108  F = new MCDataFragment();
109  insert(F);
110  }
111  return F;
112 }
113 
115  Assembler->registerSymbol(Sym);
116 }
117 
119  MCStreamer::EmitCFISections(EH, Debug);
120  EmitEHFrame = EH;
121  EmitDebugFrame = Debug;
122 }
123 
124 void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
125  SMLoc Loc) {
126  MCStreamer::EmitValueImpl(Value, Size, Loc);
128  flushPendingLabels(DF, DF->getContents().size());
129 
130  MCCVLineEntry::Make(this);
132 
133  // Avoid fixups when possible.
134  int64_t AbsValue;
135  if (Value->evaluateAsAbsolute(AbsValue, getAssembler())) {
136  EmitIntValue(AbsValue, Size);
137  return;
138  }
139  DF->getFixups().push_back(
140  MCFixup::create(DF->getContents().size(), Value,
141  MCFixup::getKindForSize(Size, false), Loc));
142  DF->getContents().resize(DF->getContents().size() + Size, 0);
143 }
144 
145 void MCObjectStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
146  // We need to create a local symbol to avoid relocations.
147  Frame.Begin = getContext().createTempSymbol();
148  EmitLabel(Frame.Begin);
149 }
150 
151 void MCObjectStreamer::EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
152  Frame.End = getContext().createTempSymbol();
153  EmitLabel(Frame.End);
154 }
155 
157  MCStreamer::EmitLabel(Symbol);
158 
159  getAssembler().registerSymbol(*Symbol);
160 
161  // If there is a current fragment, mark the symbol as pointing into it.
162  // Otherwise queue the label and set its fragment pointer when we emit the
163  // next fragment.
164  auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
165  if (F && !(getAssembler().isBundlingEnabled() &&
166  getAssembler().getRelaxAll())) {
167  Symbol->setFragment(F);
168  Symbol->setOffset(F->getContents().size());
169  } else {
170  PendingLabels.push_back(Symbol);
171  }
172 }
173 
175  int64_t IntValue;
176  if (Value->evaluateAsAbsolute(IntValue, getAssembler())) {
177  EmitULEB128IntValue(IntValue);
178  return;
179  }
180  insert(new MCLEBFragment(*Value, false));
181 }
182 
184  int64_t IntValue;
185  if (Value->evaluateAsAbsolute(IntValue, getAssembler())) {
186  EmitSLEB128IntValue(IntValue);
187  return;
188  }
189  insert(new MCLEBFragment(*Value, true));
190 }
191 
193  const MCSymbol *Symbol) {
194  report_fatal_error("This file format doesn't support weak aliases.");
195 }
196 
198  const MCExpr *Subsection) {
199  changeSectionImpl(Section, Subsection);
200 }
201 
203  const MCExpr *Subsection) {
204  assert(Section && "Cannot switch to a null section!");
205  flushPendingLabels(nullptr);
206 
207  bool Created = getAssembler().registerSection(*Section);
208 
209  int64_t IntSubsection = 0;
210  if (Subsection &&
211  !Subsection->evaluateAsAbsolute(IntSubsection, getAssembler()))
212  report_fatal_error("Cannot evaluate subsection number");
213  if (IntSubsection < 0 || IntSubsection > 8192)
214  report_fatal_error("Subsection number out of range");
215  CurInsertionPoint =
216  Section->getSubsectionInsertionPoint(unsigned(IntSubsection));
217  return Created;
218 }
219 
221  getAssembler().registerSymbol(*Symbol);
222  MCStreamer::EmitAssignment(Symbol, Value);
223 }
224 
226  return Sec.hasInstructions();
227 }
228 
230  const MCSubtargetInfo &STI) {
231  MCStreamer::EmitInstruction(Inst, STI);
232 
234  Sec->setHasInstructions(true);
235 
236  // Now that a machine instruction has been assembled into this section, make
237  // a line entry for any .loc directive that has been seen.
238  MCCVLineEntry::Make(this);
240 
241  // If this instruction doesn't need relaxation, just emit it as data.
242  MCAssembler &Assembler = getAssembler();
243  if (!Assembler.getBackend().mayNeedRelaxation(Inst)) {
244  EmitInstToData(Inst, STI);
245  return;
246  }
247 
248  // Otherwise, relax and emit it as data if either:
249  // - The RelaxAll flag was passed
250  // - Bundling is enabled and this instruction is inside a bundle-locked
251  // group. We want to emit all such instructions into the same data
252  // fragment.
253  if (Assembler.getRelaxAll() ||
254  (Assembler.isBundlingEnabled() && Sec->isBundleLocked())) {
255  MCInst Relaxed;
256  getAssembler().getBackend().relaxInstruction(Inst, STI, Relaxed);
257  while (getAssembler().getBackend().mayNeedRelaxation(Relaxed))
258  getAssembler().getBackend().relaxInstruction(Relaxed, STI, Relaxed);
259  EmitInstToData(Relaxed, STI);
260  return;
261  }
262 
263  // Otherwise emit to a separate fragment.
264  EmitInstToFragment(Inst, STI);
265 }
266 
268  const MCSubtargetInfo &STI) {
269  if (getAssembler().getRelaxAll() && getAssembler().isBundlingEnabled())
270  llvm_unreachable("All instructions should have already been relaxed");
271 
272  // Always create a new, separate fragment here, because its size can change
273  // during relaxation.
274  MCRelaxableFragment *IF = new MCRelaxableFragment(Inst, STI);
275  insert(IF);
276 
277  SmallString<128> Code;
278  raw_svector_ostream VecOS(Code);
279  getAssembler().getEmitter().encodeInstruction(Inst, VecOS, IF->getFixups(),
280  STI);
281  IF->getContents().append(Code.begin(), Code.end());
282 }
283 
284 #ifndef NDEBUG
285 static const char *const BundlingNotImplementedMsg =
286  "Aligned bundling is not implemented for this object format";
287 #endif
288 
289 void MCObjectStreamer::EmitBundleAlignMode(unsigned AlignPow2) {
291 }
292 
293 void MCObjectStreamer::EmitBundleLock(bool AlignToEnd) {
295 }
296 
299 }
300 
301 void MCObjectStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
302  unsigned Column, unsigned Flags,
303  unsigned Isa,
304  unsigned Discriminator,
305  StringRef FileName) {
306  // In case we see two .loc directives in a row, make sure the
307  // first one gets a line entry.
309 
310  this->MCStreamer::EmitDwarfLocDirective(FileNo, Line, Column, Flags,
311  Isa, Discriminator, FileName);
312 }
313 
315  const MCSymbol *B) {
316  MCContext &Context = OS.getContext();
318  const MCExpr *ARef = MCSymbolRefExpr::create(A, Variant, Context);
319  const MCExpr *BRef = MCSymbolRefExpr::create(B, Variant, Context);
320  const MCExpr *AddrDelta =
321  MCBinaryExpr::create(MCBinaryExpr::Sub, ARef, BRef, Context);
322  return AddrDelta;
323 }
324 
326  MCDwarfLineTableParams Params,
327  int64_t LineDelta, const MCSymbol *Label,
328  int PointerSize) {
329  // emit the sequence to set the address
330  OS.EmitIntValue(dwarf::DW_LNS_extended_op, 1);
331  OS.EmitULEB128IntValue(PointerSize + 1);
332  OS.EmitIntValue(dwarf::DW_LNE_set_address, 1);
333  OS.EmitSymbolValue(Label, PointerSize);
334 
335  // emit the sequence for the LineDelta (from 1) and a zero address delta.
336  MCDwarfLineAddr::Emit(&OS, Params, LineDelta, 0);
337 }
338 
340  const MCSymbol *LastLabel,
341  const MCSymbol *Label,
342  unsigned PointerSize) {
343  if (!LastLabel) {
344  emitDwarfSetLineAddr(*this, Assembler->getDWARFLinetableParams(), LineDelta,
345  Label, PointerSize);
346  return;
347  }
348  const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel);
349  int64_t Res;
350  if (AddrDelta->evaluateAsAbsolute(Res, getAssembler())) {
351  MCDwarfLineAddr::Emit(this, Assembler->getDWARFLinetableParams(), LineDelta,
352  Res);
353  return;
354  }
355  insert(new MCDwarfLineAddrFragment(LineDelta, *AddrDelta));
356 }
357 
359  const MCSymbol *Label) {
360  const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel);
361  int64_t Res;
362  if (AddrDelta->evaluateAsAbsolute(Res, getAssembler())) {
364  return;
365  }
366  insert(new MCDwarfCallFrameFragment(*AddrDelta));
367 }
368 
369 void MCObjectStreamer::EmitCVLocDirective(unsigned FunctionId, unsigned FileNo,
370  unsigned Line, unsigned Column,
371  bool PrologueEnd, bool IsStmt,
372  StringRef FileName, SMLoc Loc) {
373  // In case we see two .cv_loc directives in a row, make sure the
374  // first one gets a line entry.
375  MCCVLineEntry::Make(this);
376 
377  this->MCStreamer::EmitCVLocDirective(FunctionId, FileNo, Line, Column,
378  PrologueEnd, IsStmt, FileName, Loc);
379 }
380 
382  const MCSymbol *Begin,
383  const MCSymbol *End) {
384  getContext().getCVContext().emitLineTableForFunction(*this, FunctionId, Begin,
385  End);
386  this->MCStreamer::EmitCVLinetableDirective(FunctionId, Begin, End);
387 }
388 
390  unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum,
391  const MCSymbol *FnStartSym, const MCSymbol *FnEndSym) {
393  *this, PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym,
394  FnEndSym);
396  PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
397 }
398 
400  ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
401  StringRef FixedSizePortion) {
402  getContext().getCVContext().emitDefRange(*this, Ranges, FixedSizePortion);
403  this->MCStreamer::EmitCVDefRangeDirective(Ranges, FixedSizePortion);
404 }
405 
408 }
411 }
412 
413 
415  MCCVLineEntry::Make(this);
418  flushPendingLabels(DF, DF->getContents().size());
419  DF->getContents().append(Data.begin(), Data.end());
420 }
421 
423  int64_t Value,
424  unsigned ValueSize,
425  unsigned MaxBytesToEmit) {
426  if (MaxBytesToEmit == 0)
427  MaxBytesToEmit = ByteAlignment;
428  insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit));
429 
430  // Update the maximum alignment on the current section if necessary.
431  MCSection *CurSec = getCurrentSectionOnly();
432  if (ByteAlignment > CurSec->getAlignment())
433  CurSec->setAlignment(ByteAlignment);
434 }
435 
437  unsigned MaxBytesToEmit) {
438  EmitValueToAlignment(ByteAlignment, 0, 1, MaxBytesToEmit);
439  cast<MCAlignFragment>(getCurrentFragment())->setEmitNops(true);
440 }
441 
443  unsigned char Value,
444  SMLoc Loc) {
445  insert(new MCOrgFragment(*Offset, Value, Loc));
446 }
447 
448 // Associate DTPRel32 fixup with data and resize data area
451  flushPendingLabels(DF, DF->getContents().size());
452 
453  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
454  Value, FK_DTPRel_4));
455  DF->getContents().resize(DF->getContents().size() + 4, 0);
456 }
457 
458 // Associate DTPRel64 fixup with data and resize data area
461  flushPendingLabels(DF, DF->getContents().size());
462 
463  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
464  Value, FK_DTPRel_8));
465  DF->getContents().resize(DF->getContents().size() + 8, 0);
466 }
467 
468 // Associate TPRel32 fixup with data and resize data area
471  flushPendingLabels(DF, DF->getContents().size());
472 
473  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
474  Value, FK_TPRel_4));
475  DF->getContents().resize(DF->getContents().size() + 4, 0);
476 }
477 
478 // Associate TPRel64 fixup with data and resize data area
481  flushPendingLabels(DF, DF->getContents().size());
482 
483  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
484  Value, FK_TPRel_8));
485  DF->getContents().resize(DF->getContents().size() + 8, 0);
486 }
487 
488 // Associate GPRel32 fixup with data and resize data area
491  flushPendingLabels(DF, DF->getContents().size());
492 
493  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
494  Value, FK_GPRel_4));
495  DF->getContents().resize(DF->getContents().size() + 4, 0);
496 }
497 
498 // Associate GPRel64 fixup with data and resize data area
501  flushPendingLabels(DF, DF->getContents().size());
502 
503  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
504  Value, FK_GPRel_4));
505  DF->getContents().resize(DF->getContents().size() + 8, 0);
506 }
507 
509  const MCExpr *Expr, SMLoc Loc) {
510  int64_t OffsetValue;
511  if (!Offset.evaluateAsAbsolute(OffsetValue))
512  llvm_unreachable("Offset is not absolute");
513 
514  if (OffsetValue < 0)
515  llvm_unreachable("Offset is negative");
516 
518  flushPendingLabels(DF, DF->getContents().size());
519 
520  Optional<MCFixupKind> MaybeKind = Assembler->getBackend().getFixupKind(Name);
521  if (!MaybeKind.hasValue())
522  return true;
523 
524  MCFixupKind Kind = *MaybeKind;
525 
526  if (Expr == nullptr)
527  Expr =
528  MCSymbolRefExpr::create(getContext().createTempSymbol(), getContext());
529  DF->getFixups().push_back(MCFixup::create(OffsetValue, Expr, Kind, Loc));
530  return false;
531 }
532 
533 void MCObjectStreamer::emitFill(uint64_t NumBytes, uint8_t FillValue) {
534  assert(getCurrentSectionOnly() && "need a section");
535  insert(new MCFillFragment(FillValue, NumBytes));
536 }
537 
538 void MCObjectStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
539  SMLoc Loc) {
541  flushPendingLabels(DF, DF->getContents().size());
542 
543  int64_t IntNumBytes;
544  if (!NumBytes.evaluateAsAbsolute(IntNumBytes, getAssembler())) {
545  getContext().reportError(Loc, "expected absolute expression");
546  return;
547  }
548 
549  if (IntNumBytes <= 0) {
550  getContext().reportError(Loc, "invalid number of bytes");
551  return;
552  }
553 
554  emitFill(IntNumBytes, FillValue);
555 }
556 
557 void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
558  int64_t Expr, SMLoc Loc) {
559  int64_t IntNumValues;
560  if (!NumValues.evaluateAsAbsolute(IntNumValues, getAssembler())) {
561  getContext().reportError(Loc, "expected absolute expression");
562  return;
563  }
564 
565  if (IntNumValues < 0) {
568  "'.fill' directive with negative repeat count has no effect");
569  return;
570  }
571 
572  MCStreamer::emitFill(IntNumValues, Size, Expr);
573 }
574 
576  // If we are generating dwarf for assembly source files dump out the sections.
577  if (getContext().getGenDwarfForAssembly())
578  MCGenDwarfInfo::Emit(this);
579 
580  // Dump out the dwarf file & directory tables and line tables.
581  MCDwarfLineTable::Emit(this, getAssembler().getDWARFLinetableParams());
582 
583  flushPendingLabels(nullptr);
584  getAssembler().Finish();
585 }
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:183
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
void emitLineTableForFunction(MCObjectStreamer &OS, unsigned FuncId, const MCSymbol *FuncBegin, const MCSymbol *FuncEnd)
Emits a line table substream.
Definition: MCCodeView.cpp:192
A eight-byte dtp relative fixup.
Definition: MCFixup.h:37
LLVMContext & Context
void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion) override
This implements the CodeView '.cv_def_range' assembler directive.
static void Make(MCObjectStreamer *MCOS, MCSection *Section)
Definition: MCDwarf.cpp:50
static const char *const BundlingNotImplementedMsg
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:298
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:109
bool hasInstructions() const
Definition: MCSection.h:137
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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:120
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 relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, MCInst &Res) const =0
Relax the instruction in the given fragment to the next wider instruction.
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:118
virtual void reset()
State management.
Definition: MCStreamer.cpp:56
static void Make(MCObjectStreamer *MCOS)
Definition: MCCodeView.cpp:551
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
Definition: MCDwarf.cpp:1549
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:262
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:233
static MCFixupKind getKindForSize(unsigned Size, bool isPCRel)
Return the generic fixup kind for a value with the given size.
Definition: MCFixup.h:102
static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
Definition: MCDwarf.cpp:407
unsigned getAlignment() const
Definition: MCSection.h:117
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc())
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition: MCStreamer.cpp:809
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:765
void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize)
void EmitCVStringTableDirective() override
This implements the CodeView '.cv_stringtable' assembler directive.
virtual void EmitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:304
void emitInlineLineTableForFunction(MCObjectStreamer &OS, unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
Definition: MCCodeView.cpp:284
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.cpp:139
MCFragment * getCurrentFragment() const
struct fuzzer::@269 Flags
void setHasInstructions(bool Value)
Definition: MCSection.h:138
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
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.
A four-byte tp relative fixup.
Definition: MCFixup.h:38
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:302
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
bool EmitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc) override
Emit a .reloc directive.
bool registerSection(MCSection &Section)
MCSymbol * Begin
Definition: MCDwarf.h:496
bool mayHaveInstructions(MCSection &Sec) const override
MCContext & getContext() const
Definition: MCStreamer.h:221
void EmitBundleLock(bool AlignToEnd) override
The following instructions are a bundle-locked group.
virtual void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc)
This implements the CodeView '.cv_loc' assembler directive.
Definition: MCStreamer.cpp:241
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:722
Context object for machine code objects.
Definition: MCContext.h:51
void EmitDTPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
A four-byte gp relative fixup.
Definition: MCFixup.h:34
#define F(x, y, z)
Definition: MD5.cpp:51
Streaming object file generation interface.
MCObjectWriter & getWriter() const
Definition: MCAssembler.h:264
Function Alias Analysis false
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
void EmitDTPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
SmallVectorImpl< char > & getContents()
Definition: MCFragment.h:175
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:85
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
iterator begin() const
Definition: StringRef.h:103
void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) override
Emit the absolute difference between two symbols if possible.
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition: MCSymbol.h:270
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:249
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCFragment.h:108
A four-byte dtp relative fixup.
Definition: MCFixup.h:36
void EmitULEB128Value(const MCExpr *Value) override
Streaming machine code generation interface.
Definition: MCStreamer.h:161
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
Definition: MCContext.cpp:218
void visitUsedSymbol(const MCSymbol &Sym) override
FragmentListType::iterator iterator
Definition: MCSection.h:54
MCDwarfLineTableParams getDWARFLinetableParams() const
Definition: MCAssembler.h:266
void EmitCVLocDirective(unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt, StringRef FileName, SMLoc Loc) override
This implements the CodeView '.cv_loc' assembler directive.
virtual void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:262
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Definition: SmallVector.h:115
MCAssembler & getAssembler()
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:23
bool getRelaxAll() const
Definition: MCAssembler.h:288
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCFragment.h:200
virtual bool mayNeedRelaxation(const MCInst &Inst) const =0
Check whether the given instruction may need relaxation.
virtual Optional< MCFixupKind > getFixupKind(StringRef Name) const
Map a relocation name used in .reloc to a fixup kind.
uint32_t Offset
static const unsigned End
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:510
A eight-byte tp relative fixup.
Definition: MCFixup.h:39
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:392
const SourceMgr * getSourceManager() const
Definition: MCContext.h:241
void setOffset(uint64_t Value)
Definition: MCSymbol.h:320
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
Definition: MCFixup.h:82
void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc) override
Emit some number of copies of Value until the byte offset Offset is reached.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void emitFill(uint64_t NumBytes, uint8_t FillValue) override
Emit NumBytes bytes worth of the value specified by FillValue.
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.
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:293
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
Definition: MCStreamer.cpp:773
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
bool isBundlingEnabled() const
Definition: MCAssembler.h:291
virtual void EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
This implements the CodeView '.cv_inline_linetable' assembler directive.
Definition: MCStreamer.cpp:266
void EmitCVLinetableDirective(unsigned FunctionId, const MCSymbol *Begin, const MCSymbol *End) override
This implements the CodeView '.cv_linetable' assembler directive.
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:841
static void emitDwarfSetLineAddr(MCObjectStreamer &OS, MCDwarfLineTableParams Params, int64_t LineDelta, const MCSymbol *Label, int PointerSize)
void EmitTPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
virtual void EmitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
This implements the CodeView '.cv_def_range' assembler directive.
Definition: MCStreamer.cpp:272
static void Emit(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params)
Definition: MCDwarf.cpp:183
Basic Alias true
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Definition: SmallVector.h:119
iterator insert(iterator where, pointer New)
Definition: ilist.h:241
unsigned getNumFrameInfos()
Definition: MCStreamer.h:227
void EmitBundleUnlock() override
Ends a bundle-locked group.
void FinishImpl() override
Streamer specific finalization.
uint64_t getOffset() const
Definition: MCSymbol.h:314
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void emitDefRange(MCObjectStreamer &OS, ArrayRef< std::pair< const MCSymbol *, const MCSymbol * >> Ranges, StringRef FixedSizePortion)
Definition: MCCodeView.cpp:297
void reset() override
state management
MCAsmBackend & getBackend() const
Definition: MCAssembler.h:260
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
MCSubtargetInfo - Generic base class for all target subtargets.
void emitStringTable(MCObjectStreamer &OS)
Emits the string table substream.
Definition: MCCodeView.cpp:143
void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
virtual void emitFill(uint64_t NumBytes, uint8_t FillValue)
Emit NumBytes bytes worth of the value specified by FillValue.
Definition: MCStreamer.cpp:157
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 EmitCVInlineLinetableDirective(unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym) override
This implements the CodeView '.cv_inline_linetable' 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:100
bool isVariable() const
isVariable - Check if this is a variable symbol.
Definition: MCSymbol.h:289
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:377
CodeViewContext & getCVContext()
Definition: MCContext.cpp:500
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
const unsigned Kind
void reset()
Reuse an assembler instance.
Definition: MCAssembler.cpp:79
Fragment for data and encoded instructions.
Definition: MCFragment.h:218
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection)
Definition: MCSection.cpp:57
LLVM Value Representation.
Definition: Value.h:71
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
bool isBundleLocked() const
Definition: MCSection.h:128
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:105
Subtraction.
Definition: MCExpr.h:412
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
Definition: MCDwarf.cpp:1487
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Definition: SourceMgr.cpp:216
void EmitCVFileChecksumsDirective() override
This implements the CodeView '.cv_filechecksums' assembler directive.
Represents a location in source code.
Definition: SMLoc.h:24
void emitFileChecksums(MCObjectStreamer &OS)
Emits the file checksum substream.
Definition: MCCodeView.cpp:165
void setParent(MCSection *Value)
Definition: MCFragment.h:98
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
void Finish()
Finish - Do final processing and write the object to the output stream.
MCSection::FragmentListType & getFragmentList()
Definition: MCSection.h:143
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 EmitTPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
void resize(size_type N)
Definition: SmallVector.h:352