From de44af4c1db3c333d64ef7beeabd6b38193c024e Mon Sep 17 00:00:00 2001 From: Jyun-Yan You Date: Mon, 25 Oct 2021 21:00:23 -0700 Subject: [PATCH] [TableGen] Fix codgen of InstrMapping with multiple columns and values This patch fixes invalid syntax of generated code for InstrMapping that has multiple columns and values. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D111962 --- llvm/utils/TableGen/CodeGenMapTable.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp index aef22c5c21cc..38871eb8cf3c 100644 --- a/llvm/utils/TableGen/CodeGenMapTable.cpp +++ b/llvm/utils/TableGen/CodeGenMapTable.cpp @@ -443,14 +443,16 @@ void MapTableEmitter::emitMapFuncBody(raw_ostream &OS, 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]["< 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);