Hello.
I’m wondering how to handle the case on Disassembler when the registers used in an instruction are fixed, but the registers need to be specified in AsmString.
For example, suppose there is a MOV instruction that moves from any register to the A
register. In this case, AsmString is MOV A, X
.
The source register is arbitrary, so the register information is included in the instruction, but the destination register is fixed at A
, so no information is included in the instruction. In this case, the Inst field specified in TableGen’s Instruction class does not contain the A
register information, so the Disassembler does not decode the A register info, and MCInst A register operand information is missing. As a result, the program (llvm-objdump) crashes when MCInstPrinter’s printOperand attempts to output more operands than there are in MCInst.
If the register is not in AsmString, it can be handled by using Defs/Uses, but This cannot apply in this case.
I tried writing AsmString, A, $src
, but this resulted in a syntax error as the number of operands did not match. This is because AsmParser parsed A
as a register operand. AsmParser parses A
in the assembly code as a register, and A
and $src
exist as operands. On the other hand, AsmString would expect $src
will be the only operand.