mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 17:23:56 -06:00

This includes: - EXT.W.{B/H} - CL{O/Z}.{W/D}, CT{O/Z}.{W/D} - BYTEPICK.{W/D} - REVB.{2H/4H/2W/D} - REVH.{2W/D} - BITREV.{4B/8B}, BITREV.{W/D} - BSTRINS.{W/D}, BSTRPICK.{W/D} - MASKEQZ, MASKNEZ Signed-off-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220606124333.2060567-7-yangxiaojuan@loongson.cn> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* LoongArch emulation helpers for QEMU.
|
|
*
|
|
* Copyright (c) 2021 Loongson Technology Corporation Limited
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu/main-loop.h"
|
|
#include "cpu.h"
|
|
#include "qemu/host-utils.h"
|
|
#include "exec/helper-proto.h"
|
|
#include "exec/exec-all.h"
|
|
#include "exec/cpu_ldst.h"
|
|
#include "internals.h"
|
|
|
|
/* Exceptions helpers */
|
|
void helper_raise_exception(CPULoongArchState *env, uint32_t exception)
|
|
{
|
|
do_raise_exception(env, exception, GETPC());
|
|
}
|
|
|
|
target_ulong helper_bitrev_w(target_ulong rj)
|
|
{
|
|
return (int32_t)revbit32(rj);
|
|
}
|
|
|
|
target_ulong helper_bitrev_d(target_ulong rj)
|
|
{
|
|
return revbit64(rj);
|
|
}
|
|
|
|
target_ulong helper_bitswap(target_ulong v)
|
|
{
|
|
v = ((v >> 1) & (target_ulong)0x5555555555555555ULL) |
|
|
((v & (target_ulong)0x5555555555555555ULL) << 1);
|
|
v = ((v >> 2) & (target_ulong)0x3333333333333333ULL) |
|
|
((v & (target_ulong)0x3333333333333333ULL) << 2);
|
|
v = ((v >> 4) & (target_ulong)0x0F0F0F0F0F0F0F0FULL) |
|
|
((v & (target_ulong)0x0F0F0F0F0F0F0F0FULL) << 4);
|
|
return v;
|
|
}
|