[flang-commits] [flang] [mlir] [mlir][flang] Added Weighted[Region]BranchOpInterface's. (PR #142079)
Christian Ulmann via flang-commits
flang-commits at lists.llvm.org
Tue Jun 3 23:00:02 PDT 2025
================
@@ -80,6 +81,49 @@ detail::verifyBranchSuccessorOperands(Operation *op, unsigned succNo,
return success();
}
+//===----------------------------------------------------------------------===//
+// WeightedBranchOpInterface
+//===----------------------------------------------------------------------===//
+
+static LogicalResult verifyWeights(Operation *op, DenseI32ArrayAttr weights,
+ int64_t weightsNum,
+ llvm::StringRef weightAnchorName,
+ llvm::StringRef weightRefName) {
+ if (weights) {
+ if (weights.size() != weightsNum)
+ return op->emitError() << "expects number of " << weightAnchorName
+ << " weights to match number of " << weightRefName
+ << ": " << weights.size() << " vs " << weightsNum;
+
+ for (auto weight : llvm::enumerate(weights.asArrayRef()))
----------------
Dinistro wrote:
```suggestion
for (auto [index, weight] : llvm::enumerate(weights.asArrayRef()))
```
Nit: structured bindings are more convenient
https://github.com/llvm/llvm-project/pull/142079
More information about the flang-commits
mailing list