[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
================
@@ -148,13 +150,151 @@ 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.aeabi_attribute" << "\t" << Tag << ", " << Value;
+ AArch64TargetStreamer::emitAttribute(VendorName, Tag, Value, "",
+ Override);
+ }
+ if ("" != String) {
+ OS << "\t.aeabi_attribute" << "\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.aeabi_attribute" << "\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:
+ LLVM_FALLTHROUGH;
----------------
ostannard wrote:
You don't need to use `LLVM_FALLTHROUGH` if there is no code between two `case` statements.
https://github.com/llvm/llvm-project/pull/118771
More information about the llvm-commits
mailing list