This is an archive of the discontinued LLVM Phabricator instance.

[mlir] provide C API and Python bindings for symbol tables
ClosedPublic

Authored by ftynse on Oct 29 2021, 7:55 AM.

Details

Summary

Symbol tables are a largely useful top-level IR construct, for example, they
make it easy to access functions in a module by name instead of traversing the
list of module's operations to find the corresponding function.

Depends On D112886

Diff Detail

Event Timeline

ftynse created this revision.Oct 29 2021, 7:55 AM
ftynse requested review of this revision.Oct 29 2021, 7:55 AM
mehdi_amini added inline comments.Oct 29 2021, 12:17 PM
mlir/include/mlir-c/IR.h
776

Why don't we return a MlirStringRef with the new name to match the C++ API?

mlir/test/CAPI/ir.c
1864

I think we're missing an example of renaming, if you add an operation in the second module with the same name as one in the first module, move it there, and get the new name back.

mlir/test/python/ir/operation.py
842

These two lines are stressing my point from the parent revision: there should be a single API call to move an operation instead of a detach/reattach sequence.

ftynse updated this revision to Diff 383586.Oct 30 2021, 6:49 AM
ftynse marked 2 inline comments as done.

Address review.

mlir/include/mlir-c/IR.h
776

Because the C++ API does not return the new name either https://github.com/llvm/llvm-project/blob/3be3c944a5bacfd208b56853941b0fa4dec3ddcc/mlir/lib/IR/SymbolTable.cpp#L155.

I am happy to change that if desired.

mehdi_amini accepted this revision.Oct 30 2021, 12:12 PM
mehdi_amini added inline comments.
mlir/include/mlir-c/IR.h
776

Uh, I was sure we were returning the new name... Yeah it'd be good change to do so I think. But that's irrelevant to this patch.
(unless you want to minimize churn in the C API, so land the C++ change ahead of this one and rebase)

This revision is now accepted and ready to land.Oct 30 2021, 12:12 PM
ftynse updated this revision to Diff 383643.Oct 31 2021, 1:38 AM

Rebase and address review.

ftynse updated this revision to Diff 384034.Nov 2 2021, 4:04 AM

Rebase.

ftynse updated this revision to Diff 384046.Nov 2 2021, 4:40 AM

Another rebase.

This revision was landed with ongoing or failed builds.Nov 2 2021, 6:23 AM
This revision was automatically updated to reflect the committed changes.