Skip to content

Commit

Permalink
[Arc] Add test for explicit sub-storages during state allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO authored and CircuitCoder committed Oct 31, 2024
1 parent c922f5a commit 7678feb
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions test/Dialect/Arc/allocate-state.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
// CHECK-LABEL: arc.model @test
arc.model @test io !hw.modty<input x : i1, output y : i1> {
^bb0(%arg0: !arc.storage):
// CHECK-NEXT: ([[PTR:%.+]]: !arc.storage<5780>):
// CHECK-NEXT: ([[PTR:%.+]]: !arc.storage<5796>):

// CHECK-NEXT: arc.alloc_storage [[PTR]][0] : (!arc.storage<5780>) -> !arc.storage<1159>
// CHECK-NEXT: offset = 0
arc.alloc_state %arg0 : (!arc.storage) -> !arc.state<i1>
// CHECK-NEXT: arc.alloc_storage [[PTR]][1] : (!arc.storage<5796>) -> !arc.storage<1>
%substorage0 = arc.alloc_storage %arg0 : (!arc.storage) -> !arc.storage
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][1]
// CHECK-NEXT: arc.alloc_state [[SUBPTR]]
// CHECK-SAME: offset = 0
arc.alloc_state %substorage0 : (!arc.storage) -> !arc.state<i1>

// CHECK-NEXT: arc.alloc_storage [[PTR]][16] : (!arc.storage<5796>) -> !arc.storage<1159>
// CHECK-NEXT: arc.initial {
arc.initial {
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][0] : !arc.storage<5780> -> !arc.storage<1159>
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][16] : !arc.storage<5796> -> !arc.storage<1159>
%0 = arc.alloc_state %arg0 : (!arc.storage) -> !arc.state<i1>
arc.alloc_state %arg0 : (!arc.storage) -> !arc.state<i8>
arc.alloc_state %arg0 : (!arc.storage) -> !arc.state<i16>
Expand All @@ -28,7 +37,7 @@ arc.model @test io !hw.modty<input x : i1, output y : i1> {
// CHECK-NEXT: scf.execute_region {
scf.execute_region {
arc.state_read %0 : <i1>
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][0] : !arc.storage<5780> -> !arc.storage<1159>
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][16] : !arc.storage<5796> -> !arc.storage<1159>
// CHECK-NEXT: [[STATE:%.+]] = arc.storage.get [[SUBPTR]][0] : !arc.storage<1159> -> !arc.state<i1>
// CHECK-NEXT: arc.state_read [[STATE]] : <i1>
arc.state_read %1 : <i1>
Expand All @@ -41,10 +50,10 @@ arc.model @test io !hw.modty<input x : i1, output y : i1> {
}
// CHECK-NEXT: }

// CHECK-NEXT: arc.alloc_storage [[PTR]][1168] : (!arc.storage<5780>) -> !arc.storage<4609>
// CHECK-NEXT: arc.alloc_storage [[PTR]][1184] : (!arc.storage<5796>) -> !arc.storage<4609>
// CHECK-NEXT: arc.initial {
arc.initial {
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][1168] : !arc.storage<5780> -> !arc.storage<4609>
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][1184] : !arc.storage<5796> -> !arc.storage<4609>
arc.alloc_memory %arg0 : (!arc.storage) -> !arc.memory<4 x i1, i1>
arc.alloc_memory %arg0 : (!arc.storage) -> !arc.memory<4 x i8, i1>
arc.alloc_memory %arg0 : (!arc.storage) -> !arc.memory<4 x i16, i1>
Expand All @@ -68,12 +77,12 @@ arc.model @test io !hw.modty<input x : i1, output y : i1> {
}
// CHECK-NEXT: }

// CHECK-NEXT: arc.alloc_storage [[PTR]][5778] : (!arc.storage<5780>) -> !arc.storage<2>
// CHECK-NEXT: arc.alloc_storage [[PTR]][5794] : (!arc.storage<5796>) -> !arc.storage<2>
// CHECK-NEXT: arc.initial {
arc.initial {
arc.root_input "x", %arg0 : (!arc.storage) -> !arc.state<i1>
arc.root_output "y", %arg0 : (!arc.storage) -> !arc.state<i1>
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][5778] : !arc.storage<5780> -> !arc.storage<2>
// CHECK-NEXT: [[SUBPTR:%.+]] = arc.storage.get [[PTR]][5794] : !arc.storage<5796> -> !arc.storage<2>
// CHECK-NEXT: arc.root_input "x", [[SUBPTR]] {offset = 0 : i32}
// CHECK-NEXT: arc.root_output "y", [[SUBPTR]] {offset = 1 : i32}
}
Expand Down

0 comments on commit 7678feb

Please sign in to comment.