2022-06-06 14:42:53 +02:00
|
|
|
/* 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"
|
|
|
|
|
2023-08-22 09:19:51 +02:00
|
|
|
#define TRANS(NAME, AVAIL, FUNC, ...) \
|
target/loongarch: Add fixed point arithmetic instruction translation
This includes:
- ADD.{W/D}, SUB.{W/D}
- ADDI.{W/D}, ADDU16ID
- ALSL.{W[U]/D}
- LU12I.W, LU32I.D LU52I.D
- SLT[U], SLT[U]I
- PCADDI, PCADDU12I, PCADDU18I, PCALAU12I
- AND, OR, NOR, XOR, ANDN, ORN
- MUL.{W/D}, MULH.{W[U]/D[U]}
- MULW.D.W[U]
- DIV.{W[U]/D[U]}, MOD.{W[U]/D[U]}
- ANDI, ORI, XORI
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-5-yangxiaojuan@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-06-06 14:42:54 +02:00
|
|
|
static bool trans_##NAME(DisasContext *ctx, arg_##NAME * a) \
|
2023-08-22 09:19:51 +02:00
|
|
|
{ return avail_##AVAIL(ctx) && FUNC(ctx, a, __VA_ARGS__); }
|
|
|
|
|
|
|
|
#define avail_ALL(C) true
|
2023-08-22 09:19:52 +02:00
|
|
|
#define avail_64(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, ARCH) == \
|
|
|
|
CPUCFG1_ARCH_LA64)
|
2023-08-22 09:19:55 +02:00
|
|
|
#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))
|
2023-08-22 09:19:56 +02:00
|
|
|
#define avail_LSPW(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LSPW))
|
2023-08-22 09:19:57 +02:00
|
|
|
#define avail_LAM(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LAM))
|
2023-08-22 09:30:26 +02:00
|
|
|
#define avail_LSX(C) (FIELD_EX32((C)->cpucfg2, CPUCFG2, LSX))
|
2023-08-22 09:22:19 +02:00
|
|
|
#define avail_IOCSR(C) (FIELD_EX32((C)->cpucfg1, CPUCFG1, IOCSR))
|
target/loongarch: Add fixed point arithmetic instruction translation
This includes:
- ADD.{W/D}, SUB.{W/D}
- ADDI.{W/D}, ADDU16ID
- ALSL.{W[U]/D}
- LU12I.W, LU32I.D LU52I.D
- SLT[U], SLT[U]I
- PCADDI, PCADDU12I, PCADDU18I, PCALAU12I
- AND, OR, NOR, XOR, ANDN, ORN
- MUL.{W/D}, MULH.{W[U]/D[U]}
- MULW.D.W[U]
- DIV.{W[U]/D[U]}, MOD.{W[U]/D[U]}
- ANDI, ORI, XORI
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-5-yangxiaojuan@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-06-06 14:42:54 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
2022-06-06 14:42:53 +02:00
|
|
|
typedef struct DisasContext {
|
|
|
|
DisasContextBase base;
|
|
|
|
target_ulong page_start;
|
|
|
|
uint32_t opcode;
|
2022-11-07 03:45:25 +01:00
|
|
|
uint16_t mem_idx;
|
|
|
|
uint16_t plv;
|
2023-05-04 14:27:30 +02:00
|
|
|
int vl; /* Vector length */
|
target/loongarch: Add fixed point arithmetic instruction translation
This includes:
- ADD.{W/D}, SUB.{W/D}
- ADDI.{W/D}, ADDU16ID
- ALSL.{W[U]/D}
- LU12I.W, LU32I.D LU52I.D
- SLT[U], SLT[U]I
- PCADDI, PCADDU12I, PCADDU18I, PCALAU12I
- AND, OR, NOR, XOR, ANDN, ORN
- MUL.{W/D}, MULH.{W[U]/D[U]}
- MULW.D.W[U]
- DIV.{W[U]/D[U]}, MOD.{W[U]/D[U]}
- ANDI, ORI, XORI
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-5-yangxiaojuan@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-06-06 14:42:54 +02:00
|
|
|
TCGv zero;
|
2023-08-22 09:13:50 +02:00
|
|
|
bool la64; /* LoongArch64 mode */
|
|
|
|
bool va32; /* 32-bit virtual address */
|
2023-08-22 09:19:52 +02:00
|
|
|
uint32_t cpucfg1;
|
2023-08-22 09:19:55 +02:00
|
|
|
uint32_t cpucfg2;
|
2022-06-06 14:42:53 +02:00
|
|
|
} 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
|