Current definition of subtract with immediate instruction aliases uses CodeGenOnly defined instructions and post matcher expansion methods to emit real instructions add with immediate. However, they can directly alias add with immediate instruction and remove unnecessary definitions and code in MipsAsmParser.cpp. This patch makes no change in functionality, just removes unnecessary definitions and code.
This is a side note and something we need to fix in the future. The transformation that we do in MipsAsmParser.cpp:parseInvNum isn't entirely correct as it doesn't taking into account the size of the operands. For example, subu $2,-32768 is equivalent to addu $2, $2, 32768 but 32768 isn't encodable. We should load the immediate into $at and then use $at in the arithmetic instruction. While we don't do this, shall we emit an error message so that we don't end up with a wrong encoded immediate ?
Yes, the number should be parsed as immediate and then converted according to the size, that was the idea behind complex expansion. However, I'm facing difficulties with aliases right now, since the number of operands in alias may not correspond the number of operands in definition and that causes access violation.
Yes, the number should be parsed as immediate and then converted according to the size
This is probably what you meant but just to be sure: It should be parsed as a generic integer, tested as an integer of the right size, then rendered to the MCInst as a generic integer. You only need to override the predicate function.