64 "Invalid personality index");
65 return (
Twine(
"__aeabi_unwind_cpp_pr") +
Twine(Index)).str();
77 void emitFnStart()
override;
78 void emitFnEnd()
override;
79 void emitCantUnwind()
override;
80 void emitPersonality(
const MCSymbol *Personality)
override;
81 void emitPersonalityIndex(
unsigned Index)
override;
82 void emitHandlerData()
override;
83 void emitSetFP(
unsigned FpReg,
unsigned SpReg, int64_t
Offset = 0)
override;
84 void emitMovSP(
unsigned Reg, int64_t
Offset = 0)
override;
85 void emitPad(int64_t
Offset)
override;
88 void emitUnwindRaw(int64_t Offset,
91 void switchVendor(
StringRef Vendor)
override;
94 void emitIntTextAttribute(
unsigned Attribute,
unsigned IntValue,
97 void emitArchExtension(
unsigned ArchExt)
override;
99 void emitFPU(
unsigned FPU)
override;
100 void emitInst(
uint32_t Inst,
char Suffix =
'\0')
override;
101 void finishAttributeSection()
override;
103 void AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *SRE)
override;
111 ARMTargetAsmStreamer::ARMTargetAsmStreamer(
MCStreamer &S,
116 IsVerboseAsm(VerboseAsm) {}
118 void ARMTargetAsmStreamer::emitFnStart() { OS <<
"\t.fnstart\n"; }
119 void ARMTargetAsmStreamer::emitFnEnd() { OS <<
"\t.fnend\n"; }
120 void ARMTargetAsmStreamer::emitCantUnwind() { OS <<
"\t.cantunwind\n"; }
122 void ARMTargetAsmStreamer::emitPersonality(
const MCSymbol *Personality) {
123 OS <<
"\t.personality " << Personality->
getName() <<
'\n';
126 void ARMTargetAsmStreamer::emitPersonalityIndex(
unsigned Index) {
127 OS <<
"\t.personalityindex " << Index <<
'\n';
130 void ARMTargetAsmStreamer::emitHandlerData() { OS <<
"\t.handlerdata\n"; }
132 void ARMTargetAsmStreamer::emitSetFP(
unsigned FpReg,
unsigned SpReg,
143 void ARMTargetAsmStreamer::emitMovSP(
unsigned Reg, int64_t Offset) {
144 assert((Reg != ARM::SP && Reg != ARM::PC) &&
145 "the operand of .movsp cannot be either sp or pc");
154 void ARMTargetAsmStreamer::emitPad(int64_t Offset) {
155 OS <<
"\t.pad\t#" << Offset <<
'\n';
160 assert(RegList.
size() &&
"RegList should not be empty");
168 for (
unsigned i = 1, e = RegList.
size(); i != e; ++i) {
176 void ARMTargetAsmStreamer::switchVendor(
StringRef Vendor) {}
178 void ARMTargetAsmStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
179 OS <<
"\t.eabi_attribute\t" << Attribute <<
", " <<
Twine(Value);
183 OS <<
"\t@ " << Name;
188 void ARMTargetAsmStreamer::emitTextAttribute(
unsigned Attribute,
192 OS <<
"\t.cpu\t" << String.
lower();
195 OS <<
"\t.eabi_attribute\t" << Attribute <<
", \"" << String <<
"\"";
199 OS <<
"\t@ " << Name;
206 void ARMTargetAsmStreamer::emitIntTextAttribute(
unsigned Attribute,
212 OS <<
"\t.eabi_attribute\t" << Attribute <<
", " << IntValue;
213 if (!StringValue.
empty())
214 OS <<
", \"" << StringValue <<
"\"";
226 void ARMTargetAsmStreamer::emitArchExtension(
unsigned ArchExt) {
230 void ARMTargetAsmStreamer::emitObjectArch(
ARM::ArchKind Arch) {
234 void ARMTargetAsmStreamer::emitFPU(
unsigned FPU) {
238 void ARMTargetAsmStreamer::finishAttributeSection() {}
241 ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *S) {
246 const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
248 OS <<
"\t.thumb_set\t";
249 Symbol->
print(OS, MAI);
251 Value->
print(OS, MAI);
255 void ARMTargetAsmStreamer::emitInst(
uint32_t Inst,
char Suffix) {
262 void ARMTargetAsmStreamer::emitUnwindRaw(int64_t Offset,
264 OS <<
"\t.unwind_raw " <<
Offset;
277 struct AttributeItem {
282 NumericAndTextAttributes
286 std::string StringValue;
288 static bool LessTag(
const AttributeItem &LHS,
const AttributeItem &RHS) {
306 unsigned FPU = ARM::FK_INVALID;
313 AttributeItem *getAttributeItem(
unsigned Attribute) {
314 for (
size_t i = 0; i < Contents.
size(); ++i)
315 if (Contents[i].
Tag == Attribute)
320 void setAttributeItem(
unsigned Attribute,
unsigned Value,
321 bool OverwriteExisting) {
323 if (AttributeItem *Item = getAttributeItem(Attribute)) {
324 if (!OverwriteExisting)
326 Item->Type = AttributeItem::NumericAttribute;
327 Item->IntValue = Value;
332 AttributeItem Item = {
333 AttributeItem::NumericAttribute,
341 void setAttributeItem(
unsigned Attribute,
StringRef Value,
342 bool OverwriteExisting) {
344 if (AttributeItem *Item = getAttributeItem(Attribute)) {
345 if (!OverwriteExisting)
347 Item->Type = AttributeItem::TextAttribute;
348 Item->StringValue = Value;
353 AttributeItem Item = {
354 AttributeItem::TextAttribute,
362 void setAttributeItems(
unsigned Attribute,
unsigned IntValue,
363 StringRef StringValue,
bool OverwriteExisting) {
365 if (AttributeItem *Item = getAttributeItem(Attribute)) {
366 if (!OverwriteExisting)
368 Item->Type = AttributeItem::NumericAndTextAttributes;
369 Item->IntValue = IntValue;
370 Item->StringValue = StringValue;
375 AttributeItem Item = {
376 AttributeItem::NumericAndTextAttributes,
384 void emitArchDefaultAttributes();
385 void emitFPUDefaultAttributes();
387 ARMELFStreamer &getStreamer();
389 void emitFnStart()
override;
390 void emitFnEnd()
override;
391 void emitCantUnwind()
override;
392 void emitPersonality(
const MCSymbol *Personality)
override;
393 void emitPersonalityIndex(
unsigned Index)
override;
394 void emitHandlerData()
override;
395 void emitSetFP(
unsigned FpReg,
unsigned SpReg, int64_t Offset = 0)
override;
396 void emitMovSP(
unsigned Reg, int64_t Offset = 0)
override;
397 void emitPad(int64_t Offset)
override;
399 bool isVector)
override;
400 void emitUnwindRaw(int64_t Offset,
403 void switchVendor(
StringRef Vendor)
override;
404 void emitAttribute(
unsigned Attribute,
unsigned Value)
override;
405 void emitTextAttribute(
unsigned Attribute,
StringRef String)
override;
406 void emitIntTextAttribute(
unsigned Attribute,
unsigned IntValue,
410 void emitFPU(
unsigned FPU)
override;
411 void emitInst(
uint32_t Inst,
char Suffix =
'\0')
override;
412 void finishAttributeSection()
override;
413 void emitLabel(
MCSymbol *Symbol)
override;
415 void AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *SRE)
override;
416 void emitThumbSet(
MCSymbol *Symbol,
const MCExpr *Value)
override;
418 size_t calculateContentSize()
const;
421 void reset()
override;
442 friend class ARMTargetELFStreamer;
445 std::unique_ptr<MCObjectWriter> OW, std::unique_ptr<MCCodeEmitter> Emitter,
447 :
MCELFStreamer(Context, std::move(TAB), std::move(OW), std::move(Emitter)),
452 ~ARMELFStreamer()
override =
default;
454 void FinishImpl()
override;
459 void emitCantUnwind();
460 void emitPersonality(
const MCSymbol *Per);
461 void emitPersonalityIndex(
unsigned index);
462 void emitHandlerData();
463 void emitSetFP(
unsigned NewFpReg,
unsigned NewSpReg, int64_t Offset = 0);
464 void emitMovSP(
unsigned Reg, int64_t Offset = 0);
465 void emitPad(int64_t Offset);
470 LastMappingSymbols[getCurrentSection().first] = std::move(LastEMSInfo);
472 auto LastMappingSymbol = LastMappingSymbols.find(Section);
473 if (LastMappingSymbol != LastMappingSymbols.end()) {
474 LastEMSInfo = std::move(LastMappingSymbol->second);
477 LastEMSInfo.reset(
new ElfMappingSymbolInfo(
SMLoc(),
nullptr, 0));
486 EmitThumbMappingSymbol();
488 EmitARMMappingSymbol();
493 void emitInst(
uint32_t Inst,
char Suffix) {
496 const bool LittleEndian = getContext().getAsmInfo()->isLittleEndian();
503 EmitARMMappingSymbol();
504 for (
unsigned II = 0,
IE = Size; II !=
IE; II++) {
505 const unsigned I = LittleEndian ? (Size - II - 1) : II;
506 Buffer[Size - II - 1] = uint8_t(Inst >> I * CHAR_BIT);
512 Size = (Suffix ==
'n' ? 2 : 4);
515 EmitThumbMappingSymbol();
518 for (
unsigned II = 0,
IE = Size; II !=
IE; II = II + 2) {
519 const unsigned I0 = LittleEndian ? II + 0 : II + 1;
520 const unsigned I1 = LittleEndian ? II + 1 : II + 0;
521 Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
522 Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT);
537 EmitDataMappingSymbol();
541 void FlushPendingMappingSymbol() {
542 if (!LastEMSInfo->hasInfo())
544 ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
545 EmitMappingSymbol(
"$d", EMS->Loc, EMS->F, EMS->Offset);
552 void EmitValueImpl(
const MCExpr *Value,
unsigned Size,
SMLoc Loc)
override {
553 if (
const MCSymbolRefExpr *SRE = dyn_cast_or_null<MCSymbolRefExpr>(Value)) {
555 getContext().reportError(Loc,
"relocated expression must be 32-bit");
558 getOrCreateDataFragment();
561 EmitDataMappingSymbol();
585 enum ElfMappingSymbol {
592 struct ElfMappingSymbolInfo {
594 : Loc(Loc),
F(F),
Offset(O), State(EMS_None) {}
599 bool hasInfo() {
return F !=
nullptr; }
603 ElfMappingSymbol State;
606 void EmitDataMappingSymbol() {
607 if (LastEMSInfo->State == EMS_Data)
609 else if (LastEMSInfo->State == EMS_None) {
612 ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
613 auto *DF = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
617 EMS->F = getCurrentFragment();
618 EMS->Offset = DF->getContents().size();
619 LastEMSInfo->State = EMS_Data;
622 EmitMappingSymbol(
"$d");
623 LastEMSInfo->State = EMS_Data;
626 void EmitThumbMappingSymbol() {
627 if (LastEMSInfo->State == EMS_Thumb)
629 FlushPendingMappingSymbol();
630 EmitMappingSymbol(
"$t");
631 LastEMSInfo->State = EMS_Thumb;
634 void EmitARMMappingSymbol() {
635 if (LastEMSInfo->State == EMS_ARM)
637 FlushPendingMappingSymbol();
638 EmitMappingSymbol(
"$a");
639 LastEMSInfo->State = EMS_ARM;
643 auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
644 Name +
"." +
Twine(MappingSymbolCounter++)));
654 auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
655 Name +
"." +
Twine(MappingSymbolCounter++)));
656 EmitLabel(Symbol, Loc, F);
663 void EmitThumbFunc(
MCSymbol *Func)
override {
664 getAssembler().setIsThumbFunc(Func);
672 void reset()
override;
674 void EmitPersonalityFixup(
StringRef Name);
675 void FlushPendingOffset();
676 void FlushUnwindOpcodes(
bool NoHandlerData);
680 void SwitchToExTabSection(
const MCSymbol &FnStart);
681 void SwitchToExIdxSection(
const MCSymbol &FnStart);
686 int64_t MappingSymbolCounter = 0;
691 std::unique_ptr<ElfMappingSymbolInfo> LastEMSInfo;
697 unsigned PersonalityIndex;
701 int64_t PendingOffset;
710 ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
711 return static_cast<ARMELFStreamer &
>(Streamer);
714 void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
715 void ARMTargetELFStreamer::emitFnEnd() { getStreamer().emitFnEnd(); }
716 void ARMTargetELFStreamer::emitCantUnwind() { getStreamer().emitCantUnwind(); }
718 void ARMTargetELFStreamer::emitPersonality(
const MCSymbol *Personality) {
719 getStreamer().emitPersonality(Personality);
722 void ARMTargetELFStreamer::emitPersonalityIndex(
unsigned Index) {
723 getStreamer().emitPersonalityIndex(Index);
726 void ARMTargetELFStreamer::emitHandlerData() {
727 getStreamer().emitHandlerData();
730 void ARMTargetELFStreamer::emitSetFP(
unsigned FpReg,
unsigned SpReg,
732 getStreamer().emitSetFP(FpReg, SpReg, Offset);
735 void ARMTargetELFStreamer::emitMovSP(
unsigned Reg, int64_t
Offset) {
736 getStreamer().emitMovSP(Reg, Offset);
739 void ARMTargetELFStreamer::emitPad(int64_t
Offset) {
740 getStreamer().emitPad(Offset);
745 getStreamer().emitRegSave(RegList, isVector);
748 void ARMTargetELFStreamer::emitUnwindRaw(int64_t
Offset,
750 getStreamer().emitUnwindRaw(
Offset, Opcodes);
753 void ARMTargetELFStreamer::switchVendor(
StringRef Vendor) {
754 assert(!Vendor.
empty() &&
"Vendor cannot be empty.");
756 if (CurrentVendor == Vendor)
759 if (!CurrentVendor.empty())
760 finishAttributeSection();
762 assert(Contents.empty() &&
763 ".ARM.attributes should be flushed before changing vendor");
764 CurrentVendor = Vendor;
768 void ARMTargetELFStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
769 setAttributeItem(Attribute, Value,
true);
772 void ARMTargetELFStreamer::emitTextAttribute(
unsigned Attribute,
774 setAttributeItem(Attribute, Value,
true);
777 void ARMTargetELFStreamer::emitIntTextAttribute(
unsigned Attribute,
780 setAttributeItems(Attribute, IntValue, StringValue,
788 void ARMTargetELFStreamer::emitObjectArch(
ARM::ArchKind Value) {
792 void ARMTargetELFStreamer::emitArchDefaultAttributes() {
793 using namespace ARMBuildAttrs;
809 case ARM::ArchKind::ARMV2:
810 case ARM::ArchKind::ARMV2A:
811 case ARM::ArchKind::ARMV3:
812 case ARM::ArchKind::ARMV3M:
813 case ARM::ArchKind::ARMV4:
817 case ARM::ArchKind::ARMV4T:
818 case ARM::ArchKind::ARMV5T:
819 case ARM::ArchKind::ARMV5TE:
820 case ARM::ArchKind::ARMV6:
825 case ARM::ArchKind::ARMV6T2:
830 case ARM::ArchKind::ARMV6K:
831 case ARM::ArchKind::ARMV6KZ:
837 case ARM::ArchKind::ARMV6M:
841 case ARM::ArchKind::ARMV7A:
847 case ARM::ArchKind::ARMV7R:
853 case ARM::ArchKind::ARMV7EM:
854 case ARM::ArchKind::ARMV7M:
859 case ARM::ArchKind::ARMV8A:
860 case ARM::ArchKind::ARMV8_1A:
861 case ARM::ArchKind::ARMV8_2A:
862 case ARM::ArchKind::ARMV8_3A:
863 case ARM::ArchKind::ARMV8_4A:
871 case ARM::ArchKind::ARMV8MBaseline:
872 case ARM::ArchKind::ARMV8MMainline:
877 case ARM::ArchKind::IWMMXT:
883 case ARM::ArchKind::IWMMXT2:
895 void ARMTargetELFStreamer::emitFPU(
unsigned Value) {
899 void ARMTargetELFStreamer::emitFPUDefaultAttributes() {
914 case ARM::FK_VFPV3_FP16:
923 case ARM::FK_VFPV3_D16:
929 case ARM::FK_VFPV3_D16_FP16:
938 case ARM::FK_VFPV3XD:
943 case ARM::FK_VFPV3XD_FP16:
960 case ARM::FK_FPV4_SP_D16:
961 case ARM::FK_VFPV4_D16:
967 case ARM::FK_FP_ARMV8:
975 case ARM::FK_FPV5_SP_D16:
976 case ARM::FK_FPV5_D16:
991 case ARM::FK_NEON_FP16:
1003 case ARM::FK_NEON_VFPV4:
1012 case ARM::FK_NEON_FP_ARMV8:
1013 case ARM::FK_CRYPTO_NEON_FP_ARMV8:
1021 case ARM::FK_SOFTVFP:
1031 size_t ARMTargetELFStreamer::calculateContentSize()
const {
1033 for (
size_t i = 0; i < Contents.size(); ++i) {
1034 AttributeItem item = Contents[i];
1035 switch (item.Type) {
1036 case AttributeItem::HiddenAttribute:
1038 case AttributeItem::NumericAttribute:
1042 case AttributeItem::TextAttribute:
1044 Result += item.StringValue.size() + 1;
1046 case AttributeItem::NumericAndTextAttributes:
1049 Result += item.StringValue.size() + 1;
1056 void ARMTargetELFStreamer::finishAttributeSection() {
1065 if (FPU != ARM::FK_INVALID)
1066 emitFPUDefaultAttributes();
1069 emitArchDefaultAttributes();
1071 if (Contents.empty())
1074 llvm::sort(Contents.begin(), Contents.end(), AttributeItem::LessTag);
1076 ARMELFStreamer &Streamer = getStreamer();
1079 if (AttributeSection) {
1080 Streamer.SwitchSection(AttributeSection);
1082 AttributeSection = Streamer.getContext().getELFSection(
1084 Streamer.SwitchSection(AttributeSection);
1087 Streamer.EmitIntValue(0x41, 1);
1091 const size_t VendorHeaderSize = 4 + CurrentVendor.size() + 1;
1094 const size_t TagHeaderSize = 1 + 4;
1096 const size_t ContentsSize = calculateContentSize();
1098 Streamer.EmitIntValue(VendorHeaderSize + TagHeaderSize + ContentsSize, 4);
1099 Streamer.EmitBytes(CurrentVendor);
1100 Streamer.EmitIntValue(0, 1);
1103 Streamer.EmitIntValue(TagHeaderSize + ContentsSize, 4);
1107 for (
size_t i = 0; i < Contents.size(); ++i) {
1108 AttributeItem item = Contents[i];
1109 Streamer.EmitULEB128IntValue(item.Tag);
1110 switch (item.Type) {
1112 case AttributeItem::NumericAttribute:
1113 Streamer.EmitULEB128IntValue(item.IntValue);
1115 case AttributeItem::TextAttribute:
1116 Streamer.EmitBytes(item.StringValue);
1117 Streamer.EmitIntValue(0, 1);
1119 case AttributeItem::NumericAndTextAttributes:
1120 Streamer.EmitULEB128IntValue(item.IntValue);
1121 Streamer.EmitBytes(item.StringValue);
1122 Streamer.EmitIntValue(0, 1);
1128 FPU = ARM::FK_INVALID;
1132 ARMELFStreamer &Streamer = getStreamer();
1133 if (!Streamer.IsThumb)
1136 Streamer.getAssembler().registerSymbol(*Symbol);
1139 Streamer.EmitThumbFunc(Symbol);
1143 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *S) {
1147 void ARMTargetELFStreamer::emitThumbSet(
MCSymbol *Symbol,
const MCExpr *Value) {
1149 const MCSymbol &Sym = SRE->getSymbol();
1151 getStreamer().EmitAssignment(Symbol, Value);
1156 getStreamer().EmitThumbFunc(Symbol);
1157 getStreamer().EmitAssignment(Symbol, Value);
1160 void ARMTargetELFStreamer::emitInst(
uint32_t Inst,
char Suffix) {
1161 getStreamer().emitInst(Inst, Suffix);
1164 void ARMTargetELFStreamer::reset() { AttributeSection =
nullptr; }
1166 void ARMELFStreamer::FinishImpl() {
1174 void ARMELFStreamer::reset() {
1178 MappingSymbolCounter = 0;
1180 LastMappingSymbols.clear();
1181 LastEMSInfo.reset();
1199 if (FnSecName !=
".text") {
1200 EHSecName += FnSecName;
1208 EHSecName, Type, Flags, 0, Group, FnSection.
getUniqueID(),
1211 assert(EHSection &&
"Failed to get the required EH section");
1214 SwitchSection(EHSection);
1215 EmitCodeAlignment(4);
1218 inline void ARMELFStreamer::SwitchToExTabSection(
const MCSymbol &FnStart) {
1223 inline void ARMELFStreamer::SwitchToExIdxSection(
const MCSymbol &FnStart) {
1235 void ARMELFStreamer::EHReset() {
1238 Personality =
nullptr;
1248 UnwindOpAsm.Reset();
1251 void ARMELFStreamer::emitFnStart() {
1252 assert(FnStart ==
nullptr);
1253 FnStart = getContext().createTempSymbol();
1257 void ARMELFStreamer::emitFnEnd() {
1258 assert(FnStart &&
".fnstart must precedes .fnend");
1261 if (!ExTab && !CantUnwind)
1262 FlushUnwindOpcodes(
true);
1265 SwitchToExIdxSection(*FnStart);
1275 EmitValue(FnStartRef, 4);
1285 EmitValue(ExTabEntryRef, 4);
1291 "Compact model must use __aeabi_unwind_cpp_pr0 as personality");
1293 "Unwind opcode size for __aeabi_unwind_cpp_pr0 must be equal to 4");
1294 uint64_t Intval = Opcodes[0] |
1298 EmitIntValue(Intval, Opcodes.
size());
1308 void ARMELFStreamer::emitCantUnwind() { CantUnwind =
true; }
1312 const MCSymbol *PersonalitySym = getContext().getOrCreateSymbol(Name);
1317 visitUsedExpr(*PersonalityRef);
1324 void ARMELFStreamer::FlushPendingOffset() {
1325 if (PendingOffset != 0) {
1326 UnwindOpAsm.EmitSPOffset(-PendingOffset);
1331 void ARMELFStreamer::FlushUnwindOpcodes(
bool NoHandlerData) {
1335 int64_t LastRegSaveSPOffset = SPOffset - PendingOffset;
1336 UnwindOpAsm.EmitSPOffset(LastRegSaveSPOffset - FPOffset);
1339 FlushPendingOffset();
1343 UnwindOpAsm.Finalize(PersonalityIndex, Opcodes);
1352 SwitchToExTabSection(*FnStart);
1356 ExTab = getContext().createTempSymbol();
1366 EmitValue(PersonalityRef, 4);
1371 "Unwind opcode size for __aeabi_cpp_unwind_pr0 must be multiple of 4");
1372 for (
unsigned I = 0;
I != Opcodes.
size();
I += 4) {
1373 uint64_t Intval = Opcodes[
I] |
1374 Opcodes[
I + 1] << 8 |
1375 Opcodes[
I + 2] << 16 |
1376 Opcodes[
I + 3] << 24;
1377 EmitIntValue(Intval, 4);
1387 if (NoHandlerData && !Personality)
1391 void ARMELFStreamer::emitHandlerData() { FlushUnwindOpcodes(
false); }
1393 void ARMELFStreamer::emitPersonality(
const MCSymbol *Per) {
1395 UnwindOpAsm.setPersonality(Per);
1398 void ARMELFStreamer::emitPersonalityIndex(
unsigned Index) {
1400 PersonalityIndex =
Index;
1403 void ARMELFStreamer::emitSetFP(
unsigned NewFPReg,
unsigned NewSPReg,
1405 assert((NewSPReg == ARM::SP || NewSPReg == FPReg) &&
1406 "the operand of .setfp directive should be either $sp or $fp");
1411 if (NewSPReg == ARM::SP)
1412 FPOffset = SPOffset +
Offset;
1417 void ARMELFStreamer::emitMovSP(
unsigned Reg, int64_t
Offset) {
1418 assert((Reg != ARM::SP && Reg != ARM::PC) &&
1419 "the operand of .movsp cannot be either sp or pc");
1420 assert(FPReg == ARM::SP &&
"current FP must be SP");
1422 FlushPendingOffset();
1425 FPOffset = SPOffset +
Offset;
1431 void ARMELFStreamer::emitPad(int64_t
Offset) {
1446 for (
size_t i = 0; i < RegList.
size(); ++i) {
1448 assert(Reg < (IsVector ? 32U : 16U) &&
"Register out of range");
1449 unsigned Bit = (1u <<
Reg);
1450 if ((Mask & Bit) == 0) {
1460 SPOffset -= Count * (IsVector ? 8 : 4);
1463 FlushPendingOffset();
1465 UnwindOpAsm.EmitVFPRegSave(Mask);
1467 UnwindOpAsm.EmitRegSave(Mask);
1470 void ARMELFStreamer::emitUnwindRaw(int64_t
Offset,
1472 FlushPendingOffset();
1473 SPOffset = SPOffset -
Offset;
1474 UnwindOpAsm.EmitRaw(Opcodes);
1482 bool isVerboseAsm) {
1483 return new ARMTargetAsmStreamer(S, OS, *InstPrint, isVerboseAsm);
1494 return new ARMTargetELFStreamer(S);
1499 std::unique_ptr<MCAsmBackend> TAB,
1500 std::unique_ptr<MCObjectWriter> OW,
1501 std::unique_ptr<MCCodeEmitter> Emitter,
1502 bool RelaxAll,
bool IsThumb) {
1503 ARMELFStreamer *S =
new ARMELFStreamer(Context, std::move(TAB), std::move(OW),
1504 std::move(Emitter), IsThumb);
1511 S->getAssembler().setRelaxAll(
true);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
static SectionKind getData()
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
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.
Compute iterated dominance frontiers using a linear time algorithm.
void reset() override
state management
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Target specific streamer interface.
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const
Print the assembler register name.
static MCFixupKind getKindForSize(unsigned Size, bool isPCRel)
Return the generic fixup kind for a value with the given size.
virtual void finishAttributeSection()
StringRef getCPUAttr(ArchKind AK)
StringRef getArchExtName(unsigned ArchExtKind)
StringRef getFPUName(unsigned FPUKind)
virtual void reset()
Reset any state between object emissions, i.e.
const Triple & getTargetTriple() const
void setExternal(bool Value) const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getArchName(ArchKind AK)
Base class for the full range of assembler expressions which are needed for parsing.
Represent a reference to a symbol from inside an expression.
Context object for machine code objects.
.code16 (X86) / .code 16 (ARM)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
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.
SmallVectorImpl< char > & getContents()
MCTargetStreamer * createARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
Instances of this class represent a single low-level machine instruction.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix=true)
unsigned getUniqueID() const
void ChangeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
MCTargetStreamer * createARMObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Streaming machine code generation interface.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
unsigned const MachineRegisterInfo * MRI
const MCSymbolELF * getGroup() const
The instances of the Type class are immutable: once they are created, they are never changed...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
MCFixupKind
Extensible enumeration to represent the type of a fixup.
SmallVectorImpl< MCFixup > & getFixups()
.subsections_via_symbols (MachO)
SectionKind - This is a simple POD value that classifies the properties of a section.
void setOffset(uint64_t Value)
MCELFStreamer * createARMELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, bool RelaxAll, bool IsThumb)
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
static wasm::ValType getType(const TargetRegisterClass *RC)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
void sort(IteratorTy Start, IteratorTy End)
const MCSymbol & getSymbol() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isVector(MCInstrInfo const &MCII, MCInst const &MCI)
static Twine utohexstr(const uint64_t &Val)
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
.code32 (X86) / .code 32 (ARM)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
.type _foo, STT_FUNC # aka
Special entry for the function never unwind.
Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
StringRef getName() const
getName - Get the symbol name.
Fragment for data and encoded instructions.
LLVM_NODISCARD std::string lower() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCTargetStreamer * createARMNullTargetStreamer(MCStreamer &S)
LLVM Value Representation.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
void EmitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
StringRef - Represent a constant reference to a string, i.e.
static std::string GetAEABIUnwindPersonalityName(unsigned Index)
Represents a location in source code.
unsigned getArchAttr(ArchKind AK)
void FinishImpl() override
Streamer specific finalization.
StringRef getSectionName() const
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool=false) override
Emit the given Instruction into the current section.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.