[Mlir-commits] [mlir] [mlir][irdl] Introduce names in IRDL value lists (PR #123525)
Fehr Mathieu
llvmlistbot at llvm.org
Sun Jan 19 12:44:17 PST 2025
=?utf-8?q?Théo?= Degioanni,=?utf-8?q?Théo?= Degioanni
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/123525 at github.com>
================
@@ -78,30 +81,104 @@ LogicalResult DialectOp::verify() {
return success();
}
-LogicalResult OperandsOp::verify() {
- size_t numVariadicities = getVariadicity().size();
- size_t numOperands = getNumOperands();
+LogicalResult OperationOp::verifyRegions() {
+ // Stores pairs of value kinds and the list of names of values of this kind in
+ // the operation.
+ SmallVector<std::tuple<StringRef, llvm::SmallDenseSet<StringRef>>> valueNames;
+
+ auto insertNames = [&](StringRef kind, ArrayAttr names) {
+ llvm::SmallDenseSet<StringRef> nameSet;
+ nameSet.reserve(names.size());
+ for (auto name : names)
+ nameSet.insert(llvm::cast<StringAttr>(name).getValue());
+ valueNames.emplace_back(kind, std::move(nameSet));
+ };
- if (numOperands != numVariadicities)
- return emitOpError()
- << "the number of operands and their variadicities must be "
+ getBody().walk([&](Operation *op) {
+ TypeSwitch<Operation *>(op)
+ .Case<OperandsOp>(
+ [&](OperandsOp op) { insertNames("operands", op.getNames()); })
+ .Case<ResultsOp>(
+ [&](ResultsOp op) { insertNames("results", op.getNames()); })
+ .Case<RegionsOp>(
+ [&](RegionsOp op) { insertNames("regions", op.getNames()); });
+ });
----------------
math-fehr wrote:
Does it make sense to walk the entire region here? Should we instead only walk the toplevel operations in the block?
We might have regions in the future inside some IRDL contraints, so this will not walk over them later on.
https://github.com/llvm/llvm-project/pull/123525
More information about the Mlir-commits
mailing list