Skip to content

Commit

Permalink
[TableGen] Make CodeGenMapTable understand the namespace field of an …
Browse files Browse the repository at this point in the history
…instruction

Do not force the backends to use target name as namespace.

Original patch by Mattias Eriksson

Reviewers: stoklund, craig.topper

Reviewed By: stoklund

Subscribers: materi, llvm-commits

Differential Revision: https://reviews.llvm.org/D31322

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298834 91177308-0d34-0410-b5e6-96231b3b80d8
karka228 committed Mar 27, 2017
1 parent 306a7df commit f6c7abb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions utils/TableGen/CodeGenMapTable.cpp
Original file line number Diff line number Diff line change
@@ -367,7 +367,7 @@ unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {

ArrayRef<const CodeGenInstruction*> NumberedInstructions =
Target.getInstructionsByEnumValue();
std::string TargetName = Target.getName();
std::string Namespace = Target.getInstNamespace();
const std::vector<ListInit*> &ValueCols = InstrMapDesc.getValueCols();
unsigned NumCol = ValueCols.size();
unsigned TotalNumInstr = NumberedInstructions.size();
@@ -387,22 +387,22 @@ unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
if (ColInstrs[j] != nullptr) {
RelExists = 1;
OutStr += ", ";
OutStr += TargetName;
OutStr += Namespace;
OutStr += "::";
OutStr += ColInstrs[j]->getName();
} else { OutStr += ", (uint16_t)-1U";}
}

if (RelExists) {
OS << " { " << TargetName << "::" << CurInstr->getName();
OS << " { " << Namespace << "::" << CurInstr->getName();
OS << OutStr <<" },\n";
TableSize++;
}
}
}
if (!TableSize) {
OS << " { " << TargetName << "::" << "INSTRUCTION_LIST_END, ";
OS << TargetName << "::" << "INSTRUCTION_LIST_END }";
OS << " { " << Namespace << "::" << "INSTRUCTION_LIST_END, ";
OS << Namespace << "::" << "INSTRUCTION_LIST_END }";
}
OS << "}; // End of " << InstrMapDesc.getName() << "Table\n\n";
return TableSize;
@@ -567,7 +567,7 @@ namespace llvm {
//===----------------------------------------------------------------------===//
void EmitMapTable(RecordKeeper &Records, raw_ostream &OS) {
CodeGenTarget Target(Records);
std::string TargetName = Target.getName();
std::string NameSpace = Target.getInstNamespace();
std::vector<Record*> InstrMapVec;
InstrMapVec = Records.getAllDerivedDefinitions("InstrMapping");

@@ -577,7 +577,7 @@ void EmitMapTable(RecordKeeper &Records, raw_ostream &OS) {
OS << "#ifdef GET_INSTRMAP_INFO\n";
OS << "#undef GET_INSTRMAP_INFO\n";
OS << "namespace llvm {\n\n";
OS << "namespace " << TargetName << " {\n\n";
OS << "namespace " << NameSpace << " {\n\n";

// Emit coulumn field names and their values as enums.
emitEnums(OS, Records);
@@ -600,7 +600,7 @@ void EmitMapTable(RecordKeeper &Records, raw_ostream &OS) {
// Emit map tables and the functions to query them.
IMap.emitTablesWithFunc(OS);
}
OS << "} // End " << TargetName << " namespace\n";
OS << "} // End " << NameSpace << " namespace\n";
OS << "} // End llvm namespace\n";
OS << "#endif // GET_INSTRMAP_INFO\n\n";
}

0 comments on commit f6c7abb

Please sign in to comment.