Skip to content

Commit bb6cf73

Browse files
committedMar 27, 2017
[TableGen] Make CodeGenMapTable understand the namespace field of an 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 llvm-svn: 298834
1 parent 1dcec25 commit bb6cf73

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed
 

‎llvm/utils/TableGen/CodeGenMapTable.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
367367

368368
ArrayRef<const CodeGenInstruction*> NumberedInstructions =
369369
Target.getInstructionsByEnumValue();
370-
std::string TargetName = Target.getName();
370+
std::string Namespace = Target.getInstNamespace();
371371
const std::vector<ListInit*> &ValueCols = InstrMapDesc.getValueCols();
372372
unsigned NumCol = ValueCols.size();
373373
unsigned TotalNumInstr = NumberedInstructions.size();
@@ -387,22 +387,22 @@ unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
387387
if (ColInstrs[j] != nullptr) {
388388
RelExists = 1;
389389
OutStr += ", ";
390-
OutStr += TargetName;
390+
OutStr += Namespace;
391391
OutStr += "::";
392392
OutStr += ColInstrs[j]->getName();
393393
} else { OutStr += ", (uint16_t)-1U";}
394394
}
395395

396396
if (RelExists) {
397-
OS << " { " << TargetName << "::" << CurInstr->getName();
397+
OS << " { " << Namespace << "::" << CurInstr->getName();
398398
OS << OutStr <<" },\n";
399399
TableSize++;
400400
}
401401
}
402402
}
403403
if (!TableSize) {
404-
OS << " { " << TargetName << "::" << "INSTRUCTION_LIST_END, ";
405-
OS << TargetName << "::" << "INSTRUCTION_LIST_END }";
404+
OS << " { " << Namespace << "::" << "INSTRUCTION_LIST_END, ";
405+
OS << Namespace << "::" << "INSTRUCTION_LIST_END }";
406406
}
407407
OS << "}; // End of " << InstrMapDesc.getName() << "Table\n\n";
408408
return TableSize;
@@ -567,7 +567,7 @@ namespace llvm {
567567
//===----------------------------------------------------------------------===//
568568
void EmitMapTable(RecordKeeper &Records, raw_ostream &OS) {
569569
CodeGenTarget Target(Records);
570-
std::string TargetName = Target.getName();
570+
std::string NameSpace = Target.getInstNamespace();
571571
std::vector<Record*> InstrMapVec;
572572
InstrMapVec = Records.getAllDerivedDefinitions("InstrMapping");
573573

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.