This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add operations to BlockAndValueMapping and rename it to IRMapping
ClosedPublic

Authored by Mogball on Dec 8 2022, 12:24 PM.

Details

Summary

The patch adds operations to BlockAndValueMapping and renames it to IRMapping. When operations are cloned, old operations are mapped to the cloned operations. This allows mapping from an operation to a cloned operation. Example:

Operation *opWithRegion = ...
Operation *opInsideRegion = &opWithRegion->front().front();

IRMapping map
Operation *newOpWithRegion = opWithRegion->clone(map);
Operation *newOpInsideRegion = map.lookupOrNull(opInsideRegion);

Migration instructions:
All includes to mlir/IR/BlockAndValueMapping.h should be replaced with mlir/IR/IRMapping.h. All uses of BlockAndValueMapping need to be renamed to IRMapping.

Diff Detail

Event Timeline

Mogball created this revision.Dec 8 2022, 12:24 PM
Mogball requested review of this revision.Dec 8 2022, 12:24 PM

Something I'd considered in the past for this was just to evolve BlockAndValueMapping into something that could also map operations (i.e. something like an IRMapping). That feels like it would be nice here, to avoid duplicating the underlying code for cloning.

Mogball updated this revision to Diff 487234.Jan 8 2023, 2:16 PM

IRMapping

Mogball retitled this revision from [mlir][transforms] Add a clone utility that maps cloned operations to [mlir] Rename BlockAndValueMapping to IRMapping and add ops.Jan 8 2023, 2:27 PM
Mogball edited the summary of this revision. (Show Details)

For existing users they just need to include the new header and sed s/BlockAndValueMapping/IRMapping/g ?

Mogball retitled this revision from [mlir] Rename BlockAndValueMapping to IRMapping and add ops to [mlir] Add operations to BlockAndValueMapping and rename it to IRMapping.

For existing users they just need to include the new header and sed s/BlockAndValueMapping/IRMapping/g ?

Can you add the instructions in the commit message?

mlir/include/mlir/IR/IRMapping.h
21

IR entities?

94
mehdi_amini accepted this revision.Jan 10 2023, 11:18 AM
This revision is now accepted and ready to land.Jan 10 2023, 11:18 AM
Mogball updated this revision to Diff 488324.Jan 11 2023, 12:05 PM
Mogball marked an inline comment as done.

review comments and update description with migration instructions

Mogball edited the summary of this revision. (Show Details)Jan 11 2023, 12:07 PM
rriddle accepted this revision.Jan 12 2023, 12:31 PM

Nice, LG!

This revision was landed with ongoing or failed builds.Jan 12 2023, 1:16 PM
This revision was automatically updated to reflect the committed changes.
mlir/include/mlir/Dialect/Func/IR/FuncOps.td