[TableGen] Fix printing second PC-relative operand
authorIgor Kudrin <ikudrin@accesssoftek.com>
Wed, 23 Jun 2021 06:26:56 +0000 (13:26 +0700)
committerIgor Kudrin <ikudrin@accesssoftek.com>
Wed, 23 Jun 2021 06:27:37 +0000 (13:27 +0700)
commit36111f28edb1182273c6409c3fb7808e0e9cbd60
treea57f5fcb303a509f42b056c615c620fb382cceee
parentdfafd56daa003c1cf0604afda308111f7fff2f04
[TableGen] Fix printing second PC-relative operand

If an instruction has several operands and a PC-relative one is not the
first of them, the generator may produce the code that does not pass the
'Address' parameter to the printout method. For example, for an Arm
instruction 'LE LR, $imm', it reuses the same code as for other
instructions where the second operand is not PC-relative:

void ARMInstPrinter::printInstruction(...) {
...
  case 11:
    // BF16VDOTI_VDOTD, BF16VDOTI_VDOTQ, BF16VDOTS_VDOTD, ...
    printOperand(MI, 1, STI, O);
    O << ", ";
    printOperand(MI, 2, STI, O);
    break;
...

The patch fixes that by considering 'PCRel' when comparing
'AsmWriterOperand' values.

Differential Revision: https://reviews.llvm.org/D104698
llvm/test/TableGen/AsmWriterPCRelOp.td [new file with mode: 0644]
llvm/utils/TableGen/AsmWriterInst.h