diff options
Diffstat (limited to 'src/glsl/nir')
-rw-r--r-- | src/glsl/nir/nir_builder.h | 43 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_idiv.c | 2 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_io.c | 2 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_load_const_to_scalar.c | 2 | ||||
-rw-r--r-- | src/glsl/nir/nir_lower_tex_projector.c | 2 | ||||
-rw-r--r-- | src/glsl/nir/nir_normalize_cubemap_coords.c | 2 |
6 files changed, 15 insertions, 38 deletions
diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h index 9223e838095..08b40f8ea7c 100644 --- a/src/glsl/nir/nir_builder.h +++ b/src/glsl/nir/nir_builder.h @@ -24,12 +24,12 @@ #ifndef NIR_BUILDER_H #define NIR_BUILDER_H +#include "nir_control_flow.h" + struct exec_list; typedef struct nir_builder { - struct exec_list *cf_node_list; - nir_instr *before_instr; - nir_instr *after_instr; + nir_cursor cursor; nir_shader *shader; nir_function_impl *impl; @@ -44,42 +44,19 @@ nir_builder_init(nir_builder *build, nir_function_impl *impl) } static inline void -nir_builder_insert_after_cf_list(nir_builder *build, - struct exec_list *cf_node_list) +nir_builder_instr_insert(nir_builder *build, nir_instr *instr) { - build->cf_node_list = cf_node_list; - build->before_instr = NULL; - build->after_instr = NULL; -} + nir_instr_insert(build->cursor, instr); -static inline void -nir_builder_insert_before_instr(nir_builder *build, nir_instr *before_instr) -{ - build->cf_node_list = NULL; - build->before_instr = before_instr; - build->after_instr = NULL; + /* Move the cursor forward. */ + if (build->cursor.option == nir_cursor_after_instr) + build->cursor.instr = instr; } static inline void -nir_builder_insert_after_instr(nir_builder *build, nir_instr *after_instr) +nir_builder_cf_insert(nir_builder *build, nir_cf_node *cf) { - build->cf_node_list = NULL; - build->before_instr = NULL; - build->after_instr = after_instr; -} - -static inline void -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_instr) { - nir_instr_insert_before(build->before_instr, instr); - } else { - assert(build->after_instr); - nir_instr_insert_after(build->after_instr, instr); - build->after_instr = instr; - } + nir_cf_node_insert(build->cursor, cf); } static inline nir_ssa_def * diff --git a/src/glsl/nir/nir_lower_idiv.c b/src/glsl/nir/nir_lower_idiv.c index 7b680320783..0e1653dd274 100644 --- a/src/glsl/nir/nir_lower_idiv.c +++ b/src/glsl/nir/nir_lower_idiv.c @@ -50,7 +50,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu) is_signed = (op == nir_op_idiv); - nir_builder_insert_before_instr(bld, &alu->instr); + bld->cursor = nir_before_instr(&alu->instr); numer = nir_ssa_for_src(bld, alu->src[0].src, nir_ssa_alu_instr_src_components(alu, 0)); diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c index c9697e7845e..afb463040cc 100644 --- a/src/glsl/nir/nir_lower_io.c +++ b/src/glsl/nir/nir_lower_io.c @@ -84,7 +84,7 @@ get_io_offset(nir_deref_var *deref, nir_instr *instr, nir_src *indirect, unsigned base_offset = 0; nir_builder *b = &state->builder; - nir_builder_insert_before_instr(b, instr); + b->cursor = nir_before_instr(instr); nir_deref *tail = &deref->deref; while (tail->child != NULL) { diff --git a/src/glsl/nir/nir_lower_load_const_to_scalar.c b/src/glsl/nir/nir_lower_load_const_to_scalar.c index a90e5245898..b83ef052ea9 100644 --- a/src/glsl/nir/nir_lower_load_const_to_scalar.c +++ b/src/glsl/nir/nir_lower_load_const_to_scalar.c @@ -43,7 +43,7 @@ lower_load_const_instr_scalar(nir_load_const_instr *lower) nir_builder b; nir_builder_init(&b, nir_cf_node_get_function(&lower->instr.block->cf_node)); - nir_builder_insert_before_instr(&b, &lower->instr); + b.cursor = nir_before_instr(&lower->instr); /* Emit the individual loads. */ nir_ssa_def *loads[4]; diff --git a/src/glsl/nir/nir_lower_tex_projector.c b/src/glsl/nir/nir_lower_tex_projector.c index 357131cd728..8a482b182a9 100644 --- a/src/glsl/nir/nir_lower_tex_projector.c +++ b/src/glsl/nir/nir_lower_tex_projector.c @@ -46,7 +46,7 @@ nir_lower_tex_projector_block(nir_block *block, void *void_state) continue; nir_tex_instr *tex = nir_instr_as_tex(instr); - nir_builder_insert_before_instr(b, &tex->instr); + b->cursor = nir_before_instr(&tex->instr); /* Find the projector in the srcs list, if present. */ int proj_index; diff --git a/src/glsl/nir/nir_normalize_cubemap_coords.c b/src/glsl/nir/nir_normalize_cubemap_coords.c index 0da8447aca1..75b647f96cb 100644 --- a/src/glsl/nir/nir_normalize_cubemap_coords.c +++ b/src/glsl/nir/nir_normalize_cubemap_coords.c @@ -52,7 +52,7 @@ normalize_cubemap_coords_block(nir_block *block, void *void_state) if (tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE) continue; - nir_builder_insert_before_instr(b, &tex->instr); + b->cursor = nir_before_instr(&tex->instr); for (unsigned i = 0; i < tex->num_srcs; i++) { if (tex->src[i].src_type != nir_tex_src_coord) |