[llvm] [NFC][TableGen] Refactor DecoderEmitter.cpp (PR #135510)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 14 09:02:06 PDT 2025


================
@@ -112,12 +112,30 @@ struct OperandInfo {
   const_iterator end() const { return Fields.end(); }
 };
 
-typedef std::vector<uint8_t> DecoderTable;
-typedef uint32_t DecoderFixup;
-typedef std::vector<DecoderFixup> FixupList;
+typedef std::vector<uint32_t> FixupList;
 typedef std::vector<FixupList> FixupScopeList;
 typedef SmallSetVector<CachedHashString, 16> PredicateSet;
 typedef SmallSetVector<CachedHashString, 16> DecoderSet;
+
+struct DecoderTable : public std::vector<uint8_t> {
+  // Insert a ULEB128 encoded value into the table.
+  void insertULEB128(uint64_t Value) {
+    // Encode and emit the value to filter against.
+    uint8_t Buffer[16];
+    unsigned Len = encodeULEB128(Value, Buffer);
+    insert(end(), Buffer, Buffer + Len);
+  }
+
+  // Insert space for `NumToSkip` and return the position
+  // in the table for patching.
+  size_t insertNumToSkip() {
+    size_t Size = size();
+    push_back(0);
----------------
jurahul wrote:

Agreed, done.

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


More information about the llvm-commits mailing list