[llvm] [GlobalISel] Change MatchTable entries to 1 byte each (PR #74429)

Wang Pengcheng via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 20:23:53 PST 2023


================
@@ -92,28 +93,53 @@ bool GIMatchTableExecutor::executeMatchTable(
 
   // If the index is >= 0, it's an index in the type objects generated by
   // TableGen. If the index is <0, it's an index in the recorded types object.
-  auto getTypeFromIdx = [&](int64_t Idx) -> LLT {
+  const auto getTypeFromIdx = [&](int64_t Idx) -> LLT {
     if (Idx >= 0)
       return ExecInfo.TypeObjects[Idx];
     return State.RecordedTypes[1 - Idx];
   };
 
+  const auto nextULEB128 = [&]() {
+    unsigned N = 0;
+    uint64_t Val = decodeULEB128(MatchTable + CurrentIdx, &N);
+    CurrentIdx += N;
+    return Val;
+  };
+
+  const auto next2Bytes = [&]() {
+    auto V = readBytes<uint16_t>(MatchTable + CurrentIdx);
+    CurrentIdx += 2;
+    return V;
+  };
+
+  const auto next4Bytes = [&]() {
+    auto V = readBytes<uint32_t>(MatchTable + CurrentIdx);
+    CurrentIdx += 4;
+    return V;
+  };
+
+  const auto next8Bytes = [&]() {
+    auto V = readBytes<uint64_t>(MatchTable + CurrentIdx);
+    CurrentIdx += 8;
+    return V;
+  };
+
   while (true) {
     assert(CurrentIdx != ~0u && "Invalid MatchTable index");
-    int64_t MatcherOpcode = MatchTable[CurrentIdx++];
+    unsigned MatcherOpcode = MatchTable[CurrentIdx++];
----------------
wangpc-pp wrote:

unsigned -> uint8_t

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


More information about the llvm-commits mailing list