diff options
author | Richard Henderson <rth@twiddle.net> | 2016-10-14 12:04:32 -0500 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2017-01-10 07:59:11 -0800 |
commit | 7ec8bab3deae643b1ce579c2d65a244f30708330 (patch) | |
tree | e017911ab6448bf6878220ff174d7119ba9f19b1 /tcg/optimize.c | |
parent | 41a0e54756a9ae6b60be34bb33302a7e085fdb07 (diff) |
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>
Diffstat (limited to 'tcg/optimize.c')
-rw-r--r-- | tcg/optimize.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tcg/optimize.c b/tcg/optimize.c index 0f1349086b..f41ed2cfc1 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -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) { |