tcg: Add field extraction primitives

Adds tcg_gen_extract_* and tcg_gen_sextract_* for extraction of
fixed position bitfields, much like we already have for deposit.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Richard Henderson 2016-10-14 12:04:32 -05:00
parent 41a0e54756
commit 7ec8bab3de
15 changed files with 426 additions and 2 deletions

View file

@ -878,6 +878,19 @@ void tcg_optimize(TCGContext *s)
temps[args[2]].mask);
break;
CASE_OP_32_64(extract):
mask = extract64(temps[args[1]].mask, args[2], args[3]);
if (args[2] == 0) {
affected = temps[args[1]].mask & ~mask;
}
break;
CASE_OP_32_64(sextract):
mask = sextract64(temps[args[1]].mask, args[2], args[3]);
if (args[2] == 0 && (tcg_target_long)mask >= 0) {
affected = temps[args[1]].mask & ~mask;
}
break;
CASE_OP_32_64(or):
CASE_OP_32_64(xor):
mask = temps[args[1]].mask | temps[args[2]].mask;
@ -1048,6 +1061,22 @@ void tcg_optimize(TCGContext *s)
}
goto do_default;
CASE_OP_32_64(extract):
if (temp_is_const(args[1])) {
tmp = extract64(temps[args[1]].val, args[2], args[3]);
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
CASE_OP_32_64(sextract):
if (temp_is_const(args[1])) {
tmp = sextract64(temps[args[1]].val, args[2], args[3]);
tcg_opt_gen_movi(s, op, args, args[0], tmp);
break;
}
goto do_default;
CASE_OP_32_64(setcond):
tmp = do_constant_folding_cond(opc, args[1], args[2], args[3]);
if (tmp != 2) {