tcg: Add tcg_swap_cond.
Returns the condition as if with swapped comparison operands. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
bf76bafa5a
commit
1c086220a6
|
@ -205,11 +205,19 @@ typedef enum {
|
||||||
TCG_COND_GTU,
|
TCG_COND_GTU,
|
||||||
} TCGCond;
|
} TCGCond;
|
||||||
|
|
||||||
|
/* Invert the sense of the comparison. */
|
||||||
static inline TCGCond tcg_invert_cond(TCGCond c)
|
static inline TCGCond tcg_invert_cond(TCGCond c)
|
||||||
{
|
{
|
||||||
return (TCGCond)(c ^ 1);
|
return (TCGCond)(c ^ 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Swap the operands in a comparison. */
|
||||||
|
static inline TCGCond tcg_swap_cond(TCGCond c)
|
||||||
|
{
|
||||||
|
int mask = (c < TCG_COND_LT ? 0 : c < TCG_COND_LTU ? 7 : 15);
|
||||||
|
return (TCGCond)(c ^ mask);
|
||||||
|
}
|
||||||
|
|
||||||
static inline TCGCond tcg_unsigned_cond(TCGCond c)
|
static inline TCGCond tcg_unsigned_cond(TCGCond c)
|
||||||
{
|
{
|
||||||
return (c >= TCG_COND_LT && c <= TCG_COND_GT ? c + 4 : c);
|
return (c >= TCG_COND_LT && c <= TCG_COND_GT ? c + 4 : c);
|
||||||
|
|
Loading…
Reference in New Issue