Question for Instalias in IR to assembly

Though I have looked at the Instalias class reference in LLVM source code, I still don’t understand how to use it correctly.

For below two branch instruction,JIRL and JR.
If I define an instalias like that, does it means, whenever I want to print"jirl $ZERO, $rj, 0 " , the asmprinter will print “jr $rj” instead?


// JR: jr $ra  (jump to address$ra)
//JIRL: jirl $rd, $rj, imm16(jump to address $rj+imm16, and push PC+4 into $rd)


 def : InstAlias<"jr $rj",                (JIRL      ZERO, GPROut:$rj, 0), 3>;

That third parameter you’ve set to 3 controls whether it’s printed (and which wins if multiple aliases could apply). Setting it to 0 would disable printing entirely.

I don’t think it applies here but some kinds of operands can be too complicated for the printer to detect as well. In that case no matter what the priority is it’ll never be printed.