[clang] [AArch64]: Refactor target parser to use Bitset. (PR #65423)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 11 06:01:01 PDT 2023
================
@@ -18,38 +18,39 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <optional>
+#include <sstream>
#include <string>
using namespace llvm;
namespace {
const char *ARMArch[] = {
- "armv4", "armv4t", "armv5", "armv5t", "armv5e",
- "armv5te", "armv5tej", "armv6", "armv6j", "armv6k",
- "armv6hl", "armv6t2", "armv6kz", "armv6z", "armv6zk",
- "armv6-m", "armv6m", "armv6sm", "armv6s-m", "armv7-a",
- "armv7", "armv7a", "armv7ve", "armv7hl", "armv7l",
- "armv7-r", "armv7r", "armv7-m", "armv7m", "armv7k",
- "armv7s", "armv7e-m", "armv7em", "armv8-a", "armv8",
- "armv8a", "armv8l", "armv8.1-a", "armv8.1a", "armv8.2-a",
- "armv8.2a", "armv8.3-a", "armv8.3a", "armv8.4-a", "armv8.4a",
- "armv8.5-a", "armv8.5a", "armv8.6-a", "armv8.6a", "armv8.7-a",
- "armv8.7a", "armv8.8-a", "armv8.8a", "armv8.9-a", "armv8.9a",
- "armv8-r", "armv8r", "armv8-m.base", "armv8m.base", "armv8-m.main",
- "armv8m.main", "iwmmxt", "iwmmxt2", "xscale", "armv8.1-m.main",
- "armv9-a", "armv9", "armv9a", "armv9.1-a", "armv9.1a",
- "armv9.2-a", "armv9.2a", "armv9.3-a", "armv9.3a", "armv9.4-a",
+ "armv4", "armv4t", "armv5", "armv5t", "armv5e",
+ "armv5te", "armv5tej", "armv6", "armv6j", "armv6k",
+ "armv6hl", "armv6t2", "armv6kz", "armv6z", "armv6zk",
+ "armv6-m", "armv6m", "armv6sm", "armv6s-m", "armv7-a",
+ "armv7", "armv7a", "armv7ve", "armv7hl", "armv7l",
+ "armv7-r", "armv7r", "armv7-m", "armv7m", "armv7k",
+ "armv7s", "armv7e-m", "armv7em", "armv8-a", "armv8",
+ "armv8a", "armv8l", "armv8.1-a", "armv8.1a", "armv8.2-a",
+ "armv8.2a", "armv8.3-a", "armv8.3a", "armv8.4-a", "armv8.4a",
+ "armv8.5-a", "armv8.5a", "armv8.6-a", "armv8.6a", "armv8.7-a",
+ "armv8.7a", "armv8.8-a", "armv8.8a", "armv8.9-a", "armv8.9a",
+ "armv8-r", "armv8r", "armv8-m.base", "armv8m.base", "armv8-m.main",
+ "armv8m.main", "iwmmxt", "iwmmxt2", "xscale", "armv8.1-m.main",
+ "armv9-a", "armv9", "armv9a", "armv9.1-a", "armv9.1a",
+ "armv9.2-a", "armv9.2a", "armv9.3-a", "armv9.3a", "armv9.4-a",
"armv9.4a",
};
-template <ARM::ISAKind ISAKind>
-std::string FormatExtensionFlags(uint64_t Flags) {
+template <ARM::ISAKind ISAKind, typename T>
+std::string FormatExtensionFlags(T Flags) {
std::vector<StringRef> Features;
- if (ISAKind == ARM::ISAKind::AARCH64) {
+ if constexpr (ISAKind == ARM::ISAKind::AARCH64) {
// AEK_NONE is not meant to be shown to the user so the target parser
// does not recognise it. It is relevant here though.
- if (Flags & AArch64::AEK_NONE)
+ if (Flags.test(AArch64::AEK_NONE))
----------------
sdesmalen-arm wrote:
This assumes that `T` has a `test()` method, which is only true for the AArch64 ISAKind branch, which requires you to use the `constexpr` if-condition so that the compiler must fold away the other branch.
Can you write this in such a way that you don't need to make that assumption and don't need the constexpr? e.g. by having an overloaded `FormatExtensionFlags`, one for `uint64_t` and one for `Bitset`.
https://github.com/llvm/llvm-project/pull/65423
More information about the cfe-commits
mailing list