Add InsertionPoint and context managers to the Python API.
authorStella Laurenzo <stellaraccident@gmail.com>
Thu, 29 Oct 2020 06:16:36 +0000 (23:16 -0700)
committerStella Laurenzo <stellaraccident@gmail.com>
Fri, 30 Oct 2020 00:50:13 +0000 (17:50 -0700)
commitc645ea5e29e5e42598c3be67a28698405e8bc563
treeb78ff65e8db2eb8cdff2d6a66c79f02acfc0a9e7
parentb8c2d60df522d553a0752772aeffb4b2ad84678e
Add InsertionPoint and context managers to the Python API.

* Removes index based insertion. All insertion now happens through the insertion point.
* Introduces thread local context managers for implicit creation relative to an insertion point.
* Introduces (but does not yet use) binding the Context to the thread local context stack. Intent is to refactor all methods to take context optionally and have them use the default if available.
* Adds C APIs for mlirOperationGetParentOperation(), mlirOperationGetBlock() and mlirBlockGetTerminator().
* Removes an assert in PyOperation creation that was incorrectly constraining. There is already a TODO to rework the keepAlive field that it was guarding and without the assert, it is no worse than the current state.

Differential Revision: https://reviews.llvm.org/D90368
mlir/include/mlir-c/IR.h
mlir/lib/Bindings/Python/IRModules.cpp
mlir/lib/Bindings/Python/IRModules.h
mlir/lib/CAPI/IR/IR.cpp
mlir/test/Bindings/Python/dialects.py
mlir/test/Bindings/Python/insertion_point.py [new file with mode: 0644]
mlir/test/Bindings/Python/ir_operation.py
mlir/test/CAPI/ir.c