[MC] Reset the MCInst in the matcher function before adding opcode/operands.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 16 Dec 2014 18:05:28 +0000 (18:05 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 16 Dec 2014 18:05:28 +0000 (18:05 +0000)
On X86, the Intel asm parser tries to match all memory operand sizes when
none is explicitly specified.  For LEA, which doesn't really have a memory
operand (just a pointer one), this results in multiple successful matches,
one for each memory size.  There's no error because it's same opcode, so
really, it's just one match.  However, the tablegen'd matcher function
adds opcode/operands to the passed MCInst, and this results in multiple
duplicated operands.

This commit clears the MCInst in the tablegen'd matcher function.
We sometimes clear it when the match failed, so there's no expectation of
keeping the previous content anyway.

Differential Revision: http://reviews.llvm.org/D6670

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224347 91177308-0d34-0410-b5e6-96231b3b80d8

test/MC/X86/intel-syntax-unsized-memory.s
utils/TableGen/AsmMatcherEmitter.cpp

index 3467f8fb3e88250b9e0889300e755ecd54339649..c9d8e2a5f7c8a28b7a19533f111988c2a299be03 100644 (file)
@@ -24,3 +24,6 @@ vmovdqa [rax], ymm0
 
 // CHECK: vaddps (%rax), %zmm1, %zmm1
 vaddps zmm1, zmm1, [rax]
+
+// CHECK: leal 1(%r15d), %r9d
+lea r9d, [r15d+1]
index 5b2ff6792d4e1f8a4a8cb80c9cb017f912e5857a..85312b13923b3d792bc3643c5e02aa72205325fc 100644 (file)
@@ -2965,6 +2965,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
   OS << "      continue;\n";
   OS << "    }\n";
   OS << "\n";
+  OS << "    Inst.clear();\n\n";
   OS << "    if (matchingInlineAsm) {\n";
   OS << "      Inst.setOpcode(it->Opcode);\n";
   OS << "      convertToMapAndConstraints(it->ConvertFn, Operands);\n";