summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir_builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/nir/nir_builder.h')
-rw-r--r--src/glsl/nir/nir_builder.h43
1 files changed, 10 insertions, 33 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 *