-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ReuseIR] implement checks for closure ops (#26)
- Loading branch information
1 parent
e6b6323
commit b5f01d0
Showing
9 changed files
with
120 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
reuse-mlir/test/integration/basic/invalid_closure_args_number.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %not %reuse-opt %s 2>&1 | %FileCheck %s | ||
!closure = !reuse_ir.closure<(i32, i32) -> i32> | ||
module @test { | ||
func.func @closure_test() -> !reuse_ir.rc<!closure, nonatomic, nonfreezing> { | ||
// CHECK: error: 'reuse_ir.closure.new' op the number of arguments in the region must match the number of input types in the closure type | ||
%1 = reuse_ir.closure.new { | ||
^bb(%arg0: i32): | ||
reuse_ir.closure.yield %arg0 : i32 | ||
} : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
return %1 : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
reuse-mlir/test/integration/basic/invalid_closure_args_type.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %not %reuse-opt %s 2>&1 | %FileCheck %s | ||
!closure = !reuse_ir.closure<(index) -> index> | ||
module @test { | ||
func.func @closure_test() -> !reuse_ir.rc<!closure, nonatomic, nonfreezing> { | ||
// CHECK: error: 'reuse_ir.closure.new' op the types of arguments in the region must match the input types in the closure type | ||
%1 = reuse_ir.closure.new { | ||
^bb(%arg0: i32): | ||
%1 = arith.index_castui %arg0 : i32 to index | ||
reuse_ir.closure.yield %1 : index | ||
} : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
return %1 : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
reuse-mlir/test/integration/basic/invalid_closure_nonnull_return.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %not %reuse-opt %s 2>&1 | %FileCheck %s | ||
!closure = !reuse_ir.closure<(i32, i32)> | ||
module @test { | ||
func.func @closure_test() -> !reuse_ir.rc<!closure, nonatomic, nonfreezing> { | ||
// CHECK: error: 'reuse_ir.closure.yield' op cannot yield a value in a closure without output | ||
%1 = reuse_ir.closure.new { | ||
^bb(%arg0: i32, %arg1: i32): | ||
%2 = arith.addi %arg0, %arg1 : i32 | ||
reuse_ir.closure.yield %2 : i32 | ||
} : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
return %1 : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
reuse-mlir/test/integration/basic/invalid_closure_null_return.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %not %reuse-opt %s 2>&1 | %FileCheck %s | ||
!closure = !reuse_ir.closure<(i32, i32) -> i32> | ||
module @test { | ||
func.func @closure_test() -> !reuse_ir.rc<!closure, nonatomic, nonfreezing> { | ||
// CHECK: error: 'reuse_ir.closure.yield' op must yield a value in a closure with output | ||
%1 = reuse_ir.closure.new { | ||
^bb(%arg0: i32, %arg1: i32): | ||
%2 = arith.addi %arg0, %arg1 : i32 | ||
reuse_ir.closure.yield | ||
} : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
return %1 : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
reuse-mlir/test/integration/basic/invalid_closure_yield_type.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// RUN: %not %reuse-opt %s 2>&1 | %FileCheck %s | ||
!closure = !reuse_ir.closure<(i32, i32) -> i32> | ||
module @test { | ||
func.func @closure_test() -> !reuse_ir.rc<!closure, nonatomic, nonfreezing> { | ||
// CHECK: error: 'reuse_ir.closure.yield' op expected to yield a value of 'i32', but 'index' is found instead | ||
%1 = reuse_ir.closure.new { | ||
^bb(%arg0: i32, %arg1: i32): | ||
%2 = arith.addi %arg0, %arg1 : i32 | ||
%3 = arith.index_castui %2 : i32 to index | ||
reuse_ir.closure.yield %3 : index | ||
} : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
return %1 : !reuse_ir.rc<!closure, nonatomic, nonfreezing> | ||
} | ||
} |