-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[LLVM][Clang][AArch64] Implement AArch64 build attributes #118771
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a10af46
[LLVM][Clang][AArch64] Implement AArch64 build attributes
sivan-shani c1c4c46
Formatting
sivan-shani 8bc5b42
Fixing according to some comments:
sivan-shani 6e09e35
Add test files
sivan-shani 3450b35
Add Asm parsing
sivan-shani b323e83
Formatting
sivan-shani 4505446
add llvm test files
sivan-shani e86ca8d
Merge branch 'main' into AArch64Buildattributes
sivan-shani f4f1b1b
format
sivan-shani b651b3c
fix small bug
sivan-shani 7cde215
Fix a bug
sivan-shani 07b1f74
format
sivan-shani 06215d9
- add llvm-mc test files
sivan-shani 3b9f53e
- Fixed according to comments above
sivan-shani a09c731
- remove unused variables and includes
sivan-shani 22bee6f
Add support for private subsections, add tests for type NTBS
sivan-shani 56f496b
fix string attr for elf + test
sivan-shani 5082f08
fix spelling, add required test cases, remove unused, improve getting…
sivan-shani 85819a6
fix according to comments
sivan-shani 0fde842
Add AArch64BuildAttributes.cpp to lib/Support/BUILD.gn
sivan-shani 330cb79
fix according to comments above
sivan-shani 1535a88
fix error in a test file
sivan-shani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//===-- AArch64BuildAttributes.h - AARch64 Build Attributes -----*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file contains enumerations and support routines for AArch64 build | ||
// attributes as defined in Build Attributes for the AArch64 document. | ||
// | ||
// Build Attributes for the Arm® 64-bit Architecture (AArch64) 2024Q1 | ||
// | ||
// https://github.com/ARM-software/abi-aa/pull/230 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_SUPPORT_AARCH64BUILDATTRIBUTES_H | ||
#define LLVM_SUPPORT_AARCH64BUILDATTRIBUTES_H | ||
|
||
#include "llvm/ADT/StringRef.h" | ||
|
||
namespace llvm { | ||
|
||
namespace AArch64BuildAttributes { | ||
|
||
/// AArch64 build attributes vendors IDs (a.k.a subsection name) | ||
enum VendorID : unsigned { | ||
AEABI_FEATURE_AND_BITS = 0, | ||
AEABI_PAUTHABI = 1, | ||
VENDOR_UNKNOWN = 404 // Treated as a private subsection name | ||
}; | ||
StringRef getVendorName(unsigned const Vendor); | ||
VendorID getVendorID(StringRef const Vendor); | ||
|
||
enum SubsectionOptional : unsigned { | ||
REQUIRED = 0, | ||
OPTIONAL = 1, | ||
OPTIONAL_NOT_FOUND = 404 | ||
}; | ||
StringRef getOptionalStr(unsigned Optional); | ||
SubsectionOptional getOptionalID(StringRef Optional); | ||
StringRef getSubsectionOptionalUnknownError(); | ||
|
||
enum SubsectionType : unsigned { ULEB128 = 0, NTBS = 1, TYPE_NOT_FOUND = 404 }; | ||
StringRef getTypeStr(unsigned Type); | ||
SubsectionType getTypeID(StringRef Type); | ||
StringRef getSubsectionTypeUnknownError(); | ||
|
||
enum PauthABITags : unsigned { | ||
TAG_PAUTH_PLATFORM = 1, | ||
TAG_PAUTH_SCHEMA = 2, | ||
PAUTHABI_TAG_NOT_FOUND = 404 | ||
}; | ||
StringRef getPauthABITagsStr(unsigned PauthABITag); | ||
PauthABITags getPauthABITagsID(StringRef PauthABITag); | ||
|
||
enum FeatureAndBitsTags : unsigned { | ||
TAG_FEATURE_BTI = 0, | ||
TAG_FEATURE_PAC = 1, | ||
TAG_FEATURE_GCS = 2, | ||
FEATURE_AND_BITS_TAG_NOT_FOUND = 404 | ||
}; | ||
StringRef getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag); | ||
FeatureAndBitsTags getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag); | ||
|
||
enum FeatureAndBitsFlag : unsigned { | ||
Feature_BTI_Flag = 1 << 0, | ||
Feature_PAC_Flag = 1 << 1, | ||
Feature_GCS_Flag = 1 << 2 | ||
}; | ||
} // namespace AArch64BuildAttributes | ||
} // namespace llvm | ||
|
||
#endif // LLVM_SUPPORT_AARCH64BUILDATTRIBUTES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
//===-- AArch64BuildAttributes.cpp - AArch64 Build Attributes -------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "llvm/Support/AArch64BuildAttributes.h" | ||
#include "llvm/ADT/StringSwitch.h" | ||
|
||
namespace llvm { | ||
namespace AArch64BuildAttributes { | ||
|
||
StringRef getVendorName(unsigned Vendor) { | ||
switch (Vendor) { | ||
case AEABI_FEATURE_AND_BITS: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These switch statements will need updating every time a new enum value is added, so I don't think the |
||
return "aeabi_feature_and_bits"; | ||
case AEABI_PAUTHABI: | ||
return "aeabi_pauthabi"; | ||
case VENDOR_UNKNOWN: | ||
return ""; | ||
default: | ||
assert(0 && "Vendor name error"); | ||
return ""; | ||
} | ||
} | ||
VendorID 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 getOptionalStr(unsigned Optional) { | ||
switch (Optional) { | ||
case REQUIRED: | ||
return "required"; | ||
case OPTIONAL: | ||
return "optional"; | ||
case OPTIONAL_NOT_FOUND: | ||
default: | ||
return ""; | ||
} | ||
} | ||
SubsectionOptional getOptionalID(StringRef Optional) { | ||
return StringSwitch<SubsectionOptional>(Optional) | ||
.Case("required", REQUIRED) | ||
.Case("optional", OPTIONAL) | ||
.Default(OPTIONAL_NOT_FOUND); | ||
} | ||
StringRef getSubsectionOptionalUnknownError() { | ||
return "unknown AArch64 build attributes optionality, expected " | ||
"required|optional"; | ||
} | ||
|
||
StringRef getTypeStr(unsigned Type) { | ||
switch (Type) { | ||
case ULEB128: | ||
return "uleb128"; | ||
case NTBS: | ||
return "ntbs"; | ||
case TYPE_NOT_FOUND: | ||
default: | ||
return ""; | ||
} | ||
} | ||
SubsectionType getTypeID(StringRef Type) { | ||
return StringSwitch<SubsectionType>(Type) | ||
.Cases("uleb128", "ULEB128", ULEB128) | ||
.Cases("ntbs", "NTBS", NTBS) | ||
.Default(TYPE_NOT_FOUND); | ||
} | ||
StringRef getSubsectionTypeUnknownError() { | ||
return "unknown AArch64 build attributes type, expected uleb128|ntbs"; | ||
} | ||
|
||
StringRef getPauthABITagsStr(unsigned PauthABITag) { | ||
switch (PauthABITag) { | ||
case TAG_PAUTH_PLATFORM: | ||
return "Tag_PAuth_Platform"; | ||
case TAG_PAUTH_SCHEMA: | ||
return "Tag_PAuth_Schema"; | ||
case PAUTHABI_TAG_NOT_FOUND: | ||
default: | ||
return ""; | ||
} | ||
} | ||
PauthABITags 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 getFeatureAndBitsTagsStr(unsigned FeatureAndBitsTag) { | ||
switch (FeatureAndBitsTag) { | ||
case TAG_FEATURE_BTI: | ||
return "Tag_Feature_BTI"; | ||
case TAG_FEATURE_PAC: | ||
return "Tag_Feature_PAC"; | ||
case TAG_FEATURE_GCS: | ||
return "Tag_Feature_GCS"; | ||
case FEATURE_AND_BITS_TAG_NOT_FOUND: | ||
default: | ||
return ""; | ||
} | ||
} | ||
FeatureAndBitsTags getFeatureAndBitsTagsID(StringRef FeatureAndBitsTag) { | ||
return StringSwitch<FeatureAndBitsTags>(FeatureAndBitsTag) | ||
.Case("Tag_Feature_BTI", TAG_FEATURE_BTI) | ||
.Case("Tag_Feature_PAC", TAG_FEATURE_PAC) | ||
.Case("Tag_Feature_GCS", TAG_FEATURE_GCS) | ||
.Default(FEATURE_AND_BITS_TAG_NOT_FOUND); | ||
} | ||
} // namespace AArch64BuildAttributes | ||
} // namespace llvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ARM we have ARMBuildAttrs. Should this be shortened to AArch64BuildAttrs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That indeed will be more consistent, on the other hand, Attributes is more descriptive than Attrs, so perhaps changing ARMBuildAttrs to ARMBuildAttributes instead will give both the benefit of consistency and of clarity?
Other files use Attributes as well, and not Attrs (for example: ELFAttributes.cpp, ELFAttributeParser.cpp, HexagonAttributes.cpp, HexagonAttributeParser.cpp, CSKYAttributes.cpp, CSKYAttributeParser.cpp, MSP430Attributes.cpp, MSP430AttributeParser.cpp)
While 'attrs' does not seems to be used elsewhere.
Correction: the files names indeed does not use 'Attrs' but the names inside them does.
Not sure why I was fixated on the files names.
Will change AArch64 accordingly to match.