[all-commits] [llvm/llvm-project] dd8e44: [mlir][CAPI] Add a simple MlirOpOperand API for Ml...

Mike Urbach via All-commits all-commits at lists.llvm.org
Mon Dec 12 13:15:10 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dd8e443539cc3e3cb4389268e58934910b5455c3
      https://github.com/llvm/llvm-project/commit/dd8e443539cc3e3cb4389268e58934910b5455c3
  Author: Mike Urbach <mikeurbach at gmail.com>
  Date:   2022-12-12 (Mon, 12 Dec 2022)

  Changed paths:
    M mlir/include/mlir-c/IR.h
    M mlir/include/mlir/CAPI/IR.h
    M mlir/lib/CAPI/IR/IR.cpp
    M mlir/test/CAPI/ir.c

  Log Message:
  -----------
  [mlir][CAPI] Add a simple MlirOpOperand API for MlirValue uses.

This allows basic IR traversal via the C API, which is useful for
analyses in languages other than C++.

This starts by defining an MlirOpOperand struct to encapsulate a pair
of an owner operation and an operand number.

A new API is added for MlirValue, to return the first use of the Value
as an MlirOpOperand, or a "null" MlirOpOperand if there are no uses.

A couple APIs are added for MlirOpOperand. The first checks if an
MlirOpOperand is "null", by checking if its owner's pointer is
null. The second supports iteration along the use-def lists by
accepting an MlirOpOperand and returning the next use of the Value as
another MlirOpOperand, or a "null" MlirOpOperand if there are no more
uses.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D139596




More information about the All-commits mailing list