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

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 07:35:26 PST 2024


================
@@ -294,6 +379,58 @@ AArch64ELFStreamer &AArch64TargetELFStreamer::getStreamer() {
   return static_cast<AArch64ELFStreamer &>(Streamer);
 }
 
+void AArch64TargetELFStreamer::emitSubsection(unsigned Vendor,
+                                              unsigned IsMandatory,
+                                              unsigned ParameterType) {
+  StringRef VendorAsStr = ARMBuildAttrs::vendorToStr(Vendor);
+
+  // If exists, return.
+  for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) {
+    if (SubSection.Vendor == VendorAsStr) {
+      llvm_unreachable("AArch64 build attributes subsection already exists");
----------------
sivan-shani wrote:

It is valid and possible to emit attribute to any subsection at any time, this achieved by the usage of a vector to hold the subsections.
There is no need to mechanically 'switch' between subsections. After a subsection has been created, it is always available and it is always possible to emit an attribute into it.

For example, user can first creates all the subsections that he wants, them add attribute to any of them at any time.

This function creates a new subsection and add it to the vector. 
The check here is for the case of creating the same subsection twice.

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


More information about the llvm-commits mailing list