nir_intrinsic_instr *instr = nir_instr_as_intrinsic(ni);
unsigned mask = 0;
ppir_load_node *lnode;
- ppir_store_node *snode;
+ ppir_alu_node *alu_node;
switch (instr->intrinsic) {
case nir_intrinsic_load_input:
return &lnode->node;
- case nir_intrinsic_store_output:
- snode = ppir_node_create_dest(block, ppir_op_store_color, NULL, 0);
- if (!snode)
+ case nir_intrinsic_store_output: {
+ alu_node = ppir_node_create_dest(block, ppir_op_store_color, NULL, 0);
+ if (!alu_node)
return NULL;
- snode->index = nir_intrinsic_base(instr);
+ ppir_dest *dest = ppir_node_get_dest(&alu_node->node);
+ dest->type = ppir_target_ssa;
+ dest->ssa.num_components = instr->num_components;
+ dest->ssa.live_in = INT_MAX;
+ dest->ssa.live_out = 0;
+ dest->ssa.index = 0;
+ dest->write_mask = u_bit_consecutive(0, instr->num_components);
+
+ alu_node->num_src = 1;
for (int i = 0; i < instr->num_components; i++)
- snode->src.swizzle[i] = i;
+ alu_node->src[0].swizzle[i] = i;
- ppir_node_add_src(block->comp, &snode->node, &snode->src, instr->src,
+ ppir_node_add_src(block->comp, &alu_node->node, alu_node->src, instr->src,
u_bit_consecutive(0, instr->num_components));
- return &snode->node;
+ return &alu_node->node;
+ }
case nir_intrinsic_discard:
return ppir_emit_discard(block, ni);
if (!node->instr && !create_new_instr(block, node))
return false;
+ if (node->op == ppir_op_store_color)
+ node->instr->is_end = true;
+
break;
}
case ppir_node_type_load:
return false;
break;
}
-
- /* Only the store color node should appear here.
- * Currently we always insert a move node as the end instr.
- * But it should only be done when:
- * 1. store a const node
- * 2. store a load node
- * 3. store a reg assigned in another block like loop/if
- */
-
- assert(node->op == ppir_op_store_color);
-
- ppir_node *move = ppir_node_create(block, ppir_op_mov, -1, 0);
- if (unlikely(!move))
- return false;
-
- ppir_debug("node_to_instr create move %d from store %d\n",
- move->index, node->index);
-
- ppir_node_foreach_pred_safe(node, dep) {
- ppir_node *pred = dep->pred;
- /* we can't do this in this function except here as this
- * store is the root of this recursion */
- ppir_node_remove_dep(dep);
- ppir_node_add_dep(move, pred);
- }
-
- ppir_node_add_dep(node, move);
- list_addtail(&move->list, &node->list);
-
- ppir_alu_node *alu = ppir_node_to_alu(move);
- ppir_store_node *store = ppir_node_to_store(node);
- alu->src[0] = store->src;
- alu->num_src = 1;
-
- alu->dest.type = ppir_target_ssa;
- alu->dest.ssa.num_components = 4;
- alu->dest.ssa.live_in = INT_MAX;
- alu->dest.ssa.live_out = 0;
- alu->dest.write_mask = 0xf;
-
- store->src.type = ppir_target_ssa;
- store->src.ssa = &alu->dest.ssa;
-
- if (!create_new_instr(block, move))
- return false;
-
- move->instr->is_end = true;
- node->instr = move->instr;
-
- /* use move for the following recursion */
- *next = move;
- break;
}
case ppir_node_type_discard:
if (!create_new_instr(block, node))