diff options
author | Nicolai Hähnle <[email protected]> | 2017-05-20 17:19:06 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-07-05 12:27:07 +0200 |
commit | 34df9525f607cab0208ad9b7006b7476f0a0fe79 (patch) | |
tree | ef6f0891dd9905f1973e00aed07d36344b1046ec /src | |
parent | 3628efedf29d2b5e181ea88f24db518038ab1a92 (diff) |
nir: add NIR_PRINT environment variable
Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/nir/nir.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 1b4e47058d4..c41b0dc9313 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2308,11 +2308,22 @@ should_clone_nir(void) return should_clone; } + +static inline bool +should_print_nir(void) +{ + static int should_print = -1; + if (should_print < 0) + should_print = env_var_as_boolean("NIR_PRINT", false); + + return should_print; +} #else static inline void nir_validate_shader(nir_shader *shader) { (void) shader; } static inline void nir_metadata_set_validation_flag(nir_shader *shader) { (void) shader; } static inline void nir_metadata_check_validation_flag(nir_shader *shader) { (void) shader; } static inline bool should_clone_nir(void) { return false; } +static inline bool should_print_nir(void) { return false; } #endif /* DEBUG */ #define _PASS(nir, do_pass) do { \ @@ -2327,14 +2338,22 @@ static inline bool should_clone_nir(void) { return false; } #define NIR_PASS(progress, nir, pass, ...) _PASS(nir, \ nir_metadata_set_validation_flag(nir); \ + if (should_print_nir()) \ + printf("%s\n", #pass); \ if (pass(nir, ##__VA_ARGS__)) { \ progress = true; \ + if (should_print_nir()) \ + nir_print_shader(nir, stdout); \ nir_metadata_check_validation_flag(nir); \ } \ ) #define NIR_PASS_V(nir, pass, ...) _PASS(nir, \ + if (should_print_nir()) \ + printf("%s\n", #pass); \ pass(nir, ##__VA_ARGS__); \ + if (should_print_nir()) \ + nir_print_shader(nir, stdout); \ ) void nir_calc_dominance_impl(nir_function_impl *impl); |