[AsmParser] Match mandatory operands following optional operands.
authorIvan Kosarev <ivan.kosarev@amd.com>
Mon, 7 Nov 2022 10:22:51 +0000 (10:22 +0000)
committerIvan Kosarev <ivan.kosarev@amd.com>
Thu, 10 Nov 2022 12:49:27 +0000 (12:49 +0000)
Currently, the asm parser stops matching instruction operands as soon as
the first optional operand is encountered. This leads to the need for
custom checks on missing mandatory operands that come after optional
operands.

The patch changes the parser to always match all optional and mandatory
instruction operands, thus making the custom checks unnecessary. This is
particularly useful for the AMDGPU backend where we have numerous
optional instruction modifiers.

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

llvm/utils/TableGen/AsmMatcherEmitter.cpp

index d90b679..3be31de 100644 (file)
@@ -3686,8 +3686,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
     OS << "            break;\n";
     OS << "          }\n";
     OS << "        } else {\n";
-    OS << "          DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"but formal operand not required\\n\");\n";
-    OS << "          break;\n";
+    OS << "          DEBUG_WITH_TYPE(\"asm-matcher\", dbgs() << \"but formal "
+          "operand not required\\n\");\n";
     OS << "        }\n";
     OS << "        continue;\n";
   } else {