42 bool MCELFStreamer::isBundleLocked()
const {
59 if (RequiredBundlePadding > UINT8_MAX)
62 if (RequiredBundlePadding > 0) {
78 for (
unsigned i = 0, e = EF->
getFixups().size(); i != e; ++i) {
97 auto *
Symbol = cast<MCSymbolELF>(S);
107 auto *
Symbol = cast<MCSymbolELF>(S);
143 const MCExpr *Subsection) {
145 if (CurSection && isBundleLocked())
152 const MCSymbol *Grp = SectionELF->getGroup();
187 auto *
Symbol = cast<MCSymbolELF>(S);
229 Symbol->setExternal(
true);
234 Symbol->setExternal(
true);
240 Symbol->setExternal(
true);
245 Symbol->setExternal(
false);
294 auto *
Symbol = cast<MCSymbolELF>(S);
297 if (!
Symbol->isBindingSet()) {
299 Symbol->setExternal(
true);
320 if(
Symbol->declareCommon(Size, ByteAlignment))
322 " redeclared as different type");
330 cast<MCSymbolELF>(
Symbol)->setSize(Value);
335 auto *
Symbol = cast<MCSymbolELF>(S);
339 Symbol->setExternal(
false);
345 if (isBundleLocked())
347 fixSymbolsInTLSFixups(Value);
354 unsigned MaxBytesToEmit) {
355 if (isBundleLocked())
358 ValueSize, MaxBytesToEmit);
375 void MCELFStreamer::fixSymbolsInTLSFixups(
const MCExpr *expr) {
378 cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(
getAssembler());
385 fixSymbolsInTLSFixups(be->
getLHS());
386 fixSymbolsInTLSFixups(be->
getRHS());
448 fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr());
453 void MCELFStreamer::EmitInstToFragment(
const MCInst &Inst,
458 for (
unsigned i = 0, e = F.
getFixups().size(); i != e; ++i)
459 fixSymbolsInTLSFixups(F.
getFixups()[i].getValue());
462 void MCELFStreamer::EmitInstToData(
const MCInst &Inst,
470 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i)
471 fixSymbolsInTLSFixups(Fixups[i].getValue());
495 DF = BundleGroups.back();
496 else if (Assembler.
getRelaxAll() && !isBundleLocked())
505 else if (!isBundleLocked() && Fixups.
size() == 0) {
533 for (
unsigned i = 0, e = Fixups.
size(); i != e; ++i) {
541 if (!isBundleLocked()) {
549 assert(AlignPow2 <= 30 &&
"Invalid bundle alignment");
566 if (!isBundleLocked())
569 if (
getAssembler().getRelaxAll() && !isBundleLocked()) {
572 BundleGroups.push_back(DF);
585 else if (!isBundleLocked())
594 assert(!BundleGroups.empty() &&
"There are no bundle groups");
601 if (!isBundleLocked()) {
603 BundleGroups.pop_back();
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
virtual MCObjectWriter * createObjectWriter(raw_pwrite_stream &OS) const =0
Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file...
void EmitBundleAlignMode(unsigned AlignPow2) override
Set the bundle alignment mode from now on in the section.
const MCAsmInfo * getAsmInfo() const
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
const MCSymbol & getSymbol() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
bool hasInstructions() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
.type _foo, STT_OBJECT # aka
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void EmitBundleUnlock() override
Ends a bundle-locked group.
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override
Emit an ELF .size directive.
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 EmitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, unsigned ByteAlignment=0) override
Emit the zerofill section and an optional symbol.
unsigned getBundleAlignSize() const
void setAlignment(unsigned Value)
void writeFragmentPadding(const MCFragment &F, uint64_t FSize, MCObjectWriter *OW) const
Write the necessary bundle padding to the given object writer.
unsigned getFlags() const
void setBundleLockState(BundleLockStateType NewState)
MCCodeEmitter & getEmitter() const
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.
This is a compact (memory-size-wise) fragment for holding an encoded instruction (non-relaxable) that...
void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
std::vector< IndirectSymbolData > & getIndirectSymbols()
.type _foo, STT_NOTYPE # aka
unsigned getAlignment() const
MCContext & getContext() const
static unsigned CombineSymbolTypes(unsigned T1, unsigned T2)
Defines the object file and target independent interfaces used by the assembler backend to write nati...
void EmitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
void InitSections(bool NoExecStack) override
Create the default sections and set the initial one.
MCFragment * getCurrentFragment() const
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.
void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0) override
Emit a thread local bss (.tbss) symbol.
void setRelaxAll(bool Value)
MCSection * getCurrentSectionOnly() const
Base class for the full range of assembler expressions which are needed for parsing.
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Represent a reference to a symbol from inside an expression.
void setAlignToBundleEnd(bool V)
MCContext & getContext() const
void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
void setSubsectionsViaSymbols(bool Value)
Context object for machine code objects.
void EmitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
void setHasInstructions(bool V)
.code16 (X86) / .code 16 (ARM)
.type _foo, STT_GNU_IFUNC
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 setBundleAlignSize(unsigned Size)
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
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.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Streaming machine code generation interface.
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
.weak_def_can_be_hidden (MachO)
The instances of the Type class are immutable: once they are created, they are never changed...
void insert(MCFragment *F)
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()
static void setSectionAlignmentForBundling(const MCAssembler &Assembler, MCSection *Section)
MCAssembler & getAssembler()
MCCodeEmitter - Generic instruction encoding interface.
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
SmallVectorImpl< MCFixup > & getFixups()
.subsections_via_symbols (MachO)
MCSection * getTextSection() const
void EmitFrames(MCAsmBackend *MAB)
Binary assembler expressions.
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.
uint64_t computeBundlePadding(const MCAssembler &Assembler, const MCFragment *F, uint64_t FOffset, uint64_t FSize)
Compute the amount of padding required before the fragment F to obey bundling restrictions, where FOffset is the fragment's offset in its section and FSize is the fragment's size.
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isBundlingEnabled() const
.type _foo, STT_TLS # aka
MCSymbol * getBeginSymbol()
MCStreamer * createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll)
Takes ownership of TAB and CE.
void setVariableValue(const MCExpr *Value)
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 append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
.code32 (X86) / .code 32 (ARM)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
.type _foo, STT_COMMON # aka
void setBundlePadding(uint8_t N)
Set the padding size for this fragment.
virtual void handleAssemblerFlag(MCAssemblerFlag Flag)
Handle any target-specific assembler flags. By default, do nothing.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void FinishImpl() override
Streamer specific finalization.
.type _foo, STT_FUNC # aka
MCAsmBackend & getBackend() const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool isBundleGroupBeforeFirstInst() const
MCSubtargetInfo - Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
References to labels and assigned expressions.
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.
BundleLockStateType getBundleLockState() const
void setBundleGroupBeforeFirstInst(bool IsFirst)
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
An abstract base class for streams implementations that also support a pwrite operation.
Fragment for data and encoded instructions.
virtual MCSection * getNonexecutableStackSection(MCContext &Ctx) const
Targets can implement this method to specify a section to switch to if the translation unit doesn't h...
VariantKind getKind() const
void EmitBundleLock(bool AlignToEnd) override
The following instructions are a bundle-locked group.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
bool PopSection()
Restore the current and previous section from the section stack.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM Value Representation.
Generic interface to target specific assembler backends.
const MCObjectFileInfo * getObjectFileInfo() const
bool isBundleLocked() const
void EmitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
StringRef - Represent a constant reference to a string, i.e.
Target specific expression.
Represents a location in source code.
void FinishImpl() override
Streamer specific finalization.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
MCDataFragment * getOrCreateDataFragment()
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment...