| 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 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/Support/AArch64BuildAttributes.h" |
| 10 | #include "llvm/ADT/StringSwitch.h" |
| 11 | |
| 12 | using namespace llvm; |
| 13 | using namespace llvm::AArch64BuildAttributes; |
| 14 | |
| 15 | StringRef AArch64BuildAttributes::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 "" ; |
| 26 | } |
| 27 | } |
| 28 | VendorID AArch64BuildAttributes::getVendorID(StringRef Vendor) { |
| 29 | return StringSwitch<VendorID>(Vendor) |
| 30 | .Case(S: "aeabi_feature_and_bits" , Value: AEABI_FEATURE_AND_BITS) |
| 31 | .Case(S: "aeabi_pauthabi" , Value: AEABI_PAUTHABI) |
| 32 | .Default(Value: VENDOR_UNKNOWN); |
| 33 | } |
| 34 | |
| 35 | StringRef AArch64BuildAttributes::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 "" ; |
| 44 | } |
| 45 | } |
| 46 | SubsectionOptional AArch64BuildAttributes::getOptionalID(StringRef Optional) { |
| 47 | return StringSwitch<SubsectionOptional>(Optional) |
| 48 | .Case(S: "required" , Value: REQUIRED) |
| 49 | .Case(S: "optional" , Value: OPTIONAL) |
| 50 | .Default(Value: OPTIONAL_NOT_FOUND); |
| 51 | } |
| 52 | StringRef AArch64BuildAttributes::getSubsectionOptionalUnknownError() { |
| 53 | return "unknown AArch64 build attributes optionality, expected " |
| 54 | "required|optional" ; |
| 55 | } |
| 56 | |
| 57 | StringRef AArch64BuildAttributes::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 "" ; |
| 66 | } |
| 67 | } |
| 68 | SubsectionType AArch64BuildAttributes::getTypeID(StringRef Type) { |
| 69 | return StringSwitch<SubsectionType>(Type) |
| 70 | .Cases(S0: "uleb128" , S1: "ULEB128" , Value: ULEB128) |
| 71 | .Cases(S0: "ntbs" , S1: "NTBS" , Value: NTBS) |
| 72 | .Default(Value: TYPE_NOT_FOUND); |
| 73 | } |
| 74 | StringRef AArch64BuildAttributes::getSubsectionTypeUnknownError() { |
| 75 | return "unknown AArch64 build attributes type, expected uleb128|ntbs" ; |
| 76 | } |
| 77 | |
| 78 | StringRef AArch64BuildAttributes::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 "" ; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | PauthABITags AArch64BuildAttributes::getPauthABITagsID(StringRef PauthABITag) { |
| 91 | return StringSwitch<PauthABITags>(PauthABITag) |
| 92 | .Case(S: "Tag_PAuth_Platform" , Value: TAG_PAUTH_PLATFORM) |
| 93 | .Case(S: "Tag_PAuth_Schema" , Value: TAG_PAUTH_SCHEMA) |
| 94 | .Default(Value: PAUTHABI_TAG_NOT_FOUND); |
| 95 | } |
| 96 | |
| 97 | StringRef |
| 98 | AArch64BuildAttributes::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 "" ; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | FeatureAndBitsTags |
| 113 | AArch64BuildAttributes::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) { |
| 114 | return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag) |
| 115 | .Case(S: "Tag_Feature_BTI" , Value: TAG_FEATURE_BTI) |
| 116 | .Case(S: "Tag_Feature_PAC" , Value: TAG_FEATURE_PAC) |
| 117 | .Case(S: "Tag_Feature_GCS" , Value: TAG_FEATURE_GCS) |
| 118 | .Default(Value: FEATURE_AND_BITS_TAG_NOT_FOUND); |
| 119 | } |
| 120 | |