diff options
author | Connor Abbott <[email protected]> | 2015-06-23 10:34:22 -0700 |
---|---|---|
committer | Connor Abbott <[email protected]> | 2015-06-23 10:34:22 -0700 |
commit | fe1269cf28784450f0032432eb1f32e379beec17 (patch) | |
tree | 5ba9c13b17aee6cc731f045547385e39b85feed5 /src | |
parent | 9a3dda101e88142cb3b3eebb18883edecb21b375 (diff) |
nir/builder: add support for inserting before/after blocks
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/nir/nir_builder.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index cffe38abf0e..7d449262585 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -28,6 +28,10 @@ struct exec_list; typedef struct nir_builder { struct exec_list *cf_node_list; + + nir_block *before_block; + nir_block *after_block; + nir_instr *before_instr; nir_instr *after_instr; @@ -48,6 +52,30 @@ nir_builder_insert_after_cf_list(nir_builder *build, struct exec_list *cf_node_list) { build->cf_node_list = cf_node_list; + build->before_block = NULL; + build->after_block = NULL; + build->before_instr = NULL; + build->after_instr = NULL; +} + +static inline void +nir_builder_insert_before_block(nir_builder *build, + nir_block *block) +{ + build->cf_node_list = NULL; + build->before_block = block; + build->after_block = NULL; + build->before_instr = NULL; + build->after_instr = NULL; +} + +static inline void +nir_builder_insert_after_block(nir_builder *build, + nir_block *block) +{ + build->cf_node_list = NULL; + build->before_block = NULL; + build->after_block = block; build->before_instr = NULL; build->after_instr = NULL; } @@ -56,6 +84,8 @@ static inline void nir_builder_insert_before_instr(nir_builder *build, nir_instr *before_instr) { build->cf_node_list = NULL; + build->before_block = NULL; + build->after_block = NULL; build->before_instr = before_instr; build->after_instr = NULL; } @@ -64,6 +94,8 @@ static inline void nir_builder_insert_after_instr(nir_builder *build, nir_instr *after_instr) { build->cf_node_list = NULL; + build->before_block = NULL; + build->after_block = NULL; build->before_instr = NULL; build->after_instr = after_instr; } @@ -73,6 +105,10 @@ nir_builder_instr_insert(nir_builder *build, nir_instr *instr) { if (build->cf_node_list) { nir_instr_insert_after_cf_list(build->cf_node_list, instr); + } else if (build->before_block) { + nir_instr_insert_before_block(build->before_block, instr); + } else if (build->after_block) { + nir_instr_insert_after_block(build->after_block, instr); } else if (build->before_instr) { nir_instr_insert_before(build->before_instr, instr); } else { |