[Mlir-commits] [mlir] e07c968 - [mlir][pdl][NFC] Rename InputOp to OperandOp
River Riddle
llvmlistbot at llvm.org
Wed Mar 3 15:55:33 PST 2021
Author: River Riddle
Date: 2021-03-03T15:48:00-08:00
New Revision: e07c968a6da0c280b58e065d17698a30a3a91eab
URL: https://github.com/llvm/llvm-project/commit/e07c968a6da0c280b58e065d17698a30a3a91eab
DIFF: https://github.com/llvm/llvm-project/commit/e07c968a6da0c280b58e065d17698a30a3a91eab.diff
LOG: [mlir][pdl][NFC] Rename InputOp to OperandOp
This better matches the actual IR concept that is being modeled, and is consistent with how the rest of PDL is structured.
Differential Revision: https://reviews.llvm.org/D95718
Added:
Modified:
mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td
mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-matcher.mlir
mlir/test/Conversion/PDLToPDLInterp/pdl-to-pdl-interp-rewriter.mlir
mlir/test/Dialect/PDL/invalid.mlir
mlir/test/Dialect/PDL/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td b/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td
index 14a8400a79b9..c6d76be48494 100644
--- a/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td
+++ b/mlir/include/mlir/Dialect/PDL/IR/PDLDialect.td
@@ -43,11 +43,11 @@ def PDL_Dialect : Dialect {
```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
index 27fdd75791e4..812a71c5f099 100644
--- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
+++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
@@ -169,28 +169,28 @@ def PDL_EraseOp : PDL_Op<"erase", [HasParent<"pdl::RewriteOp">]> {
}
//===----------------------------------------------------------------------===//
-// 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 @@ def PDL_PatternOp : PDL_Op<"pattern", [IsolatedFromAbove, Symbol]> {
```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
index 81e397d5cfd3..22794aa4d991 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
@@ -36,7 +36,7 @@ static void getTreePredicates(std::vector<PositionalPredicate> &predList,
// 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<pdl::AttributeOp, pdl::InputOp, pdl::TypeOp>(val.getDefiningOp())) {
+ isa<pdl::AttributeOp, pdl::OperandOp, pdl::TypeOp>(val.getDefiningOp())) {
auto minMaxPositions = std::minmax(pos, it.first->second, comparePosDepth);
predList.emplace_back(minMaxPositions.second,
builder.getEqualTo(minMaxPositions.first));
@@ -67,8 +67,8 @@ static void getTreePredicates(std::vector<PositionalPredicate> &predList,
// 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<pdl::InputOp>()) {
+ // If this is a typed operand, add a type constraint.
+ if (auto in = val.getDefiningOp<pdl::OperandOp>()) {
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
index 6ee8a1bf4491..e82c4ab6fb16 100644
--- a/mlir/lib/Dialect/PDL/IR/PDL.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp
@@ -43,7 +43,7 @@ verifyHasBindingUseInMatcher(Operation *op,
for (Operation *user : op->getUsers()) {
if (user->getBlock() != matcherBlock)
continue;
- if (isa<AttributeOp, InputOp, OperationOp, RewriteOp>(user))
+ if (isa<AttributeOp, OperandOp, OperationOp, RewriteOp>(user))
return success();
}
return op->emitOpError()
@@ -78,10 +78,10 @@ static LogicalResult verify(AttributeOp op) {
}
//===----------------------------------------------------------------------===//
-// pdl::InputOp
+// pdl::OperandOp
//===----------------------------------------------------------------------===//
-static LogicalResult verify(InputOp op) {
+static LogicalResult verify(OperandOp op) {
return verifyHasBindingUseInMatcher(op);
}
@@ -419,7 +419,7 @@ static LogicalResult verify(RewriteOp op) {
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
index f0ace8d28d32..9d87ba5a21f0 100644
--- 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 @@ module @constraints {
// 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 @@ module @inputs {
// 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
index f4ac4e1c66f6..4b6b1ae75700 100644
--- 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 @@ module @external {
// 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 @@ module @operation_operands {
// 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 @@ module @operation_operands {
// 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
index f5c65409e671..0f4d96778277 100644
--- a/mlir/test/Dialect/PDL/invalid.mlir
+++ b/mlir/test/Dialect/PDL/invalid.mlir
@@ -63,12 +63,12 @@ pdl.pattern : benefit(1) {
// -----
//===----------------------------------------------------------------------===//
-// pdl::InputOp
+// pdl::OperandOp
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
// expected-error at 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) {
//===----------------------------------------------------------------------===//
pdl.pattern : benefit(1) {
- // expected-error at 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 at 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
index 37db36e654d4..5b6a642daf83 100644
--- a/mlir/test/Dialect/PDL/ops.mlir
+++ b/mlir/test/Dialect/PDL/ops.mlir
@@ -11,7 +11,7 @@ pdl.pattern @operations : benefit(1) {
%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 @operations : benefit(1) {
// -----
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_params : benefit(1) {
// -----
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)
}
More information about the Mlir-commits
mailing list