Skip to content

core: Match MLIR block name logic exactly #5567

@superlopuh

Description

@superlopuh

The block names are currently chosen in order of them being printed in the IR, including when printed as successors, which results in them having different orders to MLIR, where they are printed in the order they're in in the region.

It would be good to have near-0 effort when using tests from MLIR in xDSL, which is in conflict with inconsistencies in the textual format.

As noted in #5563, there's a simple mapping between the two in many cases:

// copied from mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
// basic block numbering is slightly different, the following perl one-liner gets us far:
// `perl -pe 's/\bbb(\d+)/"bb".($1==2 ? 0 : $1>2 ? $1-1 : $1)/ge'` (replace bb2 with bb0, and decrement all bb numbers > 2)
// The argument list of functions also contains an extra space in xDSL compared to MLIR.

This is due to the blocks being inserted by a lowering from regions usually, which apply similar logic. When changing the logic in xDSL to match MLIR, a similar script is likely useful to update the tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcorexDSL core (ir, textual format, ...)good first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions