-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLVM][Clang][AArch64] Implement AArch64 build attributes #118771
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
Changes from 1 commit
a10af46
c1c4c46
8bc5b42
6e09e35
3450b35
b323e83
4505446
e86ca8d
f4f1b1b
b651b3c
7cde215
07b1f74
06215d9
3b9f53e
a09c731
22bee6f
56f496b
5082f08
85819a6
0fde842
330cb79
1535a88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7821,13 +7821,6 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { | |
| // (3)uleb128 separated by 2 commas. | ||
| MCAsmParser &Parser = getParser(); | ||
|
|
||
| bool HasActiveSubsection = true; | ||
| std::unique_ptr<MCELFStreamer::AttributeSubSection> ActiveSubsection = | ||
| getTargetStreamer().getActiveAtributesSubsection(); | ||
| if (nullptr == ActiveSubsection) { | ||
| HasActiveSubsection = false; | ||
| } | ||
|
|
||
| // Consume the name (subsection name) | ||
| StringRef SubsectionName; | ||
| AArch64BuildAttributes::VendorID SubsectionNameID; | ||
|
|
@@ -7846,6 +7839,13 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { | |
| return true; | ||
| } | ||
|
|
||
| bool SubsectionExists = true; | ||
| std::unique_ptr<MCELFStreamer::AttributeSubSection> ExistingSubsection = | ||
| getTargetStreamer().getActiveSubsectionByName(SubsectionName); | ||
| if (nullptr == ExistingSubsection) { | ||
| SubsectionExists = false; | ||
| } | ||
|
|
||
| // Consume the first parameter (optionality parameter) | ||
| AArch64BuildAttributes::SubsectionOptional IsOptional; | ||
| // options: optional/required | ||
|
|
@@ -7858,20 +7858,19 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { | |
| Optionality); | ||
| return true; | ||
| } | ||
| if (HasActiveSubsection && | ||
| (SubsectionName == ActiveSubsection->VendorName)) { | ||
| if (IsOptional != ActiveSubsection->IsOptional) { | ||
| if (SubsectionExists) { | ||
| if (IsOptional != ExistingSubsection->IsOptional) { | ||
| Error(Parser.getTok().getLoc(), | ||
| "optionality mismatch! subsection '" + SubsectionName + | ||
| "' already exists with optionality defined as '" + | ||
| Twine(ActiveSubsection->IsOptional) + "' and not '" + | ||
| Twine(ExistingSubsection->IsOptional) + "' and not '" + | ||
| Twine(IsOptional) + "' (0: required, 1: optional)"); | ||
|
||
| return true; | ||
| } | ||
| } | ||
| } else { | ||
| Error(Parser.getTok().getLoc(), | ||
| "optionality parameter not found, expected required|optinal"); | ||
| "optionality parameter not found, expected required|optional"); | ||
| return true; | ||
| } | ||
| // Check for possible IsOptional unaccepted values for known subsections | ||
|
|
@@ -7906,13 +7905,12 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) { | |
| Name); | ||
| return true; | ||
| } | ||
| if (HasActiveSubsection && | ||
| (SubsectionName == ActiveSubsection->VendorName)) { | ||
| if (Type != ActiveSubsection->ParameterType) { | ||
| if (SubsectionExists) { | ||
| if (Type != ExistingSubsection->ParameterType) { | ||
| Error(Parser.getTok().getLoc(), | ||
| "type mismatch! subsection '" + SubsectionName + | ||
| "' already exists with type defined as '" + | ||
| Twine(ActiveSubsection->ParameterType) + "' and not '" + | ||
| Twine(ExistingSubsection->ParameterType) + "' and not '" + | ||
| Twine(Type) + "' (0: uleb128, 1: ntbs)"); | ||
| return true; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,9 +189,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { | |
| Override); | ||
| break; | ||
| case AArch64BuildAttributes::TAG_FEATURE_BTI: | ||
| LLVM_FALLTHROUGH; | ||
| case AArch64BuildAttributes::TAG_FEATURE_GCS: | ||
| LLVM_FALLTHROUGH; | ||
| case AArch64BuildAttributes::TAG_FEATURE_PAC: | ||
| OS << "\t.aeabi_attribute" << "\t" | ||
| << AArch64BuildAttributes::getFeatureAndBitsTagsStr(Tag) << ", " | ||
|
|
@@ -212,7 +210,6 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { | |
| Override); | ||
| break; | ||
| case AArch64BuildAttributes::TAG_PAUTH_PLATFORM: | ||
|
Collaborator
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. Again, can these be folded together? |
||
| LLVM_FALLTHROUGH; | ||
| case AArch64BuildAttributes::TAG_PAUTH_SCHEMA: | ||
| OS << "\t.aeabi_attribute" << "\t" | ||
| << AArch64BuildAttributes::getPauthABITagsStr(Tag) << ", " << Value; | ||
|
|
@@ -246,16 +243,7 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { | |
|
|
||
| switch (SubsectionID) { | ||
| default: { | ||
| assert(0 && "Subsection error"); | ||
| break; | ||
| } | ||
| case AArch64BuildAttributes::VENDOR_UNKNOWN: { | ||
| // Keep the data structure consistent with the case of ELF emission | ||
| // (important for llvm-mc asm parsing) | ||
| OS << "\t" << SubsectionTag << "\t" << SubsectionName << ", " | ||
| << OptionalStr << ", " << ParameterStr; | ||
| AArch64TargetStreamer::emitAtributesSubsection(SubsectionName, Optional, | ||
| ParameterType); | ||
| // Treated as a private subsection | ||
| break; | ||
| } | ||
| case AArch64BuildAttributes::AEABI_PAUTHABI: { | ||
|
|
@@ -265,10 +253,6 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { | |
| assert(AArch64BuildAttributes::ULEB128 == ParameterType && | ||
| "subsection .aeabi-pauthabi should be " | ||
| "marked as uleb128 and not as ntbs"); | ||
| OS << "\t" << SubsectionTag << "\t" << SubsectionName << ", " | ||
| << OptionalStr << ", " << ParameterStr; | ||
| AArch64TargetStreamer::emitAtributesSubsection(SubsectionName, Optional, | ||
| ParameterType); | ||
| break; | ||
| } | ||
| case AArch64BuildAttributes::AEABI_FEATURE_AND_BITS: { | ||
|
|
@@ -278,13 +262,15 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer { | |
| assert(AArch64BuildAttributes::ULEB128 == ParameterType && | ||
| "subsection .aeabi_feature_and_bits should " | ||
| "be marked as uleb128 and not as ntbs"); | ||
| OS << "\t" << SubsectionTag << "\t" << SubsectionName << ", " | ||
| << OptionalStr << ", " << ParameterStr; | ||
| AArch64TargetStreamer::emitAtributesSubsection(SubsectionName, Optional, | ||
| ParameterType); | ||
| break; | ||
| } | ||
| } | ||
| OS << "\t" << SubsectionTag << "\t" << SubsectionName << ", " << OptionalStr | ||
| << ", " << ParameterStr; | ||
| // Keep the data structure consistent with the case of ELF emission | ||
| // (important for llvm-mc asm parsing) | ||
| AArch64TargetStreamer::emitAtributesSubsection(SubsectionName, Optional, | ||
| ParameterType); | ||
| OS << "\n"; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -182,6 +182,16 @@ AArch64TargetStreamer::getActiveAtributesSubsection() { | |
| return nullptr; | ||
| } | ||
|
|
||
| std::unique_ptr<MCELFStreamer::AttributeSubSection> | ||
| AArch64TargetStreamer::getActiveSubsectionByName(StringRef name) { | ||
|
||
| for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) { | ||
| if (name == SubSection.VendorName) { | ||
| return std::make_unique<MCELFStreamer::AttributeSubSection>(SubSection); | ||
| } | ||
| } | ||
| return nullptr; | ||
| } | ||
|
|
||
| void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, | ||
| unsigned Value, std::string String, | ||
| bool Override) { | ||
|
|
||
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.
You don't need this extra
bool, you can just checkif (ExistingSubsection)below.