[llvm] [TableGen][DecoderEmitter] Use KnownBits for filters/encodings (NFCI) (PR #154691)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 08:59:58 PDT 2025


================
@@ -610,31 +546,34 @@ class FilterChooser {
     const RecordVal *RV = EncodingDef->getValue("SoftFail");
     const BitsInit *SFBits = RV ? dyn_cast<BitsInit>(RV->getValue()) : nullptr;
     for (unsigned i = 0; i < Bits.getNumBits(); ++i) {
-      if (SFBits && BitValue(*SFBits, i) == BitValue::BIT_TRUE)
-        Insn[i] = BitValue::BIT_UNSET;
-      else
-        Insn[i] = BitValue(Bits, i);
+      if (SFBits) {
+        const auto *B = dyn_cast<BitInit>(SFBits->getBit(i));
+        if (B && B->getValue())
+          continue;
+      }
+      if (const auto *B = dyn_cast<BitInit>(Bits.getBit(i))) {
+        if (B->getValue())
+          Insn.One.setBit(i);
+        else
+          Insn.Zero.setBit(i);
+      }
     }
     return Insn;
   }
 
-  /// dumpFilterArray - dumpFilterArray prints out debugging info for the given
-  /// filter array as a series of chars.
-  void dumpFilterArray(raw_ostream &OS, ArrayRef<BitValue> Filter) const;
-
   /// dumpStack - dumpStack traverses the filter chooser chain and calls
   /// dumpFilterArray on each filter chooser up to the top level one.
   void dumpStack(raw_ostream &OS, indent Indent) const;
 
-  bool PositionFiltered(unsigned Idx) const {
-    return FilterBitValues[Idx].isSet();
+  bool isPositionFiltered(unsigned Idx) const {
+    return FilterBits.Zero[Idx] || FilterBits.One[Idx];
----------------
jurahul wrote:

Basically, this is `KnownBits::isKnown(unsigned Idx)`, right? Should we just add this to KnowBits?

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


More information about the llvm-commits mailing list