-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(brillig): SSA globals code gen (#7021)
Co-authored-by: jfecher <[email protected]>
- Loading branch information
Showing
26 changed files
with
432 additions
and
107 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
39 changes: 39 additions & 0 deletions
39
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs
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,39 @@ | ||
use acvm::FieldElement; | ||
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; | ||
|
||
use super::{ | ||
BrilligArtifact, BrilligBlock, BrilligVariable, Function, FunctionContext, Label, ValueId, | ||
}; | ||
use crate::brillig::{brillig_ir::BrilligContext, DataFlowGraph}; | ||
|
||
pub(crate) fn convert_ssa_globals( | ||
enable_debug_trace: bool, | ||
globals: &Function, | ||
used_globals: &HashSet<ValueId>, | ||
) -> (BrilligArtifact<FieldElement>, HashMap<ValueId, BrilligVariable>) { | ||
let mut brillig_context = BrilligContext::new_for_global_init(enable_debug_trace); | ||
// The global space does not have globals itself | ||
let empty_globals = HashMap::default(); | ||
// We can use any ID here as this context is only going to be used for globals which does not differentiate | ||
// by functions and blocks. The only Label that should be used in the globals context is `Label::globals_init()` | ||
let mut function_context = FunctionContext::new(globals); | ||
brillig_context.enter_context(Label::globals_init()); | ||
|
||
let block_id = DataFlowGraph::default().make_block(); | ||
let mut brillig_block = BrilligBlock { | ||
function_context: &mut function_context, | ||
block_id, | ||
brillig_context: &mut brillig_context, | ||
variables: Default::default(), | ||
last_uses: HashMap::default(), | ||
globals: &empty_globals, | ||
building_globals: true, | ||
}; | ||
|
||
brillig_block.compile_globals(&globals.dfg, used_globals); | ||
|
||
brillig_context.return_instruction(); | ||
|
||
let artifact = brillig_context.artifact(); | ||
(artifact, function_context.ssa_value_allocations) | ||
} |
Oops, something went wrong.
82cb900
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.10
.rollup-merge
0.007
s0.006
s1.17
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench