This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Support setting operand values in C and Python APIs.
ClosedPublic

Authored by mikeurbach on Apr 27 2021, 1:43 PM.

Details

Summary

This adds mlirOperationSetOperand to the IR C API, similar to the
function to get an operand.

In the Python API, this adds operands[index] = value syntax, similar
to the syntax to get an operand with operands[index].

Diff Detail

Event Timeline

mikeurbach created this revision.Apr 27 2021, 1:43 PM
mikeurbach requested review of this revision.Apr 27 2021, 1:43 PM
mikeurbach added a subscriber: jdd.Apr 27 2021, 1:49 PM

This is something @jdd and I will use in circt, and seemed generally useful upstream in mlir. However, we weren't sure about the addition of mlirOperationSetOperand to the C API. Are there deeper considerations preventing this from being added? Or is it just something that was demand-driven and has yet to be demanded? I've been testing this patch locally with some small programs for about a week and haven't found any issues with setting operands from Python via the proposed C API.

mehdi_amini accepted this revision.Apr 27 2021, 1:54 PM
mehdi_amini added inline comments.
mlir/lib/CAPI/IR/IR.cpp
357

Can you add coverage to this function through the C unitest?

This revision is now accepted and ready to land.Apr 27 2021, 1:54 PM

Add C unittest for operands API

mikeurbach marked an inline comment as done.

Add cleanup code to new C unittest.