31 *TAB.createObjectWriter(OS), OS)),
32 EmitEHFrame(
true), EmitDebugFrame(
false) {}
42 if (PendingLabels.size()) {
49 for (
MCSymbol *Sym : PendingLabels) {
51 Sym->setOffset(FOffset);
53 PendingLabels.clear();
67 "Expected Hi to be greater than Lo");
76 EmitDebugFrame =
false;
77 PendingLabels.clear();
96 return std::prev(CurInsertionPoint);
120 EmitDebugFrame =
Debug;
133 if (Value->evaluateAsAbsolute(AbsValue,
getAssembler())) {
158 assert(!Symbol->
getFragment() &&
"Unexpected fragment on symbol data!");
167 Symbol->
setOffset(F->getContents().size());
169 PendingLabels.push_back(Symbol);
175 if (Value->evaluateAsAbsolute(IntValue,
getAssembler())) {
184 if (Value->evaluateAsAbsolute(IntValue,
getAssembler())) {
197 const MCExpr *Subsection) {
202 const MCExpr *Subsection) {
203 assert(Section &&
"Cannot switch to a null section!");
208 int64_t IntSubsection = 0;
210 !Subsection->evaluateAsAbsolute(IntSubsection,
getAssembler()))
212 if (IntSubsection < 0 || IntSubsection > 8192)
242 EmitInstToData(Inst, STI);
255 while (
getAssembler().getBackend().mayNeedRelaxation(Relaxed))
257 EmitInstToData(Relaxed, STI);
285 "Aligned bundling is not implemented for this object format";
301 unsigned Column,
unsigned Flags,
303 unsigned Discriminator,
310 Isa, Discriminator, FileName);
325 const MCSymbol *Label,
int PointerSize) {
339 unsigned PointerSize) {
346 if (AddrDelta->evaluateAsAbsolute(Res,
getAssembler())) {
357 if (AddrDelta->evaluateAsAbsolute(Res,
getAssembler())) {
374 unsigned MaxBytesToEmit) {
375 if (MaxBytesToEmit == 0)
386 unsigned MaxBytesToEmit) {
392 unsigned char Value) {
443 assert(Sec &&
"need a 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.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
static void Emit(MCStreamer *MCOS, int64_t LineDelta, uint64_t AddrDelta)
Utility function to emit the encoding to a streamer.
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)
void EmitSLEB128IntValue(int64_t Value)
Special case of EmitSLEB128Value that avoids the client having to pass in a MCExpr for constant integ...
bool hasInstructions() const
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.
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 ...
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)
virtual void reset()
State management.
static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta)
MCCodeEmitter & getEmitter() const
A raw_ostream that writes to an SmallVector or SmallString.
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
const_iterator begin(StringRef path)
Get begin iterator over path.
static MCFixupKind getKindForSize(unsigned Size, bool isPCRel)
Return the generic fixup kind for a value with the given size.
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.
bool registerSection(MCSection &Section)
unsigned getAlignment() const
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
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)
static const MCBinaryExpr * create(Opcode Op, const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCFragment * getCurrentFragment() const
void setHasInstructions(bool Value)
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.
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
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
Base class for the full range of assembler expressions which are needed for parsing.
void EmitFill(uint64_t NumBytes, uint8_t FillValue) override
Emit NumBytes bytes worth of the value specified by FillValue.
bool mayHaveInstructions(MCSection &Sec) const override
MCContext & getContext() const
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.
Context object for machine code objects.
A four-byte gp relative fixup.
Streaming object file generation interface.
MCObjectWriter & getWriter() const
SmallVectorImpl< char > & getContents()
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...
Instances of this class represent a single low-level machine instruction.
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...
bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
void EmitULEB128Value(const MCExpr *Value) override
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
void visitUsedSymbol(const MCSymbol &Sym) override
FragmentListType::iterator iterator
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.
SmallVectorImpl< MCFixup > & getFixups()
virtual bool mayNeedRelaxation(const MCInst &Inst) const =0
Check whether the given instruction may need relaxation.
iterator insert(iterator where, NodeTy *New)
MCFragment * getFragment() const
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.
void setOffset(uint64_t Value)
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
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
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.
virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size)
Emit the absolute difference between two symbols.
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
~MCObjectStreamer() override
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)
unsigned getNumFrameInfos()
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
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void reset() override
state management
MCAsmBackend & getBackend() const
MCSubtargetInfo - Generic base class for all target subtargets.
static void Make(MCObjectStreamer *MCOS, MCSection *Section)
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...
An abstract base class for streams implementations that also support a pwrite operation.
void reset()
Reuse an assembler instance.
Fragment for data and encoded instructions.
MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection)
LLVM Value Representation.
Generic interface to target specific assembler backends.
bool isBundleLocked() const
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.
static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH)
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
void setParent(MCSection *Value)
void Finish()
Finish - Do final processing and write the object to the output stream.
MCSection::FragmentListType & getFragmentList()
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)
static void Emit(MCObjectStreamer *MCOS)