Skip to content

Commit

Permalink
[VAN-1371] create multiple versions of functions as needed for unrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hoffman committed Jun 28, 2024
1 parent f690e1c commit 82962a2
Show file tree
Hide file tree
Showing 8 changed files with 539 additions and 31 deletions.
4 changes: 2 additions & 2 deletions circom/tests/arrays/array8.circom
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ component main = ArrayReturnTemplate(4);

//CHECK-LABEL: define{{.*}} i256* @return_array_B_{{[0-9]+}}
//CHECK-SAME: (i256* %[[ARENA:[0-9a-zA-Z_.]+]]){{.*}} {
//CHECK: %[[SRC_PTR:[0-9a-zA-Z_.]+]] = call i256* @return_array_A_{{[0-9]+}}(i256* %{{.*}})
//CHECK: %[[SRC_PTR:[0-9a-zA-Z_.]+]] = call i256* @return_array_A_{{[0-9\.]+}}(i256* %{{.*}})
//CHECK-NEXT: %[[DST_PTR:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %[[ARENA]], i32 2
//CHECK-NEXT: %[[COPY_SRC_0:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %[[SRC_PTR]], i32 0
//CHECK-NEXT: %[[COPY_DST_0:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %[[DST_PTR]], i32 0
Expand Down Expand Up @@ -59,7 +59,7 @@ component main = ArrayReturnTemplate(4);
//CHECK-NEXT: ret i256* %[[T10]]
//CHECK-NEXT: }

//CHECK-LABEL: define{{.*}} i256* @return_array_A_{{[0-9]+}}
//CHECK-LABEL: define{{.*}} i256* @return_array_A_{{[0-9\.]+}}
//CHECK-SAME: (i256* %[[ARENA:[0-9a-zA-Z_.]+]]){{.*}} {
//CHECK: return{{[0-9]+}}:
//CHECK-NEXT: %[[T0:[0-9a-zA-Z_.]+]] = getelementptr i256, i256* %[[ARENA]], i32 3
Expand Down
4 changes: 2 additions & 2 deletions circom/tests/calls/call_arg_arraymulti.circom
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ component main = CallArgTest();
//CHECK-NEXT: ret void
//CHECK-NEXT: }

//CHECK-LABEL: define{{.*}} i256 @sum_{{[0-9]+}}
//CHECK-LABEL: define{{.*}} i256 @sum_{{[0-9\.]+}}
//CHECK-SAME: (i256* %[[T00:[0-9a-zA-Z_.]+]]){{.*}} {
//CHECK-NEXT: [[$FUN_NAME:sum_[0-9]+]]:
//CHECK-NEXT: [[$FUN_NAME:sum_[0-9\.]+]]:
//CHECK-NEXT: br label %store1
//CHECK-EMPTY:
//CHECK-NEXT: store1:
Expand Down
4 changes: 2 additions & 2 deletions circom/tests/calls/call_arg_arraymulti_arraymulti.circom
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ component main = CallArgTest();
//CHECK-NEXT: ret void
//CHECK-NEXT: }
//
//CHECK-LABEL: define{{.*}} i256 @sum_{{[0-9]+}}
//CHECK-LABEL: define{{.*}} i256 @sum_{{[0-9\.]+}}
//CHECK-SAME: (i256* %[[T00:[0-9a-zA-Z_.]+]]){{.*}} {
//CHECK-NEXT: [[$FUN_NAME:sum_[0-9]+]]:
//CHECK-NEXT: [[$FUN_NAME:sum_[0-9\.]+]]:
//CHECK-NEXT: br label %store1
//CHECK-EMPTY:
//CHECK-NEXT: store1:
Expand Down
4 changes: 2 additions & 2 deletions circom/tests/controlflow/early_return_loop_1.circom
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ template EarlyReturn() {

component main = EarlyReturn();

//CHECK-LABEL: define{{.*}} i256 @noEarlyReturnFn_{{[0-9]+}}(i256* %0){{.*}} {
//CHECK-NEXT: noEarlyReturnFn_[[$F_ID_2:[0-9]+]]:
//CHECK-LABEL: define{{.*}} i256 @noEarlyReturnFn_{{[0-9\.]+}}(i256* %0){{.*}} {
//CHECK-NEXT: noEarlyReturnFn_[[$F_ID_2:[0-9\.]+]]:
//CHECK-NEXT: br label %store1
//CHECK-EMPTY:
//CHECK-NEXT: store1:
Expand Down
349 changes: 349 additions & 0 deletions circom/tests/controlflow/multiuse_func_with_loop.circom

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion circom/tests/type_conversions/bool_4.circom
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ component main = A();
//CHECK: store i256 %[[VAL]], i256* %{{[0-9]+}}

//CHECK-LABEL: define{{.*}} i256* @binop_bool_array_
//CHECK-SAME: [[$F_ID_2:[0-9]+]](i256* %0){{.*}} {
//CHECK-SAME: [[$F_ID_2:[0-9\.]+]](i256* %0){{.*}} {
//CHECK-COUNT-10: call void @..generated..loop.body.[[$F_ID_1]]([0 x i256]* %{{[0-9]+}}, [0 x i256]* null, i256* %{{[0-9]+}}, i256* %{{[0-9]+}}, i256* %{{[0-9]+}})

//CHECK-LABEL: define{{.*}} void @A_{{[0-9]+}}_run([0 x i256]* %0){{.*}} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> UnrolledBlockEnvData<'a> {
}

pub fn function_caller(&self) -> Option<&BucketId> {
None
self.base.function_caller()
}

pub fn get_context_kind(&self) -> EnvContextKind {
Expand Down
201 changes: 180 additions & 21 deletions circuit_passes/src/passes/loop_unroll/mod.rs

Large diffs are not rendered by default.

0 comments on commit 82962a2

Please sign in to comment.