[llvm] r224347 - [MC] Reset the MCInst in the matcher function before adding opcode/operands.

Ahmed Bougacha ahmed.bougacha at gmail.com
Tue Dec 16 10:05:28 PST 2014


Author: ab
Date: Tue Dec 16 12:05:28 2014
New Revision: 224347

URL: http://llvm.org/viewvc/llvm-project?rev=224347&view=rev
Log:
[MC] Reset the MCInst in the matcher function before adding opcode/operands.

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

Modified:
    llvm/trunk/test/MC/X86/intel-syntax-unsized-memory.s
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/trunk/test/MC/X86/intel-syntax-unsized-memory.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/intel-syntax-unsized-memory.s?rev=224347&r1=224346&r2=224347&view=diff
==============================================================================
--- llvm/trunk/test/MC/X86/intel-syntax-unsized-memory.s (original)
+++ llvm/trunk/test/MC/X86/intel-syntax-unsized-memory.s Tue Dec 16 12:05:28 2014
@@ -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]

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=224347&r1=224346&r2=224347&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Dec 16 12:05:28 2014
@@ -2965,6 +2965,7 @@ void AsmMatcherEmitter::run(raw_ostream
   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";





More information about the llvm-commits mailing list