-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Separate compilation and expression narrowing in
nargo
interf…
…ace (#4100) # Description ## Problem\* ## Summary\* This PR moves the responsibility for transforming a circuit into a certain expression width into `nargo_cli`. This gives us better separation of concerns where we no longer need to know the target backend before we compile a circuit (i.e. we can save a generic artifact and then target multiple backends using this) ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
1 parent
c29f85f
commit 62a4e37
Showing
18 changed files
with
95 additions
and
96 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use acvm::ExpressionWidth; | ||
use iter_extended::vecmap; | ||
use noirc_driver::{CompiledContract, CompiledProgram}; | ||
|
||
pub fn transform_program( | ||
mut program: CompiledProgram, | ||
expression_width: ExpressionWidth, | ||
) -> CompiledProgram { | ||
let (optimized_circuit, location_map) = | ||
acvm::compiler::compile(program.circuit, expression_width); | ||
|
||
program.circuit = optimized_circuit; | ||
program.debug.update_acir(location_map); | ||
program | ||
} | ||
|
||
pub fn transform_contract( | ||
contract: CompiledContract, | ||
expression_width: ExpressionWidth, | ||
) -> CompiledContract { | ||
let functions = vecmap(contract.functions, |mut func| { | ||
let (optimized_bytecode, location_map) = | ||
acvm::compiler::compile(func.bytecode, expression_width); | ||
func.bytecode = optimized_bytecode; | ||
func.debug.update_acir(location_map); | ||
func | ||
}); | ||
|
||
CompiledContract { functions, ..contract } | ||
} |
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.