tcg: Introduce TCG_COND_TST{EQ,NE}
Add the enumerators, adjust the helpers to match, and dump. Not supported anywhere else just yet. Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
39a6e4f87e
commit
d48097d027
@ -253,6 +253,8 @@ Jumps/Labels
|
|||||||
| ``TCG_COND_GEU /* unsigned */``
|
| ``TCG_COND_GEU /* unsigned */``
|
||||||
| ``TCG_COND_LEU /* unsigned */``
|
| ``TCG_COND_LEU /* unsigned */``
|
||||||
| ``TCG_COND_GTU /* unsigned */``
|
| ``TCG_COND_GTU /* unsigned */``
|
||||||
|
| ``TCG_COND_TSTEQ /* t1 & t2 == 0 */``
|
||||||
|
| ``TCG_COND_TSTNE /* t1 & t2 != 0 */``
|
||||||
|
|
||||||
Arithmetic
|
Arithmetic
|
||||||
----------
|
----------
|
||||||
|
@ -29,26 +29,34 @@
|
|||||||
* Conditions. Note that these are laid out for easy manipulation by
|
* Conditions. Note that these are laid out for easy manipulation by
|
||||||
* the functions below:
|
* the functions below:
|
||||||
* bit 0 is used for inverting;
|
* bit 0 is used for inverting;
|
||||||
* bit 1 is signed,
|
* bit 1 is used for conditions that need swapping (signed/unsigned).
|
||||||
* bit 2 is unsigned,
|
* bit 2 is used with bit 1 for swapping.
|
||||||
* bit 3 is used with bit 0 for swapping signed/unsigned.
|
* bit 3 is used for unsigned conditions.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/* non-signed */
|
/* non-signed */
|
||||||
TCG_COND_NEVER = 0 | 0 | 0 | 0,
|
TCG_COND_NEVER = 0 | 0 | 0 | 0,
|
||||||
TCG_COND_ALWAYS = 0 | 0 | 0 | 1,
|
TCG_COND_ALWAYS = 0 | 0 | 0 | 1,
|
||||||
|
|
||||||
|
/* equality */
|
||||||
TCG_COND_EQ = 8 | 0 | 0 | 0,
|
TCG_COND_EQ = 8 | 0 | 0 | 0,
|
||||||
TCG_COND_NE = 8 | 0 | 0 | 1,
|
TCG_COND_NE = 8 | 0 | 0 | 1,
|
||||||
|
|
||||||
|
/* "test" i.e. and then compare vs 0 */
|
||||||
|
TCG_COND_TSTEQ = 8 | 4 | 0 | 0,
|
||||||
|
TCG_COND_TSTNE = 8 | 4 | 0 | 1,
|
||||||
|
|
||||||
/* signed */
|
/* signed */
|
||||||
TCG_COND_LT = 0 | 0 | 2 | 0,
|
TCG_COND_LT = 0 | 0 | 2 | 0,
|
||||||
TCG_COND_GE = 0 | 0 | 2 | 1,
|
TCG_COND_GE = 0 | 0 | 2 | 1,
|
||||||
TCG_COND_LE = 8 | 0 | 2 | 0,
|
TCG_COND_GT = 0 | 4 | 2 | 0,
|
||||||
TCG_COND_GT = 8 | 0 | 2 | 1,
|
TCG_COND_LE = 0 | 4 | 2 | 1,
|
||||||
|
|
||||||
/* unsigned */
|
/* unsigned */
|
||||||
TCG_COND_LTU = 0 | 4 | 0 | 0,
|
TCG_COND_LTU = 8 | 0 | 2 | 0,
|
||||||
TCG_COND_GEU = 0 | 4 | 0 | 1,
|
TCG_COND_GEU = 8 | 0 | 2 | 1,
|
||||||
TCG_COND_LEU = 8 | 4 | 0 | 0,
|
TCG_COND_GTU = 8 | 4 | 2 | 0,
|
||||||
TCG_COND_GTU = 8 | 4 | 0 | 1,
|
TCG_COND_LEU = 8 | 4 | 2 | 1,
|
||||||
} TCGCond;
|
} TCGCond;
|
||||||
|
|
||||||
/* Invert the sense of the comparison. */
|
/* Invert the sense of the comparison. */
|
||||||
@ -60,25 +68,49 @@ static inline TCGCond tcg_invert_cond(TCGCond c)
|
|||||||
/* Swap the operands in a comparison. */
|
/* Swap the operands in a comparison. */
|
||||||
static inline TCGCond tcg_swap_cond(TCGCond c)
|
static inline TCGCond tcg_swap_cond(TCGCond c)
|
||||||
{
|
{
|
||||||
return c & 6 ? (TCGCond)(c ^ 9) : c;
|
return (TCGCond)(c ^ ((c & 2) << 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create an "unsigned" version of a "signed" comparison. */
|
/* Must a comparison be considered signed? */
|
||||||
static inline TCGCond tcg_unsigned_cond(TCGCond c)
|
static inline bool is_signed_cond(TCGCond c)
|
||||||
{
|
{
|
||||||
return c & 2 ? (TCGCond)(c ^ 6) : c;
|
return (c & (8 | 2)) == 2;
|
||||||
}
|
|
||||||
|
|
||||||
/* Create a "signed" version of an "unsigned" comparison. */
|
|
||||||
static inline TCGCond tcg_signed_cond(TCGCond c)
|
|
||||||
{
|
|
||||||
return c & 4 ? (TCGCond)(c ^ 6) : c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Must a comparison be considered unsigned? */
|
/* Must a comparison be considered unsigned? */
|
||||||
static inline bool is_unsigned_cond(TCGCond c)
|
static inline bool is_unsigned_cond(TCGCond c)
|
||||||
{
|
{
|
||||||
return (c & 4) != 0;
|
return (c & (8 | 2)) == (8 | 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Must a comparison be considered a test? */
|
||||||
|
static inline bool is_tst_cond(TCGCond c)
|
||||||
|
{
|
||||||
|
return (c | 1) == TCG_COND_TSTNE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create an "unsigned" version of a "signed" comparison. */
|
||||||
|
static inline TCGCond tcg_unsigned_cond(TCGCond c)
|
||||||
|
{
|
||||||
|
return is_signed_cond(c) ? (TCGCond)(c + 8) : c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a "signed" version of an "unsigned" comparison. */
|
||||||
|
static inline TCGCond tcg_signed_cond(TCGCond c)
|
||||||
|
{
|
||||||
|
return is_unsigned_cond(c) ? (TCGCond)(c - 8) : c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the eq/ne version of a tsteq/tstne comparison. */
|
||||||
|
static inline TCGCond tcg_tst_eqne_cond(TCGCond c)
|
||||||
|
{
|
||||||
|
return is_tst_cond(c) ? (TCGCond)(c - 4) : c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create the lt/ge version of a tstne/tsteq comparison of the sign. */
|
||||||
|
static inline TCGCond tcg_tst_ltge_cond(TCGCond c)
|
||||||
|
{
|
||||||
|
return is_tst_cond(c) ? (TCGCond)(c ^ 0xf) : c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -92,7 +124,7 @@ static inline TCGCond tcg_high_cond(TCGCond c)
|
|||||||
case TCG_COND_LE:
|
case TCG_COND_LE:
|
||||||
case TCG_COND_GEU:
|
case TCG_COND_GEU:
|
||||||
case TCG_COND_LEU:
|
case TCG_COND_LEU:
|
||||||
return (TCGCond)(c ^ 8);
|
return (TCGCond)(c ^ (4 | 1));
|
||||||
default:
|
default:
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -2482,7 +2482,9 @@ static const char * const cond_name[] =
|
|||||||
[TCG_COND_LTU] = "ltu",
|
[TCG_COND_LTU] = "ltu",
|
||||||
[TCG_COND_GEU] = "geu",
|
[TCG_COND_GEU] = "geu",
|
||||||
[TCG_COND_LEU] = "leu",
|
[TCG_COND_LEU] = "leu",
|
||||||
[TCG_COND_GTU] = "gtu"
|
[TCG_COND_GTU] = "gtu",
|
||||||
|
[TCG_COND_TSTEQ] = "tsteq",
|
||||||
|
[TCG_COND_TSTNE] = "tstne",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] =
|
static const char * const ldst_name[(MO_BSWAP | MO_SSIZE) + 1] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user