[AsmParser] Rework logic around "region argument parsing"
authorChris Lattner <clattner@nondot.org>
Tue, 26 Apr 2022 19:03:03 +0000 (12:03 -0700)
committerChris Lattner <clattner@nondot.org>
Thu, 28 Apr 2022 18:12:44 +0000 (11:12 -0700)
commit5dedf911deb409f6293c71ef6ef524359740f1f0
treeb285a875296d066d70f7693b808c8d9455c147a4
parent6c81b57237164319b5429ee33957004aa21db2fa
[AsmParser] Rework logic around "region argument parsing"

The asm parser had a notional distinction between parsing an
operand (like "%foo" or "%4#3") and parsing a region argument
(which isn't supposed to allow a result number like #3).

Unfortunately the implementation has two problems:

1) It didn't actually check for the result number and reject
   it.  parseRegionArgument and parseOperand were identical.
2) It had a lot of machinery built up around it that paralleled
   operand parsing.  This also was functionally identical, but
   also had some subtle differences (e.g. the parseOptional
   stuff had a different result type).

I thought about just removing all of this, but decided that the
missing error checking was important, so I reimplemented it with
a `allowResultNumber` flag on parseOperand.  This keeps the
codepaths unified and adds the missing error checks.

Differential Revision: https://reviews.llvm.org/D124470
15 files changed:
flang/lib/Optimizer/Dialect/FIROps.cpp
mlir/include/mlir/IR/OpImplementation.h
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp
mlir/lib/Dialect/SCF/SCF.cpp
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
mlir/lib/IR/FunctionImplementation.cpp
mlir/lib/Parser/Parser.cpp
mlir/test/Dialect/Affine/invalid.mlir
mlir/test/lib/Dialect/Test/TestDialect.cpp