43 #define DEBUG_TYPE "WinCOFFStreamer" 46 std::unique_ptr<MCAsmBackend> MAB,
47 std::unique_ptr<MCCodeEmitter> CE,
48 std::unique_ptr<MCObjectWriter> OW)
62 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i) {
87 auto *
Symbol = cast<MCSymbolCOFF>(S);
101 auto *
Symbol = cast<MCSymbolCOFF>(S);
105 default:
return false;
108 Symbol->setIsWeakExternal();
109 Symbol->setExternal(
true);
112 Symbol->setExternal(
true);
126 auto *
Symbol = cast<MCSymbolCOFF>(S);
128 Error(
"starting a new symbol definition without completing the " 135 Error(
"storage class specified outside of symbol definition");
140 Error(
"storage class value '" +
Twine(StorageClass) +
151 Error(
"symbol type specified outside of a symbol definition");
155 if (Type & ~0xffff) {
156 Error(
"type value '" +
Twine(Type) +
"' out of range");
161 cast<MCSymbolCOFF>(
CurSymbol)->setType((uint16_t)Type);
166 Error(
"ending symbol definition without starting one");
173 if (
getContext().getObjectFileInfo()->getTargetTriple().getArch() !=
256 auto *
Symbol = cast<MCSymbolCOFF>(S);
259 if (T.isKnownWindowsMSVCEnvironment()) {
260 if (ByteAlignment > 32)
264 Size =
std::max(Size, static_cast<uint64_t>(ByteAlignment));
268 Symbol->setExternal(
true);
269 Symbol->setCommon(Size, ByteAlignment);
271 if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
276 OS <<
" -aligncomm:\"" <<
Symbol->getName() <<
"\"," 288 auto *
Symbol = cast<MCSymbolCOFF>(S);
295 Symbol->setExternal(
false);
324 void MCWinCOFFStreamer::Error(
const Twine &Msg)
const {
Instances of this class represent a uniqued identifier for a section in the current translation unit...
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void FinishImpl() override
Streamer specific finalization.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
MCWinCOFFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCObjectWriter > OW)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void setAlignment(unsigned Value)
const MCSymbol * CurSymbol
void InitSections(bool NoExecStack) override
Create the default sections and set the initial one.
A raw_ostream that writes to an SmallVector or SmallString.
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
void PushSection()
Save the current and previous section on the section stack.
void EmitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
COFF::SymbolStorageClass StorageClass
void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override
Emits a COFF section relative relocation.
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
unsigned getAlignment() const
MCContext & getContext() const
void EmitCOFFSymbolType(int Type) override
Emit the type of the symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override
MCCodeEmitter & getEmitter() const
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.
Base class for the full range of assembler expressions which are needed for parsing.
bool registerSection(MCSection &Section)
Represent a reference to a symbol from inside an expression.
MCSection * getBSSSection() const
A four-byte section relative fixup.
void EmitWinEHHandlerData(SMLoc Loc) override
void BeginCOFFSymbolDef(MCSymbol const *Symbol) override
Start emitting COFF symbol definition.
Context object for machine code objects.
MCSection * getSXDataSection() const
A two-byte section relative fixup.
Streaming object file generation interface.
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
SmallVectorImpl< char > & getContents()
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
Instances of this class represent a single low-level machine instruction.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
void EndCOFFSymbolDef() override
Marks the end of the symbol definition.
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
void visitUsedSymbol(const MCSymbol &Sym) override
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
The instances of the Type class are immutable: once they are created, they are never changed...
void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
virtual void SwitchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
MCAssembler & getAssembler()
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
SmallVectorImpl< MCFixup > & getFixups()
void EmitCOFFSymbolStorageClass(int StorageClass) override
Emit the storage class of the symbol.
void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, SMLoc Loc=SMLoc()) override
Emit the zerofill section and an optional symbol.
const MCObjectFileInfo * getObjectFileInfo() const
void reportError(SMLoc L, const Twine &Msg)
void EmitCOFFImgRel32(MCSymbol const *Symbol, int64_t Offset) override
Emits a COFF image relative relocation.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override
Emits a COFF section index.
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Triple - Helper class for working with autoconf configuration names.
MCSection * getDrectveSection() const
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.
PowerPC TLS Dynamic Call Fixup
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override
void setIsSafeSEH() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void setType(uint16_t Ty) const
Represents a symbol table index fragment.
const Triple & getTargetTriple() const
MCSection * getCurrentSectionOnly() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
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...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override
Emits the symbol table index of a Symbol into the current section.
void FinishImpl() override
Streamer specific finalization.
Generic base class for all target subtargets.
void EmitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a thread local bss (.tbss) symbol.
Fragment for data and encoded instructions.
bool PopSection()
Restore the current and previous section from the section stack.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
void EmitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
A function that returns a base type.