[Mlir-commits] [mlir] [mlir][transform] Add transform.get_operand op (PR #78397)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Wed Jan 17 01:05:13 PST 2024
================
@@ -1464,6 +1464,35 @@ transform::GetProducerOfOperand::apply(transform::TransformRewriter &rewriter,
return DiagnosedSilenceableFailure::success();
}
+//===----------------------------------------------------------------------===//
+// GetOperandOp
+//===----------------------------------------------------------------------===//
+
+DiagnosedSilenceableFailure
+transform::GetOperandOp::apply(transform::TransformRewriter &rewriter,
+ transform::TransformResults &results,
+ transform::TransformState &state) {
+ std::optional<int64_t> maybeOperandNumber = getOperandNumber();
+ SmallVector<Value> operands;
+ for (Operation *target : state.getPayloadOps(getTarget())) {
+ if (!maybeOperandNumber) {
+ for (Value operand : target->getOperands())
+ operands.push_back(operand);
----------------
ftynse wrote:
Nit: `llvm::append_range` should work here, and will avoid the potential multiple-reallocation issue due to appending to vector in a loop.
https://github.com/llvm/llvm-project/pull/78397
More information about the Mlir-commits
mailing list