[mlir] Add insert before/after to list-like constructs in C API
authorAlex Zinenko <zinenko@google.com>
Wed, 23 Sep 2020 13:02:47 +0000 (15:02 +0200)
committerAlex Zinenko <zinenko@google.com>
Wed, 23 Sep 2020 15:29:30 +0000 (17:29 +0200)
commitc538169ee99516c178ecc00a5ec5187d78941fac
tree7305c3e97c699270d8b0e04338b9c90cf9703c74
parent9abd1e8f4e5ddd6e5e592306432fb32dd68f4c14
[mlir] Add insert before/after to list-like constructs in C API

Blocks in a region and operations in a block are organized in a linked list.
The C API only provides functions to append or to insert elements at the
specified numeric position in the list. The latter is expensive since it
requires to traverse the list. Add insert before/after functionality with low
cost that relies on the iplist elements being convertible to iterators.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D88148
mlir/include/mlir-c/IR.h
mlir/lib/CAPI/IR/IR.cpp
mlir/test/CAPI/ir.c