-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: defunctionalization pass for ssa refactor (#1870)
* feat: defunctionalization pass * Apply suggestions from self code review * feat: optimize apply function generation & usage * feat: avoid unary apply fns * fix: clippy * style: cleanup after peer review * docs: updated comments on defunctionalize * style: apply suggestions from peer review * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * style: rename field * docs: fixed doc to avoid doctest * style: addressed pr comments * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * Update crates/noirc_evaluator/src/ssa_refactor/opt/defunctionalize.rs Co-authored-by: jfecher <jake@aztecprotocol.com> * refactor: extract set type of value to the dfg * Update crates/noirc_evaluator/src/ssa_refactor/ir/dfg.rs --------- Co-authored-by: jfecher <jake@aztecprotocol.com>
- Loading branch information
1 parent
b21d1e2
commit 1d5d84d
Showing
16 changed files
with
457 additions
and
42 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
5 changes: 5 additions & 0 deletions
5
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_fns_as_values/Nargo.toml
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,5 @@ | ||
[package] | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
1 change: 1 addition & 0 deletions
1
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_fns_as_values/Prover.toml
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 @@ | ||
x = "0" |
28 changes: 28 additions & 0 deletions
28
crates/nargo_cli/tests/test_data_ssa_refactor/brillig_fns_as_values/src/main.nr
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,28 @@ | ||
struct MyStruct { | ||
operation: fn (u32) -> u32, | ||
} | ||
|
||
fn main(x: u32) { | ||
assert(wrapper(increment, x) == x + 1); | ||
assert(wrapper(decrement, x) == x - 1); | ||
assert(wrapper_with_struct(MyStruct { operation: increment }, x) == x + 1); | ||
assert(wrapper_with_struct(MyStruct { operation: decrement }, x) == x - 1); | ||
} | ||
|
||
unconstrained fn wrapper(func: fn (u32) -> u32, param: u32) -> u32 { | ||
func(param) | ||
} | ||
|
||
unconstrained fn increment(x: u32) -> u32 { | ||
x + 1 | ||
} | ||
|
||
unconstrained fn decrement(x: u32) -> u32 { | ||
x - 1 | ||
} | ||
|
||
unconstrained fn wrapper_with_struct(my_struct: MyStruct, param: u32) -> u32 { | ||
let func = my_struct.operation; | ||
func(param) | ||
} | ||
|
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
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
Oops, something went wrong.