diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2009-05-10 10:38:34 +0300 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-05-10 10:38:34 +0300 |
commit | d4b0d46898ec67e733b64b14d623550d1e7f6b9d (patch) | |
tree | 9317b59a7d64e1d1e1af8d4325b29ccfdc6b36ec /target-sparc/op_helper.c | |
parent | 38482a77f0b3f3147242c1f3eee573c51871b3a5 (diff) |
Convert sub
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'target-sparc/op_helper.c')
-rw-r--r-- | target-sparc/op_helper.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c index 3665eea7c1..5890f2902d 100644 --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -902,6 +902,76 @@ static uint32_t compute_C_addx_xcc(void) } #endif +static inline uint32_t get_C_sub_icc(target_ulong src1, target_ulong src2) +{ + uint32_t ret = 0; + + if ((src1 & 0xffffffffULL) < (src2 & 0xffffffffULL)) + ret |= PSR_CARRY; + return ret; +} + +static inline uint32_t get_V_sub_icc(target_ulong dst, target_ulong src1, + target_ulong src2) +{ + uint32_t ret = 0; + + if (((src1 ^ src2) & (src1 ^ dst)) & (1ULL << 31)) + ret |= PSR_OVF; + return ret; +} + +static uint32_t compute_all_sub(void) +{ + uint32_t ret; + + ret = get_NZ_icc(CC_DST); + ret |= get_C_sub_icc(CC_SRC, CC_SRC2); + ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2); + return ret; +} + +static uint32_t compute_C_sub(void) +{ + return get_C_sub_icc(CC_SRC, CC_SRC2); +} + +#ifdef TARGET_SPARC64 +static inline uint32_t get_C_sub_xcc(target_ulong src1, target_ulong src2) +{ + uint32_t ret = 0; + + if (src1 < src2) + ret |= PSR_CARRY; + return ret; +} + +static inline uint32_t get_V_sub_xcc(target_ulong dst, target_ulong src1, + target_ulong src2) +{ + uint32_t ret = 0; + + if (((src1 ^ src2) & (src1 ^ dst)) & (1ULL << 63)) + ret |= PSR_OVF; + return ret; +} + +static uint32_t compute_all_sub_xcc(void) +{ + uint32_t ret; + + ret = get_NZ_xcc(CC_DST); + ret |= get_C_sub_xcc(CC_SRC, CC_SRC2); + ret |= get_V_sub_xcc(CC_DST, CC_SRC, CC_SRC2); + return ret; +} + +static uint32_t compute_C_sub_xcc(void) +{ + return get_C_sub_xcc(CC_SRC, CC_SRC2); +} +#endif + static uint32_t compute_all_logic(void) { return get_NZ_icc(CC_DST); @@ -929,6 +999,7 @@ static const CCTable icc_table[CC_OP_NB] = { [CC_OP_FLAGS] = { compute_all_flags, compute_C_flags }, [CC_OP_ADD] = { compute_all_add, compute_C_add }, [CC_OP_ADDX] = { compute_all_addx, compute_C_addx }, + [CC_OP_SUB] = { compute_all_sub, compute_C_sub }, [CC_OP_LOGIC] = { compute_all_logic, compute_C_logic }, }; @@ -938,6 +1009,7 @@ static const CCTable xcc_table[CC_OP_NB] = { [CC_OP_FLAGS] = { compute_all_flags_xcc, compute_C_flags_xcc }, [CC_OP_ADD] = { compute_all_add_xcc, compute_C_add_xcc }, [CC_OP_ADDX] = { compute_all_addx_xcc, compute_C_addx_xcc }, + [CC_OP_SUB] = { compute_all_sub_xcc, compute_C_sub_xcc }, [CC_OP_LOGIC] = { compute_all_logic_xcc, compute_C_logic }, }; #endif |