forked from OSchip/llvm-project
b164f23c29
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 |
||
---|---|---|
.. | ||
mlir | ||
.style.yapf | ||
CMakeLists.txt | ||
requirements.txt |