Go to the documentation of this file.
41 #define DEBUG_TYPE "WinCOFFStreamer"
44 std::unique_ptr<MCAsmBackend> MAB,
45 std::unique_ptr<MCCodeEmitter> CE,
46 std::unique_ptr<MCObjectWriter> OW)
60 for (
unsigned i = 0,
e =
Fixups.size();
i !=
e; ++
i) {
64 DF->setHasInstructions(STI);
65 DF->getContents().append(
Code.begin(),
Code.end());
86 auto *
Symbol = cast<MCSymbolCOFF>(
S);
112 auto *
Symbol = cast<MCSymbolCOFF>(
S);
116 default:
return false;
119 Symbol->setIsWeakExternal();
120 Symbol->setExternal(
true);
123 Symbol->setExternal(
true);
137 auto *
Symbol = cast<MCSymbolCOFF>(
S);
139 Error(
"starting a new symbol definition without completing the "
146 Error(
"storage class specified outside of symbol definition");
162 Error(
"symbol type specified outside of a symbol definition");
166 if (
Type & ~0xffff) {
177 Error(
"ending symbol definition without starting one");
223 DF->getFixups().push_back(
Fixup);
224 DF->getContents().resize(
DF->getContents().size() + 2, 0);
240 DF->getFixups().push_back(
Fixup);
242 DF->getContents().resize(
DF->getContents().size() + 4, 0);
259 DF->getFixups().push_back(
Fixup);
261 DF->getContents().resize(
DF->getContents().size() + 4, 0);
266 auto *
Symbol = cast<MCSymbolCOFF>(
S);
269 if (
T.isWindowsMSVCEnvironment()) {
278 Symbol->setExternal(
true);
286 OS <<
" -aligncomm:\"" <<
Symbol->getName() <<
"\","
298 auto *
Symbol = cast<MCSymbolCOFF>(
S);
305 Symbol->setExternal(
false);
312 auto *Alias = cast<MCSymbolCOFF>(AliasS);
353 cast<MCSymbolCOFF>(
S)->setExternal(
true);
MCAsmBackend & getBackend() const
const MCObjectFileInfo * getObjectFileInfo() const
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
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.
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Context object for machine code objects.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
virtual void handleAssemblerFlag(MCAssemblerFlag Flag)
Handle any target-specific assembler flags. By default, do nothing.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
void emitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count) override
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
void EmitCOFFSymbolType(int Type) override
Emit the type of the symbol.
void visitUsedSymbol(const MCSymbol &Sym) override
void emitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
Instances of this class represent a single low-level machine instruction.
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
void emitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
void BeginCOFFSymbolDef(MCSymbol const *Symbol) override
Start emitting COFF symbol definition.
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
@ FK_Data_4
A four-byte fixup.
void setIsSafeSEH() const
Represents a location in source code.
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
@ FK_SecRel_4
A four-byte section relative fixup.
@ MCSA_AltEntry
.alt_entry (MachO)
Represents a symbol table index fragment.
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
@ FK_SecRel_2
A two-byte section relative fixup.
Streaming object file generation interface.
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void EmitCOFFSymbolStorageClass(int StorageClass) override
Emit the storage class of the symbol.
const MCSymbol & getSymbol() const
void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, SMLoc Loc=SMLoc()) override
Emit the zerofill section and an optional symbol.
MCSection * getCurrentSectionOnly() const
const Triple & getTargetTriple() const
void setType(uint16_t Ty) const
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override
Create the default sections and set the initial one.
void EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override
Emits a COFF image relative relocation.
MCCodeEmitter & getEmitter() const
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
@ MCSA_WeakReference
.weak_reference (MachO)
void EndCOFFSymbolDef() override
Marks the end of the symbol definition.
bool PopSection()
Restore the current and previous section from the section stack.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
void reportError(SMLoc L, const Twine &Msg)
Represent a reference to a symbol from inside an expression.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MCAssembler & getAssembler()
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.
unsigned getAlignment() const
PowerPC TLS Dynamic Call Fixup
StringRef - Represent a constant reference to a string, i.e.
void finishImpl() override
Streamer specific finalization.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MCSection * getDrectveSection() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
const CustomOperand< const MCSubtargetInfo & > Msg[]
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override
Emits a COFF section relative relocation.
void setAlignment(Align Value)
@ MCAF_Code64
.code64 (X86)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
void PushSection()
Save the current and previous section on the section stack.
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override
Emits a COFF section index.
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override
MCSection * getBSSSection() const
void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override
Emits the symbol table index of a Symbol into the current section.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
@ MCSA_Global
.type _foo, @gnu_unique_object
bool registerSection(MCSection &Section)
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
MCContext & getContext() const
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a thread local bss (.tbss) symbol.
Align max(MaybeAlign Lhs, Align Rhs)
A raw_ostream that writes to an SmallVector or SmallString.
const MCSymbol * CurSymbol
MCWinCOFFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCObjectWriter > OW)
void EmitWinEHHandlerData(SMLoc Loc) override
BlockVerifier::State From
void finishImpl() override
Streamer specific finalization.
void emitCodeAlignment(unsigned ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
MCSection * getSXDataSection() const
Fragment for data and encoded instructions.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Generic base class for all target subtargets.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Base class for the full range of assembler expressions which are needed for parsing.
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.
void finalizeCGProfileEntry(const MCSymbolRefExpr *&S)
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
std::vector< CGProfileEntry > CGProfile