================ @@ -151,3 +151,97 @@ llvm::createAArch64ObjectTargetStreamer(MCStreamer &S, MCTargetStreamer *llvm::createAArch64NullTargetStreamer(MCStreamer &S) { return new AArch64TargetStreamer(S); } + +void AArch64TargetStreamer::emitAtributesSubsection( + StringRef VendorName, AArch64BuildAttributes::SubsectionOptional IsOptional, + AArch64BuildAttributes::SubsectionType ParameterType) { + + // If exists, return. + for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) { + if (VendorName == SubSection.VendorName) { + activateAtributesSubsection(VendorName); + return; + } + } + // else, add the subsection + MCELFStreamer::AttributeSubSection AttSubSection; + AttSubSection.VendorName = VendorName; + AttSubSection.IsOptional = IsOptional; + AttSubSection.ParameterType = ParameterType; + AttributeSubSections.push_back(AttSubSection); + activateAtributesSubsection(VendorName); +} + +std::unique_ptr<MCELFStreamer::AttributeSubSection> +AArch64TargetStreamer::getActiveAtributesSubsection() { + for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) { + if (SubSection.IsActive) { + return std::make_unique<MCELFStreamer::AttributeSubSection>(SubSection); + } + } + return nullptr; +} + +void AArch64TargetStreamer::emitAttribute(StringRef VendorName, unsigned Tag, + unsigned Value, std::string String, + bool Override) { + + if (unsigned(-1) == Value && "" == String) { + assert(0 && "Arguments error"); + return; + } + if (AttributeSubSections.size() == 0) { + assert(0 && + "Can not add AArch64 build attribute: no AArch64 subsection exists"); + return; + } + + for (MCELFStreamer::AttributeSubSection &SubSection : AttributeSubSections) { + if (VendorName == SubSection.VendorName) { + if (!SubSection.IsActive) { + assert(0 && + "Can not add AArch64 build attribute: subsection is not active"); + return; + } + for (MCELFStreamer::AttributeItem &Item : SubSection.Content) { + if (Item.Tag == Tag) { + if (!Override) { + if ((unsigned(-1) != Value && Item.IntValue != Value) || ---------------- ostannard wrote:
Both sides of this `if` statement do the same thing (just slightly different wording in the assert). https://github.com/llvm/llvm-project/pull/118771 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits