summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_builder.h
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-04-15 15:49:15 -0400
committerRob Clark <[email protected]>2015-04-17 10:34:15 -0400
commite14af4c0672c974238bed4661ada383cf50501f6 (patch)
tree943a976272207c99d260da0467624c073347544c /src/glsl/nir/nir_builder.h
parent7a9063e7c735960d10f489314aa7623a3d262085 (diff)
nir/builder: add nir_builder_insert_after_instr()
For lowering if/else, I need a way to insert at the end of the previous block. Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir_builder.h')
-rw-r--r--src/glsl/nir/nir_builder.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/glsl/nir/nir_builder.h b/src/glsl/nir/nir_builder.h
index 587d014d3f4..d1419ee2114 100644
--- a/src/glsl/nir/nir_builder.h
+++ b/src/glsl/nir/nir_builder.h
@@ -29,6 +29,7 @@ struct exec_list;
typedef struct nir_builder {
struct exec_list *cf_node_list;
nir_instr *before_instr;
+ nir_instr *after_instr;
nir_shader *shader;
nir_function_impl *impl;
@@ -47,12 +48,24 @@ nir_builder_insert_after_cf_list(nir_builder *build,
struct exec_list *cf_node_list)
{
build->cf_node_list = cf_node_list;
+ build->before_instr = NULL;
+ build->after_instr = NULL;
}
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;
+}
+
+static inline void
+nir_builder_insert_after_instr(nir_builder *build, nir_instr *after_instr)
+{
+ build->cf_node_list = NULL;
+ build->before_instr = NULL;
+ build->after_instr = after_instr;
}
static inline void
@@ -60,9 +73,12 @@ 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 {
- assert(build->before_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;
}
}