Path: blob/main/contrib/llvm-project/llvm/lib/Support/AArch64BuildAttributes.cpp
213765 views
//===-- AArch64BuildAttributes.cpp - AArch64 Build Attributes -------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/Support/AArch64BuildAttributes.h"9#include "llvm/ADT/StringSwitch.h"1011using namespace llvm;12using namespace llvm::AArch64BuildAttributes;1314StringRef AArch64BuildAttributes::getVendorName(unsigned Vendor) {15switch (Vendor) {16case AEABI_FEATURE_AND_BITS:17return "aeabi_feature_and_bits";18case AEABI_PAUTHABI:19return "aeabi_pauthabi";20case VENDOR_UNKNOWN:21return "";22default:23assert(0 && "Vendor name error");24return "";25}26}27VendorID AArch64BuildAttributes::getVendorID(StringRef Vendor) {28return StringSwitch<VendorID>(Vendor)29.Case("aeabi_feature_and_bits", AEABI_FEATURE_AND_BITS)30.Case("aeabi_pauthabi", AEABI_PAUTHABI)31.Default(VENDOR_UNKNOWN);32}3334StringRef AArch64BuildAttributes::getOptionalStr(unsigned Optional) {35switch (Optional) {36case REQUIRED:37return "required";38case OPTIONAL:39return "optional";40case OPTIONAL_NOT_FOUND:41default:42return "";43}44}45SubsectionOptional AArch64BuildAttributes::getOptionalID(StringRef Optional) {46return StringSwitch<SubsectionOptional>(Optional)47.Case("required", REQUIRED)48.Case("optional", OPTIONAL)49.Default(OPTIONAL_NOT_FOUND);50}51StringRef AArch64BuildAttributes::getSubsectionOptionalUnknownError() {52return "unknown AArch64 build attributes optionality, expected "53"required|optional";54}5556StringRef AArch64BuildAttributes::getTypeStr(unsigned Type) {57switch (Type) {58case ULEB128:59return "uleb128";60case NTBS:61return "ntbs";62case TYPE_NOT_FOUND:63default:64return "";65}66}67SubsectionType AArch64BuildAttributes::getTypeID(StringRef Type) {68return StringSwitch<SubsectionType>(Type)69.Cases("uleb128", "ULEB128", ULEB128)70.Cases("ntbs", "NTBS", NTBS)71.Default(TYPE_NOT_FOUND);72}73StringRef AArch64BuildAttributes::getSubsectionTypeUnknownError() {74return "unknown AArch64 build attributes type, expected uleb128|ntbs";75}7677StringRef AArch64BuildAttributes::getPauthABITagsStr(unsigned PauthABITag) {78switch (PauthABITag) {79case TAG_PAUTH_PLATFORM:80return "Tag_PAuth_Platform";81case TAG_PAUTH_SCHEMA:82return "Tag_PAuth_Schema";83case PAUTHABI_TAG_NOT_FOUND:84default:85return "";86}87}8889PauthABITags AArch64BuildAttributes::getPauthABITagsID(StringRef PauthABITag) {90return 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}9596StringRef97AArch64BuildAttributes::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {98switch (FeatureAndBitsTag) {99case TAG_FEATURE_BTI:100return "Tag_Feature_BTI";101case TAG_FEATURE_PAC:102return "Tag_Feature_PAC";103case TAG_FEATURE_GCS:104return "Tag_Feature_GCS";105case FEATURE_AND_BITS_TAG_NOT_FOUND:106default:107return "";108}109}110111FeatureAndBitsTags112AArch64BuildAttributes::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) {113return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag)114.Case("Tag_Feature_BTI", TAG_FEATURE_BTI)115.Case("Tag_Feature_PAC", TAG_FEATURE_PAC)116.Case("Tag_Feature_GCS", TAG_FEATURE_GCS)117.Default(FEATURE_AND_BITS_TAG_NOT_FOUND);118}119120121