[clang] [llvm] [LLVM][Clang][AArch64] Implement AArch64 build attributes (PR #118771)
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 03:26:55 PST 2025
================
@@ -148,13 +150,177 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
OS << "\t.seh_save_any_reg_px\tq" << Reg << ", " << Offset << "\n";
}
+ void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
+ std::string String, bool Override) override {
+
+ // AArch64 build attributes for assembly attribute form:
+ // .aeabi_attribute tag, value
+ if (unsigned(-1) == Value && "" == String) {
+ assert(0 && "Arguments error");
+ return;
+ }
+
+ unsigned VendorID = AArch64BuildAttributes::getVendorID(VendorName);
+
+ switch (VendorID) {
+ default:
+ assert(0 && "Subsection name error");
+ break;
+ case AArch64BuildAttributes::VENDOR_UNKNOWN:
+ if (unsigned(-1) != Value) {
+ OS << "\t." << AArch64BuildAttributes::getAttrTag() << "\t" << Tag
+ << ", " << Value;
+ AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
+ Override);
+ }
+ if ("" != String) {
+ OS << "\t." << AArch64BuildAttributes::getAttrTag() << "\t" << Tag
+ << ", " << String;
+ AArch64TargetStreamer::emitAttribute(VendorName, Tag, unsigned(-1),
+ String, Override);
+ }
+ break;
+ // Note: AEABI_FEATURE_AND_BITS takes only unsigned values
+ case AArch64BuildAttributes::AEABI_FEATURE_AND_BITS:
+ switch (Tag) {
+ default: // allow emitting any attribute by number
+ OS << "\t." << AArch64BuildAttributes::getAttrTag() << "\t" << Tag
+ << ", " << Value;
+ // Keep the data structure consistent with the case of ELF emission
+ // (important for llvm-mc asm parsing)
+ AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
+ Override);
+ break;
+ case AArch64BuildAttributes::TAG_FEATURE_BTI:
+ OS << "\t." << AArch64BuildAttributes::getAttrTag() << "\t"
+ << AArch64BuildAttributes::getFeatureAndBitsTagsStr(
----------------
ostannard wrote:
Since we've got a function to convert the enum value to a string, could these three cases be folded together?
https://github.com/llvm/llvm-project/pull/118771
More information about the llvm-commits
mailing list