forked from OSchip/llvm-project
[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
This commit is contained in:
parent
b1bb1d4c46
commit
de44af4c1d
|
@ -443,14 +443,16 @@ void MapTableEmitter::emitMapFuncBody(raw_ostream &OS,
|
||||||
if (ValueCols.size() > 1) {
|
if (ValueCols.size() > 1) {
|
||||||
for (unsigned i = 0, e = ValueCols.size(); i < e; i++) {
|
for (unsigned i = 0, e = ValueCols.size(); i < e; i++) {
|
||||||
ListInit *ColumnI = ValueCols[i];
|
ListInit *ColumnI = ValueCols[i];
|
||||||
|
OS << " if (";
|
||||||
for (unsigned j = 0, ColSize = ColumnI->size(); j < ColSize; ++j) {
|
for (unsigned j = 0, ColSize = ColumnI->size(); j < ColSize; ++j) {
|
||||||
std::string ColName = ColFields->getElement(j)->getAsUnquotedString();
|
std::string ColName = ColFields->getElement(j)->getAsUnquotedString();
|
||||||
OS << " if (in" << ColName;
|
OS << "in" << ColName;
|
||||||
OS << " == ";
|
OS << " == ";
|
||||||
OS << ColName << "_" << ColumnI->getElement(j)->getAsUnquotedString();
|
OS << ColName << "_" << ColumnI->getElement(j)->getAsUnquotedString();
|
||||||
if (j < ColumnI->size() - 1) OS << " && ";
|
if (j < ColumnI->size() - 1)
|
||||||
else OS << ")\n";
|
OS << " && ";
|
||||||
}
|
}
|
||||||
|
OS << ")\n";
|
||||||
OS << " return " << InstrMapDesc.getName();
|
OS << " return " << InstrMapDesc.getName();
|
||||||
OS << "Table[mid]["<<i+1<<"];\n";
|
OS << "Table[mid]["<<i+1<<"];\n";
|
||||||
}
|
}
|
||||||
|
@ -480,9 +482,10 @@ void MapTableEmitter::emitTablesWithFunc(raw_ostream &OS) {
|
||||||
if (ValueCols.size() > 1) {
|
if (ValueCols.size() > 1) {
|
||||||
for (Init *CF : ColFields->getValues()) {
|
for (Init *CF : ColFields->getValues()) {
|
||||||
std::string ColName = CF->getAsUnquotedString();
|
std::string ColName = CF->getAsUnquotedString();
|
||||||
OS << ", enum " << ColName << " in" << ColName << ") {\n";
|
OS << ", enum " << ColName << " in" << ColName;
|
||||||
}
|
}
|
||||||
} else { OS << ") {\n"; }
|
}
|
||||||
|
OS << ") {\n";
|
||||||
|
|
||||||
// Emit map table.
|
// Emit map table.
|
||||||
unsigned TableSize = emitBinSearchTable(OS);
|
unsigned TableSize = emitBinSearchTable(OS);
|
||||||
|
|
Loading…
Reference in New Issue