Let a target specify whether it wants an assembly printer to be the MC version
authorJim Grosbach <grosbach@apple.com>
Thu, 30 Sep 2010 01:29:54 +0000 (01:29 +0000)
committerJim Grosbach <grosbach@apple.com>
Thu, 30 Sep 2010 01:29:54 +0000 (01:29 +0000)
or not. TableGen needs to generate the printInstruction() function as taking
an MCInstr* or a MachineInstr*, depending. Default to the old non-MC
version so that everything not yet using MC continues to just work without
fidding.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115126 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/Target.td
utils/TableGen/AsmWriterEmitter.cpp

index b141a77df4f20539e2b1f6b55c85e668bc40f77c..366a72fea7ecc3a95fcdc8eb16ebc14cb8daa649 100644 (file)
@@ -565,6 +565,11 @@ class AsmWriter {
   
   // OperandSpacing - Space between operand columns.
   int OperandSpacing = -1;
+
+  // isMCAsmWriter - Is this assembly writer for an MC emitter? This controls
+  // generation of the printInstruction() method. For MC printers, it takes
+  // an MCInstr* operand, otherwise it takes a MachineInstr*.
+  bit isMCAsmWriter = 0;
 }
 def DefaultAsmWriter : AsmWriter;
 
index 6ae0b39c8ddea911e6319c9d1b5b6d3eda324e7e..1bca6607449e9396373ed6d292da85032d8b2342 100644 (file)
@@ -243,12 +243,15 @@ void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {
   CodeGenTarget Target;
   Record *AsmWriter = Target.getAsmWriter();
   std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName");
+  bool isMC = AsmWriter->getValueAsBit("isMCAsmWriter");
+  const char *MachineInstrClassName = isMC ? "MCInst" : "MachineInstr";
 
   O <<
   "/// printInstruction - This method is automatically generated by tablegen\n"
   "/// from the instruction set description.\n"
     "void " << Target.getName() << ClassName
-            << "::printInstruction(const MachineInstr *MI, raw_ostream &O) {\n";
+            << "::printInstruction(const " << MachineInstrClassName
+            << " *MI, raw_ostream &O) {\n";
 
   std::vector<AsmWriterInst> Instructions;