[llvm] [TableGen][DecoderEmitter] Add extractBits() overloads (PR #159405)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 10:22:14 PDT 2025


================
@@ -58,6 +59,24 @@ uint64_t fieldFromInstruction(const std::bitset<N> &Insn, unsigned StartBit,
   return ((Insn >> StartBit) & Mask).to_ullong();
 }
 
+template <unsigned StartBit, unsigned NumBits, typename T>
+inline std::enable_if_t<std::is_unsigned_v<T>, T> extractBits(T Val) {
+  static_assert(StartBit + NumBits <= std::numeric_limits<T>::digits);
----------------
jurahul wrote:

this seems incorrect? Shouldn't it be sizeof(T)*CHAR_BIT or something like that?

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


More information about the llvm-commits mailing list