Skip to content

[Build Attributes] Standardize names according to convention. #124556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/include/llvm/Support/AArch64BuildAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace llvm {

namespace AArch64BuildAttributes {
namespace AArch64BuildAttrs {

/// AArch64 build attributes vendors IDs (a.k.a subsection name)
enum VendorID : unsigned {
Expand Down Expand Up @@ -69,7 +69,7 @@ enum FeatureAndBitsFlag : unsigned {
Feature_PAC_Flag = 1 << 1,
Feature_GCS_Flag = 1 << 2
};
} // namespace AArch64BuildAttributes
} // namespace AArch64BuildAttrs
} // namespace llvm

#endif // LLVM_SUPPORT_AARCH64BUILDATTRIBUTES_H
26 changes: 13 additions & 13 deletions llvm/lib/Support/AArch64BuildAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "llvm/ADT/StringSwitch.h"

using namespace llvm;
using namespace llvm::AArch64BuildAttributes;
using namespace llvm::AArch64BuildAttrs;

StringRef AArch64BuildAttributes::getVendorName(unsigned Vendor) {
StringRef AArch64BuildAttrs::getVendorName(unsigned Vendor) {
switch (Vendor) {
case AEABI_FEATURE_AND_BITS:
return "aeabi_feature_and_bits";
Expand All @@ -25,14 +25,14 @@ StringRef AArch64BuildAttributes::getVendorName(unsigned Vendor) {
return "";
}
}
VendorID AArch64BuildAttributes::getVendorID(StringRef Vendor) {
VendorID AArch64BuildAttrs::getVendorID(StringRef Vendor) {
return StringSwitch<VendorID>(Vendor)
.Case("aeabi_feature_and_bits", AEABI_FEATURE_AND_BITS)
.Case("aeabi_pauthabi", AEABI_PAUTHABI)
.Default(VENDOR_UNKNOWN);
}

StringRef AArch64BuildAttributes::getOptionalStr(unsigned Optional) {
StringRef AArch64BuildAttrs::getOptionalStr(unsigned Optional) {
switch (Optional) {
case REQUIRED:
return "required";
Expand All @@ -43,18 +43,18 @@ StringRef AArch64BuildAttributes::getOptionalStr(unsigned Optional) {
return "";
}
}
SubsectionOptional AArch64BuildAttributes::getOptionalID(StringRef Optional) {
SubsectionOptional AArch64BuildAttrs::getOptionalID(StringRef Optional) {
return StringSwitch<SubsectionOptional>(Optional)
.Case("required", REQUIRED)
.Case("optional", OPTIONAL)
.Default(OPTIONAL_NOT_FOUND);
}
StringRef AArch64BuildAttributes::getSubsectionOptionalUnknownError() {
StringRef AArch64BuildAttrs::getSubsectionOptionalUnknownError() {
return "unknown AArch64 build attributes optionality, expected "
"required|optional";
}

StringRef AArch64BuildAttributes::getTypeStr(unsigned Type) {
StringRef AArch64BuildAttrs::getTypeStr(unsigned Type) {
switch (Type) {
case ULEB128:
return "uleb128";
Expand All @@ -65,17 +65,17 @@ StringRef AArch64BuildAttributes::getTypeStr(unsigned Type) {
return "";
}
}
SubsectionType AArch64BuildAttributes::getTypeID(StringRef Type) {
SubsectionType AArch64BuildAttrs::getTypeID(StringRef Type) {
return StringSwitch<SubsectionType>(Type)
.Cases("uleb128", "ULEB128", ULEB128)
.Cases("ntbs", "NTBS", NTBS)
.Default(TYPE_NOT_FOUND);
}
StringRef AArch64BuildAttributes::getSubsectionTypeUnknownError() {
StringRef AArch64BuildAttrs::getSubsectionTypeUnknownError() {
return "unknown AArch64 build attributes type, expected uleb128|ntbs";
}

StringRef AArch64BuildAttributes::getPauthABITagsStr(unsigned PauthABITag) {
StringRef AArch64BuildAttrs::getPauthABITagsStr(unsigned PauthABITag) {
switch (PauthABITag) {
case TAG_PAUTH_PLATFORM:
return "Tag_PAuth_Platform";
Expand All @@ -87,15 +87,15 @@ StringRef AArch64BuildAttributes::getPauthABITagsStr(unsigned PauthABITag) {
}
}

PauthABITags AArch64BuildAttributes::getPauthABITagsID(StringRef PauthABITag) {
PauthABITags AArch64BuildAttrs::getPauthABITagsID(StringRef PauthABITag) {
return StringSwitch<PauthABITags>(PauthABITag)
.Case("Tag_PAuth_Platform", TAG_PAUTH_PLATFORM)
.Case("Tag_PAuth_Schema", TAG_PAUTH_SCHEMA)
.Default(PAUTHABI_TAG_NOT_FOUND);
}

StringRef
AArch64BuildAttributes::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
AArch64BuildAttrs::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
switch (FeatureAndBitsTag) {
case TAG_FEATURE_BTI:
return "Tag_Feature_BTI";
Expand All @@ -110,7 +110,7 @@ AArch64BuildAttributes::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
}

FeatureAndBitsTags
AArch64BuildAttributes::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) {
AArch64BuildAttrs::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) {
return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag)
.Case("Tag_Feature_BTI", TAG_FEATURE_BTI)
.Case("Tag_Feature_PAC", TAG_FEATURE_PAC)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ add_llvm_component_library(LLVMSupport
APFloat.cpp
APInt.cpp
APSInt.cpp
ARMBuildAttrs.cpp
ARMBuildAttributes.cpp
AArch64BuildAttributes.cpp
ARMAttributeParser.cpp
ARMWinEH.cpp
Expand Down
70 changes: 30 additions & 40 deletions llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,23 +359,23 @@ void AArch64AsmPrinter::emitStartOfAsmFile(Module &M) {
if (const auto *BTE = mdconst::extract_or_null<ConstantInt>(
M.getModuleFlag("branch-target-enforcement"))) {
if (!BTE->isZero()) {
BAFlags |= AArch64BuildAttributes::FeatureAndBitsFlag::Feature_BTI_Flag;
BAFlags |= AArch64BuildAttrs::FeatureAndBitsFlag::Feature_BTI_Flag;
GNUFlags |= ELF::GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
}
}

if (const auto *GCS = mdconst::extract_or_null<ConstantInt>(
M.getModuleFlag("guarded-control-stack"))) {
if (!GCS->isZero()) {
BAFlags |= AArch64BuildAttributes::FeatureAndBitsFlag::Feature_GCS_Flag;
BAFlags |= AArch64BuildAttrs::FeatureAndBitsFlag::Feature_GCS_Flag;
GNUFlags |= ELF::GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
}
}

if (const auto *Sign = mdconst::extract_or_null<ConstantInt>(
M.getModuleFlag("sign-return-address"))) {
if (!Sign->isZero()) {
BAFlags |= AArch64BuildAttributes::FeatureAndBitsFlag::Feature_PAC_Flag;
BAFlags |= AArch64BuildAttrs::FeatureAndBitsFlag::Feature_PAC_Flag;
GNUFlags |= ELF::GNU_PROPERTY_AARCH64_FEATURE_1_PAC;
}
}
Expand Down Expand Up @@ -478,45 +478,35 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags,

if (PAuthABIPlatform || PAuthABIVersion) {
TS->emitAtributesSubsection(
AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_PAUTHABI),
AArch64BuildAttributes::SubsectionOptional::REQUIRED,
AArch64BuildAttributes::SubsectionType::ULEB128);
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_PAUTHABI),
AArch64BuildAttributes::TAG_PAUTH_PLATFORM,
PAuthABIPlatform, "", false);
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_PAUTHABI),
AArch64BuildAttributes::TAG_PAUTH_SCHEMA, PAuthABIVersion,
"", false);
}

unsigned BTIValue =
(Flags & AArch64BuildAttributes::Feature_BTI_Flag) ? 1 : 0;
unsigned PACValue =
(Flags & AArch64BuildAttributes::Feature_PAC_Flag) ? 1 : 0;
unsigned GCSValue =
(Flags & AArch64BuildAttributes::Feature_GCS_Flag) ? 1 : 0;
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
AArch64BuildAttrs::SubsectionOptional::REQUIRED,
AArch64BuildAttrs::SubsectionType::ULEB128);
TS->emitAttribute(
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "", false);
TS->emitAttribute(
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, "", false);
}

unsigned BTIValue = (Flags & AArch64BuildAttrs::Feature_BTI_Flag) ? 1 : 0;
unsigned PACValue = (Flags & AArch64BuildAttrs::Feature_PAC_Flag) ? 1 : 0;
unsigned GCSValue = (Flags & AArch64BuildAttrs::Feature_GCS_Flag) ? 1 : 0;

if (BTIValue || PACValue || GCSValue) {
TS->emitAtributesSubsection(
AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
AArch64BuildAttributes::SubsectionOptional::OPTIONAL,
AArch64BuildAttributes::SubsectionType::ULEB128);
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
AArch64BuildAttributes::TAG_FEATURE_BTI, BTIValue, "",
false);
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
AArch64BuildAttributes::TAG_FEATURE_PAC, PACValue, "",
false);
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
AArch64BuildAttributes::TAG_FEATURE_GCS, GCSValue, "",
false);
TS->emitAtributesSubsection(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::SubsectionOptional::OPTIONAL,
AArch64BuildAttrs::SubsectionType::ULEB128);
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, "", false);
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, "", false);
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, "", false);
}
}

Expand Down
Loading
Loading