diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -379,7 +379,7 @@ operands. For example: ```mlir - %0 = alloca() : memref<8x64xf32> + %0 = alloca() : memref<8x64xf32> ``` The optional list of dimension operands are bound to the dynamic dimensions @@ -387,7 +387,7 @@ bound to the second dimension of the memref (which is dynamic). ```mlir - %0 = alloca(%d) : memref<8x?xf32> + %0 = alloca(%d) : memref<8x?xf32> ``` The optional list of symbol operands are bound to the symbols of the @@ -395,7 +395,7 @@ the symbol 's0' in the affine map specified in the allocs memref type. ```mlir - %0 = alloca()[%s] : memref<8x64xf32, + %0 = alloca()[%s] : memref<8x64xf32, affine_map<(d0, d1)[s0] -> ((d0 + s0), d1)>> ``` @@ -441,6 +441,34 @@ let hasFolder = 1; } +//===----------------------------------------------------------------------===// +// AssertOp +//===----------------------------------------------------------------------===// + +def AssertOp : Std_Op<"assert"> { + let summary = "Assert operation with message attribute"; + let description = [{ + Assert operation with single boolean operand and an error message attribute. + If the argument is `true` this operation has no effect. + Otherwise, the program execution will abort. + The provided error message may be used by a runtime to propagate the error + to the user. + + Example: + + ```mlir + assert %b, "Expected ... to be true" + ``` + }]; + + let arguments = (ins I1:$arg, StrAttr:$msg); + + let assemblyFormat = "$arg `,` $msg attr-dict"; + + // AssertOp is fully verified by its traits. + let verifier = ?; +} + //===----------------------------------------------------------------------===// // AssumeAlignmentOp //===----------------------------------------------------------------------===// diff --git a/mlir/test/Dialect/Standard/ops.mlir b/mlir/test/Dialect/Standard/ops.mlir --- a/mlir/test/Dialect/Standard/ops.mlir +++ b/mlir/test/Dialect/Standard/ops.mlir @@ -18,3 +18,7 @@ return %0 : tensor } +func @assert(%arg : i1) { + assert %arg, "Some message in case this assertion fails." + return +}