52 bool DWARFMustBeAtTheEnd;
53 bool CreatedADWARFSection;
63 void EmitDataRegionEnd();
67 std::unique_ptr<MCObjectWriter> OW,
68 std::unique_ptr<MCCodeEmitter> Emitter,
69 bool DWARFMustBeAtTheEnd,
bool label)
72 LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
73 CreatedADWARFSection(
false) {}
76 void reset()
override {
77 CreatedADWARFSection =
false;
78 HasSectionLabel.
clear();
88 void EmitEHSymAttributes(
const MCSymbol *Symbol,
MCSymbol *EHSymbol)
override;
93 unsigned Minor,
unsigned Update)
override;
94 void EmitBuildVersion(
unsigned Platform,
unsigned Major,
95 unsigned Minor,
unsigned Update)
override;
96 void EmitThumbFunc(
MCSymbol *Func)
override;
98 void EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue)
override;
102 void EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
110 void EmitIdent(
StringRef IdentString)
override {
115 getAssembler().getLOHContainer().addDirective(Kind, Args);
118 void FinishImpl()
override;
129 if (SegName ==
"__LD" && SecName ==
"__compact_unwind")
132 if (SegName ==
"__IMPORT") {
133 if (SecName ==
"__jump_table")
136 if (SecName ==
"__pointers")
140 if (SegName ==
"__TEXT" && SecName ==
"__eh_frame")
143 if (SegName ==
"__DATA" && (SecName ==
"__nl_symbol_ptr" ||
144 SecName ==
"__thread_ptr"))
150 void MCMachOStreamer::ChangeSection(
MCSection *Section,
151 const MCExpr *Subsection) {
153 bool Created = changeSectionImpl(Section, Subsection);
156 if (SegName ==
"__DWARF")
157 CreatedADWARFSection =
true;
159 assert(!CreatedADWARFSection &&
"Creating regular section after DWARF");
163 if (LabelSections && !HasSectionLabel[Section] &&
165 MCSymbol *Label = getContext().createLinkerPrivateTempSymbol();
167 HasSectionLabel[
Section] =
true;
171 void MCMachOStreamer::EmitEHSymAttributes(
const MCSymbol *Symbol,
173 getAssembler().registerSymbol(*Symbol);
176 if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
182 void MCMachOStreamer::EmitLabel(
MCSymbol *Symbol,
SMLoc Loc) {
185 if (getAssembler().isSymbolLinkerVisible(*Symbol))
197 cast<MCSymbolMachO>(
Symbol)->clearReferenceType();
205 const MCSymbol &SymA = SymAExpr->getSymbol();
207 cast<MCSymbolMachO>(
Symbol)->setAltEntry();
215 MCSymbol *Start = getContext().createTempSymbol();
219 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
220 Regions.push_back(Data);
223 void MCMachOStreamer::EmitDataRegionEnd() {
224 std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
225 assert(!Regions.empty() &&
"Mismatched .end_data_region!");
227 assert(!Data.End &&
"Mismatched .end_data_region!");
229 Data.End = getContext().createTempSymbol();
235 getAssembler().getBackend().handleAssemblerFlag(Flag);
243 getAssembler().setSubsectionsViaSymbols(
true);
249 getAssembler().getLinkerOptions().push_back(Options);
273 unsigned Minor,
unsigned Update) {
274 getAssembler().setVersionMin(Kind, Major, Minor, Update);
277 void MCMachOStreamer::EmitBuildVersion(
unsigned Platform,
unsigned Major,
278 unsigned Minor,
unsigned Update) {
283 void MCMachOStreamer::EmitThumbFunc(
MCSymbol *Symbol) {
286 getAssembler().setIsThumbFunc(Symbol);
287 cast<MCSymbolMachO>(
Symbol)->setThumbFunc();
290 bool MCMachOStreamer::EmitSymbolAttribute(
MCSymbol *Sym,
301 ISD.
Section = getCurrentSectionOnly();
302 getAssembler().getIndirectSymbols().push_back(ISD);
309 getAssembler().registerSymbol(*Symbol);
393 void MCMachOStreamer::EmitSymbolDesc(
MCSymbol *Symbol,
unsigned DescValue) {
395 getAssembler().registerSymbol(*Symbol);
396 cast<MCSymbolMachO>(
Symbol)->setDesc(DescValue);
399 void MCMachOStreamer::EmitCommonSymbol(
MCSymbol *Symbol, uint64_t
Size,
404 getAssembler().registerSymbol(*Symbol);
409 void MCMachOStreamer::EmitLocalCommonSymbol(
MCSymbol *Symbol, uint64_t Size,
410 unsigned ByteAlignment) {
412 return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
413 Symbol, Size, ByteAlignment);
417 uint64_t Size,
unsigned ByteAlignment,
423 getContext().reportError(
424 Loc,
"The usage of .zerofill is restricted to sections of " 425 "ZEROFILL type. Use .zero or .space instead.");
431 SwitchSection(Section);
435 EmitValueToAlignment(ByteAlignment, 0, 1, 0);
445 uint64_t Size,
unsigned ByteAlignment) {
446 EmitZerofill(Section, Symbol, Size, ByteAlignment);
449 void MCMachOStreamer::EmitInstToData(
const MCInst &Inst,
456 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
467 void MCMachOStreamer::FinishImpl() {
468 EmitFrames(&getAssembler().getBackend());
476 for (
const MCSymbol &Symbol : getAssembler().symbols()) {
477 if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.
isInSection() &&
481 "Invalid offset in atom defining symbol!");
489 const MCSymbol *CurrentAtom =
nullptr;
492 CurrentAtom = Symbol;
493 Frag.setAtom(CurrentAtom);
501 std::unique_ptr<MCAsmBackend> &&MAB,
502 std::unique_ptr<MCObjectWriter> &&OW,
503 std::unique_ptr<MCCodeEmitter> &&CE,
504 bool RelaxAll,
bool DWARFMustBeAtTheEnd,
505 bool LabelSections) {
507 new MCMachOStreamer(Context, std::move(MAB), std::move(OW), std::move(CE),
508 DWARFMustBeAtTheEnd, LabelSections);
510 S->EmitVersionForTarget(Target);
512 S->getAssembler().setRelaxAll(
true);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void setPrivateExtern(bool Value)
void setReferenceTypeUndefinedLazy(bool Value) const
This represents a section on a Mach-O system (used by Mac OS X).
Compute iterated dominance frontiers using a linear time algorithm.
bool isVariable() const
isVariable - Check if this is a variable symbol.
.type _foo, STT_OBJECT # aka
This represents an "assembler immediate".
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A raw_ostream that writes to an SmallVector or SmallString.
.type _foo, STT_NOTYPE # aka
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
int64_t getConstant() const
const MCSymbolRefExpr * getSymB() const
void setExternal(bool Value) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Represent a reference to a symbol from inside an expression.
void setCommon(uint64_t Size, unsigned Align)
Mark this symbol as being 'common'.
StringRef getSectionName() const
Context object for machine code objects.
void setSymbolResolver() const
.code16 (X86) / .code 16 (ARM)
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Streaming object file generation interface.
.type _foo, STT_GNU_IFUNC
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
SmallVectorImpl< char > & getContents()
StringRef getSegmentName() const
Instances of this class represent a single low-level machine instruction.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Streaming machine code generation interface.
void setWeakDefinition() const
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
.weak_def_can_be_hidden (MachO)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
SmallVectorImpl< MCFixup > & getFixups()
MCLOHType
Linker Optimization Hint Type.
const MCSymbolRefExpr * getSymA() const
const MCObjectFileInfo * getObjectFileInfo() const
.subsections_via_symbols (MachO)
uint64_t getOffset() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
static bool canGoAfterDWARF(const MCSectionMachO &MSec)
PowerPC TLS Dynamic Call Fixup
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
MCFragment * getFragment(bool SetUsed=true) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
.type _foo, STT_TLS # aka
MCSymbol * getBeginSymbol()
const Triple & getTargetTriple() const
Target - Wrapper for Target specific information.
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)
.type _foo, STT_COMMON # aka
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void FinishImpl() override
Streamer specific finalization.
.type _foo, STT_FUNC # aka
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void reset() override
state management
Generic base class for all target subtargets.
void setNoDeadStrip() const
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
StringRef getName() const
getName - Get the symbol name.
Fragment for data and encoded instructions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
StringRef - Represent a constant reference to a string, i.e.
MCStreamer * createMachOStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
Represents a location in source code.
void setWeakReference() const
bool isPrivateExtern() const
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void setBeginSymbol(MCSymbol *Sym)