[llvm] ef848f2 - [AsmParser] Match mandatory operands following optional operands.

Ivan Kosarev via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 04:51:27 PST 2022


Author: Ivan Kosarev
Date: 2022-11-10T12:49:27Z
New Revision: ef848f27d74dcff6455f05890566333bddbdb77e

URL: https://github.com/llvm/llvm-project/commit/ef848f27d74dcff6455f05890566333bddbdb77e
DIFF: https://github.com/llvm/llvm-project/commit/ef848f27d74dcff6455f05890566333bddbdb77e.diff

LOG: [AsmParser] Match mandatory operands following optional operands.

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

Added: 
    

Modified: 
    llvm/utils/TableGen/AsmMatcherEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index d90b6799773a..3be31de6ffcf 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -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 {


        


More information about the llvm-commits mailing list