-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
351 additions
and
87 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
37 changes: 37 additions & 0 deletions
37
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,37 @@ | ||
use acvm::FieldElement; | ||
use fxhash::FxHashMap as HashMap; | ||
|
||
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, | ||
) -> (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, &empty_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(), | ||
building_globals: true, | ||
}; | ||
|
||
brillig_block.compile_globals(&globals.dfg); | ||
|
||
brillig_context.return_instruction(); | ||
|
||
let artifact = brillig_context.artifact(); | ||
(artifact, function_context.ssa_value_allocations) | ||
} |
Oops, something went wrong.