26 #define ATTRIBUTE_HANDLER(Attr_) \ 27 { ARMBuildAttrs::Attr_, &ARMAttributeParser::Attr_ } 29 const ARMAttributeParser::DisplayHandler
30 ARMAttributeParser::DisplayRoutines[] = {
72 #undef ATTRIBUTE_HANDLER 74 uint64_t ARMAttributeParser::ParseInteger(
const uint8_t *
Data,
76 unsigned DecodeLength;
78 Offset += DecodeLength;
82 StringRef ARMAttributeParser::ParseString(
const uint8_t *Data,
84 const char *String =
reinterpret_cast<const char*
>(Data +
Offset);
85 size_t Length = std::strlen(String);
86 Offset = Offset + Length + 1;
90 void ARMAttributeParser::IntegerAttribute(
AttrType Tag,
const uint8_t *Data,
93 uint64_t
Value = ParseInteger(Data, Offset);
94 Attributes.insert(std::make_pair(Tag, Value));
100 void ARMAttributeParser::StringAttribute(
AttrType Tag,
const uint8_t *Data,
103 StringRef ValueDesc = ParseString(Data, Offset);
107 SW->printNumber(
"Tag", Tag);
108 if (!TagName.
empty())
109 SW->printString(
"TagName", TagName);
110 SW->printString(
"Value", ValueDesc);
114 void ARMAttributeParser::PrintAttribute(
unsigned Tag,
unsigned Value,
116 Attributes.insert(std::make_pair(Tag, Value));
122 SW->printNumber(
"Tag", Tag);
123 SW->printNumber(
"Value", Value);
124 if (!TagName.
empty())
125 SW->printString(
"TagName", TagName);
126 if (!ValueDesc.
empty())
127 SW->printString(
"Description", ValueDesc);
131 void ARMAttributeParser::CPU_arch(
AttrType Tag,
const uint8_t *Data,
133 static const char *
const Strings[] = {
134 "Pre-v4",
"ARM v4",
"ARM v4T",
"ARM v5T",
"ARM v5TE",
"ARM v5TEJ",
"ARM v6",
135 "ARM v6KZ",
"ARM v6T2",
"ARM v6K",
"ARM v7",
"ARM v6-M",
"ARM v6S-M",
136 "ARM v7E-M",
"ARM v8",
nullptr,
137 "ARM v8-M Baseline",
"ARM v8-M Mainline",
nullptr,
nullptr,
nullptr,
138 "ARM v8.1-M Mainline" 141 uint64_t Value = ParseInteger(Data, Offset);
144 PrintAttribute(Tag, Value, ValueDesc);
147 void ARMAttributeParser::CPU_arch_profile(
AttrType Tag,
const uint8_t *Data,
149 uint64_t Encoded = ParseInteger(Data, Offset);
153 default: Profile =
"Unknown";
break;
154 case 'A': Profile =
"Application";
break;
155 case 'R': Profile =
"Real-time";
break;
156 case 'M': Profile =
"Microcontroller";
break;
157 case 'S': Profile =
"Classic";
break;
158 case 0: Profile =
"None";
break;
161 PrintAttribute(Tag, Encoded, Profile);
164 void ARMAttributeParser::ARM_ISA_use(
AttrType Tag,
const uint8_t *Data,
166 static const char *
const Strings[] = {
"Not Permitted",
"Permitted" };
168 uint64_t Value = ParseInteger(Data, Offset);
171 PrintAttribute(Tag, Value, ValueDesc);
174 void ARMAttributeParser::THUMB_ISA_use(
AttrType Tag,
const uint8_t *Data,
176 static const char *
const Strings[] = {
"Not Permitted",
"Thumb-1",
"Thumb-2" };
178 uint64_t Value = ParseInteger(Data, Offset);
181 PrintAttribute(Tag, Value, ValueDesc);
184 void ARMAttributeParser::FP_arch(
AttrType Tag,
const uint8_t *Data,
186 static const char *
const Strings[] = {
187 "Not Permitted",
"VFPv1",
"VFPv2",
"VFPv3",
"VFPv3-D16",
"VFPv4",
188 "VFPv4-D16",
"ARMv8-a FP",
"ARMv8-a FP-D16" 191 uint64_t Value = ParseInteger(Data, Offset);
194 PrintAttribute(Tag, Value, ValueDesc);
197 void ARMAttributeParser::WMMX_arch(
AttrType Tag,
const uint8_t *Data,
199 static const char *
const Strings[] = {
"Not Permitted",
"WMMXv1",
"WMMXv2" };
201 uint64_t Value = ParseInteger(Data, Offset);
204 PrintAttribute(Tag, Value, ValueDesc);
207 void ARMAttributeParser::Advanced_SIMD_arch(
AttrType Tag,
const uint8_t *Data,
209 static const char *
const Strings[] = {
210 "Not Permitted",
"NEONv1",
"NEONv2+FMA",
"ARMv8-a NEON",
"ARMv8.1-a NEON" 213 uint64_t Value = ParseInteger(Data, Offset);
216 PrintAttribute(Tag, Value, ValueDesc);
219 void ARMAttributeParser::MVE_arch(
AttrType Tag,
const uint8_t *Data,
221 static const char *
const Strings[] = {
222 "Not Permitted",
"MVE integer",
"MVE integer and float" 225 uint64_t Value = ParseInteger(Data, Offset);
228 PrintAttribute(Tag, Value, ValueDesc);
231 void ARMAttributeParser::PCS_config(
AttrType Tag,
const uint8_t *Data,
233 static const char *
const Strings[] = {
234 "None",
"Bare Platform",
"Linux Application",
"Linux DSO",
"Palm OS 2004",
235 "Reserved (Palm OS)",
"Symbian OS 2004",
"Reserved (Symbian OS)" 238 uint64_t Value = ParseInteger(Data, Offset);
241 PrintAttribute(Tag, Value, ValueDesc);
244 void ARMAttributeParser::ABI_PCS_R9_use(
AttrType Tag,
const uint8_t *Data,
246 static const char *
const Strings[] = {
"v6",
"Static Base",
"TLS",
"Unused" };
248 uint64_t Value = ParseInteger(Data, Offset);
251 PrintAttribute(Tag, Value, ValueDesc);
254 void ARMAttributeParser::ABI_PCS_RW_data(
AttrType Tag,
const uint8_t *Data,
256 static const char *
const Strings[] = {
257 "Absolute",
"PC-relative",
"SB-relative",
"Not Permitted" 260 uint64_t Value = ParseInteger(Data, Offset);
263 PrintAttribute(Tag, Value, ValueDesc);
266 void ARMAttributeParser::ABI_PCS_RO_data(
AttrType Tag,
const uint8_t *Data,
268 static const char *
const Strings[] = {
269 "Absolute",
"PC-relative",
"Not Permitted" 272 uint64_t Value = ParseInteger(Data, Offset);
275 PrintAttribute(Tag, Value, ValueDesc);
278 void ARMAttributeParser::ABI_PCS_GOT_use(
AttrType Tag,
const uint8_t *Data,
280 static const char *
const Strings[] = {
281 "Not Permitted",
"Direct",
"GOT-Indirect" 284 uint64_t Value = ParseInteger(Data, Offset);
287 PrintAttribute(Tag, Value, ValueDesc);
290 void ARMAttributeParser::ABI_PCS_wchar_t(
AttrType Tag,
const uint8_t *Data,
292 static const char *
const Strings[] = {
293 "Not Permitted",
"Unknown",
"2-byte",
"Unknown",
"4-byte" 296 uint64_t Value = ParseInteger(Data, Offset);
299 PrintAttribute(Tag, Value, ValueDesc);
302 void ARMAttributeParser::ABI_FP_rounding(
AttrType Tag,
const uint8_t *Data,
304 static const char *
const Strings[] = {
"IEEE-754",
"Runtime" };
306 uint64_t Value = ParseInteger(Data, Offset);
309 PrintAttribute(Tag, Value, ValueDesc);
312 void ARMAttributeParser::ABI_FP_denormal(
AttrType Tag,
const uint8_t *Data,
314 static const char *
const Strings[] = {
315 "Unsupported",
"IEEE-754",
"Sign Only" 318 uint64_t Value = ParseInteger(Data, Offset);
321 PrintAttribute(Tag, Value, ValueDesc);
324 void ARMAttributeParser::ABI_FP_exceptions(
AttrType Tag,
const uint8_t *Data,
326 static const char *
const Strings[] = {
"Not Permitted",
"IEEE-754" };
328 uint64_t Value = ParseInteger(Data, Offset);
331 PrintAttribute(Tag, Value, ValueDesc);
334 void ARMAttributeParser::ABI_FP_user_exceptions(
AttrType Tag,
337 static const char *
const Strings[] = {
"Not Permitted",
"IEEE-754" };
339 uint64_t Value = ParseInteger(Data, Offset);
342 PrintAttribute(Tag, Value, ValueDesc);
345 void ARMAttributeParser::ABI_FP_number_model(
AttrType Tag,
const uint8_t *Data,
347 static const char *
const Strings[] = {
348 "Not Permitted",
"Finite Only",
"RTABI",
"IEEE-754" 351 uint64_t Value = ParseInteger(Data, Offset);
354 PrintAttribute(Tag, Value, ValueDesc);
357 void ARMAttributeParser::ABI_align_needed(
AttrType Tag,
const uint8_t *Data,
359 static const char *
const Strings[] = {
360 "Not Permitted",
"8-byte alignment",
"4-byte alignment",
"Reserved" 363 uint64_t Value = ParseInteger(Data, Offset);
365 std::string Description;
367 Description = std::string(Strings[Value]);
368 else if (Value <= 12)
369 Description = std::string(
"8-byte alignment, ") +
utostr(1ULL << Value)
370 + std::string(
"-byte extended alignment");
372 Description =
"Invalid";
374 PrintAttribute(Tag, Value, Description);
377 void ARMAttributeParser::ABI_align_preserved(
AttrType Tag,
const uint8_t *Data,
379 static const char *
const Strings[] = {
380 "Not Required",
"8-byte data alignment",
"8-byte data and code alignment",
384 uint64_t Value = ParseInteger(Data, Offset);
386 std::string Description;
388 Description = std::string(Strings[Value]);
389 else if (Value <= 12)
390 Description = std::string(
"8-byte stack alignment, ") +
391 utostr(1ULL << Value) + std::string(
"-byte data alignment");
393 Description =
"Invalid";
395 PrintAttribute(Tag, Value, Description);
398 void ARMAttributeParser::ABI_enum_size(
AttrType Tag,
const uint8_t *Data,
400 static const char *
const Strings[] = {
401 "Not Permitted",
"Packed",
"Int32",
"External Int32" 404 uint64_t Value = ParseInteger(Data, Offset);
407 PrintAttribute(Tag, Value, ValueDesc);
410 void ARMAttributeParser::ABI_HardFP_use(
AttrType Tag,
const uint8_t *Data,
412 static const char *
const Strings[] = {
413 "Tag_FP_arch",
"Single-Precision",
"Reserved",
"Tag_FP_arch (deprecated)" 416 uint64_t Value = ParseInteger(Data, Offset);
419 PrintAttribute(Tag, Value, ValueDesc);
422 void ARMAttributeParser::ABI_VFP_args(
AttrType Tag,
const uint8_t *Data,
424 static const char *
const Strings[] = {
425 "AAPCS",
"AAPCS VFP",
"Custom",
"Not Permitted" 428 uint64_t Value = ParseInteger(Data, Offset);
431 PrintAttribute(Tag, Value, ValueDesc);
434 void ARMAttributeParser::ABI_WMMX_args(
AttrType Tag,
const uint8_t *Data,
436 static const char *
const Strings[] = {
"AAPCS",
"iWMMX",
"Custom" };
438 uint64_t Value = ParseInteger(Data, Offset);
441 PrintAttribute(Tag, Value, ValueDesc);
444 void ARMAttributeParser::ABI_optimization_goals(
AttrType Tag,
447 static const char *
const Strings[] = {
448 "None",
"Speed",
"Aggressive Speed",
"Size",
"Aggressive Size",
"Debugging",
452 uint64_t Value = ParseInteger(Data, Offset);
455 PrintAttribute(Tag, Value, ValueDesc);
458 void ARMAttributeParser::ABI_FP_optimization_goals(
AttrType Tag,
461 static const char *
const Strings[] = {
462 "None",
"Speed",
"Aggressive Speed",
"Size",
"Aggressive Size",
"Accuracy",
466 uint64_t Value = ParseInteger(Data, Offset);
469 PrintAttribute(Tag, Value, ValueDesc);
472 void ARMAttributeParser::compatibility(
AttrType Tag,
const uint8_t *Data,
474 uint64_t
Integer = ParseInteger(Data, Offset);
475 StringRef String = ParseString(Data, Offset);
479 SW->printNumber(
"Tag", Tag);
480 SW->startLine() <<
"Value: " << Integer <<
", " << String <<
'\n';
484 SW->printString(
"Description",
StringRef(
"No Specific Requirements"));
487 SW->printString(
"Description",
StringRef(
"AEABI Conformant"));
490 SW->printString(
"Description",
StringRef(
"AEABI Non-Conformant"));
496 void ARMAttributeParser::CPU_unaligned_access(
AttrType Tag,
const uint8_t *Data,
498 static const char *
const Strings[] = {
"Not Permitted",
"v6-style" };
500 uint64_t Value = ParseInteger(Data, Offset);
503 PrintAttribute(Tag, Value, ValueDesc);
506 void ARMAttributeParser::FP_HP_extension(
AttrType Tag,
const uint8_t *Data,
508 static const char *
const Strings[] = {
"If Available",
"Permitted" };
510 uint64_t Value = ParseInteger(Data, Offset);
513 PrintAttribute(Tag, Value, ValueDesc);
516 void ARMAttributeParser::ABI_FP_16bit_format(
AttrType Tag,
const uint8_t *Data,
518 static const char *
const Strings[] = {
"Not Permitted",
"IEEE-754",
"VFPv3" };
520 uint64_t Value = ParseInteger(Data, Offset);
523 PrintAttribute(Tag, Value, ValueDesc);
526 void ARMAttributeParser::MPextension_use(
AttrType Tag,
const uint8_t *Data,
528 static const char *
const Strings[] = {
"Not Permitted",
"Permitted" };
530 uint64_t Value = ParseInteger(Data, Offset);
533 PrintAttribute(Tag, Value, ValueDesc);
536 void ARMAttributeParser::DIV_use(
AttrType Tag,
const uint8_t *Data,
538 static const char *
const Strings[] = {
539 "If Available",
"Not Permitted",
"Permitted" 542 uint64_t Value = ParseInteger(Data, Offset);
545 PrintAttribute(Tag, Value, ValueDesc);
548 void ARMAttributeParser::DSP_extension(
AttrType Tag,
const uint8_t *Data,
550 static const char *
const Strings[] = {
"Not Permitted",
"Permitted" };
552 uint64_t Value = ParseInteger(Data, Offset);
555 PrintAttribute(Tag, Value, ValueDesc);
558 void ARMAttributeParser::T2EE_use(
AttrType Tag,
const uint8_t *Data,
560 static const char *
const Strings[] = {
"Not Permitted",
"Permitted" };
562 uint64_t Value = ParseInteger(Data, Offset);
565 PrintAttribute(Tag, Value, ValueDesc);
568 void ARMAttributeParser::Virtualization_use(
AttrType Tag,
const uint8_t *Data,
570 static const char *
const Strings[] = {
571 "Not Permitted",
"TrustZone",
"Virtualization Extensions",
572 "TrustZone + Virtualization Extensions" 575 uint64_t Value = ParseInteger(Data, Offset);
578 PrintAttribute(Tag, Value, ValueDesc);
581 void ARMAttributeParser::nodefaults(
AttrType Tag,
const uint8_t *Data,
583 uint64_t Value = ParseInteger(Data, Offset);
584 PrintAttribute(Tag, Value,
"Unspecified Tags UNDEFINED");
587 void ARMAttributeParser::ParseIndexList(
const uint8_t *Data,
uint32_t &Offset,
590 unsigned DecodeLength;
591 uint64_t Value =
decodeULEB128(Data + Offset, &DecodeLength);
592 Offset += DecodeLength;
599 void ARMAttributeParser::ParseAttributeList(
const uint8_t *Data,
601 while (Offset < Length) {
602 unsigned DecodeLength;
604 Offset += DecodeLength;
606 bool Handled =
false;
608 AHI != AHE && !Handled; ++AHI) {
609 if (uint64_t(DisplayRoutines[AHI].
Attribute) == Tag) {
618 errs() <<
"unhandled AEABI Tag " << Tag
631 void ARMAttributeParser::ParseSubsection(
const uint8_t *Data,
uint32_t Length) {
634 const char *VendorName =
reinterpret_cast<const char*
>(Data +
Offset);
635 size_t VendorNameLength = std::strlen(VendorName);
636 Offset = Offset + VendorNameLength + 1;
639 SW->printNumber(
"SectionLength", Length);
640 SW->printString(
"Vendor",
StringRef(VendorName, VendorNameLength));
643 if (
StringRef(VendorName, VendorNameLength).lower() !=
"aeabi") {
647 while (Offset < Length) {
649 uint8_t Tag = Data[
Offset];
650 Offset = Offset +
sizeof(Tag);
654 Offset = Offset +
sizeof(
Size);
658 SW->printNumber(
"Size", Size);
662 errs() <<
"subsection length greater than section length\n";
670 ScopeName =
"FileAttributes";
673 ScopeName =
"SectionAttributes";
674 IndexName =
"Sections";
675 ParseIndexList(Data, Offset, Indicies);
678 ScopeName =
"SymbolAttributes";
679 IndexName =
"Symbols";
680 ParseIndexList(Data, Offset, Indicies);
689 if (!Indicies.
empty())
690 SW->printList(IndexName, Indicies);
691 ParseAttributeList(Data, Offset, Length);
693 ParseAttributeList(Data, Offset, Length);
700 unsigned SectionNumber = 0;
702 while (Offset < Section.
size()) {
708 SW->startLine() <<
"Section " << ++SectionNumber <<
" {\n";
712 if (SectionLength == 0 || (SectionLength + Offset) > Section.
size()) {
713 errs() <<
"invalid subsection length " << SectionLength <<
" at offset " 718 ParseSubsection(Section.
data() +
Offset, SectionLength);
719 Offset = Offset + SectionLength;
723 SW->startLine() <<
"}\n";
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class represents lattice values for constants.
#define ATTRIBUTE_HANDLER(Attr_)
void push_back(const T &Elt)
uint32_t read32be(const void *P)
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix=true)
size_t size() const
size - Get the array size.
uint64_t decodeULEB128(const uint8_t *p, unsigned *n=nullptr, const uint8_t *end=nullptr, const char **error=nullptr)
Utility function to decode a ULEB128 value.
static const EnumEntry< unsigned > TagNames[]
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static Twine utohexstr(const uint64_t &Val)
std::string utostr(uint64_t X, bool isNeg=false)
LLVM_NODISCARD bool empty() const
uint32_t read32le(const void *P)
LLVM Value Representation.
void Parse(ArrayRef< uint8_t > Section, bool isLittle)
StringRef - Represent a constant reference to a string, i.e.