]> Git Repo - qemu.git/blame - target/loongarch/op_helper.c
target/loongarch: Add fixed point bit instruction translation
[qemu.git] / target / loongarch / op_helper.c
CommitLineData
f8da88d7
SG
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * LoongArch emulation helpers for QEMU.
4 *
5 * Copyright (c) 2021 Loongson Technology Corporation Limited
6 */
7
8#include "qemu/osdep.h"
9#include "qemu/main-loop.h"
10#include "cpu.h"
11#include "qemu/host-utils.h"
12#include "exec/helper-proto.h"
13#include "exec/exec-all.h"
14#include "exec/cpu_ldst.h"
15#include "internals.h"
16
17/* Exceptions helpers */
18void helper_raise_exception(CPULoongArchState *env, uint32_t exception)
19{
20 do_raise_exception(env, exception, GETPC());
21}
ad08cb3f
SG
22
23target_ulong helper_bitrev_w(target_ulong rj)
24{
25 return (int32_t)revbit32(rj);
26}
27
28target_ulong helper_bitrev_d(target_ulong rj)
29{
30 return revbit64(rj);
31}
32
33target_ulong helper_bitswap(target_ulong v)
34{
35 v = ((v >> 1) & (target_ulong)0x5555555555555555ULL) |
36 ((v & (target_ulong)0x5555555555555555ULL) << 1);
37 v = ((v >> 2) & (target_ulong)0x3333333333333333ULL) |
38 ((v & (target_ulong)0x3333333333333333ULL) << 2);
39 v = ((v >> 4) & (target_ulong)0x0F0F0F0F0F0F0F0FULL) |
40 ((v & (target_ulong)0x0F0F0F0F0F0F0F0FULL) << 4);
41 return v;
42}
This page took 0.02815 seconds and 4 git commands to generate.