[Mlir-commits] [mlir] [MLIR] Add two-phase region parsing API to OpAsmParser (PR #190545)
Mehdi Amini
llvmlistbot at llvm.org
Mon Apr 6 07:11:26 PDT 2026
joker-eph wrote:
> I guess we would like to have something like, for example scf.for:
>
> region-arg($body) `=` $lowerBound `to` $upperBound` `step` $step `iter_args` `(` region-arg($body) `=` $init `)`
region-body($body)
> Underneath I imagine this would use two phase parser 1. parse region arguments 2. parse body and forward its parsed arguments to it.
I can imagine some syntax here, however I'm not clear on the need of the two-phases here. If this was all driven by the syntax like you're showing here then the generated code could construct directly the vector of region argument without this "2 phases" API. So I'm not totally clear on this.
Seems to me if we step back a bit, the fundamental being what you're doing here is providing the ability to convey "some state" between two custom parsers. You're hardcoding some API on the OpAsmParser so that this state can only be used for region argument parsing (actually, other than the API name, I would say "it can be used to carry `Argument`s between custom parsers"), but we could imagine generalizing it.
https://github.com/llvm/llvm-project/pull/190545
More information about the Mlir-commits
mailing list