return 0;
}
-static inline uint32_t get_C_add_icc(target_ulong dst, target_ulong src1)
+/* carry = (src1[31] & src2[31]) | ( ~dst[31] & (src1[31] | src2[31])) */
+static inline uint32_t get_C_add_icc(target_ulong dst, target_ulong src1,
+ target_ulong src2)
{
uint32_t ret = 0;
- if ((dst & 0xffffffffULL) < (src1 & 0xffffffffULL))
+ if (((src1 & (1ULL << 31)) & (src2 & (1ULL << 31)))
+ | ((~(dst & (1ULL << 31)))
+ & ((src1 & (1ULL << 31)) | (src2 & (1ULL << 31)))))
ret |= PSR_CARRY;
return ret;
}
return ret;
}
-static uint32_t compute_all_add(void)
-{
- uint32_t ret;
-
- ret = get_NZ_icc(CC_DST);
- ret |= get_C_add_icc(CC_DST, CC_SRC);
- ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2);
- return ret;
-}
-
-static uint32_t compute_C_add(void)
-{
- return get_C_add_icc(CC_DST, CC_SRC);
-}
-
#ifdef TARGET_SPARC64
static inline uint32_t get_C_add_xcc(target_ulong dst, target_ulong src1)
{
}
#endif
-static uint32_t compute_all_addx(void)
+static uint32_t compute_all_add(void)
{
uint32_t ret;
ret = get_NZ_icc(CC_DST);
- ret |= get_C_add_icc(CC_DST - CC_SRC2, CC_SRC);
- ret |= get_C_add_icc(CC_DST, CC_SRC);
+ ret |= get_C_add_icc(CC_DST, CC_SRC, CC_SRC2);
ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2);
return ret;
}
-static uint32_t compute_C_addx(void)
+static uint32_t compute_C_add(void)
{
- uint32_t ret;
-
- ret = get_C_add_icc(CC_DST - CC_SRC2, CC_SRC);
- ret |= get_C_add_icc(CC_DST, CC_SRC);
- return ret;
+ return get_C_add_icc(CC_DST, CC_SRC, CC_SRC2);
}
#ifdef TARGET_SPARC64
uint32_t ret;
ret = get_NZ_icc(CC_DST);
- ret |= get_C_add_icc(CC_DST, CC_SRC);
+ ret |= get_C_add_icc(CC_DST, CC_SRC, CC_SRC2);
ret |= get_V_add_icc(CC_DST, CC_SRC, CC_SRC2);
ret |= get_V_tag_icc(CC_SRC, CC_SRC2);
return ret;
static uint32_t compute_C_tadd(void)
{
- return get_C_add_icc(CC_DST, CC_SRC);
+ return get_C_add_icc(CC_DST, CC_SRC, CC_SRC2);
}
static uint32_t compute_all_taddtv(void)
uint32_t ret;
ret = get_NZ_icc(CC_DST);
- ret |= get_C_add_icc(CC_DST, CC_SRC);
+ ret |= get_C_add_icc(CC_DST, CC_SRC, CC_SRC2);
return ret;
}
static uint32_t compute_C_taddtv(void)
{
- return get_C_add_icc(CC_DST, CC_SRC);
+ return get_C_add_icc(CC_DST, CC_SRC, CC_SRC2);
}
-static inline uint32_t get_C_sub_icc(target_ulong src1, target_ulong src2)
+/* carry = (~src1[31] & src2[31]) | ( dst[31] & (~src1[31] | src2[31])) */
+static inline uint32_t get_C_sub_icc(target_ulong dst, target_ulong src1,
+ target_ulong src2)
{
uint32_t ret = 0;
- if ((src1 & 0xffffffffULL) < (src2 & 0xffffffffULL))
+ if (((~(src1 & (1ULL << 31))) & (src2 & (1ULL << 31)))
+ | ((dst & (1ULL << 31)) & (( ~(src1 & (1ULL << 31)))
+ | (src2 & (1ULL << 31)))))
ret |= PSR_CARRY;
return ret;
}
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)
}
#endif
-static uint32_t compute_all_subx(void)
+static uint32_t compute_all_sub(void)
{
uint32_t ret;
ret = get_NZ_icc(CC_DST);
- ret |= get_C_sub_icc(CC_DST - CC_SRC2, CC_SRC);
- ret |= get_C_sub_icc(CC_DST, CC_SRC2);
+ ret |= get_C_sub_icc(CC_DST, CC_SRC, CC_SRC2);
ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2);
return ret;
}
-static uint32_t compute_C_subx(void)
+static uint32_t compute_C_sub(void)
{
- uint32_t ret;
-
- ret = get_C_sub_icc(CC_DST - CC_SRC2, CC_SRC);
- ret |= get_C_sub_icc(CC_DST, CC_SRC2);
- return ret;
+ return get_C_sub_icc(CC_DST, CC_SRC, CC_SRC2);
}
#ifdef TARGET_SPARC64
uint32_t ret;
ret = get_NZ_icc(CC_DST);
- ret |= get_C_sub_icc(CC_DST, CC_SRC);
+ ret |= get_C_sub_icc(CC_DST, CC_SRC, CC_SRC2);
ret |= get_V_sub_icc(CC_DST, CC_SRC, CC_SRC2);
ret |= get_V_tag_icc(CC_SRC, CC_SRC2);
return ret;
static uint32_t compute_C_tsub(void)
{
- return get_C_sub_icc(CC_DST, CC_SRC);
+ return get_C_sub_icc(CC_DST, CC_SRC, CC_SRC2);
}
static uint32_t compute_all_tsubtv(void)
uint32_t ret;
ret = get_NZ_icc(CC_DST);
- ret |= get_C_sub_icc(CC_DST, CC_SRC);
+ ret |= get_C_sub_icc(CC_DST, CC_SRC, CC_SRC2);
return ret;
}
static uint32_t compute_C_tsubtv(void)
{
- return get_C_sub_icc(CC_DST, CC_SRC);
+ return get_C_sub_icc(CC_DST, CC_SRC, CC_SRC2);
}
static uint32_t compute_all_logic(void)
[CC_OP_FLAGS] = { compute_all_flags, compute_C_flags },
[CC_OP_DIV] = { compute_all_div, compute_C_div },
[CC_OP_ADD] = { compute_all_add, compute_C_add },
- [CC_OP_ADDX] = { compute_all_addx, compute_C_addx },
+ [CC_OP_ADDX] = { compute_all_add, compute_C_add },
[CC_OP_TADD] = { compute_all_tadd, compute_C_tadd },
[CC_OP_TADDTV] = { compute_all_taddtv, compute_C_taddtv },
[CC_OP_SUB] = { compute_all_sub, compute_C_sub },
- [CC_OP_SUBX] = { compute_all_subx, compute_C_subx },
+ [CC_OP_SUBX] = { compute_all_sub, compute_C_sub },
[CC_OP_TSUB] = { compute_all_tsub, compute_C_tsub },
[CC_OP_TSUBTV] = { compute_all_tsubtv, compute_C_tsubtv },
[CC_OP_LOGIC] = { compute_all_logic, compute_C_logic },