diff options
author | Vasily Khoruzhick <[email protected]> | 2019-08-03 09:59:27 -0700 |
---|---|---|
committer | Vasily Khoruzhick <[email protected]> | 2019-08-04 02:17:12 +0000 |
commit | c780af777158d7b351f22423556f455338cd7ed3 (patch) | |
tree | bc531c7dcff902d70342a07206df301c192a4dd6 /src/gallium/drivers/lima/ir | |
parent | aebca3961b4161574b889201f48c38bd73e2f7c3 (diff) |
lima/ppir: move alu vec to scalar lowering into NIR
Utgard PP is vec4, but some operations are scalar, utilize
NIR vec to scalar lowering pass and indicate operations that we
want to lower.
Reviewed-by: Qiang Yu <[email protected]>
Signed-off-by: Vasily Khoruzhick <[email protected]>
Diffstat (limited to 'src/gallium/drivers/lima/ir')
-rw-r--r-- | src/gallium/drivers/lima/ir/pp/lower.c | 110 |
1 files changed, 4 insertions, 106 deletions
diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c index 20520073001..2b4da2c2992 100644 --- a/src/gallium/drivers/lima/ir/pp/lower.c +++ b/src/gallium/drivers/lima/ir/pp/lower.c @@ -72,101 +72,6 @@ static bool ppir_lower_const(ppir_block *block, ppir_node *node) return true; } -static ppir_reg *create_reg(ppir_compiler *comp, int num_components) -{ - ppir_reg *r = rzalloc(comp, ppir_reg); - if (!r) - return NULL; - - r->num_components = num_components; - r->live_in = INT_MAX; - r->live_out = 0; - r->is_head = false; - list_addtail(&r->list, &comp->reg_list); - - return r; -} - -/* lower vector alu node to multi scalar nodes */ -static bool ppir_lower_vec_to_scalar(ppir_block *block, ppir_node *node) -{ - ppir_alu_node *alu = ppir_node_to_alu(node); - ppir_dest *dest = &alu->dest; - - int n = 0; - int index[4]; - - unsigned mask = dest->write_mask; - while (mask) - index[n++] = u_bit_scan(&mask); - - if (n == 1) - return true; - - ppir_reg *r; - /* we need a reg for scalar nodes to store output */ - if (dest->type == ppir_target_register) - r = dest->reg; - else { - r = create_reg(block->comp, n); - if (!r) - return false; - - /* change all successors to use reg r */ - ppir_node_foreach_succ(node, dep) { - ppir_node *succ = dep->succ; - if (succ->type == ppir_node_type_alu) { - ppir_alu_node *sa = ppir_node_to_alu(succ); - for (int i = 0; i < sa->num_src; i++) { - ppir_src *src = sa->src + i; - if (ppir_node_target_equal(src, dest)) { - src->type = ppir_target_register; - src->reg = r; - } - } - } - else { - assert(succ->type == ppir_node_type_store); - ppir_store_node *ss = ppir_node_to_store(succ); - ppir_src *src = &ss->src; - src->type = ppir_target_register; - src->reg = r; - } - } - } - - /* create each component's scalar node */ - for (int i = 0; i < n; i++) { - ppir_node *s = ppir_node_create(block, node->op, -1, 0); - if (!s) - return false; - list_addtail(&s->list, &node->list); - - ppir_alu_node *sa = ppir_node_to_alu(s); - ppir_dest *sd = &sa->dest; - sd->type = ppir_target_register; - sd->reg = r; - sd->modifier = dest->modifier; - sd->write_mask = 1 << index[i]; - - for (int j = 0; j < alu->num_src; j++) - sa->src[j] = alu->src[j]; - sa->num_src = alu->num_src; - - /* TODO: need per reg component dependancy */ - ppir_node_foreach_succ(node, dep) { - ppir_node_add_dep(dep->succ, s); - } - - ppir_node_foreach_pred(node, dep) { - ppir_node_add_dep(s, dep->pred); - } - } - - ppir_node_delete(node); - return true; -} - static bool ppir_lower_swap_args(ppir_block *block, ppir_node *node) { /* swapped op must be the next op */ @@ -210,9 +115,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node) return true; } -/* Prepare for sin and cos and then lower vector alu node to multi - * scalar nodes */ -static bool ppir_lower_sin_cos_vec_to_scalar(ppir_block *block, ppir_node *node) +static bool ppir_lower_sin_cos(ppir_block *block, ppir_node *node) { ppir_alu_node *alu = ppir_node_to_alu(node); @@ -264,7 +167,7 @@ static bool ppir_lower_sin_cos_vec_to_scalar(ppir_block *block, ppir_node *node) ppir_node_add_dep(node, mul_node); ppir_node_add_dep(mul_node, inv_2pi_node); - return ppir_lower_vec_to_scalar(block, node); + return true; } /* insert a move as the select condition to make sure it can @@ -402,13 +305,8 @@ static bool (*ppir_lower_funcs[ppir_op_num])(ppir_block *, ppir_node *) = { [ppir_op_abs] = ppir_lower_abs, [ppir_op_neg] = ppir_lower_neg, [ppir_op_const] = ppir_lower_const, - [ppir_op_rcp] = ppir_lower_vec_to_scalar, - [ppir_op_rsqrt] = ppir_lower_vec_to_scalar, - [ppir_op_log2] = ppir_lower_vec_to_scalar, - [ppir_op_exp2] = ppir_lower_vec_to_scalar, - [ppir_op_sqrt] = ppir_lower_vec_to_scalar, - [ppir_op_sin] = ppir_lower_sin_cos_vec_to_scalar, - [ppir_op_cos] = ppir_lower_sin_cos_vec_to_scalar, + [ppir_op_sin] = ppir_lower_sin_cos, + [ppir_op_cos] = ppir_lower_sin_cos, [ppir_op_lt] = ppir_lower_swap_args, [ppir_op_le] = ppir_lower_swap_args, [ppir_op_load_texture] = ppir_lower_texture, |