49 lines · cpp
1//===-- AArch64AttributeParser.cpp - AArch64 Build Attributes PArser------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with4// LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===---------------------------------------------------------------------===//9 10#include "llvm/Support/AArch64AttributeParser.h"11#include "llvm/Support/AArch64BuildAttributes.h"12 13std::vector<llvm::SubsectionAndTagToTagName> &14llvm::AArch64AttributeParser::returnTagsNamesMap() {15 static std::vector<SubsectionAndTagToTagName> TagsNamesMap = {16 {"aeabi_pauthabi", 1, "Tag_PAuth_Platform"},17 {"aeabi_pauthabi", 2, "Tag_PAuth_Schema"},18 {"aeabi_feature_and_bits", 0, "Tag_Feature_BTI"},19 {"aeabi_feature_and_bits", 1, "Tag_Feature_PAC"},20 {"aeabi_feature_and_bits", 2, "Tag_Feature_GCS"}};21 return TagsNamesMap;22}23 24llvm::AArch64BuildAttrSubsections llvm::extractBuildAttributesSubsections(25 const llvm::AArch64AttributeParser &Attributes) {26 27 llvm::AArch64BuildAttrSubsections SubSections;28 auto GetPauthValue = [&Attributes](unsigned Tag) {29 return Attributes.getAttributeValue("aeabi_pauthabi", Tag).value_or(0);30 };31 SubSections.Pauth.TagPlatform =32 GetPauthValue(llvm::AArch64BuildAttributes::TAG_PAUTH_PLATFORM);33 SubSections.Pauth.TagSchema =34 GetPauthValue(llvm::AArch64BuildAttributes::TAG_PAUTH_SCHEMA);35 36 auto GetFeatureValue = [&Attributes](unsigned Tag) {37 return Attributes.getAttributeValue("aeabi_feature_and_bits", Tag)38 .value_or(0);39 };40 SubSections.AndFeatures |=41 GetFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_BTI);42 SubSections.AndFeatures |=43 GetFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_PAC) << 1;44 SubSections.AndFeatures |=45 GetFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_GCS) << 2;46 47 return SubSections;48}49