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);
468 void emitFill(
const MCExpr &NumBytes, uint64_t FillValue,
469 SMLoc Loc)
override {
470 EmitDataMappingSymbol();
475 LastMappingSymbols[getCurrentSection().first] = std::move(LastEMSInfo);
477 auto LastMappingSymbol = LastMappingSymbols.find(Section);
478 if (LastMappingSymbol != LastMappingSymbols.end()) {
479 LastEMSInfo = std::move(LastMappingSymbol->second);
482 LastEMSInfo.reset(
new ElfMappingSymbolInfo(
SMLoc(),
nullptr, 0));
491 EmitThumbMappingSymbol();
493 EmitARMMappingSymbol();
498 void emitInst(
uint32_t Inst,
char Suffix) {
501 const bool LittleEndian = getContext().getAsmInfo()->isLittleEndian();
508 EmitARMMappingSymbol();
509 for (
unsigned II = 0,
IE = Size; II !=
IE; II++) {
510 const unsigned I = LittleEndian ? (Size - II - 1) : II;
511 Buffer[Size - II - 1] = uint8_t(Inst >> I * CHAR_BIT);
517 Size = (Suffix ==
'n' ? 2 : 4);
520 EmitThumbMappingSymbol();
523 for (
unsigned II = 0,
IE = Size; II !=
IE; II = II + 2) {
524 const unsigned I0 = LittleEndian ? II + 0 : II + 1;
525 const unsigned I1 = LittleEndian ? II + 1 : II + 0;
526 Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
527 Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT);
542 EmitDataMappingSymbol();
546 void FlushPendingMappingSymbol() {
547 if (!LastEMSInfo->hasInfo())
549 ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
550 EmitMappingSymbol(
"$d", EMS->Loc, EMS->F, EMS->Offset);
557 void EmitValueImpl(
const MCExpr *Value,
unsigned Size,
SMLoc Loc)
override {
558 if (
const MCSymbolRefExpr *SRE = dyn_cast_or_null<MCSymbolRefExpr>(Value)) {
560 getContext().reportError(Loc,
"relocated expression must be 32-bit");
563 getOrCreateDataFragment();
566 EmitDataMappingSymbol();
590 enum ElfMappingSymbol {
597 struct ElfMappingSymbolInfo {
599 : Loc(Loc),
F(F),
Offset(O), State(EMS_None) {}
604 bool hasInfo() {
return F !=
nullptr; }
608 ElfMappingSymbol State;
611 void EmitDataMappingSymbol() {
612 if (LastEMSInfo->State == EMS_Data)
614 else if (LastEMSInfo->State == EMS_None) {
617 ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
618 auto *DF = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
622 EMS->F = getCurrentFragment();
623 EMS->Offset = DF->getContents().size();
624 LastEMSInfo->State = EMS_Data;
627 EmitMappingSymbol(
"$d");
628 LastEMSInfo->State = EMS_Data;
631 void EmitThumbMappingSymbol() {
632 if (LastEMSInfo->State == EMS_Thumb)
634 FlushPendingMappingSymbol();
635 EmitMappingSymbol(
"$t");
636 LastEMSInfo->State = EMS_Thumb;
639 void EmitARMMappingSymbol() {
640 if (LastEMSInfo->State == EMS_ARM)
642 FlushPendingMappingSymbol();
643 EmitMappingSymbol(
"$a");
644 LastEMSInfo->State = EMS_ARM;
648 auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
649 Name +
"." +
Twine(MappingSymbolCounter++)));
659 auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
660 Name +
"." +
Twine(MappingSymbolCounter++)));
661 EmitLabel(Symbol, Loc, F);
668 void EmitThumbFunc(
MCSymbol *Func)
override {
669 getAssembler().setIsThumbFunc(Func);
677 void reset()
override;
679 void EmitPersonalityFixup(
StringRef Name);
680 void FlushPendingOffset();
681 void FlushUnwindOpcodes(
bool NoHandlerData);
685 void SwitchToExTabSection(
const MCSymbol &FnStart);
686 void SwitchToExIdxSection(
const MCSymbol &FnStart);
691 int64_t MappingSymbolCounter = 0;
696 std::unique_ptr<ElfMappingSymbolInfo> LastEMSInfo;
702 unsigned PersonalityIndex;
706 int64_t PendingOffset;
715 ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
716 return static_cast<ARMELFStreamer &
>(Streamer);
719 void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
720 void ARMTargetELFStreamer::emitFnEnd() { getStreamer().emitFnEnd(); }
721 void ARMTargetELFStreamer::emitCantUnwind() { getStreamer().emitCantUnwind(); }
723 void ARMTargetELFStreamer::emitPersonality(
const MCSymbol *Personality) {
724 getStreamer().emitPersonality(Personality);
727 void ARMTargetELFStreamer::emitPersonalityIndex(
unsigned Index) {
728 getStreamer().emitPersonalityIndex(Index);
731 void ARMTargetELFStreamer::emitHandlerData() {
732 getStreamer().emitHandlerData();
735 void ARMTargetELFStreamer::emitSetFP(
unsigned FpReg,
unsigned SpReg,
737 getStreamer().emitSetFP(FpReg, SpReg, Offset);
740 void ARMTargetELFStreamer::emitMovSP(
unsigned Reg, int64_t
Offset) {
741 getStreamer().emitMovSP(Reg, Offset);
744 void ARMTargetELFStreamer::emitPad(int64_t
Offset) {
745 getStreamer().emitPad(Offset);
750 getStreamer().emitRegSave(RegList, isVector);
753 void ARMTargetELFStreamer::emitUnwindRaw(int64_t
Offset,
755 getStreamer().emitUnwindRaw(
Offset, Opcodes);
758 void ARMTargetELFStreamer::switchVendor(
StringRef Vendor) {
759 assert(!Vendor.
empty() &&
"Vendor cannot be empty.");
761 if (CurrentVendor == Vendor)
764 if (!CurrentVendor.empty())
765 finishAttributeSection();
767 assert(Contents.empty() &&
768 ".ARM.attributes should be flushed before changing vendor");
769 CurrentVendor = Vendor;
773 void ARMTargetELFStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
774 setAttributeItem(Attribute, Value,
true);
777 void ARMTargetELFStreamer::emitTextAttribute(
unsigned Attribute,
779 setAttributeItem(Attribute, Value,
true);
782 void ARMTargetELFStreamer::emitIntTextAttribute(
unsigned Attribute,
785 setAttributeItems(Attribute, IntValue, StringValue,
793 void ARMTargetELFStreamer::emitObjectArch(
ARM::ArchKind Value) {
797 void ARMTargetELFStreamer::emitArchDefaultAttributes() {
798 using namespace ARMBuildAttrs;
814 case ARM::ArchKind::ARMV2:
815 case ARM::ArchKind::ARMV2A:
816 case ARM::ArchKind::ARMV3:
817 case ARM::ArchKind::ARMV3M:
818 case ARM::ArchKind::ARMV4:
822 case ARM::ArchKind::ARMV4T:
823 case ARM::ArchKind::ARMV5T:
824 case ARM::ArchKind::ARMV5TE:
825 case ARM::ArchKind::ARMV6:
830 case ARM::ArchKind::ARMV6T2:
835 case ARM::ArchKind::ARMV6K:
836 case ARM::ArchKind::ARMV6KZ:
842 case ARM::ArchKind::ARMV6M:
846 case ARM::ArchKind::ARMV7A:
852 case ARM::ArchKind::ARMV7R:
858 case ARM::ArchKind::ARMV7EM:
859 case ARM::ArchKind::ARMV7M:
864 case ARM::ArchKind::ARMV8A:
865 case ARM::ArchKind::ARMV8_1A:
866 case ARM::ArchKind::ARMV8_2A:
867 case ARM::ArchKind::ARMV8_3A:
868 case ARM::ArchKind::ARMV8_4A:
869 case ARM::ArchKind::ARMV8_5A:
877 case ARM::ArchKind::ARMV8MBaseline:
878 case ARM::ArchKind::ARMV8MMainline:
883 case ARM::ArchKind::IWMMXT:
889 case ARM::ArchKind::IWMMXT2:
901 void ARMTargetELFStreamer::emitFPU(
unsigned Value) {
905 void ARMTargetELFStreamer::emitFPUDefaultAttributes() {
920 case ARM::FK_VFPV3_FP16:
929 case ARM::FK_VFPV3_D16:
935 case ARM::FK_VFPV3_D16_FP16:
944 case ARM::FK_VFPV3XD:
949 case ARM::FK_VFPV3XD_FP16:
966 case ARM::FK_FPV4_SP_D16:
967 case ARM::FK_VFPV4_D16:
973 case ARM::FK_FP_ARMV8:
981 case ARM::FK_FPV5_SP_D16:
982 case ARM::FK_FPV5_D16:
997 case ARM::FK_NEON_FP16:
1009 case ARM::FK_NEON_VFPV4:
1018 case ARM::FK_NEON_FP_ARMV8:
1019 case ARM::FK_CRYPTO_NEON_FP_ARMV8:
1027 case ARM::FK_SOFTVFP:
1037 size_t ARMTargetELFStreamer::calculateContentSize()
const {
1039 for (
size_t i = 0; i < Contents.size(); ++i) {
1040 AttributeItem item = Contents[i];
1041 switch (item.Type) {
1042 case AttributeItem::HiddenAttribute:
1044 case AttributeItem::NumericAttribute:
1048 case AttributeItem::TextAttribute:
1050 Result += item.StringValue.size() + 1;
1052 case AttributeItem::NumericAndTextAttributes:
1055 Result += item.StringValue.size() + 1;
1062 void ARMTargetELFStreamer::finishAttributeSection() {
1071 if (FPU != ARM::FK_INVALID)
1072 emitFPUDefaultAttributes();
1075 emitArchDefaultAttributes();
1077 if (Contents.empty())
1080 llvm::sort(Contents, AttributeItem::LessTag);
1082 ARMELFStreamer &Streamer = getStreamer();
1085 if (AttributeSection) {
1086 Streamer.SwitchSection(AttributeSection);
1088 AttributeSection = Streamer.getContext().getELFSection(
1090 Streamer.SwitchSection(AttributeSection);
1093 Streamer.EmitIntValue(0x41, 1);
1097 const size_t VendorHeaderSize = 4 + CurrentVendor.size() + 1;
1100 const size_t TagHeaderSize = 1 + 4;
1102 const size_t ContentsSize = calculateContentSize();
1104 Streamer.EmitIntValue(VendorHeaderSize + TagHeaderSize + ContentsSize, 4);
1105 Streamer.EmitBytes(CurrentVendor);
1106 Streamer.EmitIntValue(0, 1);
1109 Streamer.EmitIntValue(TagHeaderSize + ContentsSize, 4);
1113 for (
size_t i = 0; i < Contents.size(); ++i) {
1114 AttributeItem item = Contents[i];
1115 Streamer.EmitULEB128IntValue(item.Tag);
1116 switch (item.Type) {
1118 case AttributeItem::NumericAttribute:
1119 Streamer.EmitULEB128IntValue(item.IntValue);
1121 case AttributeItem::TextAttribute:
1122 Streamer.EmitBytes(item.StringValue);
1123 Streamer.EmitIntValue(0, 1);
1125 case AttributeItem::NumericAndTextAttributes:
1126 Streamer.EmitULEB128IntValue(item.IntValue);
1127 Streamer.EmitBytes(item.StringValue);
1128 Streamer.EmitIntValue(0, 1);
1134 FPU = ARM::FK_INVALID;
1138 ARMELFStreamer &Streamer = getStreamer();
1139 if (!Streamer.IsThumb)
1142 Streamer.getAssembler().registerSymbol(*Symbol);
1145 Streamer.EmitThumbFunc(Symbol);
1149 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *S) {
1153 void ARMTargetELFStreamer::emitThumbSet(
MCSymbol *Symbol,
const MCExpr *Value) {
1155 const MCSymbol &Sym = SRE->getSymbol();
1157 getStreamer().EmitAssignment(Symbol, Value);
1162 getStreamer().EmitThumbFunc(Symbol);
1163 getStreamer().EmitAssignment(Symbol, Value);
1166 void ARMTargetELFStreamer::emitInst(
uint32_t Inst,
char Suffix) {
1167 getStreamer().emitInst(Inst, Suffix);
1170 void ARMTargetELFStreamer::reset() { AttributeSection =
nullptr; }
1172 void ARMELFStreamer::FinishImpl() {
1180 void ARMELFStreamer::reset() {
1184 MappingSymbolCounter = 0;
1186 LastMappingSymbols.clear();
1187 LastEMSInfo.reset();
1205 if (FnSecName !=
".text") {
1206 EHSecName += FnSecName;
1214 EHSecName, Type, Flags, 0, Group, FnSection.
getUniqueID(),
1217 assert(EHSection &&
"Failed to get the required EH section");
1220 SwitchSection(EHSection);
1221 EmitCodeAlignment(4);
1224 inline void ARMELFStreamer::SwitchToExTabSection(
const MCSymbol &FnStart) {
1229 inline void ARMELFStreamer::SwitchToExIdxSection(
const MCSymbol &FnStart) {
1241 void ARMELFStreamer::EHReset() {
1244 Personality =
nullptr;
1254 UnwindOpAsm.Reset();
1257 void ARMELFStreamer::emitFnStart() {
1258 assert(FnStart ==
nullptr);
1259 FnStart = getContext().createTempSymbol();
1263 void ARMELFStreamer::emitFnEnd() {
1264 assert(FnStart &&
".fnstart must precedes .fnend");
1267 if (!ExTab && !CantUnwind)
1268 FlushUnwindOpcodes(
true);
1271 SwitchToExIdxSection(*FnStart);
1281 EmitValue(FnStartRef, 4);
1291 EmitValue(ExTabEntryRef, 4);
1297 "Compact model must use __aeabi_unwind_cpp_pr0 as personality");
1299 "Unwind opcode size for __aeabi_unwind_cpp_pr0 must be equal to 4");
1300 uint64_t Intval = Opcodes[0] |
1304 EmitIntValue(Intval, Opcodes.
size());
1314 void ARMELFStreamer::emitCantUnwind() { CantUnwind =
true; }
1318 const MCSymbol *PersonalitySym = getContext().getOrCreateSymbol(Name);
1323 visitUsedExpr(*PersonalityRef);
1330 void ARMELFStreamer::FlushPendingOffset() {
1331 if (PendingOffset != 0) {
1332 UnwindOpAsm.EmitSPOffset(-PendingOffset);
1337 void ARMELFStreamer::FlushUnwindOpcodes(
bool NoHandlerData) {
1341 int64_t LastRegSaveSPOffset = SPOffset - PendingOffset;
1342 UnwindOpAsm.EmitSPOffset(LastRegSaveSPOffset - FPOffset);
1345 FlushPendingOffset();
1349 UnwindOpAsm.Finalize(PersonalityIndex, Opcodes);
1358 SwitchToExTabSection(*FnStart);
1362 ExTab = getContext().createTempSymbol();
1372 EmitValue(PersonalityRef, 4);
1377 "Unwind opcode size for __aeabi_cpp_unwind_pr0 must be multiple of 4");
1378 for (
unsigned I = 0;
I != Opcodes.
size();
I += 4) {
1379 uint64_t Intval = Opcodes[
I] |
1380 Opcodes[
I + 1] << 8 |
1381 Opcodes[
I + 2] << 16 |
1382 Opcodes[
I + 3] << 24;
1383 EmitIntValue(Intval, 4);
1393 if (NoHandlerData && !Personality)
1397 void ARMELFStreamer::emitHandlerData() { FlushUnwindOpcodes(
false); }
1399 void ARMELFStreamer::emitPersonality(
const MCSymbol *Per) {
1401 UnwindOpAsm.setPersonality(Per);
1404 void ARMELFStreamer::emitPersonalityIndex(
unsigned Index) {
1406 PersonalityIndex =
Index;
1409 void ARMELFStreamer::emitSetFP(
unsigned NewFPReg,
unsigned NewSPReg,
1411 assert((NewSPReg == ARM::SP || NewSPReg == FPReg) &&
1412 "the operand of .setfp directive should be either $sp or $fp");
1417 if (NewSPReg == ARM::SP)
1418 FPOffset = SPOffset +
Offset;
1423 void ARMELFStreamer::emitMovSP(
unsigned Reg, int64_t
Offset) {
1424 assert((Reg != ARM::SP && Reg != ARM::PC) &&
1425 "the operand of .movsp cannot be either sp or pc");
1426 assert(FPReg == ARM::SP &&
"current FP must be SP");
1428 FlushPendingOffset();
1431 FPOffset = SPOffset +
Offset;
1437 void ARMELFStreamer::emitPad(int64_t
Offset) {
1452 for (
size_t i = 0; i < RegList.
size(); ++i) {
1454 assert(Reg < (IsVector ? 32U : 16U) &&
"Register out of range");
1455 unsigned Bit = (1u <<
Reg);
1456 if ((Mask & Bit) == 0) {
1466 SPOffset -= Count * (IsVector ? 8 : 4);
1469 FlushPendingOffset();
1471 UnwindOpAsm.EmitVFPRegSave(Mask);
1473 UnwindOpAsm.EmitRegSave(Mask);
1476 void ARMELFStreamer::emitUnwindRaw(int64_t
Offset,
1478 FlushPendingOffset();
1479 SPOffset = SPOffset -
Offset;
1480 UnwindOpAsm.EmitRaw(Opcodes);
1488 bool isVerboseAsm) {
1489 return new ARMTargetAsmStreamer(S, OS, *InstPrint, isVerboseAsm);
1500 return new ARMTargetELFStreamer(S);
1505 std::unique_ptr<MCAsmBackend> TAB,
1506 std::unique_ptr<MCObjectWriter> OW,
1507 std::unique_ptr<MCCodeEmitter> Emitter,
1508 bool RelaxAll,
bool IsThumb) {
1509 ARMELFStreamer *S =
new ARMELFStreamer(Context, std::move(TAB), std::move(OW),
1510 std::move(Emitter), IsThumb);
1517 S->getAssembler().setRelaxAll(
true);
Instances of this class represent a uniqued identifier for a section in the current translation unit...
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.
This class represents lattice values for constants.
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.
void push_back(const T &Elt)
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)
virtual void reset()
Reset any state between object emissions, i.e.
const Triple & getTargetTriple() const
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
.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.
StringRef getArchExtName(unsigned ArchExtKind)
.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
Generic base class for all target subtargets.
StringRef getFPUName(unsigned FPUKind)
This represents a section on linux, lots of unix variants and some bare metal systems.
Special entry for the function never unwind.
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.
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.