mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
tcg: Add support for vector compare select
Perform a per-element conditional move. This combination operation is easier to implement on some host vector units than plain cmp+bitsel. Omit the usual gvec interface, as this is intended to be used by target-specific gvec expansion call-backs. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
38dc12947e
commit
f75da2988e
8 changed files with 75 additions and 0 deletions
|
@ -119,6 +119,11 @@ bool tcg_can_emit_vecop_list(const TCGOpcode *list,
|
|||
continue;
|
||||
}
|
||||
break;
|
||||
case INDEX_op_cmpsel_vec:
|
||||
if (tcg_can_emit_vec_op(INDEX_op_cmp_vec, type, vece)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -159,6 +164,20 @@ void vec_gen_4(TCGOpcode opc, TCGType type, unsigned vece,
|
|||
op->args[3] = c;
|
||||
}
|
||||
|
||||
static void vec_gen_6(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r,
|
||||
TCGArg a, TCGArg b, TCGArg c, TCGArg d, TCGArg e)
|
||||
{
|
||||
TCGOp *op = tcg_emit_op(opc);
|
||||
TCGOP_VECL(op) = type - TCG_TYPE_V64;
|
||||
TCGOP_VECE(op) = vece;
|
||||
op->args[0] = r;
|
||||
op->args[1] = a;
|
||||
op->args[2] = b;
|
||||
op->args[3] = c;
|
||||
op->args[4] = d;
|
||||
op->args[5] = e;
|
||||
}
|
||||
|
||||
static void vec_gen_op2(TCGOpcode opc, unsigned vece, TCGv_vec r, TCGv_vec a)
|
||||
{
|
||||
TCGTemp *rt = tcgv_vec_temp(r);
|
||||
|
@ -717,3 +736,43 @@ void tcg_gen_bitsel_vec(unsigned vece, TCGv_vec r, TCGv_vec a,
|
|||
tcg_temp_free_vec(t);
|
||||
}
|
||||
}
|
||||
|
||||
void tcg_gen_cmpsel_vec(TCGCond cond, unsigned vece, TCGv_vec r,
|
||||
TCGv_vec a, TCGv_vec b, TCGv_vec c, TCGv_vec d)
|
||||
{
|
||||
TCGTemp *rt = tcgv_vec_temp(r);
|
||||
TCGTemp *at = tcgv_vec_temp(a);
|
||||
TCGTemp *bt = tcgv_vec_temp(b);
|
||||
TCGTemp *ct = tcgv_vec_temp(c);
|
||||
TCGTemp *dt = tcgv_vec_temp(d);
|
||||
TCGArg ri = temp_arg(rt);
|
||||
TCGArg ai = temp_arg(at);
|
||||
TCGArg bi = temp_arg(bt);
|
||||
TCGArg ci = temp_arg(ct);
|
||||
TCGArg di = temp_arg(dt);
|
||||
TCGType type = rt->base_type;
|
||||
const TCGOpcode *hold_list;
|
||||
int can;
|
||||
|
||||
tcg_debug_assert(at->base_type >= type);
|
||||
tcg_debug_assert(bt->base_type >= type);
|
||||
tcg_debug_assert(ct->base_type >= type);
|
||||
tcg_debug_assert(dt->base_type >= type);
|
||||
|
||||
tcg_assert_listed_vecop(INDEX_op_cmpsel_vec);
|
||||
hold_list = tcg_swap_vecop_list(NULL);
|
||||
can = tcg_can_emit_vec_op(INDEX_op_cmpsel_vec, type, vece);
|
||||
|
||||
if (can > 0) {
|
||||
vec_gen_6(INDEX_op_cmpsel_vec, type, vece, ri, ai, bi, ci, di, cond);
|
||||
} else if (can < 0) {
|
||||
tcg_expand_vec_op(INDEX_op_cmpsel_vec, type, vece,
|
||||
ri, ai, bi, ci, di, cond);
|
||||
} else {
|
||||
TCGv_vec t = tcg_temp_new_vec(type);
|
||||
tcg_gen_cmp_vec(cond, vece, t, a, b);
|
||||
tcg_gen_bitsel_vec(vece, r, t, c, d);
|
||||
tcg_temp_free_vec(t);
|
||||
}
|
||||
tcg_swap_vecop_list(hold_list);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue