Merge pull request #8 from lioncash/optimize

Backport REV16 optimizations from qemu
This commit is contained in:
Merry 2018-02-05 20:58:58 +00:00 committed by GitHub
commit 82c4212ce3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 20 deletions

View file

@ -3789,26 +3789,15 @@ static void handle_rev16(DisasContext *s, unsigned int sf,
TCGv_i64 tcg_rd = cpu_reg(s, rd);
TCGv_i64 tcg_tmp = tcg_temp_new_i64(tcg_ctx);
TCGv_i64 tcg_rn = read_cpu_reg(s, rn, sf);
TCGv_i64 mask = tcg_const_i64(tcg_ctx, sf ? 0x00ff00ff00ff00ffull : 0x00ff00ff);
tcg_gen_andi_i64(tcg_ctx, tcg_tmp, tcg_rn, 0xffff);
tcg_gen_bswap16_i64(tcg_ctx, tcg_rd, tcg_tmp);
tcg_gen_shri_i64(tcg_ctx, tcg_tmp, tcg_rn, 16);
tcg_gen_andi_i64(tcg_ctx, tcg_tmp, tcg_tmp, 0xffff);
tcg_gen_bswap16_i64(tcg_ctx, tcg_tmp, tcg_tmp);
tcg_gen_deposit_i64(tcg_ctx, tcg_rd, tcg_rd, tcg_tmp, 16, 16);
if (sf) {
tcg_gen_shri_i64(tcg_ctx, tcg_tmp, tcg_rn, 32);
tcg_gen_andi_i64(tcg_ctx, tcg_tmp, tcg_tmp, 0xffff);
tcg_gen_bswap16_i64(tcg_ctx, tcg_tmp, tcg_tmp);
tcg_gen_deposit_i64(tcg_ctx, tcg_rd, tcg_rd, tcg_tmp, 32, 16);
tcg_gen_shri_i64(tcg_ctx, tcg_tmp, tcg_rn, 48);
tcg_gen_bswap16_i64(tcg_ctx, tcg_tmp, tcg_tmp);
tcg_gen_deposit_i64(tcg_ctx, tcg_rd, tcg_rd, tcg_tmp, 48, 16);
}
tcg_gen_shri_i64(tcg_ctx, tcg_tmp, tcg_rn, 8);
tcg_gen_and_i64(tcg_ctx, tcg_rd, tcg_rn, mask);
tcg_gen_and_i64(tcg_ctx, tcg_tmp, tcg_tmp, mask);
tcg_gen_shli_i64(tcg_ctx, tcg_rd, tcg_rd, 8);
tcg_gen_or_i64(tcg_ctx, tcg_rd, tcg_rd, tcg_tmp);
tcg_temp_free_i64(tcg_ctx, mask);
tcg_temp_free_i64(tcg_ctx, tcg_tmp);
}

View file

@ -248,11 +248,13 @@ static void gen_rev16(DisasContext *s, TCGv_i32 var)
{
TCGContext *tcg_ctx = s->uc->tcg_ctx;
TCGv_i32 tmp = tcg_temp_new_i32(tcg_ctx);
TCGv_i32 mask = tcg_const_i32(tcg_ctx, 0x00ff00ff);
tcg_gen_shri_i32(tcg_ctx, tmp, var, 8);
tcg_gen_andi_i32(tcg_ctx, tmp, tmp, 0x00ff00ff);
tcg_gen_and_i32(tcg_ctx, tmp, tmp, mask);
tcg_gen_and_i32(tcg_ctx, var, var, mask);
tcg_gen_shli_i32(tcg_ctx, var, var, 8);
tcg_gen_andi_i32(tcg_ctx, var, var, 0xff00ff00);
tcg_gen_or_i32(tcg_ctx, var, var, tmp);
tcg_temp_free_i32(tcg_ctx, mask);
tcg_temp_free_i32(tcg_ctx, tmp);
}