[PATCH] D21994: [mips][ias] Check '$rs = $rd' constraints when both registers are in AsmText.

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 5 07:42:57 PDT 2016


dsanders created this revision.
dsanders added a reviewer: sdardis.
dsanders added a subscriber: llvm-commits.
Herald added subscribers: sdardis, dsanders.

This is one possible solution to the problem of ignoring constraints that Simon
raised in D21615 but it's a bit of a hack.

The integrated assembler currently ignores violations of the tied register
constraints when the operands involved in a tie are both present in the AsmText.
For example, 'dati $rs, $rt, $imm' with the '$rs = $rt' will silently replace
$rt with $rs. So 'dati $2, $3, 1' is processed as if the user provided
'dati $2, $2, 1' without any diagnostic being emitted.

This is difficult to solve properly because there are multiple parts of the
matcher that are silently forcing these constraints to be met. Tied operands are
rendered to instructions by cloning previously rendered operands but this is
unnecessary because the matcher was already instructed to render the operand it
would have cloned. This is also unnecessary because earlier code has already
replaced the MCParsedOperand with the one it was tied to (so the parsed input
is matched as if it were 'dati <RegIdx 2>, <RegIdx 2>, <Imm 1>'). As a result,
it looks like fixing this properly amounts to a rewrite of the tied operand
handling which affects all targets.

This patch however, merely inserts a checking hook just before the
substitution of MCParsedOperands and the Mips target overrides it. It's not
possible to accurately check the registers are the same this early (because
numeric registers haven't been bound to a register class yet) so it cheats a
bit and checks that the tokens that produced the operand are lexically
identical. This works because tied registers need to have the same register
class but it does have a flaw. It will reject 'dati $4, $a0, 1' for violating
the constraint even though $a0 ends up as the same register as $4.

http://reviews.llvm.org/D21994

Files:
  include/llvm/MC/MCParser/MCTargetAsmParser.h
  lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  lib/Target/Mips/Mips64r6InstrInfo.td
  test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt
  test/MC/Disassembler/Mips/mips64r6/valid-mips64r6.txt
  test/MC/Mips/mips64r6/invalid.s
  test/MC/Mips/mips64r6/valid.s
  utils/TableGen/AsmMatcherEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21994.62751.patch
Type: text/x-patch
Size: 19751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160705/da2fc269/attachment.bin>


More information about the llvm-commits mailing list