[llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 01:16:59 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 5d38a3406b11c70e6f0d1a880b78ed404aba2c36 a10af4639c827bd44ff25bd60b820186b5bec74f --extensions cpp,h -- llvm/include/llvm/BinaryFormat/ELF.h llvm/include/llvm/MC/MCELFStreamer.h llvm/include/llvm/Support/ARMBuildAttributes.h llvm/lib/MC/MCELFStreamer.cpp llvm/lib/Support/ARMBuildAttrs.cpp llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h
index 351c7ddd3b..0e37948d3d 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -113,36 +113,46 @@ public:
     // [<uint32: subsection-length> NTBS: vendor-name <bytes: vendor-data>]*
     StringRef Vendor;
     // <uint8: optional> <uint8: parameter type> <attribute>*
-    unsigned IsMandatory;  // SubsectionMandatory::REQUIRED (0), SubsectionMandatory::OPTIONAL (1)
-    unsigned ParameterType; // SubsectionType::ULEB128 (0), SubsectionType::NTBS (1)
+    unsigned IsMandatory; // SubsectionMandatory::REQUIRED (0),
+                          // SubsectionMandatory::OPTIONAL (1)
+    unsigned
+        ParameterType; // SubsectionType::ULEB128 (0), SubsectionType::NTBS (1)
     SmallVector<AttributeItem, 64> Content;
   };
 
   // Attributes that are added and managed entirely by target.
   SmallVector<AttributeItem, 64> Contents;
   void setAttributeItem(unsigned Attribute, unsigned Value,
-                        bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes);
+                        bool OverwriteExisting,
+                        SmallVector<AttributeItem, 64> &Attributes);
   void setAttributeItem(unsigned Attribute, StringRef Value,
-                        bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes);
+                        bool OverwriteExisting,
+                        SmallVector<AttributeItem, 64> &Attributes);
   void setAttributeItems(unsigned Attribute, unsigned IntValue,
-                         StringRef StringValue, bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes);
+                         StringRef StringValue, bool OverwriteExisting,
+                         SmallVector<AttributeItem, 64> &Attributes);
   void emitAttributesSection(StringRef Vendor, const Twine &Section,
                              unsigned Type, MCSection *&AttributeSection) {
     createAttributesSection(Vendor, Section, Type, AttributeSection, Contents);
   }
-  void emitAttributesSection(MCSection *&AttributeSection,
-  const Twine &Section, unsigned Type, SmallVector<AttributeSubSection, 64> &SubSectionVec) {
+  void
+  emitAttributesSection(MCSection *&AttributeSection, const Twine &Section,
+                        unsigned Type,
+                        SmallVector<AttributeSubSection, 64> &SubSectionVec) {
     createAttributesSection(AttributeSection, Section, Type, SubSectionVec);
   }
 
 private:
-  AttributeItem *getAttributeItem(unsigned Attribute, SmallVector<AttributeItem, 64> &Attributes);
+  AttributeItem *getAttributeItem(unsigned Attribute,
+                                  SmallVector<AttributeItem, 64> &Attributes);
   size_t calculateContentSize(SmallVector<AttributeItem, 64> &AttrsVec) const;
   void createAttributesSection(StringRef Vendor, const Twine &Section,
                                unsigned Type, MCSection *&AttributeSection,
                                SmallVector<AttributeItem, 64> &AttrsVec);
-  void createAttributesSection(MCSection *&AttributeSection, const Twine & Section,
-                               unsigned Type, SmallVector<AttributeSubSection, 64> &SubSectionVec);
+  void
+  createAttributesSection(MCSection *&AttributeSection, const Twine &Section,
+                          unsigned Type,
+                          SmallVector<AttributeSubSection, 64> &SubSectionVec);
 
   // GNU attributes that will get emitted at the end of the asm file.
   SmallVector<AttributeItem, 64> GNUAttributes;
diff --git a/llvm/include/llvm/Support/ARMBuildAttributes.h b/llvm/include/llvm/Support/ARMBuildAttributes.h
index 5e17ccf835..788d72977d 100644
--- a/llvm/include/llvm/Support/ARMBuildAttributes.h
+++ b/llvm/include/llvm/Support/ARMBuildAttributes.h
@@ -28,32 +28,23 @@ namespace ARMBuildAttrs {
 const TagNameMap &getARMAttributeTags();
 
 /// AArch64 build attributes vendors (=subsection name)
-enum Vendor : unsigned {
-  AEBI_FEATURE_AND_BITS = 0,
-  AEBI_PAUTHABI = 1
-};
+enum Vendor : unsigned { AEBI_FEATURE_AND_BITS = 0, AEBI_PAUTHABI = 1 };
 
 inline StringRef vendorToStr(unsigned Vendor) {
-  switch(Vendor) {
-    default:
-      llvm_unreachable("unknown AArch64 vendor name");
-      return "";
-    case AEBI_FEATURE_AND_BITS:
-      return "aeabi-feature-and-bits";
-    case AEBI_PAUTHABI:
-      return "aeabi-pauthabi";
+  switch (Vendor) {
+  default:
+    llvm_unreachable("unknown AArch64 vendor name");
+    return "";
+  case AEBI_FEATURE_AND_BITS:
+    return "aeabi-feature-and-bits";
+  case AEBI_PAUTHABI:
+    return "aeabi-pauthabi";
   }
 }
 
-enum SubsectionMandatory : unsigned {
-  OPTIONAL = 0,
-  REQUIRED = 1
-};
+enum SubsectionMandatory : unsigned { OPTIONAL = 0, REQUIRED = 1 };
 
-enum SubsectionType : unsigned {
-  ULEB128 = 0,
-  NTBS = 1
-};
+enum SubsectionType : unsigned { ULEB128 = 0, NTBS = 1 };
 
 enum FeatureAndBitsTags : unsigned {
   Tag_PAuth_Platform = 1,
@@ -136,20 +127,16 @@ enum AttrType : unsigned {
   MPextension_use_old = 70   // recoded to MPextension_use (ABI r2.08)
 };
 
-enum AVAttr {
-  AV_cpp_exceptions         = 6,
-  AV_eba                    = 16
-};
+enum AVAttr { AV_cpp_exceptions = 6, AV_eba = 16 };
 
-StringRef AttrTypeAsString(StringRef Vendor, unsigned Attr, bool HasTagPrefix = true);
+StringRef AttrTypeAsString(StringRef Vendor, unsigned Attr,
+                           bool HasTagPrefix = true);
 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix = true);
 StringRef AttrTypeAsString(AVAttr Attr, bool HasTagPrefix = true);
 int AttrTypeFromString(StringRef Vendor, StringRef Tag);
 
 // Magic numbers for .ARM.attributes
-enum AttrMagic {
-  Format_Version  = 0x41
-};
+enum AttrMagic { Format_Version = 0x41 };
 
 // Legal Values for CPU_arch, (=6), uleb128
 enum CPUArch {
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 34a7367a18..576d4997a3 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -635,8 +635,9 @@ void MCELFStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
   llvm_unreachable("ELF doesn't support this directive");
 }
 
-void MCELFStreamer::setAttributeItem(unsigned Attribute, unsigned Value,
-                                     bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes) {
+void MCELFStreamer::setAttributeItem(
+    unsigned Attribute, unsigned Value, bool OverwriteExisting,
+    SmallVector<AttributeItem, 64> &Attributes) {
   // Look for existing attribute item
   if (AttributeItem *Item = getAttributeItem(Attribute, Attributes)) {
     if (!OverwriteExisting)
@@ -652,8 +653,9 @@ void MCELFStreamer::setAttributeItem(unsigned Attribute, unsigned Value,
   Contents.push_back(Item);
 }
 
-void MCELFStreamer::setAttributeItem(unsigned Attribute, StringRef Value,
-                                     bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes) {
+void MCELFStreamer::setAttributeItem(
+    unsigned Attribute, StringRef Value, bool OverwriteExisting,
+    SmallVector<AttributeItem, 64> &Attributes) {
   // Look for existing attribute item
   if (AttributeItem *Item = getAttributeItem(Attribute, Attributes)) {
     if (!OverwriteExisting)
@@ -669,9 +671,9 @@ void MCELFStreamer::setAttributeItem(unsigned Attribute, StringRef Value,
   Contents.push_back(Item);
 }
 
-void MCELFStreamer::setAttributeItems(unsigned Attribute, unsigned IntValue,
-                                      StringRef StringValue,
-                                      bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes) {
+void MCELFStreamer::setAttributeItems(
+    unsigned Attribute, unsigned IntValue, StringRef StringValue,
+    bool OverwriteExisting, SmallVector<AttributeItem, 64> &Attributes) {
   // Look for existing attribute item
   if (AttributeItem *Item = getAttributeItem(Attribute, Attributes)) {
     if (!OverwriteExisting)
@@ -689,15 +691,16 @@ void MCELFStreamer::setAttributeItems(unsigned Attribute, unsigned IntValue,
 }
 
 MCELFStreamer::AttributeItem *
-MCELFStreamer::getAttributeItem(unsigned Attribute, SmallVector<AttributeItem, 64> &Attributes) {
+MCELFStreamer::getAttributeItem(unsigned Attribute,
+                                SmallVector<AttributeItem, 64> &Attributes) {
   for (AttributeItem &Item : Attributes)
     if (Item.Tag == Attribute)
       return &Item;
   return nullptr;
 }
 
-size_t
-MCELFStreamer::calculateContentSize(SmallVector<AttributeItem, 64> &AttrsVec) const {
+size_t MCELFStreamer::calculateContentSize(
+    SmallVector<AttributeItem, 64> &AttrsVec) const {
   size_t Result = 0;
   for (const AttributeItem &Item : AttrsVec) {
     switch (Item.Type) {
@@ -783,14 +786,15 @@ void MCELFStreamer::createAttributesSection(
   AttrsVec.clear();
 }
 
-void MCELFStreamer::createAttributesSection(MCSection *&AttributeSection,
-  const Twine &Section, unsigned Type, SmallVector<AttributeSubSection, 64> &SubSectionVec) {
-// <format-version: 'A'>
-// [ <uint32: subsection-length> NTBS: vendor-name
-//   <bytes: vendor-data>
-// ]*
-// vendor-data expends to:
-// <uint8: optional> <uint8: parameter type> <attribute>*
+void MCELFStreamer::createAttributesSection(
+    MCSection *&AttributeSection, const Twine &Section, unsigned Type,
+    SmallVector<AttributeSubSection, 64> &SubSectionVec) {
+  // <format-version: 'A'>
+  // [ <uint32: subsection-length> NTBS: vendor-name
+  //   <bytes: vendor-data>
+  // ]*
+  // vendor-data expends to:
+  // <uint8: optional> <uint8: parameter type> <attribute>*
   if (SubSectionVec.size() == 0) {
     return;
   }
@@ -821,20 +825,20 @@ void MCELFStreamer::createAttributesSection(MCSection *&AttributeSection,
     for (AttributeItem &Item : SubSection.Content) {
       emitULEB128IntValue(Item.Tag);
       switch (Item.Type) {
-        default:
-          llvm_unreachable("Invalid attribute type");
-        case AttributeItem::NumericAttribute:
-          emitULEB128IntValue(Item.IntValue);
-          break;
-        case AttributeItem::TextAttribute:
-          emitBytes(Item.StringValue);
-          emitInt8(0); // '\0'
-          break;
-        case AttributeItem::NumericAndTextAttributes:
-          emitULEB128IntValue(Item.IntValue);
-          emitBytes(Item.StringValue);
-          emitInt8(0); // '\0'
-          break;
+      default:
+        llvm_unreachable("Invalid attribute type");
+      case AttributeItem::NumericAttribute:
+        emitULEB128IntValue(Item.IntValue);
+        break;
+      case AttributeItem::TextAttribute:
+        emitBytes(Item.StringValue);
+        emitInt8(0); // '\0'
+        break;
+      case AttributeItem::NumericAndTextAttributes:
+        emitULEB128IntValue(Item.IntValue);
+        emitBytes(Item.StringValue);
+        emitInt8(0); // '\0'
+        break;
       }
     }
   }
diff --git a/llvm/lib/Support/ARMBuildAttrs.cpp b/llvm/lib/Support/ARMBuildAttrs.cpp
index 96d0f312d7..457e7d66a7 100644
--- a/llvm/lib/Support/ARMBuildAttrs.cpp
+++ b/llvm/lib/Support/ARMBuildAttrs.cpp
@@ -70,26 +70,26 @@ const TagNameItem ARMAttributeTags[] = {
 };
 
 const TagNameItem AVAttributeTags[] = {
-  { ARMBuildAttrs::AV_cpp_exceptions, "Tag_AV_cpp_exceptions" },
-  { ARMBuildAttrs::AV_eba, "Tag_AV_eba" },
+    {ARMBuildAttrs::AV_cpp_exceptions, "Tag_AV_cpp_exceptions"},
+    {ARMBuildAttrs::AV_eba, "Tag_AV_eba"},
 };
 
-template<typename T, size_t N> int FromString(T (&Table)[N], StringRef Tag) {
+template <typename T, size_t N> int FromString(T (&Table)[N], StringRef Tag) {
   bool HasTagPrefix = Tag.starts_with("Tag_");
-  for (unsigned TI = 0;  TI < N; ++TI)
+  for (unsigned TI = 0; TI < N; ++TI)
     if (Table[TI].tagName.drop_front(HasTagPrefix ? 0 : 4) == Tag)
       return Table[TI].attr;
   return -1;
 }
 
-template<typename T, size_t N, typename A>
+template <typename T, size_t N, typename A>
 StringRef AsString(T (&Table)[N], A Attr, bool HasTagPrefix) {
   for (unsigned TI = 0; TI < N; ++TI)
     if (Table[TI].attr == Attr)
       return Table[TI].tagName.drop_front(HasTagPrefix ? 0 : 4);
   return StringRef();
 }
-}
+} // namespace
 
 namespace llvm {
 namespace ARMBuildAttrs {
@@ -120,5 +120,5 @@ int AttrTypeFromString(StringRef Vendor, StringRef Tag) {
 
 static constexpr TagNameMap tagNameMap(ARMAttributeTags);
 const TagNameMap &getARMAttributeTags() { return tagNameMap; }
-}
-}
+} // namespace ARMBuildAttrs
+} // namespace llvm
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index f5e6a580fc..ca60e249e1 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -202,7 +202,8 @@ public:
   bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst);
 
   // Emit Build Attributes
-  void emitAttributes(unsigned Flags, uint64_t PAuthABIPlatform, uint64_t PAuthABIVersion, AArch64TargetStreamer* TS);
+  void emitAttributes(unsigned Flags, uint64_t PAuthABIPlatform,
+                      uint64_t PAuthABIVersion, AArch64TargetStreamer *TS);
 
   void EmitToStreamer(MCStreamer &S, const MCInst &Inst);
   void EmitToStreamer(const MCInst &Inst) {
@@ -337,8 +338,10 @@ void AArch64AsmPrinter::emitStartOfAsmFile(Module &M) {
     return;
 
   // For emitting build attributes and .note.gnu.property section
-  auto *TS = static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());
-  // Assemble feature flags that may require creation of build attributes and a note section.
+  auto *TS =
+      static_cast<AArch64TargetStreamer *>(OutStreamer->getTargetStreamer());
+  // Assemble feature flags that may require creation of build attributes and a
+  // note section.
   unsigned BAFlags = 0;
   unsigned GNUFlags = 0;
   if (const auto *BTE = mdconst::extract_or_null<ConstantInt>(
@@ -453,26 +456,35 @@ void AArch64AsmPrinter::emitSled(const MachineInstr &MI, SledKind Kind) {
   recordSled(CurSled, MI, Kind, 2);
 }
 
-void AArch64AsmPrinter::emitAttributes(unsigned Flags, uint64_t PAuthABIPlatform, uint64_t PAuthABIVersion, AArch64TargetStreamer* TS) {
+void AArch64AsmPrinter::emitAttributes(unsigned Flags,
+                                       uint64_t PAuthABIPlatform,
+                                       uint64_t PAuthABIVersion,
+                                       AArch64TargetStreamer *TS) {
 
   PAuthABIPlatform = (PAuthABIPlatform == uint64_t(-1)) ? 0 : PAuthABIPlatform;
   PAuthABIVersion = (PAuthABIVersion == uint64_t(-1)) ? 0 : PAuthABIVersion;
 
-  if(PAuthABIPlatform || PAuthABIVersion) {
+  if (PAuthABIPlatform || PAuthABIVersion) {
     TS->emitSubsection(ARMBuildAttrs::AEBI_PAUTHABI, 0, 0);
-    TS->emitAttribute(ARMBuildAttrs::AEBI_PAUTHABI, ARMBuildAttrs::Tag_PAuth_Platform, PAuthABIPlatform, false);
-    TS->emitAttribute(ARMBuildAttrs::AEBI_PAUTHABI, ARMBuildAttrs::Tag_PAuth_Schema, PAuthABIVersion, false);
+    TS->emitAttribute(ARMBuildAttrs::AEBI_PAUTHABI,
+                      ARMBuildAttrs::Tag_PAuth_Platform, PAuthABIPlatform,
+                      false);
+    TS->emitAttribute(ARMBuildAttrs::AEBI_PAUTHABI,
+                      ARMBuildAttrs::Tag_PAuth_Schema, PAuthABIVersion, false);
   }
 
   unsigned BTIValue = (Flags & ARMBuildAttrs::Feature_BTI_Flag) ? 1 : 0;
   unsigned PACValue = (Flags & ARMBuildAttrs::Feature_PAC_Flag) ? 1 : 0;
   unsigned GCSValue = (Flags & ARMBuildAttrs::Feature_GCS_Flag) ? 1 : 0;
 
-  if(BTIValue || PACValue || GCSValue) {
+  if (BTIValue || PACValue || GCSValue) {
     TS->emitSubsection(ARMBuildAttrs::AEBI_FEATURE_AND_BITS, 1, 0);
-    TS->emitAttribute(ARMBuildAttrs::AEBI_FEATURE_AND_BITS, ARMBuildAttrs::Tag_Feature_BTI, BTIValue, false);
-    TS->emitAttribute(ARMBuildAttrs::AEBI_FEATURE_AND_BITS, ARMBuildAttrs::Tag_Feature_PAC, PACValue, false);
-    TS->emitAttribute(ARMBuildAttrs::AEBI_FEATURE_AND_BITS, ARMBuildAttrs::Tag_Feature_GCS, GCSValue, false);
+    TS->emitAttribute(ARMBuildAttrs::AEBI_FEATURE_AND_BITS,
+                      ARMBuildAttrs::Tag_Feature_BTI, BTIValue, false);
+    TS->emitAttribute(ARMBuildAttrs::AEBI_FEATURE_AND_BITS,
+                      ARMBuildAttrs::Tag_Feature_PAC, PACValue, false);
+    TS->emitAttribute(ARMBuildAttrs::AEBI_FEATURE_AND_BITS,
+                      ARMBuildAttrs::Tag_Feature_GCS, GCSValue, false);
   }
 }
 
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
index e57b070313..cb594785a0 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -151,69 +151,83 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
     OS << "\t.seh_save_any_reg_px\tq" << Reg << ", " << Offset << "\n";
   }
 
-  void emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value, bool Override) override {
+  void emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value,
+                     bool Override) override {
     // AArch64 build attributes for assembly attribute form:
     // .aeabi_attribute tag, value
 
-    switch(Vendor) {
-      default: llvm_unreachable("unknown AArch64 build attributes subsection name");
-
-      case ARMBuildAttrs::AEBI_FEATURE_AND_BITS:
-        switch(Tag) {
-          default: llvm_unreachable("unknown tag for the feature-and-bits subsection");
-          case ARMBuildAttrs::Tag_Feature_BTI:
-            OS << "\t.aeabi_attribute\t" << "Tag_Feature_BTI" << ", " << Value;
-            break;
-          case ARMBuildAttrs::Tag_Feature_GCS:
-            OS << "\t.aeabi_attribute\t" << "Tag_Feature_GCS" << ", " << Value;
-            break;
-          case ARMBuildAttrs::Tag_Feature_PAC:
-            OS << "\t.aeabi_attribute\t" << "Tag_Feature_PAC" << ", " << Value;
-            break;
-        }
+    switch (Vendor) {
+    default:
+      llvm_unreachable("unknown AArch64 build attributes subsection name");
+
+    case ARMBuildAttrs::AEBI_FEATURE_AND_BITS:
+      switch (Tag) {
+      default:
+        llvm_unreachable("unknown tag for the feature-and-bits subsection");
+      case ARMBuildAttrs::Tag_Feature_BTI:
+        OS << "\t.aeabi_attribute\t" << "Tag_Feature_BTI" << ", " << Value;
+        break;
+      case ARMBuildAttrs::Tag_Feature_GCS:
+        OS << "\t.aeabi_attribute\t" << "Tag_Feature_GCS" << ", " << Value;
+        break;
+      case ARMBuildAttrs::Tag_Feature_PAC:
+        OS << "\t.aeabi_attribute\t" << "Tag_Feature_PAC" << ", " << Value;
         break;
+      }
+      break;
 
-      case ARMBuildAttrs::AEBI_PAUTHABI:
-        switch(Tag) {
-          default: llvm_unreachable("unknown tag for the feature-and-bits subsection");
-          case ARMBuildAttrs::Tag_PAuth_Platform:
-            OS << "\t.aeabi_attribute\t" << "Tag_PAuth_Platform" << ", " << Value;
-            break;
-          case ARMBuildAttrs::Tag_PAuth_Schema:
-            OS << "\t.aeabi_attribute\t" << "Tag_PAuth_Schema" << ", " << Value;
-            break;
+    case ARMBuildAttrs::AEBI_PAUTHABI:
+      switch (Tag) {
+      default:
+        llvm_unreachable("unknown tag for the feature-and-bits subsection");
+      case ARMBuildAttrs::Tag_PAuth_Platform:
+        OS << "\t.aeabi_attribute\t" << "Tag_PAuth_Platform" << ", " << Value;
         break;
-        }
+      case ARMBuildAttrs::Tag_PAuth_Schema:
+        OS << "\t.aeabi_attribute\t" << "Tag_PAuth_Schema" << ", " << Value;
+        break;
+        break;
+      }
     }
     OS << "\n";
   }
 
-  void emitSubsection(unsigned SubsectionName, unsigned Optional, unsigned ParameterType) override {
+  void emitSubsection(unsigned SubsectionName, unsigned Optional,
+                      unsigned ParameterType) override {
     // The AArch64 build attributes assembly subsection header format:
     // ".aeabi_subsection name, optional, parameter type"
     // optional: required (0) optional (1)
     // parameter type: uleb128 or ULEB128 (0) ntbs or NTBS (1)
 
-    assert((Optional == 0 || Optional == 1) && "unsupported parameter for Optional");
-    assert((ParameterType == 0 || ParameterType == 1) && "unsupported parameter for ParameterType");
+    assert((Optional == 0 || Optional == 1) &&
+           "unsupported parameter for Optional");
+    assert((ParameterType == 0 || ParameterType == 1) &&
+           "unsupported parameter for ParameterType");
 
     StringRef OptionalStr = Optional ? "optional" : "required";
     StringRef ParameterStr = ParameterType ? "NTBS" : "ULEB128";
 
-    switch(SubsectionName) {
-      default: llvm_unreachable("unknown AArch64 build attributes subsection name");
-
-      case ARMBuildAttrs::AEBI_FEATURE_AND_BITS:
-        assert(Optional == 1 && "subsection .aeabi-feature-and-bits should be marked as optional and not as mandatory");
-        assert(ParameterType == 0 && "subsection .aeabi-feature-and-bits should be marked as uleb128 and not as ntbs");
-        OS << "\t.aeabi_subsection\t" << ".aeabi-feature-and-bits" << ", " << OptionalStr << ", " << ParameterStr;
-        break;
+    switch (SubsectionName) {
+    default:
+      llvm_unreachable("unknown AArch64 build attributes subsection name");
+
+    case ARMBuildAttrs::AEBI_FEATURE_AND_BITS:
+      assert(Optional == 1 && "subsection .aeabi-feature-and-bits should be "
+                              "marked as optional and not as mandatory");
+      assert(ParameterType == 0 && "subsection .aeabi-feature-and-bits should "
+                                   "be marked as uleb128 and not as ntbs");
+      OS << "\t.aeabi_subsection\t" << ".aeabi-feature-and-bits" << ", "
+         << OptionalStr << ", " << ParameterStr;
+      break;
 
-      case ARMBuildAttrs::AEBI_PAUTHABI:
-        assert(Optional == 0 && "subsection .aeabi-pauthabi should be marked as mandatory and not as optional");
-        assert(ParameterType == 0 && "subsection .aeabi-pauthabi should be marked as uleb128 and not as ntbs");
-        OS << "\t.aeabi_subsection\t" << ".aeabi-pauthabi" << ", " << OptionalStr << ", " << ParameterStr;
-        break;
+    case ARMBuildAttrs::AEBI_PAUTHABI:
+      assert(Optional == 0 && "subsection .aeabi-pauthabi should be marked as "
+                              "mandatory and not as optional");
+      assert(ParameterType == 0 && "subsection .aeabi-pauthabi should be "
+                                   "marked as uleb128 and not as ntbs");
+      OS << "\t.aeabi_subsection\t" << ".aeabi-pauthabi" << ", " << OptionalStr
+         << ", " << ParameterStr;
+      break;
     }
     OS << "\n";
   }
@@ -224,7 +238,8 @@ public:
 
 AArch64TargetAsmStreamer::AArch64TargetAsmStreamer(MCStreamer &S,
                                                    formatted_raw_ostream &OS)
-  : AArch64TargetStreamer(S), OS(OS), VendorTag("eabi"), IsVerboseAsm(S.isVerboseAsm()) {}
+    : AArch64TargetStreamer(S), OS(OS), VendorTag("eabi"),
+      IsVerboseAsm(S.isVerboseAsm()) {}
 
 void AArch64TargetAsmStreamer::emitInst(uint32_t Inst) {
   OS << "\t.inst\t0x" << Twine::utohexstr(Inst) << "\n";
@@ -364,7 +379,9 @@ AArch64ELFStreamer &AArch64TargetELFStreamer::getStreamer() {
   return static_cast<AArch64ELFStreamer &>(Streamer);
 }
 
-void AArch64TargetELFStreamer::emitSubsection(unsigned Vendor, unsigned IsMandatory, unsigned ParameterType) {
+void AArch64TargetELFStreamer::emitSubsection(unsigned Vendor,
+                                              unsigned IsMandatory,
+                                              unsigned ParameterType) {
   StringRef VendorAsStr = ARMBuildAttrs::vendorToStr(Vendor);
 
   // If exists, return.
@@ -382,11 +399,13 @@ void AArch64TargetELFStreamer::emitSubsection(unsigned Vendor, unsigned IsMandat
   AttributeSubSections.push_back(AttSubSection);
 }
 
-void AArch64TargetELFStreamer::emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value, bool Override) {
+void AArch64TargetELFStreamer::emitAttribute(unsigned Vendor, unsigned Tag,
+                                             unsigned Value, bool Override) {
   StringRef VendorAsStr = ARMBuildAttrs::vendorToStr(Vendor);
 
   if (AttributeSubSections.size() == 0) {
-    llvm_unreachable("Attribute can not be added unless the required AArch64 build attributes subsection exists");
+    llvm_unreachable("Attribute can not be added unless the required AArch64 "
+                     "build attributes subsection exists");
     return;
   }
 
@@ -408,7 +427,8 @@ void AArch64TargetELFStreamer::emitAttribute(unsigned Vendor, unsigned Tag, unsi
       return;
     }
   }
-  llvm_unreachable("Attribute can not be added unless the required AArch64 build attributes subsection exists");
+  llvm_unreachable("Attribute can not be added unless the required AArch64 "
+                   "build attributes subsection exists");
 }
 
 void AArch64TargetELFStreamer::emitInst(uint32_t Inst) {
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
index 7d90759cfc..913754af6f 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
@@ -92,8 +92,10 @@ public:
   virtual void emitARM64WinCFISaveAnyRegQPX(unsigned Reg, int Offset) {}
 
   /// Build attributes implementation
-  virtual void emitSubsection(unsigned Vendor, unsigned IsMandatory, unsigned ParameterType) {}
-  virtual void emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value, bool Override) {}
+  virtual void emitSubsection(unsigned Vendor, unsigned IsMandatory,
+                              unsigned ParameterType) {}
+  virtual void emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value,
+                             bool Override) {}
 
 private:
   std::unique_ptr<AssemblerConstantPools> ConstantPools;
@@ -108,8 +110,10 @@ private:
   SmallVector<MCELFStreamer::AttributeSubSection, 64> AttributeSubSections;
 
   /// Build attributes implementation
-  void emitSubsection(unsigned Vendor, unsigned IsMandatory, unsigned ParameterType) override;
-  void emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value, bool Override) override;
+  void emitSubsection(unsigned Vendor, unsigned IsMandatory,
+                      unsigned ParameterType) override;
+  void emitAttribute(unsigned Vendor, unsigned Tag, unsigned Value,
+                     bool Override) override;
 
   void emitInst(uint32_t Inst) override;
   void emitDirectiveVariantPCS(MCSymbol *Symbol) override;
@@ -117,7 +121,7 @@ private:
 
 public:
   AArch64TargetELFStreamer(MCStreamer &S)
-    : AArch64TargetStreamer(S), CurrentVendor("aeabi") {}
+      : AArch64TargetStreamer(S), CurrentVendor("aeabi") {}
 };
 
 class AArch64TargetWinCOFFStreamer : public llvm::AArch64TargetStreamer {
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index b6a16de748..8c7fc4e7a1 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -793,20 +793,23 @@ void ARMTargetELFStreamer::switchVendor(StringRef Vendor) {
 
 void ARMTargetELFStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
   getStreamer().setAttributeItem(Attribute, Value,
-                                 /* OverwriteExisting= */ true, getStreamer().Contents);
+                                 /* OverwriteExisting= */ true,
+                                 getStreamer().Contents);
 }
 
 void ARMTargetELFStreamer::emitTextAttribute(unsigned Attribute,
                                              StringRef Value) {
   getStreamer().setAttributeItem(Attribute, Value,
-                                 /* OverwriteExisting= */ true, getStreamer().Contents);
+                                 /* OverwriteExisting= */ true,
+                                 getStreamer().Contents);
 }
 
 void ARMTargetELFStreamer::emitIntTextAttribute(unsigned Attribute,
                                                 unsigned IntValue,
                                                 StringRef StringValue) {
   getStreamer().setAttributeItems(Attribute, IntValue, StringValue,
-                                  /* OverwriteExisting= */ true, getStreamer().Contents);
+                                  /* OverwriteExisting= */ true,
+                                  getStreamer().Contents);
 }
 
 void ARMTargetELFStreamer::emitArch(ARM::ArchKind Value) {
@@ -821,12 +824,15 @@ void ARMTargetELFStreamer::emitArchDefaultAttributes() {
   using namespace ARMBuildAttrs;
   ARMELFStreamer &S = getStreamer();
 
-  S.setAttributeItem(CPU_name, ARM::getCPUAttr(Arch), false, getStreamer().Contents);
+  S.setAttributeItem(CPU_name, ARM::getCPUAttr(Arch), false,
+                     getStreamer().Contents);
 
   if (EmittedArch == ARM::ArchKind::INVALID)
-    S.setAttributeItem(CPU_arch, ARM::getArchAttr(Arch), false, getStreamer().Contents);
+    S.setAttributeItem(CPU_arch, ARM::getArchAttr(Arch), false,
+                       getStreamer().Contents);
   else
-    S.setAttributeItem(CPU_arch, ARM::getArchAttr(EmittedArch), false, getStreamer().Contents);
+    S.setAttributeItem(CPU_arch, ARM::getArchAttr(EmittedArch), false,
+                       getStreamer().Contents);
 
   switch (Arch) {
   case ARM::ArchKind::ARMV4:
@@ -843,15 +849,17 @@ void ARMTargetELFStreamer::emitArchDefaultAttributes() {
     break;
 
   case ARM::ArchKind::ARMV6T2:
-    S.setAttributeItem(ARM_ISA_use, Allowed, false,getStreamer().Contents);
-    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false, getStreamer().Contents);
+    S.setAttributeItem(ARM_ISA_use, Allowed, false, getStreamer().Contents);
+    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::ARMV6K:
   case ARM::ArchKind::ARMV6KZ:
     S.setAttributeItem(ARM_ISA_use, Allowed, false, getStreamer().Contents);
     S.setAttributeItem(THUMB_ISA_use, Allowed, false, getStreamer().Contents);
-    S.setAttributeItem(Virtualization_use, AllowTZ, false, getStreamer().Contents);
+    S.setAttributeItem(Virtualization_use, AllowTZ, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::ARMV6M:
@@ -859,21 +867,27 @@ void ARMTargetELFStreamer::emitArchDefaultAttributes() {
     break;
 
   case ARM::ArchKind::ARMV7A:
-    S.setAttributeItem(CPU_arch_profile, ApplicationProfile, false, getStreamer().Contents);
+    S.setAttributeItem(CPU_arch_profile, ApplicationProfile, false,
+                       getStreamer().Contents);
     S.setAttributeItem(ARM_ISA_use, Allowed, false, getStreamer().Contents);
-    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false, getStreamer().Contents);
+    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::ARMV7R:
-    S.setAttributeItem(CPU_arch_profile, RealTimeProfile, false, getStreamer().Contents);
+    S.setAttributeItem(CPU_arch_profile, RealTimeProfile, false,
+                       getStreamer().Contents);
     S.setAttributeItem(ARM_ISA_use, Allowed, false, getStreamer().Contents);
-    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false, getStreamer().Contents);
+    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::ARMV7EM:
   case ARM::ArchKind::ARMV7M:
-    S.setAttributeItem(CPU_arch_profile, MicroControllerProfile, false, getStreamer().Contents);
-    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false, getStreamer().Contents);
+    S.setAttributeItem(CPU_arch_profile, MicroControllerProfile, false,
+                       getStreamer().Contents);
+    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::ARMV8A:
@@ -893,17 +907,22 @@ void ARMTargetELFStreamer::emitArchDefaultAttributes() {
   case ARM::ArchKind::ARMV9_4A:
   case ARM::ArchKind::ARMV9_5A:
   case ARM::ArchKind::ARMV9_6A:
-    S.setAttributeItem(CPU_arch_profile, ApplicationProfile, false, getStreamer().Contents);
+    S.setAttributeItem(CPU_arch_profile, ApplicationProfile, false,
+                       getStreamer().Contents);
     S.setAttributeItem(ARM_ISA_use, Allowed, false, getStreamer().Contents);
-    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false, getStreamer().Contents);
+    S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false,
+                       getStreamer().Contents);
     S.setAttributeItem(MPextension_use, Allowed, false, getStreamer().Contents);
-    S.setAttributeItem(Virtualization_use, AllowTZVirtualization, false, getStreamer().Contents);
+    S.setAttributeItem(Virtualization_use, AllowTZVirtualization, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::ARMV8MBaseline:
   case ARM::ArchKind::ARMV8MMainline:
-    S.setAttributeItem(THUMB_ISA_use, AllowThumbDerived, false, getStreamer().Contents);
-    S.setAttributeItem(CPU_arch_profile, MicroControllerProfile, false, getStreamer().Contents);
+    S.setAttributeItem(THUMB_ISA_use, AllowThumbDerived, false,
+                       getStreamer().Contents);
+    S.setAttributeItem(CPU_arch_profile, MicroControllerProfile, false,
+                       getStreamer().Contents);
     break;
 
   case ARM::ArchKind::IWMMXT:
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
index d8a177a90a..4bc205e3f4 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
@@ -330,7 +330,8 @@ private:
 
   void emitAttribute(uint32_t Attribute, uint32_t Value) override {
     getStreamer().setAttributeItem(Attribute, Value,
-                                   /*OverwriteExisting=*/true, getStreamer().Contents);
+                                   /*OverwriteExisting=*/true,
+                                   getStreamer().Contents);
   }
 };
 
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index ae536accb3..b5e2338f37 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -57,19 +57,22 @@ void RISCVTargetELFStreamer::emitDirectiveOptionRelax() {}
 void RISCVTargetELFStreamer::emitDirectiveOptionNoRelax() {}
 
 void RISCVTargetELFStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
-  getStreamer().setAttributeItem(Attribute, Value, /*OverwriteExisting=*/true, getStreamer().Contents);
+  getStreamer().setAttributeItem(Attribute, Value, /*OverwriteExisting=*/true,
+                                 getStreamer().Contents);
 }
 
 void RISCVTargetELFStreamer::emitTextAttribute(unsigned Attribute,
                                                StringRef String) {
-  getStreamer().setAttributeItem(Attribute, String, /*OverwriteExisting=*/true, getStreamer().Contents);
+  getStreamer().setAttributeItem(Attribute, String, /*OverwriteExisting=*/true,
+                                 getStreamer().Contents);
 }
 
 void RISCVTargetELFStreamer::emitIntTextAttribute(unsigned Attribute,
                                                   unsigned IntValue,
                                                   StringRef StringValue) {
   getStreamer().setAttributeItems(Attribute, IntValue, StringValue,
-                                  /*OverwriteExisting=*/true, getStreamer().Contents);
+                                  /*OverwriteExisting=*/true,
+                                  getStreamer().Contents);
 }
 
 void RISCVTargetELFStreamer::finishAttributeSection() {

``````````

</details>


https://github.com/llvm/llvm-project/pull/118771


More information about the llvm-commits mailing list