mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
tcg: Introduce helpers for integer min/max
These operations are re-invented by several targets so far. Several supported hosts have insns for these, so place the expanders out-of-line for a future introduction of tcg opcodes. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20180508151437.4232-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
cd95fc28fb
commit
b87fb8cd9f
40
tcg/tcg-op.c
40
tcg/tcg-op.c
@ -1033,6 +1033,26 @@ void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg)
|
||||
}
|
||||
}
|
||||
|
||||
void tcg_gen_smin_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b)
|
||||
{
|
||||
tcg_gen_movcond_i32(TCG_COND_LT, ret, a, b, a, b);
|
||||
}
|
||||
|
||||
void tcg_gen_umin_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b)
|
||||
{
|
||||
tcg_gen_movcond_i32(TCG_COND_LTU, ret, a, b, a, b);
|
||||
}
|
||||
|
||||
void tcg_gen_smax_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b)
|
||||
{
|
||||
tcg_gen_movcond_i32(TCG_COND_LT, ret, a, b, b, a);
|
||||
}
|
||||
|
||||
void tcg_gen_umax_i32(TCGv_i32 ret, TCGv_i32 a, TCGv_i32 b)
|
||||
{
|
||||
tcg_gen_movcond_i32(TCG_COND_LTU, ret, a, b, b, a);
|
||||
}
|
||||
|
||||
/* 64-bit ops */
|
||||
|
||||
#if TCG_TARGET_REG_BITS == 32
|
||||
@ -2438,6 +2458,26 @@ void tcg_gen_mulsu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2)
|
||||
tcg_temp_free_i64(t2);
|
||||
}
|
||||
|
||||
void tcg_gen_smin_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b)
|
||||
{
|
||||
tcg_gen_movcond_i64(TCG_COND_LT, ret, a, b, a, b);
|
||||
}
|
||||
|
||||
void tcg_gen_umin_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b)
|
||||
{
|
||||
tcg_gen_movcond_i64(TCG_COND_LTU, ret, a, b, a, b);
|
||||
}
|
||||
|
||||
void tcg_gen_smax_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b)
|
||||
{
|
||||
tcg_gen_movcond_i64(TCG_COND_LT, ret, a, b, b, a);
|
||||
}
|
||||
|
||||
void tcg_gen_umax_i64(TCGv_i64 ret, TCGv_i64 a, TCGv_i64 b)
|
||||
{
|
||||
tcg_gen_movcond_i64(TCG_COND_LTU, ret, a, b, b, a);
|
||||
}
|
||||
|
||||
/* Size changing operations. */
|
||||
|
||||
void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg)
|
||||
|
16
tcg/tcg-op.h
16
tcg/tcg-op.h
@ -324,6 +324,10 @@ void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_ext16u_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_bswap16_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg);
|
||||
void tcg_gen_smin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2);
|
||||
void tcg_gen_smax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2);
|
||||
void tcg_gen_umin_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2);
|
||||
void tcg_gen_umax_i32(TCGv_i32, TCGv_i32 arg1, TCGv_i32 arg2);
|
||||
|
||||
static inline void tcg_gen_discard_i32(TCGv_i32 arg)
|
||||
{
|
||||
@ -517,6 +521,10 @@ void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_bswap16_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_bswap32_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_bswap64_i64(TCGv_i64 ret, TCGv_i64 arg);
|
||||
void tcg_gen_smin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2);
|
||||
void tcg_gen_smax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2);
|
||||
void tcg_gen_umin_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2);
|
||||
void tcg_gen_umax_i64(TCGv_i64, TCGv_i64 arg1, TCGv_i64 arg2);
|
||||
|
||||
#if TCG_TARGET_REG_BITS == 64
|
||||
static inline void tcg_gen_discard_i64(TCGv_i64 arg)
|
||||
@ -1025,6 +1033,10 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);
|
||||
#define tcg_gen_mulu2_tl tcg_gen_mulu2_i64
|
||||
#define tcg_gen_muls2_tl tcg_gen_muls2_i64
|
||||
#define tcg_gen_mulsu2_tl tcg_gen_mulsu2_i64
|
||||
#define tcg_gen_smin_tl tcg_gen_smin_i64
|
||||
#define tcg_gen_umin_tl tcg_gen_umin_i64
|
||||
#define tcg_gen_smax_tl tcg_gen_smax_i64
|
||||
#define tcg_gen_umax_tl tcg_gen_umax_i64
|
||||
#define tcg_gen_atomic_cmpxchg_tl tcg_gen_atomic_cmpxchg_i64
|
||||
#define tcg_gen_atomic_xchg_tl tcg_gen_atomic_xchg_i64
|
||||
#define tcg_gen_atomic_fetch_add_tl tcg_gen_atomic_fetch_add_i64
|
||||
@ -1123,6 +1135,10 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);
|
||||
#define tcg_gen_mulu2_tl tcg_gen_mulu2_i32
|
||||
#define tcg_gen_muls2_tl tcg_gen_muls2_i32
|
||||
#define tcg_gen_mulsu2_tl tcg_gen_mulsu2_i32
|
||||
#define tcg_gen_smin_tl tcg_gen_smin_i32
|
||||
#define tcg_gen_umin_tl tcg_gen_umin_i32
|
||||
#define tcg_gen_smax_tl tcg_gen_smax_i32
|
||||
#define tcg_gen_umax_tl tcg_gen_umax_i32
|
||||
#define tcg_gen_atomic_cmpxchg_tl tcg_gen_atomic_cmpxchg_i32
|
||||
#define tcg_gen_atomic_xchg_tl tcg_gen_atomic_xchg_i32
|
||||
#define tcg_gen_atomic_fetch_add_tl tcg_gen_atomic_fetch_add_i32
|
||||
|
Loading…
Reference in New Issue
Block a user