[llvm] [RISCV]Add support for resolving encoding conflicts among vendor specific CSRs (PR #96174)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 3 10:36:31 PDT 2024


================
@@ -478,25 +498,33 @@ void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
   OS << "      return false;\n";
   OS << "    });\n\n";
 
-  OS << "  if (Idx == Table.end()";
-
-  for (const auto &Field : Index.Fields)
-    OS << " ||\n      Key." << Field.Name << " != Idx->" << Field.Name;
-  OS << ")\n    return nullptr;\n";
+  if (!ShouldReturnRange) {
+    OS << "  if (Idx == Table.end()";
+    for (const auto &Field : Index.Fields)
+      OS << " ||\n      Key." << Field.Name << " != Idx->" << Field.Name;
+  }
 
-  if (IsPrimary)
+  if (ShouldReturnRange)
+    OS << "  return llvm::make_range(It.first, It.second);\n";
+  else if (IsPrimary) {
----------------
topperc wrote:

@quic-garvgupt I asked the question about `IsPrimary` because of this code that has to index the table using `Idx->_index` when the `IsPrimary` is false.

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


More information about the llvm-commits mailing list