From 15eacb9b525ad7f6b9326eeb8eeb151721d66570 Mon Sep 17 00:00:00 2001 From: Yongbok Kim Date: Fri, 27 Jun 2014 08:49:05 +0100 Subject: target-mips: add ALIGN, DALIGN, BITSWAP and DBITSWAP instructions Signed-off-by: Yongbok Kim Signed-off-by: Leon Alrae Reviewed-by: Aurelien Jarno --- target-mips/op_helper.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'target-mips/op_helper.c') diff --git a/target-mips/op_helper.c b/target-mips/op_helper.c index df97b35f87..c9841e26f8 100644 --- a/target-mips/op_helper.c +++ b/target-mips/op_helper.c @@ -266,6 +266,29 @@ target_ulong helper_mulshiu(CPUMIPSState *env, target_ulong arg1, (uint64_t)(uint32_t)arg2); } +static inline target_ulong bitswap(target_ulong v) +{ + v = ((v >> 1) & (target_ulong)0x5555555555555555) | + ((v & (target_ulong)0x5555555555555555) << 1); + v = ((v >> 2) & (target_ulong)0x3333333333333333) | + ((v & (target_ulong)0x3333333333333333) << 2); + v = ((v >> 4) & (target_ulong)0x0F0F0F0F0F0F0F0F) | + ((v & (target_ulong)0x0F0F0F0F0F0F0F0F) << 4); + return v; +} + +#ifdef TARGET_MIPS64 +target_ulong helper_dbitswap(target_ulong rt) +{ + return bitswap(rt); +} +#endif + +target_ulong helper_bitswap(target_ulong rt) +{ + return (int32_t)bitswap(rt); +} + #ifndef CONFIG_USER_ONLY static inline hwaddr do_translate_address(CPUMIPSState *env, -- cgit v1.2.3