diff --git a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td --- a/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td +++ b/mlir/include/mlir/Dialect/PDLInterp/IR/PDLInterpOps.td @@ -370,6 +370,29 @@ let assemblyFormat = "$value `are` $types attr-dict `->` successors"; } +//===----------------------------------------------------------------------===// +// pdl_interp::ChooseRangeOp +//===----------------------------------------------------------------------===// + +def PDLInterp_ChooseRangeOp + : PDLInterp_Op<"choose_range", [NoSideEffect]> { + let summary = "Nondeterministic choice of a range of PDL Values from a list" + "of ranges."; + let description = [{ + `pdl_interp.choose_range` returns an `range` of PDL Values from a given + `list` of ranges. A range/ordering of PDL values is selected and then the + rest of the pattern is executed until `pdl_interp.finalize` is reached. + Example: + ```mlir + %order = pdl_interp.choose_range from %list + ``` + }]; + + let arguments = (ins PDL_RangeOf>:$list); + let results = (outs PDL_RangeOf:$range); + let assemblyFormat = "`from` $list attr-dict"; +} + //===----------------------------------------------------------------------===// // pdl_interp::ContinueOp //===----------------------------------------------------------------------===// @@ -719,6 +742,29 @@ let assemblyFormat = "`of` $value `:` type($value) attr-dict"; } +//===----------------------------------------------------------------------===// +// pdl_interp::GetItemOp +//===----------------------------------------------------------------------===// + +def PDLInterp_GetItemOp : PDLInterp_Op<"get_item"> { + let summary = "Gets an operand at index from a range of values."; + let description = [{ + `pdl_interp.get_item` gets a `value` specified at a particular + `index` from a range of values/operands, `values`. + Example: + ```mlir + %0 = pdl_interp.get_item 0 from %values + ``` + }]; + + let arguments = (ins + PDL_RangeOf:$values, + Confined:$index + ); + let results = (outs PDL_Value:$value); + let assemblyFormat = "$index `from` $values attr-dict"; +} + //===----------------------------------------------------------------------===// // pdl_interp::GetOperandOp //===----------------------------------------------------------------------===// @@ -786,6 +832,28 @@ ]; } +//===----------------------------------------------------------------------===// +// pdl_interp::GetPermutationsOp +//===----------------------------------------------------------------------===// + +def PDLInterp_GetPermutationsOp : + PDLInterp_Op<"get_permutations", [NoSideEffect]> { + let summary = "Get the permutations of given list of PDL Values."; + let description = [{ + `pdl_interp.get_permutations` operation gets all the permutations of a given + list of PDL Values. If the `list` has values [0 , 1] then `permutations` will + be a list of lists [[0 , 1], [1 , 0]]. + Example: + ```mlir + %0 = pdl_interp.get_permutations for %list + ``` + }]; + + let arguments = (ins PDL_RangeOf:$list); + let results = (outs PDL_RangeOf>:$permutations); + let assemblyFormat = "`for` $list attr-dict"; +} + //===----------------------------------------------------------------------===// // pdl_interp::GetResultOp //===----------------------------------------------------------------------===// @@ -960,6 +1028,28 @@ ]; } +//===----------------------------------------------------------------------===// +// pdl_interp::IsCommutativeOp +//===----------------------------------------------------------------------===// +def PDLInterp_IsCommutativeOp + : PDLInterp_PredicateOp<"is_commutative", [NoSideEffect]> { + let summary = "Check if a positional value is a commutative operation"; + let description = [{ + `pdl_interp.is_commutative` operation checks whether a positional value is a + commutative operation, and on success this operation branches to the true + destination; otherwise, the false destination is taken. + + Example: + + ```mlir + pdl_interp.is_commutative %op : !pdl.operation -> ^matchDest, ^failureDest + ``` + }]; + + let arguments = (ins PDL_Operation:$op); + let assemblyFormat = "$op `:` type($op) attr-dict `->` successors"; +} + //===----------------------------------------------------------------------===// // pdl_interp::IsNotNullOp //===----------------------------------------------------------------------===//