[clang] [AArch64]: Refactor target parser to use Bitset. (PR #65423)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 11 06:01:03 PDT 2023


================
@@ -69,6 +70,26 @@ std::string FormatExtensionFlags(uint64_t Flags) {
   return llvm::join(Features, ", ");
 }
 
+std::string SerializeExtensionFlags(Bitset<AArch64::AEK_EXTENSIONS_MAX> Flags) {
+  static_assert((AArch64::AEK_EXTENSIONS_MAX % 4 == 0),
+    "AArch64::AEK_EXTENSIONS_MAX shoubld be divisible by 4");
+
+  std::string SerializedFlags;
+  int HexValue = 0;
+  for (unsigned int i = 0; i < AArch64::AEK_EXTENSIONS_MAX; i++) {
+    HexValue <<= 1;
+    HexValue |= (int)Flags[i];
+    if ((i + 1) % 4 == 0) {
+      std::ostringstream ss;
----------------
sdesmalen-arm wrote:

Is it worth creating the std::ostringstream once and use that instead of SerializedFlags, rather than what you're doing here?

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


More information about the cfe-commits mailing list