|
| 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 | +namespace llvm { |
| 13 | +namespace AArch64BuildAttributes { |
| 14 | + |
| 15 | +StringRef 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 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); |
| 33 | +} |
| 34 | + |
| 35 | +StringRef 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 getOptionalID(StringRef Optional) { |
| 47 | + return StringSwitch<SubsectionOptional>(Optional) |
| 48 | + .Case("required", REQUIRED) |
| 49 | + .Case("optional", OPTIONAL) |
| 50 | + .Default(OPTIONAL_NOT_FOUND); |
| 51 | +} |
| 52 | +StringRef getSubsectionOptionalUnknownError() { |
| 53 | + return "unknown AArch64 build attributes optionality, expected " |
| 54 | + "required|optional"; |
| 55 | +} |
| 56 | + |
| 57 | +StringRef 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 getTypeID(StringRef Type) { |
| 69 | + return StringSwitch<SubsectionType>(Type) |
| 70 | + .Cases("uleb128", "ULEB128", ULEB128) |
| 71 | + .Cases("ntbs", "NTBS", NTBS) |
| 72 | + .Default(TYPE_NOT_FOUND); |
| 73 | +} |
| 74 | +StringRef getSubsectionTypeUnknownError() { |
| 75 | + return "unknown AArch64 build attributes type, expected uleb128|ntbs"; |
| 76 | +} |
| 77 | + |
| 78 | +StringRef 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 | +PauthABITags getPauthABITagsID(StringRef PauthABITag) { |
| 90 | + return StringSwitch<PauthABITags>(PauthABITag) |
| 91 | + .Case("Tag_PAuth_Platform", TAG_PAUTH_PLATFORM) |
| 92 | + .Case("Tag_PAuth_Schema", TAG_PAUTH_SCHEMA) |
| 93 | + .Default(PAUTHABI_TAG_NOT_FOUND); |
| 94 | +} |
| 95 | + |
| 96 | +StringRef getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) { |
| 97 | + switch (FeatureAndBitsTag) { |
| 98 | + case TAG_FEATURE_BTI: |
| 99 | + return "Tag_Feature_BTI"; |
| 100 | + case TAG_FEATURE_PAC: |
| 101 | + return "Tag_Feature_PAC"; |
| 102 | + case TAG_FEATURE_GCS: |
| 103 | + return "Tag_Feature_GCS"; |
| 104 | + case FEATURE_AND_BITS_TAG_NOT_FOUND: |
| 105 | + default: |
| 106 | + return ""; |
| 107 | + } |
| 108 | +} |
| 109 | +FeatureAndBitsTags getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) { |
| 110 | + return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag) |
| 111 | + .Case("Tag_Feature_BTI", TAG_FEATURE_BTI) |
| 112 | + .Case("Tag_Feature_PAC", TAG_FEATURE_PAC) |
| 113 | + .Case("Tag_Feature_GCS", TAG_FEATURE_GCS) |
| 114 | + .Default(FEATURE_AND_BITS_TAG_NOT_FOUND); |
| 115 | +} |
| 116 | +} // namespace AArch64BuildAttributes |
| 117 | +} // namespace llvm |
0 commit comments