45class AArch64ELFStreamer;
49 std::string VendorTag;
54 OS <<
"\t.variant_pcs\t" <<
Symbol->getName() <<
"\n";
58 OS <<
"\t.arch\t" <<
Name <<
"\n";
62 OS <<
"\t.arch_extension\t" <<
Name <<
"\n";
66 OS <<
"\t.seh_stackalloc\t" <<
Size <<
"\n";
69 OS <<
"\t.seh_save_r19r20_x\t" <<
Offset <<
"\n";
72 OS <<
"\t.seh_save_fplr\t" <<
Offset <<
"\n";
75 OS <<
"\t.seh_save_fplr_x\t" <<
Offset <<
"\n";
78 OS <<
"\t.seh_save_reg\tx" <<
Reg <<
", " <<
Offset <<
"\n";
81 OS <<
"\t.seh_save_reg_x\tx" <<
Reg <<
", " <<
Offset <<
"\n";
84 OS <<
"\t.seh_save_regp\tx" <<
Reg <<
", " <<
Offset <<
"\n";
87 OS <<
"\t.seh_save_regp_x\tx" <<
Reg <<
", " <<
Offset <<
"\n";
90 OS <<
"\t.seh_save_lrpair\tx" <<
Reg <<
", " <<
Offset <<
"\n";
93 OS <<
"\t.seh_save_freg\td" <<
Reg <<
", " <<
Offset <<
"\n";
96 OS <<
"\t.seh_save_freg_x\td" <<
Reg <<
", " <<
Offset <<
"\n";
99 OS <<
"\t.seh_save_fregp\td" <<
Reg <<
", " <<
Offset <<
"\n";
102 OS <<
"\t.seh_save_fregp_x\td" <<
Reg <<
", " <<
Offset <<
"\n";
106 OS <<
"\t.seh_add_fp\t" <<
Size <<
"\n";
118 OS <<
"\t.seh_clear_unwound_to_call\n";
121 OS <<
"\t.seh_pac_sign_lr\n";
125 OS <<
"\t.seh_save_any_reg\tx" <<
Reg <<
", " <<
Offset <<
"\n";
128 OS <<
"\t.seh_save_any_reg_p\tx" <<
Reg <<
", " <<
Offset <<
"\n";
131 OS <<
"\t.seh_save_any_reg\td" <<
Reg <<
", " <<
Offset <<
"\n";
134 OS <<
"\t.seh_save_any_reg_p\td" <<
Reg <<
", " <<
Offset <<
"\n";
137 OS <<
"\t.seh_save_any_reg\tq" <<
Reg <<
", " <<
Offset <<
"\n";
140 OS <<
"\t.seh_save_any_reg_p\tq" <<
Reg <<
", " <<
Offset <<
"\n";
143 OS <<
"\t.seh_save_any_reg_x\tx" <<
Reg <<
", " <<
Offset <<
"\n";
146 OS <<
"\t.seh_save_any_reg_px\tx" <<
Reg <<
", " <<
Offset <<
"\n";
149 OS <<
"\t.seh_save_any_reg_x\td" <<
Reg <<
", " <<
Offset <<
"\n";
152 OS <<
"\t.seh_save_any_reg_px\td" <<
Reg <<
", " <<
Offset <<
"\n";
155 OS <<
"\t.seh_save_any_reg_x\tq" <<
Reg <<
", " <<
Offset <<
"\n";
158 OS <<
"\t.seh_save_any_reg_px\tq" <<
Reg <<
", " <<
Offset <<
"\n";
161 OS <<
"\t.seh_allocz\t" <<
Offset <<
"\n";
164 OS <<
"\t.seh_save_zreg\tz" <<
Reg <<
", " <<
Offset <<
"\n";
167 OS <<
"\t.seh_save_preg\tp" <<
Reg <<
", " <<
Offset <<
"\n";
171 std::string
String)
override {
176 assert(0 &&
"Arguments error");
184 if (
unsigned(-1) !=
Value) {
185 OS <<
"\t.aeabi_attribute" <<
"\t" <<
Tag <<
", " <<
Value;
189 OS <<
"\t.aeabi_attribute" <<
"\t" <<
Tag <<
", " <<
String;
198 OS <<
"\t.aeabi_attribute" <<
"\t" <<
Tag <<
", " <<
Value;
206 OS <<
"\t.aeabi_attribute" <<
"\t" <<
Tag <<
", " <<
Value <<
"\t// "
216 OS <<
"\t.aeabi_attribute" <<
"\t" <<
Tag <<
", " <<
Value;
223 OS <<
"\t.aeabi_attribute" <<
"\t" <<
Tag <<
", " <<
Value <<
"\t// "
243 assert((0 == Optional || 1 == Optional) &&
245 assert((0 == ParameterType || 1 == ParameterType) &&
248 std::string SubsectionTag =
".aeabi_subsection";
252 switch (SubsectionID) {
259 "subsection .aeabi-pauthabi should be marked as "
260 "required and not as optional");
262 "subsection .aeabi-pauthabi should be "
263 "marked as uleb128 and not as ntbs");
268 "subsection .aeabi_feature_and_bits should be "
269 "marked as optional and not as required");
271 "subsection .aeabi_feature_and_bits should "
272 "be marked as uleb128 and not as ntbs");
276 OS <<
"\t" << SubsectionTag <<
"\t" << SubsectionName <<
", " << OptionalStr
277 <<
", " << ParameterStr;
289AArch64TargetAsmStreamer::AArch64TargetAsmStreamer(
MCStreamer &S,
293void AArch64TargetAsmStreamer::emitInst(
uint32_t Inst) {
313 AArch64ELFStreamer(
MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
314 std::unique_ptr<MCObjectWriter> OW,
315 std::unique_ptr<MCCodeEmitter>
Emitter)
328 auto It = LastMappingSymbols.find(Section);
329 if (It != LastMappingSymbols.end())
330 LastEMS = It->second;
331 else if (ImplicitMapSyms)
332 LastEMS =
Section->isText() ? EMS_A64 : EMS_Data;
344 void reset()
override {
346 LastMappingSymbols.clear();
355 emitA64MappingSymbol();
367 for (
char &
C : Buffer) {
372 emitA64MappingSymbol();
380 emitDataMappingSymbol();
388 emitDataMappingSymbol();
393 SMLoc Loc)
override {
394 emitDataMappingSymbol();
399 enum ElfMappingSymbol {
405 void emitDataMappingSymbol() {
406 if (LastEMS == EMS_Data)
408 emitMappingSymbol(
"$d");
412 void emitA64MappingSymbol() {
413 if (LastEMS == EMS_A64)
415 emitMappingSymbol(
"$x");
427 ElfMappingSymbol LastEMS;
428 bool ImplicitMapSyms;
432AArch64ELFStreamer &AArch64TargetELFStreamer::getStreamer() {
433 return static_cast<AArch64ELFStreamer &
>(
Streamer);
436void AArch64TargetELFStreamer::emitAttributesSubsection(
443void AArch64TargetELFStreamer::emitAttribute(
StringRef VendorName,
unsigned Tag,
446 if (
unsigned(-1) !=
Value)
452void AArch64TargetELFStreamer::emitInst(
uint32_t Inst) {
453 getStreamer().emitInst(Inst);
456void AArch64TargetELFStreamer::emitDirectiveVariantPCS(
MCSymbol *Symbol) {
457 getStreamer().getAssembler().registerSymbol(*Symbol);
461void AArch64TargetELFStreamer::finish() {
463 AArch64ELFStreamer &S = getStreamer();
465 auto &
Asm = S.getAssembler();
467 S.emitAttributesSection(AttributeSection,
".ARM.attributes",
477 if (S.ImplicitMapSyms) {
478 auto &Syms =
Asm.getSymbols();
479 const size_t NumSyms = Syms.size();
482 S.switchSection(&Sec);
483 if (S.LastEMS == (Sec.isText() ? AArch64ELFStreamer::EMS_Data
484 : AArch64ELFStreamer::EMS_A64))
486 {&Sec, {NumSyms, S.emitMappingSymbol(Sec.isText() ?
"$x" :
"$d")}});
488 if (Syms.size() != NumSyms) {
493 if (!
Sym->isInSection())
495 auto It = EndMapSym.
find(&
Sym->getSection());
496 if (It != EndMapSym.
end())
497 It->second.first =
I;
502 if (!
Sym->isInSection())
504 auto It = EndMapSym.
find(&
Sym->getSection());
507 if (It != EndMapSym.
end() &&
I == It->second.first) {
512 Syms = std::move(NewSyms);
515 for (
auto &
F : S.getWriter().getFileNames())
532 for (
auto &
F : *Text) {
545 if (
Sym.isMemtag()) {
556 S.switchSection(MemtagSec);
563 S.emitRelocDirective(*Zero,
"BFD_RELOC_NONE", SRE);
570 return new AArch64TargetAsmStreamer(S,
OS);
575 std::unique_ptr<MCAsmBackend> &&TAB,
576 std::unique_ptr<MCObjectWriter> &&OW,
577 std::unique_ptr<MCCodeEmitter> &&
Emitter) {
578 return new AArch64ELFStreamer(
Context, std::move(TAB), std::move(OW),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
dxil DXContainer Global Emitter
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
static uint32_t getFlags(const Symbol *Sym)
virtual void emitARM64WinCFISaveAnyRegIX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveRegP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegQX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegDPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegDX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveRegPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegQ(unsigned Reg, int Offset)
virtual void emitDirectiveArch(StringRef Name)
virtual void emitARM64WinCFISaveAnyRegQP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegD(unsigned Reg, int Offset)
virtual void emitAttributesSubsection(StringRef VendorName, AArch64BuildAttributes::SubsectionOptional IsOptional, AArch64BuildAttributes::SubsectionType ParameterType)
Build attributes implementation.
virtual void emitARM64WinCFISavePReg(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveFReg(unsigned Reg, int Offset)
virtual void emitDirectiveArchExtension(StringRef Name)
virtual void emitARM64WinCFIPACSignLR()
virtual void emitARM64WinCFISaveAnyRegI(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveFRegPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveRegX(unsigned Reg, int Offset)
virtual void emitARM64WinCFIAllocStack(unsigned Size)
virtual void emitARM64WinCFISaveFPLRX(int Offset)
virtual void emitARM64WinCFIAllocZ(int Offset)
virtual void emitARM64WinCFISaveNext()
virtual void emitDirectiveVariantPCS(MCSymbol *Symbol)
Callback used to implement the .variant_pcs directive.
virtual void emitARM64WinCFISaveR19R20X(int Offset)
virtual void emitARM64WinCFIAddFP(unsigned Size)
virtual void emitARM64WinCFISaveFPLR(int Offset)
virtual void emitARM64WinCFIClearUnwoundToCall()
virtual void emitARM64WinCFISaveFRegP(unsigned Reg, int Offset)
virtual void emitARM64WinCFIECContext()
virtual void emitARM64WinCFISaveAnyRegQPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveFRegX(unsigned Reg, int Offset)
SmallVector< MCELFStreamer::AttributeSubSection, 64 > AttributeSubSections
virtual void emitARM64WinCFISetFP()
virtual void emitARM64WinCFISaveAnyRegDP(unsigned Reg, int Offset)
virtual void emitARM64WinCFISaveAnyRegIPX(unsigned Reg, int Offset)
virtual void emitARM64WinCFIEpilogEnd()
virtual void emitARM64WinCFIMachineFrame()
virtual void emitARM64WinCFISaveZReg(unsigned Reg, int Offset)
virtual void emitARM64WinCFIPrologEnd()
virtual void emitARM64WinCFITrapFrame()
virtual void emitARM64WinCFIContext()
virtual void emitARM64WinCFISaveReg(unsigned Reg, int Offset)
virtual void emitARM64WinCFINop()
virtual void emitARM64WinCFISaveLRPair(unsigned Reg, int Offset)
virtual void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value, std::string String)
virtual void emitInst(uint32_t Inst)
Callback used to implement the .inst directive.
virtual void emitARM64WinCFIEpilogStart()
virtual void emitARM64WinCFISaveAnyRegIP(unsigned Reg, int Offset)
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Context object for machine code objects.
const MCObjectFileInfo * getObjectFileInfo() const
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
LLVM_ABI MCSymbol * createLocalSymbol(StringRef Name)
Create a local, non-temporary symbol like an ELF mapping symbol.
const MCTargetOptions * getTargetOptions() const
void changeSection(MCSection *Section, uint32_t Subsection=0) override
This is called by popSection and switchSection, if the current section changes.
void reset() override
state management
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
Base class for the full range of assembler expressions which are needed for parsing.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Instances of this class represent a single low-level machine instruction.
MCSection * getTextSection() const
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
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.
This represents a section on linux, lots of unix variants and some bare metal systems.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Streaming machine code generation interface.
MCContext & getContext() const
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Generic base class for all target subtargets.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Target specific streamer interface.
Represents a location in source code.
void truncate(size_type N)
Like resize, but requires that N is less than size().
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
static Twine utohexstr(const uint64_t &Val)
LLVM Value Representation.
StringRef getPauthABITagsStr(unsigned PauthABITag)
StringRef getOptionalStr(unsigned Optional)
VendorID
AArch64 build attributes vendors IDs (a.k.a subsection name)
StringRef getSubsectionTypeUnknownError()
StringRef getSubsectionOptionalUnknownError()
VendorID getVendorID(StringRef const Vendor)
StringRef getTypeStr(unsigned Type)
StringRef getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag)
@ C
The default llvm calling convention, compatible with C.
@ STO_AARCH64_VARIANT_PCS
@ SHT_AARCH64_MEMTAG_GLOBALS_STATIC
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
MCStreamer * createAArch64ELFStreamer(const Triple &, MCContext &Context, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter)
MCTargetStreamer * createAArch64AsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
This struct is a compact representation of a valid (non-zero power of two) alignment.