I am considering using MipsInstPrinter::printAliasInstr, which is auto-generated in MipsGenAsmWriter.inc, to print assembly idioms defined as instruction aliases. For example, an instruction which used to be printed as <br>
<br>"nor $1, $2, $zero"<br><br>can be printed as<br><br>"not $1, $2"<br><br>This is nice because it makes the code printed by code-gen or disassembler more readable.<br><br>However, the code in AsmWriterEmitter::EmitPrintAliasInstruction seems to ignore instruction aliases if an operand that is not a register nor an immediate appears in the result instruction DAG. For example, the folllowing instruction alias pattern is not handled in MipsGenAsmWriter.inc because the third operand of BEQ is a brtarget:<br>
<br>def : InstAlias<"b $offset", (BEQ ZERO, ZERO, brtarget:$offset)>;<br><br>The code which decides not to include this alias is located near line 856 in AsmWriterEmitter.cpp:<br><br>for (unsigned i = 0, e = LastOpNo; i != e; ++i) {<br>
...<br> switch (RO.Kind) {<br> case CodeGenInstAlias::ResultOperand::K_Record: {<br> ...<br> if (Rec->isSubClassOf("RegisterClass")) {<br> ...<br> } else {<br> assert(Rec->isSubClassOf("Operand") && "Unexpected operand!"); // <- line 856<br>
// FIXME: We may need to handle these situations.<br> delete IAP;<br> IAP = 0;<br> CantHandle = true;<br> ...<br><br><br>My question is, what has to be changed to make MipsInstPrinter::printAliasInstr generate the code to handle the BEQ instruction alias?<br>
Is there a reason this part wasn't implemented?<br><br>