[PATCH] D111962: [TableGen] Fix codgen of InstrMapping with multiple columns and values

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 25 21:03:58 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGde44af4c1db3: [TableGen] Fix codgen of InstrMapping with multiple columns and values (authored by jyyou.tw, committed by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111962/new/

https://reviews.llvm.org/D111962

Files:
  llvm/utils/TableGen/CodeGenMapTable.cpp


Index: llvm/utils/TableGen/CodeGenMapTable.cpp
===================================================================
--- llvm/utils/TableGen/CodeGenMapTable.cpp
+++ llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -443,14 +443,16 @@
   if (ValueCols.size() > 1) {
     for (unsigned i = 0, e = ValueCols.size(); i < e; i++) {
       ListInit *ColumnI = ValueCols[i];
+      OS << "  if (";
       for (unsigned j = 0, ColSize = ColumnI->size(); j < ColSize; ++j) {
         std::string ColName = ColFields->getElement(j)->getAsUnquotedString();
-        OS << "  if (in" << ColName;
+        OS << "in" << ColName;
         OS << " == ";
         OS << ColName << "_" << ColumnI->getElement(j)->getAsUnquotedString();
-        if (j < ColumnI->size() - 1) OS << " && ";
-        else OS << ")\n";
+        if (j < ColumnI->size() - 1)
+          OS << " && ";
       }
+      OS << ")\n";
       OS << "    return " << InstrMapDesc.getName();
       OS << "Table[mid]["<<i+1<<"];\n";
     }
@@ -480,9 +482,10 @@
   if (ValueCols.size() > 1) {
     for (Init *CF : ColFields->getValues()) {
       std::string ColName = CF->getAsUnquotedString();
-      OS << ", enum " << ColName << " in" << ColName << ") {\n";
+      OS << ", enum " << ColName << " in" << ColName;
     }
-  } else { OS << ") {\n"; }
+  }
+  OS << ") {\n";
 
   // Emit map table.
   unsigned TableSize = emitBinSearchTable(OS);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111962.382181.patch
Type: text/x-patch
Size: 1390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211026/25f3dc5d/attachment.bin>


More information about the llvm-commits mailing list