From cec0c0cc7d06fd1a5bb04dd9388e0a7a78f42df7 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Mon, 22 Jan 2024 14:11:22 -0500 Subject: [PATCH 1/4] add --show-monomorphized option to dump monomorphized program during compilation --- compiler/noirc_driver/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index db69d41c704..e89688c9659 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -75,6 +75,10 @@ pub struct CompileOptions { /// Disables the builtin macros being used in the compiler #[arg(long, hide = true)] pub disable_macros: bool, + + /// Disables the builtin macros being used in the compiler + #[arg(long, hide = true)] + pub show_monomorphized: bool, } /// Helper type used to signify where only warnings are expected in file diagnostics @@ -391,6 +395,11 @@ pub fn compile_no_check( let hash = fxhash::hash64(&program); let hashes_match = cached_program.as_ref().map_or(false, |program| program.hash == hash); + if options.show_monomorphized { + println!("Monomorphized AST for program with hash: {}", hash); + println!("{program}"); + println!(); + } // If user has specified that they want to see intermediate steps printed then we should // force compilation even if the program hasn't changed. From cf8e34bc11d37d7023c692e40226013ebd229cf1 Mon Sep 17 00:00:00 2001 From: "Michael J. Klein" Date: Mon, 22 Jan 2024 14:17:37 -0500 Subject: [PATCH 2/4] remove extra newline: appears to be unneeded --- compiler/noirc_driver/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index e89688c9659..3d7545208f7 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -398,7 +398,6 @@ pub fn compile_no_check( if options.show_monomorphized { println!("Monomorphized AST for program with hash: {}", hash); println!("{program}"); - println!(); } // If user has specified that they want to see intermediate steps printed then we should From a2a8c7a72660c75f514b3a64da5ba9a143913c67 Mon Sep 17 00:00:00 2001 From: Michael J Klein Date: Mon, 22 Jan 2024 14:28:15 -0500 Subject: [PATCH 3/4] Update compiler/noirc_driver/src/lib.rs Co-authored-by: jfecher --- compiler/noirc_driver/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index 3d7545208f7..389c41be718 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -76,7 +76,7 @@ pub struct CompileOptions { #[arg(long, hide = true)] pub disable_macros: bool, - /// Disables the builtin macros being used in the compiler + /// Outputs the monomorphized IR to stdout for debugging #[arg(long, hide = true)] pub show_monomorphized: bool, } From 38c2569b4e98874a5fa7fe5326cc7c7b7ca42e10 Mon Sep 17 00:00:00 2001 From: Michael J Klein Date: Mon, 22 Jan 2024 14:28:37 -0500 Subject: [PATCH 4/4] Update compiler/noirc_driver/src/lib.rs Co-authored-by: jfecher --- compiler/noirc_driver/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index 389c41be718..a2570b26f3e 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -396,7 +396,6 @@ pub fn compile_no_check( let hash = fxhash::hash64(&program); let hashes_match = cached_program.as_ref().map_or(false, |program| program.hash == hash); if options.show_monomorphized { - println!("Monomorphized AST for program with hash: {}", hash); println!("{program}"); }