[llvm] [TableGen] Simplify insertBits (NFC) (PR #137538)

Hongjune Kim via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 21:56:23 PDT 2025


================
@@ -2145,16 +2145,14 @@ static void emitInsertBits(formatted_raw_ostream &OS) {
 // Helper function for inserting bits extracted from an encoded instruction into
 // a field.
 template <typename InsnType>
-static std::enable_if_t<std::is_integral<InsnType>::value>
-insertBits(InsnType &field, InsnType bits, unsigned startBit, unsigned numBits) {
-  assert(startBit + numBits <= sizeof field * 8);
-  field |= (InsnType)bits << startBit;
-}
-
-template <typename InsnType>
-static std::enable_if_t<!std::is_integral<InsnType>::value>
-insertBits(InsnType &field, uint64_t bits, unsigned startBit, unsigned numBits) {
-  field.insertBits(bits, startBit, numBits);
+static void insertBits(InsnType &field, InsnType bits, unsigned startBit,
+                       unsigned numBits) {
----------------
HongjuneKim wrote:

`numBits` needs attribute [[maybe_unused]]. If `InsnType` is integral and compiled with the release configuration, `Wunused-but-set-parameter` warning is reported.

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


More information about the llvm-commits mailing list