[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
================
@@ -0,0 +1,123 @@
+//===-- AArch64BuildAttributes.cpp - AArch64 Build Attributes -------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/AArch64BuildAttributes.h"
+#include "llvm/ADT/StringSwitch.h"
+
+namespace llvm {
+namespace AArch64BuildAttributes {
+
+StringRef getVendorName(unsigned Vendor) {
+ switch (Vendor) {
+ case AEABI_FEATURE_AND_BITS:
+ return "aeabi_feature_and_bits";
+ case AEABI_PAUTHABI:
+ return "aeabi_pauthabi";
+ case VENDOR_UNKNOWN:
+ return "";
+ default:
+ assert(0 && "Vendor name error");
+ return "";
+ }
+}
+VendorID getVendorID(StringRef Vendor) {
+ return StringSwitch<VendorID>(Vendor)
+ .Case("aeabi_feature_and_bits", AEABI_FEATURE_AND_BITS)
+ .Case("aeabi_pauthabi", AEABI_PAUTHABI)
+ .Default(VENDOR_UNKNOWN);
+}
+
+StringRef getOptionalStr(unsigned Optional) {
+ switch (Optional) {
+ case REQUIRED:
+ return "required";
+ case OPTIONAL:
+ return "optional";
+ case OPTIONAL_NOT_FOUND:
+ LLVM_FALLTHROUGH;
+ default:
+ return "";
+ }
+}
+SubsectionOptional getOptionalID(StringRef Optional) {
+ return StringSwitch<SubsectionOptional>(Optional)
+ .Case("required", REQUIRED)
+ .Case("optional", OPTIONAL)
+ .Default(OPTIONAL_NOT_FOUND);
+}
+StringRef getSubsectionOptionalUnknownError() {
+ return "unknown AArch64 build attributes optionality, expected "
+ "required|optional";
+}
+
+StringRef getTypeStr(unsigned Type) {
+ switch (Type) {
+ case ULEB128:
+ return "uleb128";
+ case NTBS:
+ return "ntbs";
+ case TYPE_NOT_FOUND:
+ LLVM_FALLTHROUGH;
+ default:
+ return "";
+ }
+}
+SubsectionType getTypeID(StringRef Type) {
+ return StringSwitch<SubsectionType>(Type)
+ .Case("uleb128", ULEB128)
----------------
ostannard wrote:
This can be shortened using e.g. `.Cases("uleb128", "ULEB128", ULEB128)`
https://github.com/llvm/llvm-project/pull/118771
More information about the llvm-commits
mailing list