[clang][bytecode][NFC] Only get expr when checking for UB (#125397)
[llvm-project.git] / llvm / lib / Support / AArch64BuildAttributes.cpp
blobe36667ca711e0354c45f13e54a7242d6a849a295
1 //===-- AArch64BuildAttributes.cpp - AArch64 Build Attributes -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Support/AArch64BuildAttributes.h"
10 #include "llvm/ADT/StringSwitch.h"
12 using namespace llvm;
13 using namespace llvm::AArch64BuildAttrs;
15 StringRef AArch64BuildAttrs::getVendorName(unsigned Vendor) {
16 switch (Vendor) {
17 case AEABI_FEATURE_AND_BITS:
18 return "aeabi_feature_and_bits";
19 case AEABI_PAUTHABI:
20 return "aeabi_pauthabi";
21 case VENDOR_UNKNOWN:
22 return "";
23 default:
24 assert(0 && "Vendor name error");
25 return "";
28 VendorID AArch64BuildAttrs::getVendorID(StringRef Vendor) {
29 return StringSwitch<VendorID>(Vendor)
30 .Case("aeabi_feature_and_bits", AEABI_FEATURE_AND_BITS)
31 .Case("aeabi_pauthabi", AEABI_PAUTHABI)
32 .Default(VENDOR_UNKNOWN);
35 StringRef AArch64BuildAttrs::getOptionalStr(unsigned Optional) {
36 switch (Optional) {
37 case REQUIRED:
38 return "required";
39 case OPTIONAL:
40 return "optional";
41 case OPTIONAL_NOT_FOUND:
42 default:
43 return "";
46 SubsectionOptional AArch64BuildAttrs::getOptionalID(StringRef Optional) {
47 return StringSwitch<SubsectionOptional>(Optional)
48 .Case("required", REQUIRED)
49 .Case("optional", OPTIONAL)
50 .Default(OPTIONAL_NOT_FOUND);
52 StringRef AArch64BuildAttrs::getSubsectionOptionalUnknownError() {
53 return "unknown AArch64 build attributes optionality, expected "
54 "required|optional";
57 StringRef AArch64BuildAttrs::getTypeStr(unsigned Type) {
58 switch (Type) {
59 case ULEB128:
60 return "uleb128";
61 case NTBS:
62 return "ntbs";
63 case TYPE_NOT_FOUND:
64 default:
65 return "";
68 SubsectionType AArch64BuildAttrs::getTypeID(StringRef Type) {
69 return StringSwitch<SubsectionType>(Type)
70 .Cases("uleb128", "ULEB128", ULEB128)
71 .Cases("ntbs", "NTBS", NTBS)
72 .Default(TYPE_NOT_FOUND);
74 StringRef AArch64BuildAttrs::getSubsectionTypeUnknownError() {
75 return "unknown AArch64 build attributes type, expected uleb128|ntbs";
78 StringRef AArch64BuildAttrs::getPauthABITagsStr(unsigned PauthABITag) {
79 switch (PauthABITag) {
80 case TAG_PAUTH_PLATFORM:
81 return "Tag_PAuth_Platform";
82 case TAG_PAUTH_SCHEMA:
83 return "Tag_PAuth_Schema";
84 case PAUTHABI_TAG_NOT_FOUND:
85 default:
86 return "";
90 PauthABITags AArch64BuildAttrs::getPauthABITagsID(StringRef PauthABITag) {
91 return StringSwitch<PauthABITags>(PauthABITag)
92 .Case("Tag_PAuth_Platform", TAG_PAUTH_PLATFORM)
93 .Case("Tag_PAuth_Schema", TAG_PAUTH_SCHEMA)
94 .Default(PAUTHABI_TAG_NOT_FOUND);
97 StringRef
98 AArch64BuildAttrs::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
99 switch (FeatureAndBitsTag) {
100 case TAG_FEATURE_BTI:
101 return "Tag_Feature_BTI";
102 case TAG_FEATURE_PAC:
103 return "Tag_Feature_PAC";
104 case TAG_FEATURE_GCS:
105 return "Tag_Feature_GCS";
106 case FEATURE_AND_BITS_TAG_NOT_FOUND:
107 default:
108 return "";
112 FeatureAndBitsTags
113 AArch64BuildAttrs::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) {
114 return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag)
115 .Case("Tag_Feature_BTI", TAG_FEATURE_BTI)
116 .Case("Tag_Feature_PAC", TAG_FEATURE_PAC)
117 .Case("Tag_Feature_GCS", TAG_FEATURE_GCS)
118 .Default(FEATURE_AND_BITS_TAG_NOT_FOUND);