From 653e3c406e4abe5da068f31227b0d5bfbd6806fc Mon Sep 17 00:00:00 2001 From: Timothy Hoffman <4001421+tim-hoffman@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:38:56 -0500 Subject: [PATCH] Add running pass name debug print (#46) --- circuit_passes/src/passes/conditional_flattening.rs | 4 ++++ .../src/passes/deterministic_subcomponent_invocation.rs | 4 ++++ circuit_passes/src/passes/loop_unroll.rs | 4 ++++ circuit_passes/src/passes/mapped_to_indexed.rs | 4 ++++ circuit_passes/src/passes/mod.rs | 5 +++++ circuit_passes/src/passes/simplification.rs | 4 ++++ circuit_passes/src/passes/unknown_index_sanitization.rs | 4 ++++ 7 files changed, 29 insertions(+) diff --git a/circuit_passes/src/passes/conditional_flattening.rs b/circuit_passes/src/passes/conditional_flattening.rs index 63ea9b185..84e32ed5d 100644 --- a/circuit_passes/src/passes/conditional_flattening.rs +++ b/circuit_passes/src/passes/conditional_flattening.rs @@ -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); } diff --git a/circuit_passes/src/passes/deterministic_subcomponent_invocation.rs b/circuit_passes/src/passes/deterministic_subcomponent_invocation.rs index 949bbda55..cb6448fcb 100644 --- a/circuit_passes/src/passes/deterministic_subcomponent_invocation.rs +++ b/circuit_passes/src/passes/deterministic_subcomponent_invocation.rs @@ -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); } diff --git a/circuit_passes/src/passes/loop_unroll.rs b/circuit_passes/src/passes/loop_unroll.rs index 318b64dbc..8aed5c73b 100644 --- a/circuit_passes/src/passes/loop_unroll.rs +++ b/circuit_passes/src/passes/loop_unroll.rs @@ -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); } diff --git a/circuit_passes/src/passes/mapped_to_indexed.rs b/circuit_passes/src/passes/mapped_to_indexed.rs index 7712f2b3b..4a7df6b32 100644 --- a/circuit_passes/src/passes/mapped_to_indexed.rs +++ b/circuit_passes/src/passes/mapped_to_indexed.rs @@ -153,6 +153,10 @@ impl InterpreterObserver for MappedToIndexedPass { } impl CircuitTransformationPass for MappedToIndexedPass { + fn name(&self) -> &str { + "MappedToIndexedPass" + } + fn get_updated_field_constants(&self) -> Vec { self.memory.borrow().constant_fields.clone() } diff --git a/circuit_passes/src/passes/mod.rs b/circuit_passes/src/passes/mod.rs index 7aef0c06c..7f8db765d 100644 --- a/circuit_passes/src/passes/mod.rs +++ b/circuit_passes/src/passes/mod.rs @@ -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(); @@ -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); } diff --git a/circuit_passes/src/passes/simplification.rs b/circuit_passes/src/passes/simplification.rs index 0f30d250b..4868231da 100644 --- a/circuit_passes/src/passes/simplification.rs +++ b/circuit_passes/src/passes/simplification.rs @@ -118,6 +118,10 @@ impl InterpreterObserver for SimplificationPass { } impl CircuitTransformationPass for SimplificationPass { + fn name(&self) -> &str { + "SimplificationPass" + } + fn get_updated_field_constants(&self) -> Vec { self.memory.borrow().constant_fields.clone() } diff --git a/circuit_passes/src/passes/unknown_index_sanitization.rs b/circuit_passes/src/passes/unknown_index_sanitization.rs index 31eb8a021..68d92da9d 100644 --- a/circuit_passes/src/passes/unknown_index_sanitization.rs +++ b/circuit_passes/src/passes/unknown_index_sanitization.rs @@ -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)),