[llvm] [LLVM][MC] Add support to cull inactive decoders in decoder emitter (PR #154865)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 26 20:30:07 PDT 2025


================
@@ -72,20 +72,17 @@ insertBits(IntType &field, IntType bits, unsigned startBit, unsigned numBits) {
   field |= bits << startBit;
 }
 
-// InsnBitWidth is essentially a type trait used by the decoder emitter to query
-// the supported bitwidth for a given type. But default, the value is 0, making
-// it an invalid type for use as `InsnType` when instantiating the decoder.
-template <typename T> inline constexpr uint32_t InsnBitWidth = 0;
-
-// Provide specializations for commonly used types.
-// Integer types.
-template <> inline constexpr uint32_t InsnBitWidth<uint8_t> = 8;
-template <> inline constexpr uint32_t InsnBitWidth<uint16_t> = 16;
-template <> inline constexpr uint32_t InsnBitWidth<uint32_t> = 32;
-template <> inline constexpr uint32_t InsnBitWidth<uint64_t> = 64;
-
-// std::bitset<N>.
-template <size_t N> inline constexpr uint32_t InsnBitWidth<std::bitset<N>> = N;
+// isSupportedInsnBitWidth is a type trait used by the decoder emitter to query
+// if type `T` can be used for the template type parameter `InsnType` for
+// decoding instructions with bitwidth `N`. Each backend is supposed to provide
+// specializations for the types it uses for instantiating the decoder. Note
+// that if the decoder is instantiated multiple times with different `InsnType`
+// types, only a single one of them should return `isSupportedInsnBitWidth` as
+// true for a given bit width.
+template <typename T>
+inline constexpr bool isSupportedInsnBitWidth(uint32_t BitWidth) {
----------------
s-barannikov wrote:

Sure

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


More information about the llvm-commits mailing list