nir_var_global,
nir_var_local,
nir_var_uniform,
+ nir_var_shader_storage,
nir_var_system_value
} nir_variable_mode;
*/
bool is_packed;
- /**
- * If this pointer is non-NULL then this register has exactly one
- * definition and that definition dominates all of its uses. This is
- * set by the out-of-SSA pass so that backends can get SSA-like
- * information even once they have gone out of SSA.
- */
- struct nir_instr *parent_instr;
-
/** set of nir_instr's where this register is used (read from) */
struct list_head uses;
return exec_node_data(nir_instr, prev, node);
}
+static inline bool
+nir_instr_is_first(nir_instr *instr)
+{
+ return exec_node_is_head_sentinel(exec_node_get_prev(&instr->node));
+}
+
+static inline bool
+nir_instr_is_last(nir_instr *instr)
+{
+ return exec_node_is_tail_sentinel(exec_node_get_next(&instr->node));
+}
+
typedef struct {
/** for debugging only, can be NULL */
const char* name;
return src;
}
-static inline nir_instr *
-nir_src_get_parent_instr(const nir_src *src)
-{
- if (src->is_ssa) {
- return src->ssa->parent_instr;
- } else {
- return src->reg.reg->parent_instr;
- }
-}
-
static inline nir_dest
nir_dest_for_reg(nir_register *reg)
{
#define nir_foreach_phi_src(phi, entry) \
foreach_list_typed(nir_phi_src, entry, node, &(phi)->srcs)
+#define nir_foreach_phi_src_safe(phi, entry) \
+ foreach_list_typed_safe(nir_phi_src, entry, node, &(phi)->srcs)
typedef struct {
nir_instr instr;
foreach_list_typed_reverse(nir_instr, instr, node, &(block)->instr_list)
#define nir_foreach_instr_safe(block, instr) \
foreach_list_typed_safe(nir_instr, instr, node, &(block)->instr_list)
+#define nir_foreach_instr_safe_reverse(block, instr) \
+ foreach_list_typed_safe_reverse(nir_instr, instr, node, &(block)->instr_list)
typedef struct nir_if {
nir_cf_node cf_node;
struct exec_list body; /** < list of nir_cf_node */
- nir_block *start_block, *end_block;
+ nir_block *end_block;
/** list for all local variables in the function */
struct exec_list locals;
nir_metadata valid_metadata;
} nir_function_impl;
+static inline nir_block *
+nir_start_block(nir_function_impl *impl)
+{
+ return (nir_block *) exec_list_get_head(&impl->body);
+}
+
static inline nir_cf_node *
nir_cf_node_next(nir_cf_node *node)
{
nir_function_impl *nir_cf_node_get_function(nir_cf_node *node);
-/** puts a control flow node immediately after another control flow node */
-void nir_cf_node_insert_after(nir_cf_node *node, nir_cf_node *after);
-
-/** puts a control flow node immediately before another control flow node */
-void nir_cf_node_insert_before(nir_cf_node *node, nir_cf_node *before);
-
-/** puts a control flow node at the beginning of a list from an if, loop, or function */
-void nir_cf_node_insert_begin(struct exec_list *list, nir_cf_node *node);
-
-/** puts a control flow node at the end of a list from an if, loop, or function */
-void nir_cf_node_insert_end(struct exec_list *list, nir_cf_node *node);
-
-/** removes a control flow node, doing any cleanup necessary */
-void nir_cf_node_remove(nir_cf_node *node);
-
/** requests that the given pieces of metadata be generated */
void nir_metadata_require(nir_function_impl *impl, nir_metadata required);
/** dirties all but the preserved metadata */
void nir_lower_locals_to_regs(nir_shader *shader);
-void nir_assign_var_locations_scalar(struct exec_list *var_list,
- unsigned *size);
-void nir_assign_var_locations_scalar_direct_first(nir_shader *shader,
- struct exec_list *var_list,
- unsigned *direct_size,
- unsigned *size);
+void nir_assign_var_locations(struct exec_list *var_list,
+ unsigned *size,
+ bool is_scalar);
+void nir_assign_var_locations_direct_first(nir_shader *shader,
+ struct exec_list *var_list,
+ unsigned *direct_size,
+ unsigned *size,
+ bool is_scalar);
-void nir_lower_io(nir_shader *shader);
+void nir_lower_io(nir_shader *shader, bool is_scalar);
void nir_lower_vars_to_ssa(nir_shader *shader);
void nir_lower_vec_to_movs(nir_shader *shader);
void nir_lower_alu_to_scalar(nir_shader *shader);
+void nir_lower_load_const_to_scalar(nir_shader *shader);
void nir_lower_phis_to_scalar(nir_shader *shader);
void nir_convert_to_ssa_impl(nir_function_impl *impl);
void nir_convert_to_ssa(nir_shader *shader);
-/* If convert_everything is true, convert all values (even those not involved
- * in a phi node) to registers. If false, only convert SSA values involved in
- * phi nodes to registers.
+/* If phi_webs_only is true, only convert SSA values involved in phi nodes to
+ * registers. If false, convert all values (even those not involved in a phi
+ * node) to registers.
*/
void nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only);
bool nir_opt_remove_phis(nir_shader *shader);
+bool nir_opt_undef(nir_shader *shader);
+
void nir_sweep(nir_shader *shader);
#ifdef __cplusplus