================
@@ -54,6 +61,101 @@ struct CastInfo<To, const mlir::OpFoldResult>
namespace mlir {
/// Allow printing to a stream.
raw_ostream &operator<<(raw_ostream &os, OpFoldResult ofr);
+
+/// The result of a fold of any op. Replacement i is an Attribute (replace
+/// result i with a constant), a Value (replace result i with that value), or
+/// null / op->getResult(i) (keep result i). A separate bit records an in-place
+/// change of the op.
+class [[nodiscard]] OpFoldResults {
+public:
+ /// Failure: the fold did not apply and the IR is unchanged.
+ OpFoldResults() = default;
+ /// Failure, the same as the default constructor.
+ OpFoldResults(std::nullptr_t);
+ /// success(): the op changed in place. failure(): failure.
+ OpFoldResults(LogicalResult status);
+ /// One replacement. Valid only when the op has exactly one result at run
+ /// time. A null replacement, or the op's own result, keeps the result, so
the
+ /// fold fails. Unlike `OpFoldResult fold`, the op's own result does not mean
+ /// in place; use success() or setModifiedInPlace() for an in-place change.
+ OpFoldResults(OpFoldResult replacement);
+ OpFoldResults(Value replacement);
+ OpFoldResults(Attribute replacement);
----------------
joker-eph wrote:
It's not clear to me why we need these? Can we just get away with the
initializer_list variants?
https://github.com/llvm/llvm-project/pull/229215
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits