aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2021-10-07 18:29:03 +0200
committerAlex Zinenko <zinenko@google.com>2021-10-08 09:49:48 +0200
commitb164f23c29fdf8b1e82fc4cfeab79c9fb6df918d (patch)
tree5544b5ca2877b401c7d6be8e23ad38b3142c1807 /llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
parentcb879d00d8d54383447c1d94ec4ef0b28873dcaa (diff)
downloadllvm-b164f23c29fdf8b1e82fc4cfeab79c9fb6df918d.zip
llvm-b164f23c29fdf8b1e82fc4cfeab79c9fb6df918d.tar.gz
llvm-b164f23c29fdf8b1e82fc4cfeab79c9fb6df918d.tar.bz2
[mlir][python] support taking ops instead of values in op constructors
Introduce support for accepting ops instead of values when constructing ops. A single-result op can be used instead of a value, including in lists of values, and any op can be used instead of a list of values. This is similar to, but more powerful, than the C++ API that allows for implicitly casting an OpType to Value if it is statically known to have a single result - the cast in Python is based on the op dynamically having a single result, and also handles the multi-result case. This allows to build IR in a more concise way: op = dialect.produce_multiple_results() other = dialect.produce_single_result() dialect.consume_multiple_results(other, op) instead of having to access the results manually op = dialect.produce.multiple_results() other = dialect.produce_single_result() dialect.consume_multiple_results(other.result, op.operation.results) The dispatch is implemented directly in Python and is triggered automatically for autogenerated OpView subclasses. Extension OpView classes should use the functions provided in ods_common.py if they want to implement this behavior. An alternative could be to implement the dispatch in the C++ bindings code, but it would require to forward opaque types through all Python functions down to a binding call, which makes it hard to inspect them in Python, e.g., to obtain the types of values. Reviewed By: gysit Differential Revision: https://reviews.llvm.org/D111306
Diffstat (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp')
0 files changed, 0 insertions, 0 deletions