[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 15 04:35:37 PST 2025
================
@@ -7806,6 +7815,267 @@ bool AArch64AsmParser::parseDirectiveSEHSaveAnyReg(SMLoc L, bool Paired,
return false;
}
+bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) {
+ // Expecting 3 AsmToken::Identifier after '.aeabi_subsection', a name and 2
+ // parameters, e.g.: .aeabi_subsection (1)aeabi_feature_and_bits, (2)optional,
+ // (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;
+ if (Parser.getTok().is(AsmToken::Identifier)) {
+ SubsectionName = Parser.getTok().getIdentifier();
+ SubsectionNameID = AArch64BuildAttributes::getVendorID(SubsectionName);
+ } else {
+ Error(Parser.getTok().getLoc(), "subsection name not found");
+ return true;
+ }
+ Parser.Lex();
+ // consume a comma
+ // parseComma() return *false* on success, and call Lex(), no need to call
+ // Lex() again.
+ if (Parser.parseComma()) {
+ return true;
+ }
+
+ // Consume the first parameter (optionality parameter)
+ AArch64BuildAttributes::SubsectionOptional IsOptional;
+ // options: optional/required
+ if (Parser.getTok().is(AsmToken::Identifier)) {
+ StringRef Optionality = Parser.getTok().getIdentifier();
+ IsOptional = AArch64BuildAttributes::getOptionalID(Optionality);
+ if (AArch64BuildAttributes::OPTIONAL_NOT_FOUND == IsOptional) {
+ Error(Parser.getTok().getLoc(),
+ AArch64BuildAttributes::getSubsectionOptionalUnknownError() + ": " +
+ Optionality);
+ return true;
+ }
+ if (HasActiveSubsection &&
----------------
ostannard wrote:
This won't catch mis-matches with unknown subsection names which are not currently active. For example:
```
.aeabi_subsection foo, optional, uleb128
.aeabi_subsection bar, optional, uleb128
.aeabi_subsection foo, required, uleb128 // should be error, subsection `foo` was previously defined as optional
```
https://github.com/llvm/llvm-project/pull/118771
More information about the llvm-commits
mailing list