Skip to content

Commit de4bbbf

Browse files
authored
[Build Attributes] Standardize names according to convention. (llvm#124556)
The de-facto convention for build attributes file and class names seems to be 'Attrs' in the class name and 'Attributes' in the file name. Accordingly, change file ARMBuildAttrs.cpp -> ARMBuildAttributes.cpp And class AArch64BuildAttrs --> AArch64BuildAttributes
1 parent 9c92824 commit de4bbbf

File tree

9 files changed

+118
-134
lines changed

9 files changed

+118
-134
lines changed

llvm/include/llvm/Support/AArch64BuildAttributes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace llvm {
2424

25-
namespace AArch64BuildAttributes {
25+
namespace AArch64BuildAttrs {
2626

2727
/// AArch64 build attributes vendors IDs (a.k.a subsection name)
2828
enum VendorID : unsigned {
@@ -69,7 +69,7 @@ enum FeatureAndBitsFlag : unsigned {
6969
Feature_PAC_Flag = 1 << 1,
7070
Feature_GCS_Flag = 1 << 2
7171
};
72-
} // namespace AArch64BuildAttributes
72+
} // namespace AArch64BuildAttrs
7373
} // namespace llvm
7474

7575
#endif // LLVM_SUPPORT_AARCH64BUILDATTRIBUTES_H

llvm/lib/Support/AArch64BuildAttributes.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
#include "llvm/ADT/StringSwitch.h"
1111

1212
using namespace llvm;
13-
using namespace llvm::AArch64BuildAttributes;
13+
using namespace llvm::AArch64BuildAttrs;
1414

15-
StringRef AArch64BuildAttributes::getVendorName(unsigned Vendor) {
15+
StringRef AArch64BuildAttrs::getVendorName(unsigned Vendor) {
1616
switch (Vendor) {
1717
case AEABI_FEATURE_AND_BITS:
1818
return "aeabi_feature_and_bits";
@@ -25,14 +25,14 @@ StringRef AArch64BuildAttributes::getVendorName(unsigned Vendor) {
2525
return "";
2626
}
2727
}
28-
VendorID AArch64BuildAttributes::getVendorID(StringRef Vendor) {
28+
VendorID AArch64BuildAttrs::getVendorID(StringRef Vendor) {
2929
return StringSwitch<VendorID>(Vendor)
3030
.Case("aeabi_feature_and_bits", AEABI_FEATURE_AND_BITS)
3131
.Case("aeabi_pauthabi", AEABI_PAUTHABI)
3232
.Default(VENDOR_UNKNOWN);
3333
}
3434

35-
StringRef AArch64BuildAttributes::getOptionalStr(unsigned Optional) {
35+
StringRef AArch64BuildAttrs::getOptionalStr(unsigned Optional) {
3636
switch (Optional) {
3737
case REQUIRED:
3838
return "required";
@@ -43,18 +43,18 @@ StringRef AArch64BuildAttributes::getOptionalStr(unsigned Optional) {
4343
return "";
4444
}
4545
}
46-
SubsectionOptional AArch64BuildAttributes::getOptionalID(StringRef Optional) {
46+
SubsectionOptional AArch64BuildAttrs::getOptionalID(StringRef Optional) {
4747
return StringSwitch<SubsectionOptional>(Optional)
4848
.Case("required", REQUIRED)
4949
.Case("optional", OPTIONAL)
5050
.Default(OPTIONAL_NOT_FOUND);
5151
}
52-
StringRef AArch64BuildAttributes::getSubsectionOptionalUnknownError() {
52+
StringRef AArch64BuildAttrs::getSubsectionOptionalUnknownError() {
5353
return "unknown AArch64 build attributes optionality, expected "
5454
"required|optional";
5555
}
5656

57-
StringRef AArch64BuildAttributes::getTypeStr(unsigned Type) {
57+
StringRef AArch64BuildAttrs::getTypeStr(unsigned Type) {
5858
switch (Type) {
5959
case ULEB128:
6060
return "uleb128";
@@ -65,17 +65,17 @@ StringRef AArch64BuildAttributes::getTypeStr(unsigned Type) {
6565
return "";
6666
}
6767
}
68-
SubsectionType AArch64BuildAttributes::getTypeID(StringRef Type) {
68+
SubsectionType AArch64BuildAttrs::getTypeID(StringRef Type) {
6969
return StringSwitch<SubsectionType>(Type)
7070
.Cases("uleb128", "ULEB128", ULEB128)
7171
.Cases("ntbs", "NTBS", NTBS)
7272
.Default(TYPE_NOT_FOUND);
7373
}
74-
StringRef AArch64BuildAttributes::getSubsectionTypeUnknownError() {
74+
StringRef AArch64BuildAttrs::getSubsectionTypeUnknownError() {
7575
return "unknown AArch64 build attributes type, expected uleb128|ntbs";
7676
}
7777

78-
StringRef AArch64BuildAttributes::getPauthABITagsStr(unsigned PauthABITag) {
78+
StringRef AArch64BuildAttrs::getPauthABITagsStr(unsigned PauthABITag) {
7979
switch (PauthABITag) {
8080
case TAG_PAUTH_PLATFORM:
8181
return "Tag_PAuth_Platform";
@@ -87,15 +87,15 @@ StringRef AArch64BuildAttributes::getPauthABITagsStr(unsigned PauthABITag) {
8787
}
8888
}
8989

90-
PauthABITags AArch64BuildAttributes::getPauthABITagsID(StringRef PauthABITag) {
90+
PauthABITags AArch64BuildAttrs::getPauthABITagsID(StringRef PauthABITag) {
9191
return StringSwitch<PauthABITags>(PauthABITag)
9292
.Case("Tag_PAuth_Platform", TAG_PAUTH_PLATFORM)
9393
.Case("Tag_PAuth_Schema", TAG_PAUTH_SCHEMA)
9494
.Default(PAUTHABI_TAG_NOT_FOUND);
9595
}
9696

9797
StringRef
98-
AArch64BuildAttributes::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
98+
AArch64BuildAttrs::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
9999
switch (FeatureAndBitsTag) {
100100
case TAG_FEATURE_BTI:
101101
return "Tag_Feature_BTI";
@@ -110,7 +110,7 @@ AArch64BuildAttributes::getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) {
110110
}
111111

112112
FeatureAndBitsTags
113-
AArch64BuildAttributes::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) {
113+
AArch64BuildAttrs::getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) {
114114
return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag)
115115
.Case("Tag_Feature_BTI", TAG_FEATURE_BTI)
116116
.Case("Tag_Feature_PAC", TAG_FEATURE_PAC)

llvm/lib/Support/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ add_llvm_component_library(LLVMSupport
143143
APFloat.cpp
144144
APInt.cpp
145145
APSInt.cpp
146-
ARMBuildAttrs.cpp
146+
ARMBuildAttributes.cpp
147147
AArch64BuildAttributes.cpp
148148
ARMAttributeParser.cpp
149149
ARMWinEH.cpp

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -359,23 +359,23 @@ void AArch64AsmPrinter::emitStartOfAsmFile(Module &M) {
359359
if (const auto *BTE = mdconst::extract_or_null<ConstantInt>(
360360
M.getModuleFlag("branch-target-enforcement"))) {
361361
if (!BTE->isZero()) {
362-
BAFlags |= AArch64BuildAttributes::FeatureAndBitsFlag::Feature_BTI_Flag;
362+
BAFlags |= AArch64BuildAttrs::FeatureAndBitsFlag::Feature_BTI_Flag;
363363
GNUFlags |= ELF::GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
364364
}
365365
}
366366

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

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

479479
if (PAuthABIPlatform || PAuthABIVersion) {
480480
TS->emitAtributesSubsection(
481-
AArch64BuildAttributes::getVendorName(
482-
AArch64BuildAttributes::AEABI_PAUTHABI),
483-
AArch64BuildAttributes::SubsectionOptional::REQUIRED,
484-
AArch64BuildAttributes::SubsectionType::ULEB128);
485-
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
486-
AArch64BuildAttributes::AEABI_PAUTHABI),
487-
AArch64BuildAttributes::TAG_PAUTH_PLATFORM,
488-
PAuthABIPlatform, "", false);
489-
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
490-
AArch64BuildAttributes::AEABI_PAUTHABI),
491-
AArch64BuildAttributes::TAG_PAUTH_SCHEMA, PAuthABIVersion,
492-
"", false);
493-
}
494-
495-
unsigned BTIValue =
496-
(Flags & AArch64BuildAttributes::Feature_BTI_Flag) ? 1 : 0;
497-
unsigned PACValue =
498-
(Flags & AArch64BuildAttributes::Feature_PAC_Flag) ? 1 : 0;
499-
unsigned GCSValue =
500-
(Flags & AArch64BuildAttributes::Feature_GCS_Flag) ? 1 : 0;
481+
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
482+
AArch64BuildAttrs::SubsectionOptional::REQUIRED,
483+
AArch64BuildAttrs::SubsectionType::ULEB128);
484+
TS->emitAttribute(
485+
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
486+
AArch64BuildAttrs::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "", false);
487+
TS->emitAttribute(
488+
AArch64BuildAttrs::getVendorName(AArch64BuildAttrs::AEABI_PAUTHABI),
489+
AArch64BuildAttrs::TAG_PAUTH_SCHEMA, PAuthABIVersion, "", false);
490+
}
491+
492+
unsigned BTIValue = (Flags & AArch64BuildAttrs::Feature_BTI_Flag) ? 1 : 0;
493+
unsigned PACValue = (Flags & AArch64BuildAttrs::Feature_PAC_Flag) ? 1 : 0;
494+
unsigned GCSValue = (Flags & AArch64BuildAttrs::Feature_GCS_Flag) ? 1 : 0;
501495

502496
if (BTIValue || PACValue || GCSValue) {
503-
TS->emitAtributesSubsection(
504-
AArch64BuildAttributes::getVendorName(
505-
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
506-
AArch64BuildAttributes::SubsectionOptional::OPTIONAL,
507-
AArch64BuildAttributes::SubsectionType::ULEB128);
508-
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
509-
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
510-
AArch64BuildAttributes::TAG_FEATURE_BTI, BTIValue, "",
511-
false);
512-
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
513-
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
514-
AArch64BuildAttributes::TAG_FEATURE_PAC, PACValue, "",
515-
false);
516-
TS->emitAttribute(AArch64BuildAttributes::getVendorName(
517-
AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
518-
AArch64BuildAttributes::TAG_FEATURE_GCS, GCSValue, "",
519-
false);
497+
TS->emitAtributesSubsection(AArch64BuildAttrs::getVendorName(
498+
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
499+
AArch64BuildAttrs::SubsectionOptional::OPTIONAL,
500+
AArch64BuildAttrs::SubsectionType::ULEB128);
501+
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
502+
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
503+
AArch64BuildAttrs::TAG_FEATURE_BTI, BTIValue, "", false);
504+
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
505+
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
506+
AArch64BuildAttrs::TAG_FEATURE_PAC, PACValue, "", false);
507+
TS->emitAttribute(AArch64BuildAttrs::getVendorName(
508+
AArch64BuildAttrs::AEABI_FEATURE_AND_BITS),
509+
AArch64BuildAttrs::TAG_FEATURE_GCS, GCSValue, "", false);
520510
}
521511
}
522512

0 commit comments

Comments
 (0)