Skip to content

Commit

Permalink
Add running pass name debug print (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hoffman authored Aug 18, 2023
1 parent 0e67892 commit 653e3c4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions circuit_passes/src/passes/conditional_flattening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ impl InterpreterObserver for ConditionalFlattening {
}

impl CircuitTransformationPass for ConditionalFlattening {
fn name(&self) -> &str {
"ConditionalFlattening"
}

fn pre_hook_circuit(&self, circuit: &Circuit) {
self.memory.borrow_mut().fill_from_circuit(circuit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ impl InterpreterObserver for DeterministicSubCmpInvokePass {
}

impl CircuitTransformationPass for DeterministicSubCmpInvokePass {
fn name(&self) -> &str {
"DeterministicSubCmpInvokePass"
}

fn pre_hook_circuit(&self, circuit: &Circuit) {
self.memory.borrow_mut().fill_from_circuit(circuit);
}
Expand Down
4 changes: 4 additions & 0 deletions circuit_passes/src/passes/loop_unroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ impl InterpreterObserver for LoopUnrollPass {
}

impl CircuitTransformationPass for LoopUnrollPass {
fn name(&self) -> &str {
"LoopUnrollPass"
}

fn pre_hook_circuit(&self, circuit: &Circuit) {
self.memory.borrow_mut().fill_from_circuit(circuit);
}
Expand Down
4 changes: 4 additions & 0 deletions circuit_passes/src/passes/mapped_to_indexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ impl InterpreterObserver for MappedToIndexedPass {
}

impl CircuitTransformationPass for MappedToIndexedPass {
fn name(&self) -> &str {
"MappedToIndexedPass"
}

fn get_updated_field_constants(&self) -> Vec<String> {
self.memory.borrow().constant_fields.clone()
}
Expand Down
5 changes: 5 additions & 0 deletions circuit_passes/src/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ macro_rules! pre_hook {
}

pub trait CircuitTransformationPass {
fn name(&self) -> &str;

fn transform_circuit(&self, circuit: &Circuit) -> Circuit {
self.pre_hook_circuit(&circuit);
let templates = circuit.templates.iter().map(|t| self.transform_template(t)).collect();
Expand Down Expand Up @@ -430,6 +432,9 @@ impl PassManager {
pub fn transform_circuit(&self, circuit: Circuit) -> Circuit {
let mut transformed_circuit = circuit;
for pass in self.passes.borrow().iter() {
if cfg!(debug_assertions) {
println!("Do {}...", pass.name());
}
transformed_circuit = pass.transform_circuit(&transformed_circuit);
assert_unique_ids_in_circuit(&transformed_circuit);
}
Expand Down
4 changes: 4 additions & 0 deletions circuit_passes/src/passes/simplification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ impl InterpreterObserver for SimplificationPass {
}

impl CircuitTransformationPass for SimplificationPass {
fn name(&self) -> &str {
"SimplificationPass"
}

fn get_updated_field_constants(&self) -> Vec<String> {
self.memory.borrow().constant_fields.clone()
}
Expand Down
4 changes: 4 additions & 0 deletions circuit_passes/src/passes/unknown_index_sanitization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ impl InterpreterObserver for UnknownIndexSanitizationPass {
}

impl CircuitTransformationPass for UnknownIndexSanitizationPass {
fn name(&self) -> &str {
"UnknownIndexSanitizationPass"
}

fn transform_load_bucket(&self, bucket: &LoadBucket) -> InstructionPointer {
let bounded_fn_symbol = match self.load_replacements.borrow().get(bucket) {
Some(index_range) => Some(get_array_load_symbol(index_range)),
Expand Down

0 comments on commit 653e3c4

Please sign in to comment.