| 1 | //===-- AArch64AttributeParser.cpp - AArch64 Build Attributes PArser------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with |
| 4 | // LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===---------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/Support/AArch64AttributeParser.h" |
| 11 | #include "llvm/Support/AArch64BuildAttributes.h" |
| 12 | |
| 13 | std::vector<llvm::SubsectionAndTagToTagName> & |
| 14 | llvm::AArch64AttributeParser::returnTagsNamesMap() { |
| 15 | static std::vector<SubsectionAndTagToTagName> TagsNamesMap = { |
| 16 | {.SubsectionName: "aeabi_pauthabi" , .Tag: 1, .TagName: "Tag_PAuth_Platform" }, |
| 17 | {.SubsectionName: "aeabi_pauthabi" , .Tag: 2, .TagName: "Tag_PAuth_Schema" }, |
| 18 | {.SubsectionName: "aeabi_feature_and_bits" , .Tag: 0, .TagName: "Tag_Feature_BTI" }, |
| 19 | {.SubsectionName: "aeabi_feature_and_bits" , .Tag: 1, .TagName: "Tag_Feature_PAC" }, |
| 20 | {.SubsectionName: "aeabi_feature_and_bits" , .Tag: 2, .TagName: "Tag_Feature_GCS" }}; |
| 21 | return TagsNamesMap; |
| 22 | } |
| 23 | |
| 24 | llvm::AArch64BuildAttrSubsections llvm::( |
| 25 | const llvm::AArch64AttributeParser &Attributes) { |
| 26 | |
| 27 | llvm::AArch64BuildAttrSubsections SubSections; |
| 28 | auto GetPauthValue = [&Attributes](unsigned Tag) { |
| 29 | return Attributes.getAttributeValue(BuildAttrSubsectionName: "aeabi_pauthabi" , Tag).value_or(u: 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(BuildAttrSubsectionName: "aeabi_feature_and_bits" , Tag) |
| 38 | .value_or(u: 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 | |