[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()); });
+ });
+
+ // Verify that no two operand, result or region share the same name.
----------------
math-fehr wrote:
Can you add a comment here that `irdl.operands` / result / region have a verifier that checks that there is not twice the same name inside each of them?
https://github.com/llvm/llvm-project/pull/123525
More information about the Mlir-commits
mailing list