63 "Invalid personality index");
64 return (
Twine(
"__aeabi_unwind_cpp_pr") +
Twine(Index)).str();
76 void emitFnStart()
override;
77 void emitFnEnd()
override;
78 void emitCantUnwind()
override;
79 void emitPersonality(
const MCSymbol *Personality)
override;
80 void emitPersonalityIndex(
unsigned Index)
override;
81 void emitHandlerData()
override;
82 void emitSetFP(
unsigned FpReg,
unsigned SpReg, int64_t
Offset = 0)
override;
83 void emitMovSP(
unsigned Reg, int64_t
Offset = 0)
override;
84 void emitPad(int64_t
Offset)
override;
87 void emitUnwindRaw(int64_t
Offset,
90 void switchVendor(
StringRef Vendor)
override;
93 void emitIntTextAttribute(
unsigned Attribute,
unsigned IntValue,
95 void emitArch(
unsigned Arch)
override;
96 void emitArchExtension(
unsigned ArchExt)
override;
97 void emitObjectArch(
unsigned Arch)
override;
98 void emitFPU(
unsigned FPU)
override;
99 void emitInst(
uint32_t Inst,
char Suffix =
'\0')
override;
100 void finishAttributeSection()
override;
102 void AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *SRE)
override;
110 ARMTargetAsmStreamer::ARMTargetAsmStreamer(
MCStreamer &S,
115 IsVerboseAsm(VerboseAsm) {}
117 void ARMTargetAsmStreamer::emitFnStart() { OS <<
"\t.fnstart\n"; }
118 void ARMTargetAsmStreamer::emitFnEnd() { OS <<
"\t.fnend\n"; }
119 void ARMTargetAsmStreamer::emitCantUnwind() { OS <<
"\t.cantunwind\n"; }
121 void ARMTargetAsmStreamer::emitPersonality(
const MCSymbol *Personality) {
122 OS <<
"\t.personality " << Personality->
getName() <<
'\n';
125 void ARMTargetAsmStreamer::emitPersonalityIndex(
unsigned Index) {
126 OS <<
"\t.personalityindex " << Index <<
'\n';
129 void ARMTargetAsmStreamer::emitHandlerData() { OS <<
"\t.handlerdata\n"; }
131 void ARMTargetAsmStreamer::emitSetFP(
unsigned FpReg,
unsigned SpReg,
134 InstPrinter.printRegName(OS, FpReg);
136 InstPrinter.printRegName(OS, SpReg);
142 void ARMTargetAsmStreamer::emitMovSP(
unsigned Reg, int64_t Offset) {
143 assert((Reg != ARM::SP && Reg != ARM::PC) &&
144 "the operand of .movsp cannot be either sp or pc");
147 InstPrinter.printRegName(OS, Reg);
153 void ARMTargetAsmStreamer::emitPad(int64_t Offset) {
154 OS <<
"\t.pad\t#" << Offset <<
'\n';
159 assert(RegList.
size() &&
"RegList should not be empty");
165 InstPrinter.printRegName(OS, RegList[0]);
167 for (
unsigned i = 1, e = RegList.
size(); i != e; ++i) {
169 InstPrinter.printRegName(OS, RegList[i]);
175 void ARMTargetAsmStreamer::switchVendor(
StringRef Vendor) {}
177 void ARMTargetAsmStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
178 OS <<
"\t.eabi_attribute\t" << Attribute <<
", " <<
Twine(Value);
182 OS <<
"\t@ " << Name;
187 void ARMTargetAsmStreamer::emitTextAttribute(
unsigned Attribute,
191 OS <<
"\t.cpu\t" << String.
lower();
194 OS <<
"\t.eabi_attribute\t" << Attribute <<
", \"" << String <<
"\"";
198 OS <<
"\t@ " << Name;
205 void ARMTargetAsmStreamer::emitIntTextAttribute(
unsigned Attribute,
211 OS <<
"\t.eabi_attribute\t" << Attribute <<
", " << IntValue;
212 if (!StringValue.
empty())
213 OS <<
", \"" << StringValue <<
"\"";
221 void ARMTargetAsmStreamer::emitArch(
unsigned Arch) {
225 void ARMTargetAsmStreamer::emitArchExtension(
unsigned ArchExt) {
229 void ARMTargetAsmStreamer::emitObjectArch(
unsigned Arch) {
233 void ARMTargetAsmStreamer::emitFPU(
unsigned FPU) {
237 void ARMTargetAsmStreamer::finishAttributeSection() {}
240 ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *S) {
245 const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
247 OS <<
"\t.thumb_set\t";
248 Symbol->
print(OS, MAI);
250 Value->
print(OS, MAI);
254 void ARMTargetAsmStreamer::emitInst(
uint32_t Inst,
char Suffix) {
261 void ARMTargetAsmStreamer::emitUnwindRaw(int64_t Offset,
263 OS <<
"\t.unwind_raw " <<
Offset;
276 struct AttributeItem {
281 NumericAndTextAttributes
285 std::string StringValue;
287 static bool LessTag(
const AttributeItem &LHS,
const AttributeItem &RHS) {
305 unsigned FPU = ARM::FK_INVALID;
306 unsigned Arch = ARM::AK_INVALID;
307 unsigned EmittedArch = ARM::AK_INVALID;
312 AttributeItem *getAttributeItem(
unsigned Attribute) {
313 for (
size_t i = 0; i < Contents.size(); ++i)
314 if (Contents[i].
Tag == Attribute)
319 void setAttributeItem(
unsigned Attribute,
unsigned Value,
320 bool OverwriteExisting) {
322 if (AttributeItem *Item = getAttributeItem(Attribute)) {
323 if (!OverwriteExisting)
325 Item->Type = AttributeItem::NumericAttribute;
326 Item->IntValue = Value;
331 AttributeItem Item = {
332 AttributeItem::NumericAttribute,
337 Contents.push_back(Item);
340 void setAttributeItem(
unsigned Attribute,
StringRef Value,
341 bool OverwriteExisting) {
343 if (AttributeItem *Item = getAttributeItem(Attribute)) {
344 if (!OverwriteExisting)
346 Item->Type = AttributeItem::TextAttribute;
347 Item->StringValue = Value;
352 AttributeItem Item = {
353 AttributeItem::TextAttribute,
358 Contents.push_back(Item);
361 void setAttributeItems(
unsigned Attribute,
unsigned IntValue,
362 StringRef StringValue,
bool OverwriteExisting) {
364 if (AttributeItem *Item = getAttributeItem(Attribute)) {
365 if (!OverwriteExisting)
367 Item->Type = AttributeItem::NumericAndTextAttributes;
368 Item->IntValue = IntValue;
369 Item->StringValue = StringValue;
374 AttributeItem Item = {
375 AttributeItem::NumericAndTextAttributes,
380 Contents.push_back(Item);
383 void emitArchDefaultAttributes();
384 void emitFPUDefaultAttributes();
394 void emitSetFP(
unsigned FpReg,
unsigned SpReg, int64_t Offset = 0)
override;
395 void emitMovSP(
unsigned Reg, int64_t Offset = 0)
override;
396 void emitPad(int64_t Offset)
override;
398 bool isVector)
override;
403 void emitAttribute(
unsigned Attribute,
unsigned Value)
override;
407 void emitArch(
unsigned Arch)
override;
409 void emitFPU(
unsigned FPU)
override;
417 size_t calculateContentSize()
const;
420 void reset()
override;
441 friend class ARMTargetELFStreamer;
445 :
MCELFStreamer(Context, TAB, OS, Emitter), IsThumb(IsThumb) {
449 ~ARMELFStreamer()
override =
default;
456 void emitCantUnwind();
457 void emitPersonality(
const MCSymbol *Per);
458 void emitPersonalityIndex(
unsigned index);
459 void emitHandlerData();
460 void emitSetFP(
unsigned NewFpReg,
unsigned NewSpReg, int64_t Offset = 0);
461 void emitMovSP(
unsigned Reg, int64_t Offset = 0);
462 void emitPad(int64_t Offset);
469 auto LastMappingSymbol = LastMappingSymbols.find(Section);
470 if (LastMappingSymbol != LastMappingSymbols.end()) {
471 LastEMSInfo = std::move(LastMappingSymbol->second);
474 LastEMSInfo.reset(
new ElfMappingSymbolInfo(
SMLoc(),
nullptr, 0));
483 EmitThumbMappingSymbol();
485 EmitARMMappingSymbol();
490 void emitInst(
uint32_t Inst,
char Suffix) {
500 EmitARMMappingSymbol();
501 for (
unsigned II = 0,
IE = Size; II !=
IE; II++) {
502 const unsigned I = LittleEndian ? (Size - II - 1) : II;
503 Buffer[Size - II - 1] = uint8_t(Inst >> I * CHAR_BIT);
509 Size = (Suffix ==
'n' ? 2 : 4);
512 EmitThumbMappingSymbol();
513 for (
unsigned II = 0,
IE = Size; II !=
IE; II = II + 2) {
514 const unsigned I0 = LittleEndian ? II + 0 : (Size - II - 1);
515 const unsigned I1 = LittleEndian ? II + 1 : (Size - II - 2);
516 Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
517 Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT);
532 EmitDataMappingSymbol();
536 void FlushPendingMappingSymbol() {
537 if (!LastEMSInfo->hasInfo())
539 ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
540 EmitMappingSymbol(
"$d", EMS->Loc, EMS->F, EMS->Offset);
548 if (
const MCSymbolRefExpr *SRE = dyn_cast_or_null<MCSymbolRefExpr>(Value)) {
549 if (SRE->getKind() == MCSymbolRefExpr::VK_ARM_SBREL && !(Size == 4)) {
556 EmitDataMappingSymbol();
580 enum ElfMappingSymbol {
587 struct ElfMappingSymbolInfo {
589 : Loc(Loc), F(F), Offset(O), State(EMS_None) {}
594 bool hasInfo() {
return F !=
nullptr; }
598 ElfMappingSymbol State;
601 void EmitDataMappingSymbol() {
602 if (LastEMSInfo->State == EMS_Data)
604 else if (LastEMSInfo->State == EMS_None) {
607 ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
613 EMS->Offset = DF->getContents().size();
614 LastEMSInfo->State = EMS_Data;
617 EmitMappingSymbol(
"$d");
618 LastEMSInfo->State = EMS_Data;
621 void EmitThumbMappingSymbol() {
622 if (LastEMSInfo->State == EMS_Thumb)
624 FlushPendingMappingSymbol();
625 EmitMappingSymbol(
"$t");
626 LastEMSInfo->State = EMS_Thumb;
629 void EmitARMMappingSymbol() {
630 if (LastEMSInfo->State == EMS_ARM)
632 FlushPendingMappingSymbol();
633 EmitMappingSymbol(
"$a");
634 LastEMSInfo->State = EMS_ARM;
639 Name +
"." +
Twine(MappingSymbolCounter++)));
650 Name +
"." +
Twine(MappingSymbolCounter++)));
667 void reset()
override;
669 void EmitPersonalityFixup(
StringRef Name);
670 void FlushPendingOffset();
671 void FlushUnwindOpcodes(
bool NoHandlerData);
675 void SwitchToExTabSection(
const MCSymbol &FnStart);
676 void SwitchToExIdxSection(
const MCSymbol &FnStart);
681 int64_t MappingSymbolCounter = 0;
686 std::unique_ptr<ElfMappingSymbolInfo> LastEMSInfo;
692 unsigned PersonalityIndex;
696 int64_t PendingOffset;
705 ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
706 return static_cast<ARMELFStreamer &
>(Streamer);
709 void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
710 void ARMTargetELFStreamer::emitFnEnd() { getStreamer().emitFnEnd(); }
711 void ARMTargetELFStreamer::emitCantUnwind() { getStreamer().emitCantUnwind(); }
713 void ARMTargetELFStreamer::emitPersonality(
const MCSymbol *Personality) {
714 getStreamer().emitPersonality(Personality);
717 void ARMTargetELFStreamer::emitPersonalityIndex(
unsigned Index) {
718 getStreamer().emitPersonalityIndex(Index);
721 void ARMTargetELFStreamer::emitHandlerData() {
722 getStreamer().emitHandlerData();
725 void ARMTargetELFStreamer::emitSetFP(
unsigned FpReg,
unsigned SpReg,
727 getStreamer().emitSetFP(FpReg, SpReg, Offset);
730 void ARMTargetELFStreamer::emitMovSP(
unsigned Reg, int64_t Offset) {
731 getStreamer().emitMovSP(Reg, Offset);
734 void ARMTargetELFStreamer::emitPad(int64_t Offset) {
735 getStreamer().emitPad(Offset);
740 getStreamer().emitRegSave(RegList, isVector);
743 void ARMTargetELFStreamer::emitUnwindRaw(int64_t Offset,
745 getStreamer().emitUnwindRaw(Offset, Opcodes);
748 void ARMTargetELFStreamer::switchVendor(
StringRef Vendor) {
749 assert(!Vendor.
empty() &&
"Vendor cannot be empty.");
751 if (CurrentVendor == Vendor)
754 if (!CurrentVendor.empty())
755 finishAttributeSection();
757 assert(Contents.empty() &&
758 ".ARM.attributes should be flushed before changing vendor");
759 CurrentVendor = Vendor;
763 void ARMTargetELFStreamer::emitAttribute(
unsigned Attribute,
unsigned Value) {
764 setAttributeItem(Attribute, Value,
true);
767 void ARMTargetELFStreamer::emitTextAttribute(
unsigned Attribute,
769 setAttributeItem(Attribute, Value,
true);
772 void ARMTargetELFStreamer::emitIntTextAttribute(
unsigned Attribute,
775 setAttributeItems(Attribute, IntValue, StringValue,
779 void ARMTargetELFStreamer::emitArch(
unsigned Value) {
783 void ARMTargetELFStreamer::emitObjectArch(
unsigned Value) {
787 void ARMTargetELFStreamer::emitArchDefaultAttributes() {
788 using namespace ARMBuildAttrs;
794 if (EmittedArch == ARM::AK_INVALID)
814 case ARM::AK_ARMV5TE:
820 case ARM::AK_ARMV6T2:
826 case ARM::AK_ARMV6KZ:
854 case ARM::AK_ARMV8_1A:
855 case ARM::AK_ARMV8_2A:
863 case ARM::AK_ARMV8MBaseline:
864 case ARM::AK_ARMV8MMainline:
875 case ARM::AK_IWMMXT2:
887 void ARMTargetELFStreamer::emitFPU(
unsigned Value) {
891 void ARMTargetELFStreamer::emitFPUDefaultAttributes() {
906 case ARM::FK_VFPV3_FP16:
915 case ARM::FK_VFPV3_D16:
921 case ARM::FK_VFPV3_D16_FP16:
930 case ARM::FK_VFPV3XD:
935 case ARM::FK_VFPV3XD_FP16:
952 case ARM::FK_FPV4_SP_D16:
953 case ARM::FK_VFPV4_D16:
959 case ARM::FK_FP_ARMV8:
967 case ARM::FK_FPV5_SP_D16:
968 case ARM::FK_FPV5_D16:
983 case ARM::FK_NEON_FP16:
995 case ARM::FK_NEON_VFPV4:
1004 case ARM::FK_NEON_FP_ARMV8:
1005 case ARM::FK_CRYPTO_NEON_FP_ARMV8:
1013 case ARM::FK_SOFTVFP:
1023 size_t ARMTargetELFStreamer::calculateContentSize()
const {
1025 for (
size_t i = 0; i < Contents.size(); ++i) {
1026 AttributeItem item = Contents[i];
1027 switch (item.Type) {
1028 case AttributeItem::HiddenAttribute:
1030 case AttributeItem::NumericAttribute:
1034 case AttributeItem::TextAttribute:
1036 Result += item.StringValue.size() + 1;
1038 case AttributeItem::NumericAndTextAttributes:
1041 Result += item.StringValue.size() + 1;
1048 void ARMTargetELFStreamer::finishAttributeSection() {
1057 if (FPU != ARM::FK_INVALID)
1058 emitFPUDefaultAttributes();
1060 if (Arch != ARM::AK_INVALID)
1061 emitArchDefaultAttributes();
1063 if (Contents.empty())
1066 std::sort(Contents.begin(), Contents.end(), AttributeItem::LessTag);
1068 ARMELFStreamer &Streamer = getStreamer();
1071 if (AttributeSection) {
1072 Streamer.SwitchSection(AttributeSection);
1074 AttributeSection = Streamer.getContext().getELFSection(
1076 Streamer.SwitchSection(AttributeSection);
1079 Streamer.EmitIntValue(0x41, 1);
1083 const size_t VendorHeaderSize = 4 + CurrentVendor.size() + 1;
1086 const size_t TagHeaderSize = 1 + 4;
1088 const size_t ContentsSize = calculateContentSize();
1090 Streamer.EmitIntValue(VendorHeaderSize + TagHeaderSize + ContentsSize, 4);
1091 Streamer.EmitBytes(CurrentVendor);
1092 Streamer.EmitIntValue(0, 1);
1095 Streamer.EmitIntValue(TagHeaderSize + ContentsSize, 4);
1099 for (
size_t i = 0; i < Contents.size(); ++i) {
1100 AttributeItem item = Contents[i];
1101 Streamer.EmitULEB128IntValue(item.Tag);
1102 switch (item.Type) {
1104 case AttributeItem::NumericAttribute:
1105 Streamer.EmitULEB128IntValue(item.IntValue);
1107 case AttributeItem::TextAttribute:
1108 Streamer.EmitBytes(item.StringValue);
1109 Streamer.EmitIntValue(0, 1);
1111 case AttributeItem::NumericAndTextAttributes:
1112 Streamer.EmitULEB128IntValue(item.IntValue);
1113 Streamer.EmitBytes(item.StringValue);
1114 Streamer.EmitIntValue(0, 1);
1120 FPU = ARM::FK_INVALID;
1123 void ARMTargetELFStreamer::emitLabel(
MCSymbol *Symbol) {
1124 ARMELFStreamer &Streamer = getStreamer();
1125 if (!Streamer.IsThumb)
1128 Streamer.getAssembler().registerSymbol(*Symbol);
1131 Streamer.EmitThumbFunc(Symbol);
1135 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(
const MCSymbolRefExpr *S) {
1139 void ARMTargetELFStreamer::emitThumbSet(
MCSymbol *Symbol,
const MCExpr *Value) {
1141 const MCSymbol &Sym = SRE->getSymbol();
1143 getStreamer().EmitAssignment(Symbol, Value);
1148 getStreamer().EmitThumbFunc(Symbol);
1149 getStreamer().EmitAssignment(Symbol, Value);
1152 void ARMTargetELFStreamer::emitInst(
uint32_t Inst,
char Suffix) {
1153 getStreamer().emitInst(Inst, Suffix);
1156 void ARMTargetELFStreamer::reset() { AttributeSection =
nullptr; }
1158 void ARMELFStreamer::FinishImpl() {
1163 MCELFStreamer::FinishImpl();
1166 void ARMELFStreamer::reset() {
1170 MappingSymbolCounter = 0;
1171 MCELFStreamer::reset();
1189 if (FnSecName !=
".text") {
1190 EHSecName += FnSecName;
1198 EHSecName, Type, Flags, 0, Group, FnSection.
getUniqueID(),
1201 assert(EHSection &&
"Failed to get the required EH section");
1204 SwitchSection(EHSection);
1205 EmitCodeAlignment(4);
1208 inline void ARMELFStreamer::SwitchToExTabSection(
const MCSymbol &FnStart) {
1210 SectionKind::getData(), FnStart);
1213 inline void ARMELFStreamer::SwitchToExIdxSection(
const MCSymbol &FnStart) {
1216 SectionKind::getData(), FnStart);
1225 void ARMELFStreamer::EHReset() {
1228 Personality =
nullptr;
1238 UnwindOpAsm.Reset();
1241 void ARMELFStreamer::emitFnStart() {
1242 assert(FnStart ==
nullptr);
1243 FnStart = getContext().createTempSymbol();
1247 void ARMELFStreamer::emitFnEnd() {
1248 assert(FnStart &&
".fnstart must precedes .fnend");
1251 if (!ExTab && !CantUnwind)
1252 FlushUnwindOpcodes(
true);
1255 SwitchToExIdxSection(*FnStart);
1261 MCSymbolRefExpr::create(FnStart,
1262 MCSymbolRefExpr::VK_ARM_PREL31,
1265 EmitValue(FnStartRef, 4);
1272 MCSymbolRefExpr::create(ExTab,
1273 MCSymbolRefExpr::VK_ARM_PREL31,
1275 EmitValue(ExTabEntryRef, 4);
1281 "Compact model must use __aeabi_unwind_cpp_pr0 as personality");
1283 "Unwind opcode size for __aeabi_unwind_cpp_pr0 must be equal to 4");
1284 uint64_t Intval = Opcodes[0] |
1288 EmitIntValue(Intval, Opcodes.
size());
1298 void ARMELFStreamer::emitCantUnwind() { CantUnwind =
true; }
1301 void ARMELFStreamer::EmitPersonalityFixup(
StringRef Name) {
1302 const MCSymbol *PersonalitySym = getContext().getOrCreateSymbol(Name);
1305 PersonalitySym, MCSymbolRefExpr::VK_ARM_NONE, getContext());
1307 visitUsedExpr(*PersonalityRef);
1311 MCFixup::getKindForSize(4,
false)));
1314 void ARMELFStreamer::FlushPendingOffset() {
1315 if (PendingOffset != 0) {
1316 UnwindOpAsm.EmitSPOffset(-PendingOffset);
1321 void ARMELFStreamer::FlushUnwindOpcodes(
bool NoHandlerData) {
1325 int64_t LastRegSaveSPOffset = SPOffset - PendingOffset;
1326 UnwindOpAsm.EmitSPOffset(LastRegSaveSPOffset - FPOffset);
1329 FlushPendingOffset();
1333 UnwindOpAsm.Finalize(PersonalityIndex, Opcodes);
1342 SwitchToExTabSection(*FnStart);
1346 ExTab = getContext().createTempSymbol();
1352 MCSymbolRefExpr::create(Personality,
1353 MCSymbolRefExpr::VK_ARM_PREL31,
1356 EmitValue(PersonalityRef, 4);
1361 "Unwind opcode size for __aeabi_cpp_unwind_pr0 must be multiple of 4");
1362 for (
unsigned I = 0;
I != Opcodes.
size();
I += 4) {
1363 uint64_t Intval = Opcodes[
I] |
1364 Opcodes[
I + 1] << 8 |
1365 Opcodes[
I + 2] << 16 |
1366 Opcodes[
I + 3] << 24;
1367 EmitIntValue(Intval, 4);
1377 if (NoHandlerData && !Personality)
1381 void ARMELFStreamer::emitHandlerData() { FlushUnwindOpcodes(
false); }
1383 void ARMELFStreamer::emitPersonality(
const MCSymbol *Per) {
1385 UnwindOpAsm.setPersonality(Per);
1388 void ARMELFStreamer::emitPersonalityIndex(
unsigned Index) {
1390 PersonalityIndex = Index;
1393 void ARMELFStreamer::emitSetFP(
unsigned NewFPReg,
unsigned NewSPReg,
1395 assert((NewSPReg == ARM::SP || NewSPReg == FPReg) &&
1396 "the operand of .setfp directive should be either $sp or $fp");
1401 if (NewSPReg == ARM::SP)
1402 FPOffset = SPOffset +
Offset;
1407 void ARMELFStreamer::emitMovSP(
unsigned Reg, int64_t Offset) {
1408 assert((Reg != ARM::SP && Reg != ARM::PC) &&
1409 "the operand of .movsp cannot be either sp or pc");
1410 assert(FPReg == ARM::SP &&
"current FP must be SP");
1412 FlushPendingOffset();
1415 FPOffset = SPOffset +
Offset;
1421 void ARMELFStreamer::emitPad(int64_t Offset) {
1436 for (
size_t i = 0; i < RegList.
size(); ++i) {
1438 assert(Reg < (IsVector ? 32U : 16U) &&
"Register out of range");
1439 unsigned Bit = (1u <<
Reg);
1440 if ((Mask & Bit) == 0) {
1450 SPOffset -= Count * (IsVector ? 8 : 4);
1453 FlushPendingOffset();
1455 UnwindOpAsm.EmitVFPRegSave(Mask);
1457 UnwindOpAsm.EmitRegSave(Mask);
1460 void ARMELFStreamer::emitUnwindRaw(int64_t Offset,
1462 FlushPendingOffset();
1463 SPOffset = SPOffset -
Offset;
1464 UnwindOpAsm.EmitRaw(Opcodes);
1472 bool isVerboseAsm) {
1473 return new ARMTargetAsmStreamer(S, OS, *InstPrint, isVerboseAsm);
1484 return new ARMTargetELFStreamer(S);
1492 ARMELFStreamer *S =
new ARMELFStreamer(Context, TAB, OS, Emitter, IsThumb);
1499 S->getAssembler().setRelaxAll(
true);
void setIsThumbFunc(const MCSymbol *Func)
Flag a function symbol as the target of a .thumb_func directive.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
virtual void emitInst(uint32_t Inst, char Suffix= '\0')
MCELFStreamer * createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll, bool IsThumb)
virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE)
virtual void emitFPU(unsigned FPU)
const MCAsmInfo * getAsmInfo() const
StringRef getSectionName() const
void EmitBytes(StringRef Data) override
Emit the bytes in Data into the output.
const MCSymbol & getSymbol() const
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
void reset() override
state management
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Target specific streamer interface.
virtual void emitPad(int64_t Offset)
unsigned getUniqueID() const
virtual void finishAttributeSection()
StringRef getArchExtName(unsigned ArchExtKind)
virtual void emitPersonality(const MCSymbol *Personality)
StringRef getFPUName(unsigned FPUKind)
unsigned getArchAttr(unsigned ArchKind)
virtual void reset()
Reset any state between object emissions, i.e.
virtual void emitPersonalityIndex(unsigned Index)
MCFragment * getCurrentFragment() const
StringRef getArchName(unsigned ArchKind)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
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.
Reg
All possible values of the reg field in the ModR/M byte.
Represent a reference to a symbol from inside an expression.
virtual void emitLabel(MCSymbol *Symbol)
MCContext & getContext() const
bool isLittleEndian() const
True if the target is little endian.
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).
.code16 (X86) / .code 16 (ARM)
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.
const MCSymbolELF * getGroup() const
virtual void emitMovSP(unsigned Reg, int64_t Offset=0)
void setExternal(bool Value) const
virtual void emitCantUnwind()
Special entry for the function never unwind.
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.
virtual void emitAttribute(unsigned Attribute, unsigned Value)
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)
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.
virtual void emitRegSave(const SmallVectorImpl< unsigned > &RegList, bool isVector)
unsigned const MachineRegisterInfo * MRI
The instances of the Type class are immutable: once they are created, they are never changed...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value)
MCAssembler & getAssembler()
virtual void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset=0)
MCCodeEmitter - Generic instruction encoding interface.
virtual void emitObjectArch(unsigned Arch)
MCFixupKind
Extensible enumeration to represent the type of a fixup.
SmallVectorImpl< MCFixup > & getFixups()
virtual void emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl< uint8_t > &Opcodes)
void reportError(SMLoc L, const Twine &Msg)
.subsections_via_symbols (MachO)
SectionKind - This is a simple POD value that classifies the properties of a section.
void setOffset(uint64_t Value)
static wasm::ValType getType(const TargetRegisterClass *RC)
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.
virtual void emitFnStart()
MCStreamer & getStreamer()
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)
bool isDefined(bool SetUsed=true) const
isDefined - Check if this symbol is defined (i.e., it has an address).
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
MCSection & getSection(bool SetUsed=true) const
Get the section associated with a defined, non-absolute symbol.
.code32 (X86) / .code 32 (ARM)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
static std::vector< std::string > Flags
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
StringRef getCPUAttr(unsigned ArchKind)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
StringRef getName() const
getName - Get the symbol name.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
.type _foo, STT_FUNC # aka
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue="")
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MCSubtargetInfo - Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
const Triple & getTargetTriple() const
getTargetTriple - Return the target triple string.
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
static std::string utohexstr(uint64_t X, bool LowerCase=false)
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
An abstract base class for streams implementations that also support a pwrite operation.
Fragment for data and encoded instructions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCTargetStreamer * createARMNullTargetStreamer(MCStreamer &S)
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
virtual void emitHandlerData()
LLVM Value Representation.
Generic interface to target specific assembler backends.
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.
virtual void emitArch(unsigned Arch)
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())
static std::string GetAEABIUnwindPersonalityName(unsigned Index)
Represents a location in source code.
void FinishImpl() override
Streamer specific finalization.
LLVM_NODISCARD std::string lower() const
MCDataFragment * getOrCreateDataFragment()
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment...
virtual void switchVendor(StringRef Vendor)
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool=false) override
Emit the given Instruction into the current section.
virtual void emitTextAttribute(unsigned Attribute, StringRef String)