nir: Add and use initializer #defines for nir_src and nir_dest
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
This commit is contained in:
@@ -824,7 +824,7 @@ nir_visitor::evaluate_rvalue(ir_rvalue* ir)
|
|||||||
nir_dest *dest = get_instr_dest(this->result);
|
nir_dest *dest = get_instr_dest(this->result);
|
||||||
|
|
||||||
assert(dest->is_ssa);
|
assert(dest->is_ssa);
|
||||||
nir_src src;
|
nir_src src = NIR_SRC_INIT;
|
||||||
src.is_ssa = true;
|
src.is_ssa = true;
|
||||||
src.ssa = &dest->ssa;
|
src.ssa = &dest->ssa;
|
||||||
|
|
||||||
|
@@ -497,6 +497,8 @@ typedef struct nir_src {
|
|||||||
bool is_ssa;
|
bool is_ssa;
|
||||||
} nir_src;
|
} nir_src;
|
||||||
|
|
||||||
|
#define NIR_SRC_INIT (nir_src) { { { NULL } } }
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
nir_reg_dest reg;
|
nir_reg_dest reg;
|
||||||
@@ -506,10 +508,12 @@ typedef struct {
|
|||||||
bool is_ssa;
|
bool is_ssa;
|
||||||
} nir_dest;
|
} nir_dest;
|
||||||
|
|
||||||
|
#define NIR_DEST_INIT (nir_dest) { { { NULL } } }
|
||||||
|
|
||||||
static inline nir_src
|
static inline nir_src
|
||||||
nir_src_for_ssa(nir_ssa_def *def)
|
nir_src_for_ssa(nir_ssa_def *def)
|
||||||
{
|
{
|
||||||
nir_src src;
|
nir_src src = NIR_SRC_INIT;
|
||||||
|
|
||||||
src.is_ssa = true;
|
src.is_ssa = true;
|
||||||
src.ssa = def;
|
src.ssa = def;
|
||||||
@@ -520,7 +524,7 @@ nir_src_for_ssa(nir_ssa_def *def)
|
|||||||
static inline nir_src
|
static inline nir_src
|
||||||
nir_src_for_reg(nir_register *reg)
|
nir_src_for_reg(nir_register *reg)
|
||||||
{
|
{
|
||||||
nir_src src;
|
nir_src src = NIR_SRC_INIT;
|
||||||
|
|
||||||
src.is_ssa = false;
|
src.is_ssa = false;
|
||||||
src.reg.reg = reg;
|
src.reg.reg = reg;
|
||||||
@@ -543,12 +547,9 @@ nir_src_get_parent_instr(const nir_src *src)
|
|||||||
static inline nir_dest
|
static inline nir_dest
|
||||||
nir_dest_for_reg(nir_register *reg)
|
nir_dest_for_reg(nir_register *reg)
|
||||||
{
|
{
|
||||||
nir_dest dest;
|
nir_dest dest = NIR_DEST_INIT;
|
||||||
|
|
||||||
dest.is_ssa = false;
|
|
||||||
dest.reg.reg = reg;
|
dest.reg.reg = reg;
|
||||||
dest.reg.indirect = NULL;
|
|
||||||
dest.reg.base_offset = 0;
|
|
||||||
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
@@ -231,8 +231,7 @@ static inline nir_ssa_def *
|
|||||||
nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
|
nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
|
||||||
unsigned num_components, bool use_fmov)
|
unsigned num_components, bool use_fmov)
|
||||||
{
|
{
|
||||||
nir_alu_src alu_src;
|
nir_alu_src alu_src = { NIR_SRC_INIT };
|
||||||
memset(&alu_src, 0, sizeof(alu_src));
|
|
||||||
alu_src.src = nir_src_for_ssa(src);
|
alu_src.src = nir_src_for_ssa(src);
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
alu_src.swizzle[i] = swiz[i];
|
alu_src.swizzle[i] = swiz[i];
|
||||||
@@ -251,8 +250,7 @@ nir_ssa_for_src(nir_builder *build, nir_src src, int num_components)
|
|||||||
if (src.is_ssa && src.ssa->num_components == num_components)
|
if (src.is_ssa && src.ssa->num_components == num_components)
|
||||||
return src.ssa;
|
return src.ssa;
|
||||||
|
|
||||||
nir_alu_src alu;
|
nir_alu_src alu = { NIR_SRC_INIT };
|
||||||
memset(&alu, 0, sizeof(alu));
|
|
||||||
alu.src = src;
|
alu.src = src;
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
alu.swizzle[j] = j;
|
alu.swizzle[j] = j;
|
||||||
|
@@ -95,9 +95,8 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr
|
|||||||
|
|
||||||
instr->sampler_array_size = glsl_get_length(deref->type);
|
instr->sampler_array_size = glsl_get_length(deref->type);
|
||||||
|
|
||||||
nir_src empty;
|
nir_instr_rewrite_src(&instr->instr, &deref_array->indirect,
|
||||||
memset(&empty, 0, sizeof empty);
|
NIR_SRC_INIT);
|
||||||
nir_instr_rewrite_src(&instr->instr, &deref_array->indirect, empty);
|
|
||||||
|
|
||||||
if (deref_array->deref.child)
|
if (deref_array->deref.child)
|
||||||
ralloc_strcat(&name, "[0]");
|
ralloc_strcat(&name, "[0]");
|
||||||
|
@@ -109,9 +109,8 @@ nir_lower_tex_projector_block(nir_block *block, void *void_state)
|
|||||||
/* Now move the later tex sources down the array so that the projector
|
/* Now move the later tex sources down the array so that the projector
|
||||||
* disappears.
|
* disappears.
|
||||||
*/
|
*/
|
||||||
nir_src dead;
|
nir_instr_rewrite_src(&tex->instr, &tex->src[proj_index].src,
|
||||||
memset(&dead, 0, sizeof dead);
|
NIR_SRC_INIT);
|
||||||
nir_instr_rewrite_src(&tex->instr, &tex->src[proj_index].src, dead);
|
|
||||||
memmove(&tex->src[proj_index],
|
memmove(&tex->src[proj_index],
|
||||||
&tex->src[proj_index + 1],
|
&tex->src[proj_index + 1],
|
||||||
(tex->num_srcs - proj_index) * sizeof(*tex->src));
|
(tex->num_srcs - proj_index) * sizeof(*tex->src));
|
||||||
|
@@ -276,7 +276,7 @@ construct_value(const nir_search_value *value, nir_alu_type type,
|
|||||||
const nir_search_variable *var = nir_search_value_as_variable(value);
|
const nir_search_variable *var = nir_search_value_as_variable(value);
|
||||||
assert(state->variables_seen & (1 << var->variable));
|
assert(state->variables_seen & (1 << var->variable));
|
||||||
|
|
||||||
nir_alu_src val;
|
nir_alu_src val = { NIR_SRC_INIT };
|
||||||
nir_alu_src_copy(&val, &state->variables[var->variable], mem_ctx);
|
nir_alu_src_copy(&val, &state->variables[var->variable], mem_ctx);
|
||||||
|
|
||||||
assert(!var->is_constant);
|
assert(!var->is_constant);
|
||||||
|
Reference in New Issue
Block a user