[TableGen] AsmMatcher: allow repeated input operands
authorSjoerd Meijer <sjoerd.meijer@arm.com>
Thu, 30 May 2019 07:38:09 +0000 (07:38 +0000)
committerSjoerd Meijer <sjoerd.meijer@arm.com>
Thu, 30 May 2019 07:38:09 +0000 (07:38 +0000)
commitbb4839d4157b3dc2552687f2e6dcb20245d2988e
tree5b4fd5ac1b1bbbdf6e8258f2589bb6744affdf7c
parent433a19168379cc87c7ea4ee8dbdca5b76f2e4b30
[TableGen] AsmMatcher: allow repeated input operands

If an assembly instruction has to mention an input operand name twice,
for example the MVE VMOV instruction that accesses two lanes of the
same vector by writing 'vmov r1, r2, q0[3], q0[1]', then the obvious
way to write its AsmString is to include the same operand (here $Qd)
twice. But this causes the AsmMatcher generator to omit that
instruction completely from the match table, on the basis that the
generator isn't clever enough to deal with the duplication.

But you need to have _some_ way of dealing with an instruction like
this - and in this case, where the mnemonic is shared with many other
instructions that the AsmMatcher does handle, it would be very painful
to take it out of the AsmMatcher system completely.

A nicer way is to add a custom AsmMatchConverter routine, and let that
deal with the problem if the autogenerated converter can't. But that
doesn't work, because TableGen leaves the instruction out of its table
_even_ if you provide a custom converter.

Solution: this change, which makes TableGen relax the restriction on
duplicated operands in the case where there's a custom converter.

Patch by: Simon Tatham

Differential Revision: https://reviews.llvm.org/D60695

llvm-svn: 362066
llvm/utils/TableGen/AsmMatcherEmitter.cpp