LLVM 19.0.0git
MCObjectStreamer.cpp
Go to the documentation of this file.
1//===- lib/MC/MCObjectStreamer.cpp - Object File MCStreamer Interface -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "llvm/MC/MCAsmInfo.h"
12#include "llvm/MC/MCAssembler.h"
14#include "llvm/MC/MCCodeView.h"
15#include "llvm/MC/MCContext.h"
16#include "llvm/MC/MCDwarf.h"
17#include "llvm/MC/MCExpr.h"
20#include "llvm/MC/MCSection.h"
21#include "llvm/MC/MCSymbol.h"
22#include "llvm/MC/MCValue.h"
25using namespace llvm;
26
28 std::unique_ptr<MCAsmBackend> TAB,
29 std::unique_ptr<MCObjectWriter> OW,
30 std::unique_ptr<MCCodeEmitter> Emitter)
32 Assembler(std::make_unique<MCAssembler>(
33 Context, std::move(TAB), std::move(Emitter), std::move(OW))),
34 EmitEHFrame(true), EmitDebugFrame(false) {
35 if (Assembler->getBackendPtr())
36 setAllowAutoPadding(Assembler->getBackend().allowAutoPadding());
37}
38
40
41// AssemblerPtr is used for evaluation of expressions and causes
42// difference between asm and object outputs. Return nullptr to in
43// inline asm mode to limit divergence to assembly inputs.
46 return Assembler.get();
47 return nullptr;
48}
49
51 MCSection *CurSection = getCurrentSectionOnly();
52 if (CurSection) {
53 // Register labels that have not yet been assigned to a Section.
54 if (!PendingLabels.empty()) {
55 for (MCSymbol* Sym : PendingLabels)
56 CurSection->addPendingLabel(Sym);
57 PendingLabels.clear();
58 }
59
60 // Add this label to the current Section / Subsection.
61 CurSection->addPendingLabel(S, CurSubsectionIdx);
62
63 // Add this Section to the list of PendingLabelSections.
64 PendingLabelSections.insert(CurSection);
65 } else
66 // There is no Section / Subsection for this label yet.
67 PendingLabels.push_back(S);
68}
69
71 assert(F);
72 MCSection *CurSection = getCurrentSectionOnly();
73 if (!CurSection) {
74 assert(PendingLabels.empty());
75 return;
76 }
77 // Register labels that have not yet been assigned to a Section.
78 if (!PendingLabels.empty()) {
79 for (MCSymbol* Sym : PendingLabels)
80 CurSection->addPendingLabel(Sym, CurSubsectionIdx);
81 PendingLabels.clear();
82 }
83
84 // Associate the labels with F.
85 CurSection->flushPendingLabels(F, FOffset, CurSubsectionIdx);
86}
87
89 // Register labels that have not yet been assigned to a Section.
90 if (!PendingLabels.empty()) {
91 MCSection *CurSection = getCurrentSectionOnly();
92 assert(CurSection);
93 for (MCSymbol* Sym : PendingLabels)
94 CurSection->addPendingLabel(Sym, CurSubsectionIdx);
95 PendingLabels.clear();
96 }
97
98 // Assign an empty data fragment to all remaining pending labels.
99 for (MCSection* Section : PendingLabelSections)
100 Section->flushPendingLabels();
101}
102
103// When fixup's offset is a forward declared label, e.g.:
104//
105// .reloc 1f, R_MIPS_JALR, foo
106// 1: nop
107//
108// postpone adding it to Fixups vector until the label is defined and its offset
109// is known.
110void MCObjectStreamer::resolvePendingFixups() {
111 for (PendingMCFixup &PendingFixup : PendingFixups) {
112 if (!PendingFixup.Sym || PendingFixup.Sym->isUndefined ()) {
113 getContext().reportError(PendingFixup.Fixup.getLoc(),
114 "unresolved relocation offset");
115 continue;
116 }
117 flushPendingLabels(PendingFixup.DF, PendingFixup.DF->getContents().size());
118 PendingFixup.Fixup.setOffset(PendingFixup.Sym->getOffset() +
119 PendingFixup.Fixup.getOffset());
120
121 // If the location symbol to relocate is in MCEncodedFragmentWithFixups,
122 // put the Fixup into location symbol's fragment. Otherwise
123 // put into PendingFixup.DF
124 MCFragment *SymFragment = PendingFixup.Sym->getFragment();
125 switch (SymFragment->getKind()) {
129 cast<MCEncodedFragmentWithFixups<8, 1>>(SymFragment)
130 ->getFixups()
131 .push_back(PendingFixup.Fixup);
132 break;
135 cast<MCEncodedFragmentWithFixups<32, 4>>(SymFragment)
136 ->getFixups()
137 .push_back(PendingFixup.Fixup);
138 break;
139 default:
140 PendingFixup.DF->getFixups().push_back(PendingFixup.Fixup);
141 break;
142 }
143 }
144 PendingFixups.clear();
145}
146
147// As a compile-time optimization, avoid allocating and evaluating an MCExpr
148// tree for (Hi - Lo) when Hi and Lo are offsets into the same fragment.
149static std::optional<uint64_t> absoluteSymbolDiff(const MCSymbol *Hi,
150 const MCSymbol *Lo) {
151 assert(Hi && Lo);
152 if (!Hi->getFragment() || Hi->getFragment() != Lo->getFragment() ||
153 Hi->isVariable() || Lo->isVariable())
154 return std::nullopt;
155
156 return Hi->getOffset() - Lo->getOffset();
157}
158
160 const MCSymbol *Lo,
161 unsigned Size) {
162 if (!getAssembler().getContext().getTargetTriple().isRISCV())
163 if (std::optional<uint64_t> Diff = absoluteSymbolDiff(Hi, Lo))
164 return emitIntValue(*Diff, Size);
166}
167
169 const MCSymbol *Lo) {
170 if (!getAssembler().getContext().getTargetTriple().isRISCV())
171 if (std::optional<uint64_t> Diff = absoluteSymbolDiff(Hi, Lo)) {
172 emitULEB128IntValue(*Diff);
173 return;
174 }
176}
177
179 if (Assembler)
180 Assembler->reset();
181 CurInsertionPoint = MCSection::iterator();
182 EmitEHFrame = true;
183 EmitDebugFrame = false;
184 PendingLabels.clear();
185 PendingLabelSections.clear();
187}
188
190 if (!getNumFrameInfos())
191 return;
192
193 if (EmitEHFrame)
194 MCDwarfFrameEmitter::Emit(*this, MAB, true);
195
196 if (EmitDebugFrame)
197 MCDwarfFrameEmitter::Emit(*this, MAB, false);
198}
199
201 assert(getCurrentSectionOnly() && "No current section!");
202
203 if (CurInsertionPoint != getCurrentSectionOnly()->getFragmentList().begin())
204 return &*std::prev(CurInsertionPoint);
205
206 return nullptr;
207}
208
210 const MCAssembler &Assembler,
211 const MCSubtargetInfo *STI) {
212 if (!F.hasInstructions())
213 return true;
214 // Do not add data after a linker-relaxable instruction. The difference
215 // between a new label and a label at or before the linker-relaxable
216 // instruction cannot be resolved at assemble-time.
217 if (F.isLinkerRelaxable())
218 return false;
219 // When bundling is enabled, we don't want to add data to a fragment that
220 // already has instructions (see MCELFStreamer::emitInstToData for details)
221 if (Assembler.isBundlingEnabled())
222 return Assembler.getRelaxAll();
223 // If the subtarget is changed mid fragment we start a new fragment to record
224 // the new STI.
225 return !STI || F.getSubtargetInfo() == STI;
226}
227
230 MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
231 if (!F || !canReuseDataFragment(*F, *Assembler, STI)) {
232 F = new MCDataFragment();
233 insert(F);
234 }
235 return F;
236}
237
239 Assembler->registerSymbol(Sym);
240}
241
244 EmitEHFrame = EH;
245 EmitDebugFrame = Debug;
246}
247
249 SMLoc Loc) {
252 flushPendingLabels(DF, DF->getContents().size());
253
255
256 // Avoid fixups when possible.
257 int64_t AbsValue;
258 if (Value->evaluateAsAbsolute(AbsValue, getAssemblerPtr())) {
259 if (!isUIntN(8 * Size, AbsValue) && !isIntN(8 * Size, AbsValue)) {
261 Loc, "value evaluated as " + Twine(AbsValue) + " is out of range.");
262 return;
263 }
264 emitIntValue(AbsValue, Size);
265 return;
266 }
267 DF->getFixups().push_back(
268 MCFixup::create(DF->getContents().size(), Value,
269 MCFixup::getKindForSize(Size, false), Loc));
270 DF->getContents().resize(DF->getContents().size() + Size, 0);
271}
272
273MCSymbol *MCObjectStreamer::emitCFILabel() {
274 MCSymbol *Label = getContext().createTempSymbol("cfi");
275 emitLabel(Label);
276 return Label;
277}
278
279void MCObjectStreamer::emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) {
280 // We need to create a local symbol to avoid relocations.
282 emitLabel(Frame.Begin);
283}
284
285void MCObjectStreamer::emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) {
286 Frame.End = getContext().createTempSymbol();
287 emitLabel(Frame.End);
288}
289
291 MCStreamer::emitLabel(Symbol, Loc);
292
293 getAssembler().registerSymbol(*Symbol);
294
295 // If there is a current fragment, mark the symbol as pointing into it.
296 // Otherwise queue the label and set its fragment pointer when we emit the
297 // next fragment.
298 auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
299 if (F && !(getAssembler().isBundlingEnabled() &&
300 getAssembler().getRelaxAll())) {
301 Symbol->setFragment(F);
302 Symbol->setOffset(F->getContents().size());
303 } else {
304 // Assign all pending labels to offset 0 within the dummy "pending"
305 // fragment. (They will all be reassigned to a real fragment in
306 // flushPendingLabels())
307 Symbol->setOffset(0);
308 addPendingLabel(Symbol);
309 }
310
312}
313
315 auto Assignments = pendingAssignments.find(Symbol);
316 if (Assignments != pendingAssignments.end()) {
317 for (const PendingAssignment &A : Assignments->second)
318 emitAssignment(A.Symbol, A.Value);
319
320 pendingAssignments.erase(Assignments);
321 }
322}
323
324// Emit a label at a previously emitted fragment/offset position. This must be
325// within the currently-active section.
328 assert(F->getParent() == getCurrentSectionOnly());
329
330 MCStreamer::emitLabel(Symbol, Loc);
331 getAssembler().registerSymbol(*Symbol);
332 auto *DF = dyn_cast_or_null<MCDataFragment>(F);
333 Symbol->setOffset(Offset);
334 if (DF) {
335 Symbol->setFragment(F);
336 } else {
337 assert(isa<MCDummyFragment>(F) &&
338 "F must either be an MCDataFragment or the pending MCDummyFragment");
339 assert(Offset == 0);
340 addPendingLabel(Symbol);
341 }
342}
343
345 int64_t IntValue;
346 if (Value->evaluateAsAbsolute(IntValue, getAssemblerPtr())) {
347 emitULEB128IntValue(IntValue);
348 return;
349 }
350 insert(new MCLEBFragment(*Value, false));
351}
352
354 int64_t IntValue;
355 if (Value->evaluateAsAbsolute(IntValue, getAssemblerPtr())) {
356 emitSLEB128IntValue(IntValue);
357 return;
358 }
359 insert(new MCLEBFragment(*Value, true));
360}
361
363 const MCSymbol *Symbol) {
364 report_fatal_error("This file format doesn't support weak aliases.");
365}
366
368 const MCExpr *Subsection) {
369 changeSectionImpl(Section, Subsection);
370}
371
373 const MCExpr *Subsection) {
374 assert(Section && "Cannot switch to a null section!");
376
377 bool Created = getAssembler().registerSection(*Section);
378
379 int64_t IntSubsection = 0;
380 if (Subsection &&
381 !Subsection->evaluateAsAbsolute(IntSubsection, getAssemblerPtr())) {
382 getContext().reportError(Subsection->getLoc(),
383 "cannot evaluate subsection number");
384 }
385 if (!isUInt<31>(IntSubsection)) {
386 getContext().reportError(Subsection->getLoc(),
387 "subsection number " + Twine(IntSubsection) +
388 " is not within [0,2147483647]");
389 }
390
391 CurSubsectionIdx = unsigned(IntSubsection);
392 CurInsertionPoint =
393 Section->getSubsectionInsertionPoint(CurSubsectionIdx);
394 return Created;
395}
396
398 getAssembler().registerSymbol(*Symbol);
401}
402
404 const MCExpr *Value) {
405 const MCSymbol *Target = &cast<MCSymbolRefExpr>(*Value).getSymbol();
406
407 // If the symbol already exists, emit the assignment. Otherwise, emit it
408 // later only if the symbol is also emitted.
409 if (Target->isRegistered())
410 emitAssignment(Symbol, Value);
411 else
412 pendingAssignments[Target].push_back({Symbol, Value});
413}
414
416 return Sec.hasInstructions();
417}
418
420 const MCSubtargetInfo &STI) {
421 const MCSection &Sec = *getCurrentSectionOnly();
422 if (Sec.isVirtualSection()) {
424 " section '" + Sec.getName() +
425 "' cannot have instructions");
426 return;
427 }
428 getAssembler().getBackend().emitInstructionBegin(*this, Inst, STI);
429 emitInstructionImpl(Inst, STI);
431}
432
433void MCObjectStreamer::emitInstructionImpl(const MCInst &Inst,
434 const MCSubtargetInfo &STI) {
436
438 Sec->setHasInstructions(true);
439
440 // Now that a machine instruction has been assembled into this section, make
441 // a line entry for any .loc directive that has been seen.
443
444 // If this instruction doesn't need relaxation, just emit it as data.
445 MCAssembler &Assembler = getAssembler();
446 MCAsmBackend &Backend = Assembler.getBackend();
447 if (!(Backend.mayNeedRelaxation(Inst, STI) ||
448 Backend.allowEnhancedRelaxation())) {
449 emitInstToData(Inst, STI);
450 return;
451 }
452
453 // Otherwise, relax and emit it as data if either:
454 // - The RelaxAll flag was passed
455 // - Bundling is enabled and this instruction is inside a bundle-locked
456 // group. We want to emit all such instructions into the same data
457 // fragment.
458 if (Assembler.getRelaxAll() ||
459 (Assembler.isBundlingEnabled() && Sec->isBundleLocked())) {
460 MCInst Relaxed = Inst;
461 while (Backend.mayNeedRelaxation(Relaxed, STI))
462 Backend.relaxInstruction(Relaxed, STI);
463 emitInstToData(Relaxed, STI);
464 return;
465 }
466
467 // Otherwise emit to a separate fragment.
468 emitInstToFragment(Inst, STI);
469}
470
472 const MCSubtargetInfo &STI) {
473 if (getAssembler().getRelaxAll() && getAssembler().isBundlingEnabled())
474 llvm_unreachable("All instructions should have already been relaxed");
475
476 // Always create a new, separate fragment here, because its size can change
477 // during relaxation.
478 MCRelaxableFragment *IF = new MCRelaxableFragment(Inst, STI);
479 insert(IF);
480
481 SmallString<128> Code;
482 getAssembler().getEmitter().encodeInstruction(Inst, Code, IF->getFixups(),
483 STI);
484 IF->getContents().append(Code.begin(), Code.end());
485}
486
487#ifndef NDEBUG
488static const char *const BundlingNotImplementedMsg =
489 "Aligned bundling is not implemented for this object format";
490#endif
491
494}
495
496void MCObjectStreamer::emitBundleLock(bool AlignToEnd) {
498}
499
502}
503
504void MCObjectStreamer::emitDwarfLocDirective(unsigned FileNo, unsigned Line,
505 unsigned Column, unsigned Flags,
506 unsigned Isa,
507 unsigned Discriminator,
508 StringRef FileName) {
509 // In case we see two .loc directives in a row, make sure the
510 // first one gets a line entry.
512
513 this->MCStreamer::emitDwarfLocDirective(FileNo, Line, Column, Flags, Isa,
514 Discriminator, FileName);
515}
516
518 const MCSymbol *B, SMLoc Loc) {
519 MCContext &Context = OS.getContext();
521 const MCExpr *ARef = MCSymbolRefExpr::create(A, Variant, Context);
522 const MCExpr *BRef = MCSymbolRefExpr::create(B, Variant, Context);
523 const MCExpr *AddrDelta =
525 return AddrDelta;
526}
527
530 int64_t LineDelta, const MCSymbol *Label,
531 int PointerSize) {
532 // emit the sequence to set the address
533 OS.emitIntValue(dwarf::DW_LNS_extended_op, 1);
534 OS.emitULEB128IntValue(PointerSize + 1);
535 OS.emitIntValue(dwarf::DW_LNE_set_address, 1);
536 OS.emitSymbolValue(Label, PointerSize);
537
538 // emit the sequence for the LineDelta (from 1) and a zero address delta.
539 MCDwarfLineAddr::Emit(&OS, Params, LineDelta, 0);
540}
541
543 const MCSymbol *LastLabel,
544 const MCSymbol *Label,
545 unsigned PointerSize) {
546 if (!LastLabel) {
547 emitDwarfSetLineAddr(*this, Assembler->getDWARFLinetableParams(), LineDelta,
548 Label, PointerSize);
549 return;
550 }
551 const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel, SMLoc());
552 insert(new MCDwarfLineAddrFragment(LineDelta, *AddrDelta));
553}
554
556 MCSymbol *LastLabel) {
557 // Emit a DW_LNE_end_sequence for the end of the section.
558 // Use the section end label to compute the address delta and use INT64_MAX
559 // as the line delta which is the signal that this is actually a
560 // DW_LNE_end_sequence.
561 MCSymbol *SectionEnd = endSection(Section);
562
563 // Switch back the dwarf line section, in case endSection had to switch the
564 // section.
565 MCContext &Ctx = getContext();
567
568 const MCAsmInfo *AsmInfo = Ctx.getAsmInfo();
569 emitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd,
570 AsmInfo->getCodePointerSize());
571}
572
574 const MCSymbol *Label,
575 SMLoc Loc) {
576 const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel, Loc);
577 insert(new MCDwarfCallFrameFragment(*AddrDelta, nullptr));
578}
579
581 unsigned Line, unsigned Column,
582 bool PrologueEnd, bool IsStmt,
583 StringRef FileName, SMLoc Loc) {
584 // Validate the directive.
585 if (!checkCVLocSection(FunctionId, FileNo, Loc))
586 return;
587
588 // Emit a label at the current position and record it in the CodeViewContext.
589 MCSymbol *LineSym = getContext().createTempSymbol();
590 emitLabel(LineSym);
592 FileNo, Line, Column, PrologueEnd,
593 IsStmt);
594}
595
597 const MCSymbol *Begin,
598 const MCSymbol *End) {
600 End);
601 this->MCStreamer::emitCVLinetableDirective(FunctionId, Begin, End);
602}
603
605 unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum,
606 const MCSymbol *FnStartSym, const MCSymbol *FnEndSym) {
608 *this, PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym,
609 FnEndSym);
611 PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
612}
613
615 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
616 StringRef FixedSizePortion) {
617 MCFragment *Frag =
618 getContext().getCVContext().emitDefRange(*this, Ranges, FixedSizePortion);
619 // Attach labels that were pending before we created the defrange fragment to
620 // the beginning of the new fragment.
621 flushPendingLabels(Frag, 0);
622 this->MCStreamer::emitCVDefRangeDirective(Ranges, FixedSizePortion);
623}
624
627}
630}
631
634}
635
639 flushPendingLabels(DF, DF->getContents().size());
640 DF->getContents().append(Data.begin(), Data.end());
641}
642
644 unsigned ValueSize,
645 unsigned MaxBytesToEmit) {
646 if (MaxBytesToEmit == 0)
647 MaxBytesToEmit = Alignment.value();
648 insert(new MCAlignFragment(Alignment, Value, ValueSize, MaxBytesToEmit));
649
650 // Update the maximum alignment on the current section if necessary.
652 CurSec->ensureMinAlignment(Alignment);
653}
654
656 const MCSubtargetInfo *STI,
657 unsigned MaxBytesToEmit) {
658 emitValueToAlignment(Alignment, 0, 1, MaxBytesToEmit);
659 cast<MCAlignFragment>(getCurrentFragment())->setEmitNops(true, STI);
660}
661
663 unsigned char Value,
664 SMLoc Loc) {
665 insert(new MCOrgFragment(*Offset, Value, Loc));
666}
667
668// Associate DTPRel32 fixup with data and resize data area
671 flushPendingLabels(DF, DF->getContents().size());
672
673 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
675 DF->getContents().resize(DF->getContents().size() + 4, 0);
676}
677
678// Associate DTPRel64 fixup with data and resize data area
681 flushPendingLabels(DF, DF->getContents().size());
682
683 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
685 DF->getContents().resize(DF->getContents().size() + 8, 0);
686}
687
688// Associate TPRel32 fixup with data and resize data area
691 flushPendingLabels(DF, DF->getContents().size());
692
693 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
694 Value, FK_TPRel_4));
695 DF->getContents().resize(DF->getContents().size() + 4, 0);
696}
697
698// Associate TPRel64 fixup with data and resize data area
701 flushPendingLabels(DF, DF->getContents().size());
702
703 DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
704 Value, FK_TPRel_8));
705 DF->getContents().resize(DF->getContents().size() + 8, 0);
706}
707
708// Associate GPRel32 fixup with data and resize data area
711 flushPendingLabels(DF, DF->getContents().size());
712
713 DF->getFixups().push_back(
714 MCFixup::create(DF->getContents().size(), Value, FK_GPRel_4));
715 DF->getContents().resize(DF->getContents().size() + 4, 0);
716}
717
718// Associate GPRel64 fixup with data and resize data area
721 flushPendingLabels(DF, DF->getContents().size());
722
723 DF->getFixups().push_back(
724 MCFixup::create(DF->getContents().size(), Value, FK_GPRel_4));
725 DF->getContents().resize(DF->getContents().size() + 8, 0);
726}
727
728static std::optional<std::pair<bool, std::string>>
729getOffsetAndDataFragment(const MCSymbol &Symbol, uint32_t &RelocOffset,
730 MCDataFragment *&DF) {
731 if (Symbol.isVariable()) {
732 const MCExpr *SymbolExpr = Symbol.getVariableValue();
733 MCValue OffsetVal;
734 if(!SymbolExpr->evaluateAsRelocatable(OffsetVal, nullptr, nullptr))
735 return std::make_pair(false,
736 std::string("symbol in .reloc offset is not "
737 "relocatable"));
738 if (OffsetVal.isAbsolute()) {
739 RelocOffset = OffsetVal.getConstant();
740 MCFragment *Fragment = Symbol.getFragment();
741 // FIXME Support symbols with no DF. For example:
742 // .reloc .data, ENUM_VALUE, <some expr>
743 if (!Fragment || Fragment->getKind() != MCFragment::FT_Data)
744 return std::make_pair(false,
745 std::string("symbol in offset has no data "
746 "fragment"));
747 DF = cast<MCDataFragment>(Fragment);
748 return std::nullopt;
749 }
750
751 if (OffsetVal.getSymB())
752 return std::make_pair(false,
753 std::string(".reloc symbol offset is not "
754 "representable"));
755
756 const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*OffsetVal.getSymA());
757 if (!SRE.getSymbol().isDefined())
758 return std::make_pair(false,
759 std::string("symbol used in the .reloc offset is "
760 "not defined"));
761
762 if (SRE.getSymbol().isVariable())
763 return std::make_pair(false,
764 std::string("symbol used in the .reloc offset is "
765 "variable"));
766
767 MCFragment *Fragment = SRE.getSymbol().getFragment();
768 // FIXME Support symbols with no DF. For example:
769 // .reloc .data, ENUM_VALUE, <some expr>
770 if (!Fragment || Fragment->getKind() != MCFragment::FT_Data)
771 return std::make_pair(false,
772 std::string("symbol in offset has no data "
773 "fragment"));
774 RelocOffset = SRE.getSymbol().getOffset() + OffsetVal.getConstant();
775 DF = cast<MCDataFragment>(Fragment);
776 } else {
777 RelocOffset = Symbol.getOffset();
778 MCFragment *Fragment = Symbol.getFragment();
779 // FIXME Support symbols with no DF. For example:
780 // .reloc .data, ENUM_VALUE, <some expr>
781 if (!Fragment || Fragment->getKind() != MCFragment::FT_Data)
782 return std::make_pair(false,
783 std::string("symbol in offset has no data "
784 "fragment"));
785 DF = cast<MCDataFragment>(Fragment);
786 }
787 return std::nullopt;
788}
789
790std::optional<std::pair<bool, std::string>>
792 const MCExpr *Expr, SMLoc Loc,
793 const MCSubtargetInfo &STI) {
794 std::optional<MCFixupKind> MaybeKind =
795 Assembler->getBackend().getFixupKind(Name);
796 if (!MaybeKind)
797 return std::make_pair(true, std::string("unknown relocation name"));
798
799 MCFixupKind Kind = *MaybeKind;
800 if (Expr)
801 visitUsedExpr(*Expr);
802 else
803 Expr =
804 MCSymbolRefExpr::create(getContext().createTempSymbol(), getContext());
805
807 flushPendingLabels(DF, DF->getContents().size());
808
809 MCValue OffsetVal;
810 if (!Offset.evaluateAsRelocatable(OffsetVal, nullptr, nullptr))
811 return std::make_pair(false,
812 std::string(".reloc offset is not relocatable"));
813 if (OffsetVal.isAbsolute()) {
814 if (OffsetVal.getConstant() < 0)
815 return std::make_pair(false, std::string(".reloc offset is negative"));
816 DF->getFixups().push_back(
817 MCFixup::create(OffsetVal.getConstant(), Expr, Kind, Loc));
818 return std::nullopt;
819 }
820 if (OffsetVal.getSymB())
821 return std::make_pair(false,
822 std::string(".reloc offset is not representable"));
823
824 const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*OffsetVal.getSymA());
825 const MCSymbol &Symbol = SRE.getSymbol();
826 if (Symbol.isDefined()) {
827 uint32_t SymbolOffset = 0;
828 std::optional<std::pair<bool, std::string>> Error =
829 getOffsetAndDataFragment(Symbol, SymbolOffset, DF);
830
831 if (Error != std::nullopt)
832 return Error;
833
834 DF->getFixups().push_back(
835 MCFixup::create(SymbolOffset + OffsetVal.getConstant(),
836 Expr, Kind, Loc));
837 return std::nullopt;
838 }
839
840 PendingFixups.emplace_back(
841 &SRE.getSymbol(), DF,
842 MCFixup::create(OffsetVal.getConstant(), Expr, Kind, Loc));
843 return std::nullopt;
844}
845
846void MCObjectStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
847 SMLoc Loc) {
849 flushPendingLabels(DF, DF->getContents().size());
850
851 assert(getCurrentSectionOnly() && "need a section");
852 insert(new MCFillFragment(FillValue, 1, NumBytes, Loc));
853}
854
855void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
856 int64_t Expr, SMLoc Loc) {
857 int64_t IntNumValues;
858 // Do additional checking now if we can resolve the value.
859 if (NumValues.evaluateAsAbsolute(IntNumValues, getAssemblerPtr())) {
860 if (IntNumValues < 0) {
863 "'.fill' directive with negative repeat count has no effect");
864 return;
865 }
866 // Emit now if we can for better errors.
867 int64_t NonZeroSize = Size > 4 ? 4 : Size;
868 Expr &= ~0ULL >> (64 - NonZeroSize * 8);
869 for (uint64_t i = 0, e = IntNumValues; i != e; ++i) {
870 emitIntValue(Expr, NonZeroSize);
871 if (NonZeroSize < Size)
872 emitIntValue(0, Size - NonZeroSize);
873 }
874 return;
875 }
876
877 // Otherwise emit as fragment.
879 flushPendingLabels(DF, DF->getContents().size());
880
881 assert(getCurrentSectionOnly() && "need a section");
882 insert(new MCFillFragment(Expr, Size, NumValues, Loc));
883}
884
885void MCObjectStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLength,
886 SMLoc Loc, const MCSubtargetInfo &STI) {
887 // Emit an NOP fragment.
889 flushPendingLabels(DF, DF->getContents().size());
890
891 assert(getCurrentSectionOnly() && "need a section");
892
893 insert(new MCNopsFragment(NumBytes, ControlledNopLength, Loc, STI));
894}
895
897 getAssembler().addFileName(Filename);
898}
899
901 StringRef CompilerVersion,
902 StringRef TimeStamp,
903 StringRef Description) {
904 getAssembler().addFileName(Filename);
905 getAssembler().setCompilerVersion(CompilerVersion.str());
906 // TODO: add TimeStamp and Description to .file symbol table entry
907 // with the integrated assembler.
908}
909
912}
913
916}
917
920
921 // If we are generating dwarf for assembly source files dump out the sections.
922 if (getContext().getGenDwarfForAssembly())
924
925 // Dump out the dwarf file & directory tables and line tables.
926 MCDwarfLineTable::emit(this, getAssembler().getDWARFLinetableParams());
927
928 // Emit pseudo probes for the current module.
930
931 // Update any remaining pending labels with empty data fragments.
933
934 resolvePendingFixups();
936}
basic Basic Alias true
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
dxil DXContainer Global Emitter
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
std::string Name
uint64_t Size
bool End
Definition: ELF_riscv.cpp:480
Symbol * Sym
Definition: ELF_riscv.cpp:479
static const MCExpr * buildSymbolDiff(MCObjectStreamer &OS, const MCSymbol *A, const MCSymbol *B, SMLoc Loc)
static const char *const BundlingNotImplementedMsg
static std::optional< std::pair< bool, std::string > > getOffsetAndDataFragment(const MCSymbol &Symbol, uint32_t &RelocOffset, MCDataFragment *&DF)
static void emitDwarfSetLineAddr(MCObjectStreamer &OS, MCDwarfLineTableParams Params, int64_t LineDelta, const MCSymbol *Label, int PointerSize)
static std::optional< uint64_t > absoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo)
static bool canReuseDataFragment(const MCDataFragment &F, const MCAssembler &Assembler, const MCSubtargetInfo *STI)
#define F(x, y, z)
Definition: MD5.cpp:55
LLVMContext & Context
bool Debug
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
void emitLineTableForFunction(MCObjectStreamer &OS, unsigned FuncId, const MCSymbol *FuncBegin, const MCSymbol *FuncEnd)
Emits a line table substream.
Definition: MCCodeView.cpp:350
void emitFileChecksums(MCObjectStreamer &OS)
Emits the file checksum substream.
Definition: MCCodeView.cpp:193
void recordCVLoc(MCContext &Ctx, const MCSymbol *Label, unsigned FunctionId, unsigned FileNo, unsigned Line, unsigned Column, bool PrologueEnd, bool IsStmt)
Saves the information from the currently parsed .cv_loc directive and sets CVLocSeen.
Definition: MCCodeView.cpp:131
void emitFileChecksumOffset(MCObjectStreamer &OS, unsigned FileNo)
Emits the offset into the checksum table of the given file number.
Definition: MCCodeView.cpp:248
void emitInlineLineTableForFunction(MCObjectStreamer &OS, unsigned PrimaryFunctionId, unsigned SourceFileId, unsigned SourceLineNum, const MCSymbol *FnStartSym, const MCSymbol *FnEndSym)
Definition: MCCodeView.cpp:445
void emitStringTable(MCObjectStreamer &OS)
Emits the string table substream.
Definition: MCCodeView.cpp:171
MCFragment * emitDefRange(MCObjectStreamer &OS, ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion)
Definition: MCCodeView.cpp:458
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:43
virtual bool allowEnhancedRelaxation() const
Return true if this target allows an unrelaxable instruction to be emitted into RelaxableFragment and...
Definition: MCAsmBackend.h:63
virtual void relaxInstruction(MCInst &Inst, const MCSubtargetInfo &STI) const
Relax the instruction in the given fragment to the next wider instruction.
Definition: MCAsmBackend.h:186
virtual bool mayNeedRelaxation(const MCInst &Inst, const MCSubtargetInfo &STI) const
Check whether the given instruction may need relaxation.
Definition: MCAsmBackend.h:163
virtual void emitInstructionEnd(MCObjectStreamer &OS, const MCInst &Inst)
Definition: MCAsmBackend.h:70
virtual void emitInstructionBegin(MCObjectStreamer &OS, const MCInst &Inst, const MCSubtargetInfo &STI)
Give the target a chance to manipulate state related to instruction alignment (e.g.
Definition: MCAsmBackend.h:68
virtual std::optional< MCFixupKind > getFixupKind(StringRef Name) const
Map a relocation name used in .reloc to a fixup kind.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Definition: MCAsmInfo.h:553
void Finish()
Finish - Do final processing and write the object to the output stream.
bool isBundlingEnabled() const
Definition: MCAssembler.h:365
MCObjectWriter & getWriter() const
Definition: MCAssembler.h:338
bool getRelaxAll() const
Definition: MCAssembler.h:362
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:336
void addFileName(StringRef FileName)
Definition: MCAssembler.h:487
MCAsmBackend & getBackend() const
Definition: MCAssembler.h:334
bool registerSection(MCSection &Section)
bool registerSymbol(const MCSymbol &Symbol)
MCDwarfLineTableParams getDWARFLinetableParams() const
Definition: MCAssembler.h:340
void setCompilerVersion(std::string CompilerVers)
Definition: MCAssembler.h:491
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition: MCExpr.cpp:183
@ Sub
Subtraction.
Definition: MCExpr.h:515
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
Encode the given Inst to bytes and append to CB.
Context object for machine code objects.
Definition: MCContext.h:76
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:450
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
Definition: MCContext.cpp:321
void RemapDebugPaths()
Definition: MCContext.cpp:899
void clearDwarfLocSeen()
Definition: MCContext.h:784
CodeViewContext & getCVContext()
Definition: MCContext.cpp:1009
const SourceMgr * getSourceManager() const
Definition: MCContext.h:435
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:446
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1064
Fragment for data and encoded instructions.
Definition: MCFragment.h:242
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
Definition: MCDwarf.cpp:1854
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:668
static void make(MCStreamer *MCOS, MCSection *Section)
Definition: MCDwarf.cpp:94
static void emit(MCStreamer *MCOS, MCDwarfLineTableParams Params)
Definition: MCDwarf.cpp:259
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Definition: MCExpr.cpp:810
SMLoc getLoc() const
Definition: MCExpr.h:82
static MCFixupKind getKindForSize(unsigned Size, bool IsPCRel)
Return the generic fixup kind for a value with the given size.
Definition: MCFixup.h:109
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
Definition: MCFixup.h:87
FragmentType getKind() const
Definition: MCFragment.h:94
static void Emit(MCStreamer *MCOS)
Definition: MCDwarf.cpp:1137
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
SMLoc getLoc() const
Definition: MCInst.h:204
MCSection * getDwarfLineSection() const
Streaming object file generation interface.
void reset() override
state management
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
void emitDwarfLineEndEntry(MCSection *Section, MCSymbol *LastLabel) override
Emit the debug line end entry.
void emitValueToAlignment(Align Alignment, 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 emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void emitULEB128Value(const MCExpr *Value) override
void emitSLEB128Value(const MCExpr *Value) override
void emitNops(int64_t NumBytes, int64_t ControlledNopLength, SMLoc Loc, const MCSubtargetInfo &STI) override
MCDataFragment * getOrCreateDataFragment(const MCSubtargetInfo *STI=nullptr)
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment.
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 emitCVStringTableDirective() override
This implements the CodeView '.cv_stringtable' assembler directive.
void emitBundleAlignMode(Align Alignment) override
Set the bundle alignment mode from now on in the section.
MCAssembler & getAssembler()
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
void emitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label, unsigned PointerSize) override
If targets does not support representing debug line section by .loc/.file directives in assembly outp...
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.
void emitDTPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a dtprel (32-bit DTP relative) value.
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void emitBundleLock(bool AlignToEnd) override
The following instructions are a bundle-locked group.
void emitPendingAssignments(MCSymbol *Symbol)
Emits pending conditional assignments that depend on Symbol being emitted.
void emitFileDirective(StringRef Filename) override
Switch to a new logical file.
void emitCVDefRangeDirective(ArrayRef< std::pair< const MCSymbol *, const MCSymbol * > > Ranges, StringRef FixedSizePortion) override
This implements the CodeView '.cv_def_range' assembler directive.
void emitGPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a gprel64 (64-bit GP relative) value.
MCAssembler * getAssemblerPtr() override
void flushPendingLabels()
Create a data fragment for any pending labels across all Sections and Subsections.
virtual void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F, uint64_t Offset)
std::optional< std::pair< bool, std::string > > emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc, const MCSubtargetInfo &STI) override
Record a relocation described by the .reloc directive.
void emitAddrsigSym(const MCSymbol *Sym) override
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
void visitUsedSymbol(const MCSymbol &Sym) override
void emitGPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a gprel32 (32-bit GP relative) value.
void insert(MCFragment *F)
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 emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
MCObjectStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
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.
void finishImpl() override
Streamer specific finalization.
void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo) override
Emit the absolute difference between two symbols encoded with ULEB128.
void emitBundleUnlock() override
Ends a bundle-locked group.
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
void emitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, const MCSymbol *Label, SMLoc Loc)
void emitCFISections(bool EH, bool Debug) override
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 addPendingLabel(MCSymbol *label)
Assign a label to the current Section and Subsection even though a fragment is not yet present.
bool mayHaveInstructions(MCSection &Sec) const override
MCFragment * getCurrentFragment() const
void emitCodeAlignment(Align ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
void emitFrames(MCAsmBackend *MAB)
void changeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
void emitTPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a tprel (64-bit TP relative) value.
void emitCVFileChecksumOffsetDirective(unsigned FileNo) override
This implements the CodeView '.cv_filechecksumoffset' assembler directive.
void emitTPRel32Value(const MCExpr *Value) override
Emit the expression Value into the output as a tprel (32-bit TP relative) value.
void emitConditionalAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol, but only if Value is also emitted.
void emitCVFileChecksumsDirective() override
This implements the CodeView '.cv_filechecksums' assembler directive.
void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *Begin, const MCSymbol *End) override
This implements the CodeView '.cv_linetable' assembler directive.
void emitDTPRel64Value(const MCExpr *Value) override
Emit the expression Value into the output as a dtprel (64-bit DTP relative) value.
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.
void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) override
Emit the absolute difference between two symbols if possible.
void emitAddrsigSection()
Tell the object writer to emit an address-significance table during writeObject().
void addAddrsigSymbol(const MCSymbol *Sym)
Record the given symbol in the address-significance table to be written diring writeObject().
static void emit(MCObjectStreamer *MCOS)
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:274
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
void addPendingLabel(MCSymbol *label, unsigned Subsection=0)
Add a pending label for the requested subsection.
Definition: MCSection.cpp:91
virtual StringRef getVirtualSectionKind() const
Definition: MCSection.cpp:89
void ensureMinAlignment(Align MinAlignment)
Makes sure that Alignment is at least MinAlignment.
Definition: MCSection.h:144
void flushPendingLabels(MCFragment *F, uint64_t FOffset=0, unsigned Subsection=0)
Associate all pending labels in a subsection with a fragment.
Definition: MCSection.cpp:95
bool hasInstructions() const
Definition: MCSection.h:166
void setHasInstructions(bool Value)
Definition: MCSection.h:167
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
bool isBundleLocked() const
Definition: MCSection.h:157
StringRef getName() const
Definition: MCSection.h:124
FragmentListType::iterator iterator
Definition: MCSection.h:64
Streaming machine code generation interface.
Definition: MCStreamer.h:212
virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
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:263
virtual void emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi, const MCSymbol *Lo)
Emit the absolute difference between two symbols encoded with ULEB128.
bool getUseAssemblerInfoForParsing()
Definition: MCStreamer.h:302
MCContext & getContext() const
Definition: MCStreamer.h:297
bool checkCVLocSection(unsigned FuncId, unsigned FileNo, SMLoc Loc)
Returns true if the .cv_loc directive is in the right section.
Definition: MCStreamer.cpp:325
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:424
void setAllowAutoPadding(bool v)
Definition: MCStreamer.h:308
virtual void reset()
State management.
Definition: MCStreamer.cpp:102
virtual void emitCVLinetableDirective(unsigned FunctionId, const MCSymbol *FnStart, const MCSymbol *FnEnd)
This implements the CodeView '.cv_linetable' assembler directive.
Definition: MCStreamer.cpp:347
virtual void emitCFISections(bool EH, bool Debug)
Definition: MCStreamer.cpp:446
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:134
unsigned getNumFrameInfos()
Definition: MCStreamer.cpp:116
unsigned emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:162
MCSymbol * endSection(MCSection *Section)
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
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:369
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:393
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.
unsigned emitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:172
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:351
void visitUsedExpr(const MCExpr &Expr)
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
const MCSymbol & getSymbol() const
Definition: MCExpr.h:408
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:395
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:250
bool isVariable() const
isVariable - Check if this is a variable symbol.
Definition: MCSymbol.h:300
uint64_t getOffset() const
Definition: MCSymbol.h:327
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:397
This represents an "assembler immediate".
Definition: MCValue.h:36
int64_t getConstant() const
Definition: MCValue.h:43
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:45
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:44
bool isAbsolute() const
Is this an absolute (as opposed to relocatable) value.
Definition: MCValue.h:49
Represents a location in source code.
Definition: SMLoc.h:23
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges={}, ArrayRef< SMFixIt > FixIts={}, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
Definition: SourceMgr.cpp:352
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
LLVM Value Representation.
Definition: Value.h:74
This class represents a function that is read from a sample profile.
Definition: FunctionId.h:36
#define INT64_MAX
Definition: DataTypes.h:71
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:228
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:156
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:21
@ FK_DTPRel_4
A four-byte dtp relative fixup.
Definition: MCFixup.h:36
@ FK_DTPRel_8
A eight-byte dtp relative fixup.
Definition: MCFixup.h:37
@ FK_TPRel_4
A four-byte tp relative fixup.
Definition: MCFixup.h:38
@ FK_GPRel_4
A four-byte gp relative fixup.
Definition: MCFixup.h:34
@ FK_TPRel_8
A eight-byte tp relative fixup.
Definition: MCFixup.h:39
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
Definition: MathExtras.h:233
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1858
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
MCSymbol * Begin
Definition: MCDwarf.h:700