diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td b/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td --- a/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td @@ -43,11 +43,11 @@ ```mlir // pdl.pattern contains metadata similarly to a `RewritePattern`. pdl.pattern : benefit(1) { - // External input operand values are specified via `pdl.input` operations. + // External input operand values are specified via `pdl.operand` operations. // Result types are constrainted via `pdl.type` operations. %resultType = pdl.type - %inputOperand = pdl.input + %inputOperand = pdl.operand %root, %results = pdl.operation "foo.op"(%inputOperand) -> %resultType pdl.rewrite %root { pdl.replace %root with (%inputOperand) diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td --- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td @@ -169,28 +169,28 @@ } //===----------------------------------------------------------------------===// -// pdl::InputOp +// pdl::OperandOp //===----------------------------------------------------------------------===// -def PDL_InputOp : PDL_Op<"input", [HasParent<"pdl::PatternOp">]> { - let summary = "Define an input value in a pattern"; +def PDL_OperandOp : PDL_Op<"operand", [HasParent<"pdl::PatternOp">]> { + let summary = "Define an external input operand in a pattern"; let description = [{ - `pdl.input` operations capture external operand edges into an operation + `pdl.operand` operations capture external operand edges into an operation node that originate from operations or block arguments not otherwise specified within the pattern (e.g. via `pdl.operation`). These operations - define, and partially constrain, input operands of a given operation. - A `pdl.input` may partially constrain an input operand by specifying an - expected value type (via a `pdl.type` operation). + define individual operands of a given operation. A `pdl.operand` may + partially constrain an operand by specifying an expected value type + (via a `pdl.type` operation). Example: ```mlir - // Define an input operand: - %operand = pdl.input + // Define an external operand: + %operand = pdl.operand - // Define an input operand with an expected type: + // Define an external operand with an expected type: %type = pdl.type : i32 - %attr = pdl.input : %type + %operand = pdl.operand : %type ``` }]; @@ -289,10 +289,10 @@ ```mlir // Provide a pattern matching "foo.op" that replaces the root with its - // input. + // operand. pdl.pattern : benefit(1) { %resultType = pdl.type - %inputOperand = pdl.input + %inputOperand = pdl.operand %root, %results = pdl.operation "foo.op"(%inputOperand) -> (%resultType) pdl.rewrite %root { pdl.replace %root with (%inputOperand) diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp --- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp @@ -36,7 +36,7 @@ // If this is an input value that has been visited in the tree, add a // constraint to ensure that both instances refer to the same value. if (!it.second && - isa(val.getDefiningOp())) { + isa(val.getDefiningOp())) { auto minMaxPositions = std::minmax(pos, it.first->second, comparePosDepth); predList.emplace_back(minMaxPositions.second, builder.getEqualTo(minMaxPositions.first)); @@ -67,8 +67,8 @@ // Prevent traversal into a null value. predList.emplace_back(pos, builder.getIsNotNull()); - // If this is a typed input, add a type constraint. - if (auto in = val.getDefiningOp()) { + // If this is a typed operand, add a type constraint. + if (auto in = val.getDefiningOp()) { if (Value type = in.type()) { getTreePredicates(predList, type, builder, inputs, builder.getType(pos)); diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp --- a/mlir/lib/Dialect/PDL/IR/PDL.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp @@ -43,7 +43,7 @@ for (Operation *user : op->getUsers()) { if (user->getBlock() != matcherBlock) continue; - if (isa(user)) + if (isa(user)) return success(); } return op->emitOpError() @@ -78,10 +78,10 @@ } //===----------------------------------------------------------------------===// -// pdl::InputOp +// pdl::OperandOp //===----------------------------------------------------------------------===// -static LogicalResult verify(InputOp op) { +static LogicalResult verify(OperandOp op) { return verifyHasBindingUseInMatcher(op); } @@ -419,7 +419,7 @@ static LogicalResult verify(TypeOp op) { return verifyHasBindingUseInMatcher( - op, "`pdl.attribute`, `pdl.input`, or `pdl.operation`"); + op, "`pdl.attribute`, `pdl.operand`, or `pdl.operation`"); } //===----------------------------------------------------------------------===// diff --git a/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir b/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir --- a/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir +++ b/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir @@ -66,8 +66,8 @@ // CHECK: pdl_interp.apply_constraint "multi_constraint" [true](%[[INPUT]], %[[INPUT1]] : !pdl.value, !pdl.value) pdl.pattern : benefit(1) { - %input0 = pdl.input - %input1 = pdl.input + %input0 = pdl.operand + %input1 = pdl.operand pdl.apply_constraint "multi_constraint"[true](%input0, %input1 : !pdl.value, !pdl.value) @@ -94,7 +94,7 @@ // CHECK-DAG: pdl_interp.are_equal %[[INPUT]], %[[INPUT1]] : !pdl.value pdl.pattern : benefit(1) { %type = pdl.type : i64 - %input = pdl.input : %type + %input = pdl.operand : %type %root = pdl.operation(%input, %input) pdl.rewrite %root with "rewriter" } diff --git a/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir b/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir --- a/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir +++ b/mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir @@ -8,7 +8,7 @@ // CHECK: func @pdl_generated_rewriter(%[[ROOT:.*]]: !pdl.operation, %[[INPUT:.*]]: !pdl.value) // CHECK: pdl_interp.apply_rewrite "rewriter" [true](%[[INPUT]] : !pdl.value) on %[[ROOT]] pdl.pattern : benefit(1) { - %input = pdl.input + %input = pdl.operand %root = pdl.operation "foo.op"(%input) pdl.rewrite %root with "rewriter"[true](%input : !pdl.value) } @@ -59,7 +59,7 @@ // CHECK: %[[OPERAND1:.*]] = pdl_interp.get_result 0 of %[[NEWOP]] // CHECK: pdl_interp.create_operation "foo.op2"(%[[OPERAND1]]) pdl.pattern : benefit(1) { - %operand = pdl.input + %operand = pdl.operand %root = pdl.operation "foo.op"(%operand) pdl.rewrite %root { %type = pdl.type : i32 @@ -80,7 +80,7 @@ // CHECK: %[[OPERAND1:.*]] = pdl_interp.get_result 0 of %[[NEWOP]] // CHECK: pdl_interp.create_operation "foo.op2"(%[[OPERAND1]]) pdl.pattern : benefit(1) { - %operand = pdl.input + %operand = pdl.operand %root = pdl.operation "foo.op"(%operand) pdl.rewrite %root { %type = pdl.type : i32 diff --git a/mlir/test/Dialect/PDL/invalid.mlir b/mlir/test/Dialect/PDL/invalid.mlir --- a/mlir/test/Dialect/PDL/invalid.mlir +++ b/mlir/test/Dialect/PDL/invalid.mlir @@ -63,12 +63,12 @@ // ----- //===----------------------------------------------------------------------===// -// pdl::InputOp +// pdl::OperandOp //===----------------------------------------------------------------------===// pdl.pattern : benefit(1) { // expected-error@below {{expected a bindable (i.e. `pdl.operation`) user when defined in the matcher body of a `pdl.pattern`}} - %unused = pdl.input + %unused = pdl.operand %op = pdl.operation "foo.op" pdl.rewrite %op with "rewriter" @@ -246,7 +246,7 @@ //===----------------------------------------------------------------------===// pdl.pattern : benefit(1) { - // expected-error@below {{expected a bindable (i.e. `pdl.attribute`, `pdl.input`, or `pdl.operation`) user when defined in the matcher body of a `pdl.pattern`}} + // expected-error@below {{expected a bindable (i.e. `pdl.attribute`, `pdl.operand`, or `pdl.operation`) user when defined in the matcher body of a `pdl.pattern`}} %unused = pdl.type %op = pdl.operation "foo.op" diff --git a/mlir/test/Dialect/PDL/ops.mlir b/mlir/test/Dialect/PDL/ops.mlir --- a/mlir/test/Dialect/PDL/ops.mlir +++ b/mlir/test/Dialect/PDL/ops.mlir @@ -11,7 +11,7 @@ %op0, %op0_result = pdl.operation {"attr" = %attribute} -> %type // Operation with input. - %input = pdl.input + %input = pdl.operand %root = pdl.operation(%op0_result, %input) pdl.rewrite %root with "rewriter" } @@ -19,7 +19,7 @@ // ----- pdl.pattern @rewrite_with_args : benefit(1) { - %input = pdl.input + %input = pdl.operand %root = pdl.operation(%input) pdl.rewrite %root with "rewriter"(%input : !pdl.value) } @@ -34,7 +34,7 @@ // ----- pdl.pattern @rewrite_with_args_and_params : benefit(1) { - %input = pdl.input + %input = pdl.operand %root = pdl.operation(%input) pdl.rewrite %root with "rewriter"["I am param"](%input : !pdl.value) }