mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
tcg: Implement tcg_gen_extract2_{i32,i64}
Will be helpful for s390x. Input 128 bit and output 64 bit only, which is sufficient for now. Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20190225154204.26751-1-david@redhat.com> [rth: Add matching tcg_gen_extract2_i32.] Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
3284aa1281
commit
2089fcc9e7
2 changed files with 50 additions and 0 deletions
44
tcg/tcg-op.c
44
tcg/tcg-op.c
|
@ -809,6 +809,28 @@ void tcg_gen_sextract_i32(TCGv_i32 ret, TCGv_i32 arg,
|
|||
tcg_gen_sari_i32(ret, ret, 32 - len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract 32-bits from a 64-bit input, ah:al, starting from ofs.
|
||||
* Unlike tcg_gen_extract_i32 above, len is fixed at 32.
|
||||
*/
|
||||
void tcg_gen_extract2_i32(TCGv_i32 ret, TCGv_i32 al, TCGv_i32 ah,
|
||||
unsigned int ofs)
|
||||
{
|
||||
tcg_debug_assert(ofs <= 32);
|
||||
if (ofs == 0) {
|
||||
tcg_gen_mov_i32(ret, al);
|
||||
} else if (ofs == 32) {
|
||||
tcg_gen_mov_i32(ret, ah);
|
||||
} else if (al == ah) {
|
||||
tcg_gen_rotri_i32(ret, al, ofs);
|
||||
} else {
|
||||
TCGv_i32 t0 = tcg_temp_new_i32();
|
||||
tcg_gen_shri_i32(t0, al, ofs);
|
||||
tcg_gen_deposit_i32(ret, t0, ah, 32 - ofs, ofs);
|
||||
tcg_temp_free_i32(t0);
|
||||
}
|
||||
}
|
||||
|
||||
void tcg_gen_movcond_i32(TCGCond cond, TCGv_i32 ret, TCGv_i32 c1,
|
||||
TCGv_i32 c2, TCGv_i32 v1, TCGv_i32 v2)
|
||||
{
|
||||
|
@ -2297,6 +2319,28 @@ void tcg_gen_sextract_i64(TCGv_i64 ret, TCGv_i64 arg,
|
|||
tcg_gen_sari_i64(ret, ret, 64 - len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract 64 bits from a 128-bit input, ah:al, starting from ofs.
|
||||
* Unlike tcg_gen_extract_i64 above, len is fixed at 64.
|
||||
*/
|
||||
void tcg_gen_extract2_i64(TCGv_i64 ret, TCGv_i64 al, TCGv_i64 ah,
|
||||
unsigned int ofs)
|
||||
{
|
||||
tcg_debug_assert(ofs <= 64);
|
||||
if (ofs == 0) {
|
||||
tcg_gen_mov_i64(ret, al);
|
||||
} else if (ofs == 64) {
|
||||
tcg_gen_mov_i64(ret, ah);
|
||||
} else if (al == ah) {
|
||||
tcg_gen_rotri_i64(ret, al, ofs);
|
||||
} else {
|
||||
TCGv_i64 t0 = tcg_temp_new_i64();
|
||||
tcg_gen_shri_i64(t0, al, ofs);
|
||||
tcg_gen_deposit_i64(ret, t0, ah, 64 - ofs, ofs);
|
||||
tcg_temp_free_i64(t0);
|
||||
}
|
||||
}
|
||||
|
||||
void tcg_gen_movcond_i64(TCGCond cond, TCGv_i64 ret, TCGv_i64 c1,
|
||||
TCGv_i64 c2, TCGv_i64 v1, TCGv_i64 v2)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue