llvm.org GIT mirror llvm / bef419a
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362066 91177308-0d34-0410-b5e6-96231b3b80d8 Sjoerd Meijer 2 months ago
1 changed file(s) with 5 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
10711071 // handle, the target should be refactored to use operands instead of
10721072 // modifiers.
10731073 //
1074 // Also, check for instructions which reference the operand multiple times;
1075 // this implies a constraint we would not honor.
1074 // Also, check for instructions which reference the operand multiple times,
1075 // if they don't define a custom AsmMatcher: this implies a constraint that
1076 // the built-in matching code would not honor.
10761077 std::set OperandNames;
10771078 for (const AsmOperand &Op : AsmOperands) {
10781079 StringRef Tok = Op.Token;
10821083 "' not supported by asm matcher. Mark isCodeGenOnly!");
10831084 // Verify that any operand is only mentioned once.
10841085 // We reject aliases and ignore instructions for now.
1085 if (!IsAlias && Tok[0] == '$' && !OperandNames.insert(Tok).second) {
1086 if (!IsAlias && TheDef->getValueAsString("AsmMatchConverter").empty() &&
1087 Tok[0] == '$' && !OperandNames.insert(Tok).second) {
10861088 LLVM_DEBUG({
10871089 errs() << "warning: '" << TheDef->getName() << "': "
10881090 << "ignoring instruction with tied operand '"