19#define ATTRIBUTE_HANDLER(attr) \
20 { ARMBuildAttrs::attr, &ARMAttributeParser::attr }
22const ARMAttributeParser::DisplayHandler ARMAttributeParser::displayRoutines[] =
70#undef ATTRIBUTE_HANDLER
75 StringRef desc =
de.getCStrRef(
cursor);
78 DictScope scope(*
sw,
"Attribute");
79 sw->printNumber(
"Tag", tag);
81 sw->printString(
"TagName", tagName);
82 sw->printString(
"Value", desc);
108 "ARM v8.1-M Mainline",
116 uint64_t value =
de.getULEB128(
cursor);
120 default: profile =
"Unknown";
break;
121 case 'A': profile =
"Application";
break;
122 case 'R': profile =
"Real-time";
break;
123 case 'M': profile =
"Microcontroller";
break;
124 case 'S': profile =
"Classic";
break;
125 case 0: profile =
"None";
break;
133 static const char *
const strings[] = {
"Not Permitted",
"Permitted"};
138 static const char *
const strings[] = {
"Not Permitted",
"Thumb-1",
"Thumb-2",
144 static const char *
const strings[] = {
145 "Not Permitted",
"VFPv1",
"VFPv2",
"VFPv3",
"VFPv3-D16",
146 "VFPv4",
"VFPv4-D16",
"ARMv8-a FP",
"ARMv8-a FP-D16"};
151 static const char *
const strings[] = {
"Not Permitted",
"WMMXv1",
"WMMXv2"};
156 static const char *
const strings[] = {
"Not Permitted",
"NEONv1",
"NEONv2+FMA",
157 "ARMv8-a NEON",
"ARMv8.1-a NEON"};
162 static const char *
const strings[] = {
"Not Permitted",
"MVE integer",
163 "MVE integer and float"};
168 static const char *
const strings[] = {
"None",
173 "Reserved (Palm OS)",
175 "Reserved (Symbian OS)"};
180 static const char *
const strings[] = {
"v6",
"Static Base",
"TLS",
"Unused"};
185 static const char *
const strings[] = {
"Absolute",
"PC-relative",
186 "SB-relative",
"Not Permitted"};
191 static const char *
const strings[] = {
"Absolute",
"PC-relative",
197 static const char *
const strings[] = {
"Not Permitted",
"Direct",
203 static const char *
const strings[] = {
"Not Permitted",
"Unknown",
"2-byte",
204 "Unknown",
"4-byte"};
209 static const char *
const strings[] = {
"IEEE-754",
"Runtime"};
214 static const char *
const strings[] = {
"Unsupported",
"IEEE-754",
"Sign Only"};
219 static const char *
const strings[] = {
"Not Permitted",
"IEEE-754"};
222Error ARMAttributeParser::ABI_FP_user_exceptions(
AttrType tag) {
223 static const char *
const strings[] = {
"Not Permitted",
"IEEE-754"};
228 static const char *
const strings[] = {
"Not Permitted",
"Finite Only",
"RTABI",
234 static const char *
const strings[] = {
"Not Permitted",
"8-byte alignment",
235 "4-byte alignment",
"Reserved"};
237 uint64_t value =
de.getULEB128(
cursor);
239 std::string description;
240 if (value < std::size(strings))
241 description = strings[value];
242 else if (value <= 12)
243 description =
"8-byte alignment, " +
utostr(1ULL << value) +
244 "-byte extended alignment";
246 description =
"Invalid";
253 static const char *strings[] = {
"Not Required",
"8-byte data alignment",
254 "8-byte data and code alignment",
"Reserved"};
256 uint64_t value =
de.getULEB128(
cursor);
258 std::string description;
259 if (value < std::size(strings))
260 description = std::string(strings[value]);
261 else if (value <= 12)
262 description = std::string(
"8-byte stack alignment, ") +
263 utostr(1ULL << value) + std::string(
"-byte data alignment");
265 description =
"Invalid";
272 static const char *
const strings[] = {
"Not Permitted",
"Packed",
"Int32",
278 static const char *
const strings[] = {
"Tag_FP_arch",
"Single-Precision",
279 "Reserved",
"Tag_FP_arch (deprecated)"};
284 static const char *
const strings[] = {
"AAPCS",
"AAPCS VFP",
"Custom",
290 static const char *
const strings[] = {
"AAPCS",
"iWMMX",
"Custom"};
294Error ARMAttributeParser::ABI_optimization_goals(
AttrType tag) {
295 static const char *
const strings[] = {
296 "None",
"Speed",
"Aggressive Speed",
297 "Size",
"Aggressive Size",
"Debugging",
302Error ARMAttributeParser::ABI_FP_optimization_goals(
AttrType tag) {
303 static const char *
const strings[] = {
304 "None",
"Speed",
"Aggressive Speed",
"Size",
"Aggressive Size",
305 "Accuracy",
"Best Accuracy"};
311 uint64_t integer =
de.getULEB128(
cursor);
312 StringRef
string =
de.getCStrRef(
cursor);
315 DictScope scope(*
sw,
"Attribute");
316 sw->printNumber(
"Tag", tag);
317 sw->startLine() <<
"Value: " << integer <<
", " <<
string <<
'\n';
318 sw->printString(
"TagName",
323 sw->printString(
"Description", StringRef(
"No Specific Requirements"));
326 sw->printString(
"Description", StringRef(
"AEABI Conformant"));
329 sw->printString(
"Description", StringRef(
"AEABI Non-Conformant"));
336Error ARMAttributeParser::CPU_unaligned_access(
AttrType tag) {
337 static const char *
const strings[] = {
"Not Permitted",
"v6-style"};
342 static const char *
const strings[] = {
"If Available",
"Permitted"};
347 static const char *
const strings[] = {
"Not Permitted",
"IEEE-754",
"VFPv3"};
352 static const char *
const strings[] = {
"Not Permitted",
"Permitted"};
357 static const char *
const strings[] = {
"If Available",
"Not Permitted",
363 static const char *
const strings[] = {
"Not Permitted",
"Permitted"};
368 static const char *
const strings[] = {
"Not Permitted",
"Permitted"};
373 static const char *
const strings[] = {
374 "Not Permitted",
"TrustZone",
"Virtualization Extensions",
375 "TrustZone + Virtualization Extensions"};
380 static const char *
const strings[] = {
"Not Permitted",
381 "Permitted in NOP space",
"Permitted"};
386 static const char *
const strings[] = {
"Not Permitted",
387 "Permitted in NOP space",
"Permitted"};
392 static const char *
const strings[] = {
"Not Used",
"Used"};
397 static const char *
const strings[] = {
"Not Used",
"Used"};
402 uint64_t value =
de.getULEB128(
cursor);
407Error ARMAttributeParser::also_compatible_with(
AttrType tag) {
410 std::optional<Error> returnValue;
412 SmallString<8> Description;
413 raw_svector_ostream DescStream(Description);
415 uint64_t InitialOffset =
cursor.tell();
416 StringRef RawStringValue =
de.getCStrRef(
cursor);
417 uint64_t FinalOffset =
cursor.tell();
418 cursor.seek(InitialOffset);
419 uint64_t InnerTag =
de.getULEB128(
cursor);
423 return Item.
attr == InnerTag;
426 if (!ValidInnerTag) {
429 Twine(InnerTag) +
" is not a valid tag number");
433 uint64_t InnerValue =
de.getULEB128(
cursor);
435 if (InnerValue >= strings.size()) {
438 Twine(InnerValue) +
" is not a valid " +
443 <<
" = " << InnerValue;
444 if (strings[InnerValue])
445 DescStream <<
" (" << strings[InnerValue] <<
')';
453 " cannot be recursively defined");
459 StringRef InnerValue =
de.getCStrRef(
cursor);
461 <<
" = " << InnerValue;
465 uint64_t InnerValue =
de.getULEB128(
cursor);
467 <<
" = " << InnerValue;
474 DictScope scope(*
sw,
"Attribute");
475 sw->printNumber(
"Tag", tag);
476 sw->printString(
"TagName",
478 sw->printStringEscaped(
"Value", RawStringValue);
479 if (!Description.
empty()) {
480 sw->printString(
"Description", Description);
486 return returnValue ? std::move(*returnValue) :
Error::
success();
489Error ARMAttributeParser::handler(uint64_t tag,
bool &handled) {
491 for (
const auto &AH : displayRoutines) {
492 if (uint64_t(AH.attribute) == tag) {
493 if (
Error e = (this->*AH.routine)(
static_cast<AttrType>(tag)))
#define ATTRIBUTE_HANDLER(attr)
static const char *const CPU_arch_strings[]
void setAttributeString(unsigned tag, StringRef value)
TagNameMap tagToStringMap
void printAttribute(unsigned tag, unsigned value, StringRef valueDesc)
DataExtractor::Cursor cursor
Error parseStringAttribute(const char *name, unsigned tag, ArrayRef< const char * > strings)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
constexpr bool empty() const
empty - Check if the string is empty.
@ ABI_FP_optimization_goals
LLVM_ABI StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, bool hasTagPrefix=true)
This is an optimization pass for GlobalISel generic memory operations.
std::string utostr(uint64_t X, bool isNeg=false)
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
ArrayRef(const T &OneElt) -> ArrayRef< T >