From 7678feb7b329e3329b216ebff6750f7347d0982c Mon Sep 17 00:00:00 2001 From: Asuna Date: Thu, 31 Oct 2024 19:56:44 +0800 Subject: [PATCH] [Arc] Add test for explicit sub-storages during state allocation --- test/Dialect/Arc/allocate-state.mlir | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/test/Dialect/Arc/allocate-state.mlir b/test/Dialect/Arc/allocate-state.mlir index ede5ee063289..d28b6e156a53 100644 --- a/test/Dialect/Arc/allocate-state.mlir +++ b/test/Dialect/Arc/allocate-state.mlir @@ -3,12 +3,21 @@ // CHECK-LABEL: arc.model @test arc.model @test io !hw.modty { ^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 + // 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 + + // 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 arc.alloc_state %arg0 : (!arc.storage) -> !arc.state arc.alloc_state %arg0 : (!arc.storage) -> !arc.state @@ -28,7 +37,7 @@ arc.model @test io !hw.modty { // CHECK-NEXT: scf.execute_region { scf.execute_region { arc.state_read %0 : - // 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 // CHECK-NEXT: arc.state_read [[STATE]] : arc.state_read %1 : @@ -41,10 +50,10 @@ arc.model @test io !hw.modty { } // 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> @@ -68,12 +77,12 @@ arc.model @test io !hw.modty { } // 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 arc.root_output "y", %arg0 : (!arc.storage) -> !arc.state - // 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} }