This patch replaces the obsolete IOCSR_BRD bit with CRC in cpucfg1[25], in both LA464 and LA132 CPU initialization functions. The corresponding field macro in `cpu.h` is updated to reflect this change. Additionally, the availability macro `avail_CRC()` is introduced in `translate.h` to check the CRC feature flag. All CRC-related instruction translations are updated to be gated by the new CRC feature flag instead of hardcoded CPU features. This ensures correctness and configurability when enabling CRC instructions based on hardware capabilities. Signed-off-by: WANG Rui <wangrui@loongson.cn> Reviewed-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20250418082103.447780-2-wangrui@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
61 lines
1.9 KiB
C
61 lines
1.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* LoongArch translation routines.
|
|
*
|
|
* Copyright (c) 2021 Loongson Technology Corporation Limited
|
|
*/
|
|
|
|
#ifndef TARGET_LOONGARCH_TRANSLATE_H
|
|
#define TARGET_LOONGARCH_TRANSLATE_H
|
|
|
|
#include "exec/translator.h"
|
|
|
|
#define TRANS(NAME, AVAIL, FUNC, ...) \
|
|
static bool trans_##NAME(DisasContext *ctx, arg_##NAME * a) \
|
|
{ return avail_##AVAIL(ctx) && FUNC(ctx, a, __VA_ARGS__); }
|
|
|
|
#define avail_ALL(C) true
|
|
#define avail_64(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, ARCH) == \
|
|
CPUCFG1_ARCH_LA64)
|
|
#define avail_FP(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, FP))
|
|
#define avail_FP_SP(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, FP_SP))
|
|
#define avail_FP_DP(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, FP_DP))
|
|
#define avail_LSPW(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LSPW))
|
|
#define avail_LAM(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LAM))
|
|
#define avail_LSX(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LSX))
|
|
#define avail_LASX(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LASX))
|
|
#define avail_IOCSR(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, IOCSR))
|
|
#define avail_CRC(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, CRC))
|
|
|
|
/*
|
|
* If an operation is being performed on less than TARGET_LONG_BITS,
|
|
* it may require the inputs to be sign- or zero-extended; which will
|
|
* depend on the exact operation being performed.
|
|
*/
|
|
typedef enum {
|
|
EXT_NONE,
|
|
EXT_SIGN,
|
|
EXT_ZERO,
|
|
} DisasExtend;
|
|
|
|
typedef struct DisasContext {
|
|
DisasContextBase base;
|
|
target_ulong page_start;
|
|
uint32_t opcode;
|
|
uint16_t mem_idx;
|
|
uint16_t plv;
|
|
int vl; /* Vector length */
|
|
TCGv zero;
|
|
bool la64; /* LoongArch64 mode */
|
|
bool va32; /* 32-bit virtual address */
|
|
uint32_t cpucfg1;
|
|
uint32_t cpucfg2;
|
|
} DisasContext;
|
|
|
|
void generate_exception(DisasContext *ctx, int excp);
|
|
|
|
extern TCGv cpu_gpr[32], cpu_pc;
|
|
extern TCGv_i32 cpu_fscr0;
|
|
extern TCGv_i64 cpu_fpr[32];
|
|
|
|
#endif
|