mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 01:50:24 +08:00
RISC-V: Support rvv extension with released version 1.0.
2021-11-17 Jim Wilson <jimw@sifive.com> Kito Cheng <kito.cheng@sifive.com> Nelson Chu <nelson.chu@sifive.com> This patch is porting from the following riscv github, https://github.com/riscv/riscv-binutils-gdb/tree/rvv-1.0.x And here is the vector spec, https://github.com/riscv/riscv-v-spec bfd/ * elfxx-riscv.c (riscv_implicit_subsets): Added imply rules of v, zve and zvl extensions. (riscv_supported_std_ext): Updated verison of v to 1.0. (riscv_supported_std_z_ext): Added zve and zvl extensions. (riscv_parse_check_conflicts): The zvl extensions need to enable either v or zve extension. (riscv_multi_subset_supports): Check the subset list to know if the INSN_CLASS_V and INSN_CLASS_ZVEF instructions are supported. gas/ * config/tc-riscv.c (enum riscv_csr_class): Added CSR_CLASS_V. (enum reg_class): Added RCLASS_VECR and RCLASS_VECM. (validate_riscv_insn): Check whether the rvv operands are valid. (md_begin): Initialize register hash for rvv registers. (macro_build): Added rvv operands when expanding rvv pseudoes. (vector_macro): Expand rvv macros into one or more instructions. (macro): Likewise. (my_getVsetvliExpression): Similar to my_getVsetvliExpression, but used for parsing vsetvli operands. (riscv_ip): Parse and encode rvv operands. Besides, The rvv loads and stores with EEW 64 cannot be used when zve32x is enabled. * testsuite/gas/riscv/priv-reg-fail-version-1p10.d: Updated -march to rv32ifv_zkr. * testsuite/gas/riscv/priv-reg-fail-version-1p11.d: Likewise. * testsuite/gas/riscv/priv-reg-fail-version-1p9p1.d: Likewise. * testsuite/gas/riscv/priv-reg.s: Added rvv csr testcases. * testsuite/gas/riscv/priv-reg-version-1p10.d: Likewise. * testsuite/gas/riscv/priv-reg-version-1p11.d: Likewise. * testsuite/gas/riscv/priv-reg-version-1p9p1.d: Likewise. * testsuite/gas/riscv/march-imply-v.d: New testcase. * testsuite/gas/riscv/vector-insns-fail-zve32xf.d: Likewise. * testsuite/gas/riscv/vector-insns-fail-zve32xf.l: Likewise. * testsuite/gas/riscv/vector-insns-fail-zvl.d: Likewise. * testsuite/gas/riscv/vector-insns-fail-zvl.l: Likewise. * testsuite/gas/riscv/vector-insns-vmsgtvx.d: Likewise. * testsuite/gas/riscv/vector-insns-vmsgtvx.s: Likewise. * testsuite/gas/riscv/vector-insns-zero-imm.d: Likewise. * testsuite/gas/riscv/vector-insns-zero-imm.s: Likewise. * testsuite/gas/riscv/vector-insns.d: Likewise. * testsuite/gas/riscv/vector-insns.s: Likewise. include/ * opcode/riscv-opc.h: Defined mask/match encodings and csrs for rvv. * opcode/riscv.h: Defined rvv immediate encodings and fields. (enum riscv_insn_class): Added INSN_CLASS_V and INSN_CLASS_ZVEF. (INSN_V_EEW64): Defined. (M_VMSGE, M_VMSGEU): Added for the rvv pseudoes. opcodes/ * riscv-dis.c (print_insn_args): Dump the rvv operands. * riscv-opc.c (riscv_vecr_names_numeric): Defined rvv registers. (riscv_vecm_names_numeric): Likewise. (riscv_vsew): Likewise. (riscv_vlmul): Likewise. (riscv_vta): Likewise. (riscv_vma): Likewise. (match_vs1_eq_vs2): Added for rvv Vu operand. (match_vd_eq_vs1_eq_vs2): Added for rvv Vv operand. (riscv_opcodes): Added rvv v1.0 instructions.
This commit is contained in:
@ -101,6 +101,16 @@ static const char * const riscv_pred_succ[16] =
|
||||
((RV_X(x, 3, 2) << 1) | (RV_X(x, 10, 2) << 3) | (RV_X(x, 2, 1) << 5) | (RV_X(x, 5, 2) << 6) | (-RV_X(x, 12, 1) << 8))
|
||||
#define EXTRACT_CJTYPE_IMM(x) \
|
||||
((RV_X(x, 3, 3) << 1) | (RV_X(x, 11, 1) << 4) | (RV_X(x, 2, 1) << 5) | (RV_X(x, 7, 1) << 6) | (RV_X(x, 6, 1) << 7) | (RV_X(x, 9, 2) << 8) | (RV_X(x, 8, 1) << 10) | (-RV_X(x, 12, 1) << 11))
|
||||
#define EXTRACT_RVV_VI_IMM(x) \
|
||||
(RV_X(x, 15, 5) | (-RV_X(x, 19, 1) << 5))
|
||||
#define EXTRACT_RVV_VI_UIMM(x) \
|
||||
(RV_X(x, 15, 5))
|
||||
#define EXTRACT_RVV_OFFSET(x) \
|
||||
(RV_X(x, 29, 3))
|
||||
#define EXTRACT_RVV_VB_IMM(x) \
|
||||
(RV_X(x, 20, 10))
|
||||
#define EXTRACT_RVV_VC_IMM(x) \
|
||||
(RV_X(x, 20, 11))
|
||||
|
||||
#define ENCODE_ITYPE_IMM(x) \
|
||||
(RV_X(x, 0, 12) << 20)
|
||||
@ -142,6 +152,10 @@ static const char * const riscv_pred_succ[16] =
|
||||
((RV_X(x, 1, 2) << 3) | (RV_X(x, 3, 2) << 10) | (RV_X(x, 5, 1) << 2) | (RV_X(x, 6, 2) << 5) | (RV_X(x, 8, 1) << 12))
|
||||
#define ENCODE_CJTYPE_IMM(x) \
|
||||
((RV_X(x, 1, 3) << 3) | (RV_X(x, 4, 1) << 11) | (RV_X(x, 5, 1) << 2) | (RV_X(x, 6, 1) << 7) | (RV_X(x, 7, 1) << 6) | (RV_X(x, 8, 2) << 9) | (RV_X(x, 10, 1) << 8) | (RV_X(x, 11, 1) << 12))
|
||||
#define ENCODE_RVV_VB_IMM(x) \
|
||||
(RV_X(x, 0, 10) << 20)
|
||||
#define ENCODE_RVV_VC_IMM(x) \
|
||||
(RV_X(x, 0, 11) << 20)
|
||||
|
||||
#define VALID_ITYPE_IMM(x) (EXTRACT_ITYPE_IMM(ENCODE_ITYPE_IMM(x)) == (x))
|
||||
#define VALID_STYPE_IMM(x) (EXTRACT_STYPE_IMM(ENCODE_STYPE_IMM(x)) == (x))
|
||||
@ -165,6 +179,8 @@ static const char * const riscv_pred_succ[16] =
|
||||
#define VALID_CLTYPE_LD_IMM(x) (EXTRACT_CLTYPE_LD_IMM(ENCODE_CLTYPE_LD_IMM(x)) == (x))
|
||||
#define VALID_CBTYPE_IMM(x) (EXTRACT_CBTYPE_IMM(ENCODE_CBTYPE_IMM(x)) == (x))
|
||||
#define VALID_CJTYPE_IMM(x) (EXTRACT_CJTYPE_IMM(ENCODE_CJTYPE_IMM(x)) == (x))
|
||||
#define VALID_RVV_VB_IMM(x) (EXTRACT_RVV_VB_IMM(ENCODE_RVV_VB_IMM(x)) == (x))
|
||||
#define VALID_RVV_VC_IMM(x) (EXTRACT_RVV_VC_IMM(ENCODE_RVV_VC_IMM(x)) == (x))
|
||||
|
||||
#define RISCV_RTYPE(insn, rd, rs1, rs2) \
|
||||
((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2))
|
||||
@ -268,6 +284,36 @@ static const char * const riscv_pred_succ[16] =
|
||||
#define OP_SH_RNUM 20
|
||||
#define OP_MASK_RNUM 0xf
|
||||
|
||||
/* RVV fields. */
|
||||
|
||||
#define OP_MASK_VD 0x1f
|
||||
#define OP_SH_VD 7
|
||||
#define OP_MASK_VS1 0x1f
|
||||
#define OP_SH_VS1 15
|
||||
#define OP_MASK_VS2 0x1f
|
||||
#define OP_SH_VS2 20
|
||||
#define OP_MASK_VIMM 0x1f
|
||||
#define OP_SH_VIMM 15
|
||||
#define OP_MASK_VMASK 0x1
|
||||
#define OP_SH_VMASK 25
|
||||
#define OP_MASK_VFUNCT6 0x3f
|
||||
#define OP_SH_VFUNCT6 26
|
||||
#define OP_MASK_VLMUL 0x7
|
||||
#define OP_SH_VLMUL 0
|
||||
#define OP_MASK_VSEW 0x7
|
||||
#define OP_SH_VSEW 3
|
||||
#define OP_MASK_VTA 0x1
|
||||
#define OP_SH_VTA 6
|
||||
#define OP_MASK_VMA 0x1
|
||||
#define OP_SH_VMA 7
|
||||
#define OP_MASK_VTYPE_RES 0x1
|
||||
#define OP_SH_VTYPE_RES 10
|
||||
#define OP_MASK_VWD 0x1
|
||||
#define OP_SH_VWD 26
|
||||
|
||||
#define NVECR 32
|
||||
#define NVECM 1
|
||||
|
||||
/* ABI names for selected x-registers. */
|
||||
|
||||
#define X_RA 1
|
||||
@ -338,6 +384,8 @@ enum riscv_insn_class
|
||||
INSN_CLASS_ZBB_OR_ZBKB,
|
||||
INSN_CLASS_ZBC_OR_ZBKC,
|
||||
INSN_CLASS_ZKND_OR_ZKNE,
|
||||
INSN_CLASS_V,
|
||||
INSN_CLASS_ZVEF,
|
||||
};
|
||||
|
||||
/* This structure holds information for a particular instruction. */
|
||||
@ -396,6 +444,8 @@ struct riscv_opcode
|
||||
#define INSN_JSR 0x00000006
|
||||
/* Instruction is a data reference. */
|
||||
#define INSN_DREF 0x00000008
|
||||
/* Instruction is allowed when eew >= 64. */
|
||||
#define INSN_V_EEW64 0x10000000
|
||||
|
||||
/* We have 5 data reference sizes, which we can encode in 3 bits. */
|
||||
#define INSN_DATA_SIZE 0x00000070
|
||||
@ -441,6 +491,8 @@ enum
|
||||
M_ZEXTW,
|
||||
M_SEXTB,
|
||||
M_SEXTH,
|
||||
M_VMSGE,
|
||||
M_VMSGEU,
|
||||
M_NUM_MACROS
|
||||
};
|
||||
|
||||
@ -456,6 +508,12 @@ extern const char * const riscv_gpr_names_numeric[NGPR];
|
||||
extern const char * const riscv_gpr_names_abi[NGPR];
|
||||
extern const char * const riscv_fpr_names_numeric[NFPR];
|
||||
extern const char * const riscv_fpr_names_abi[NFPR];
|
||||
extern const char * const riscv_vecr_names_numeric[NVECR];
|
||||
extern const char * const riscv_vecm_names_numeric[NVECM];
|
||||
extern const char * const riscv_vsew[8];
|
||||
extern const char * const riscv_vlmul[8];
|
||||
extern const char * const riscv_vta[2];
|
||||
extern const char * const riscv_vma[2];
|
||||
|
||||
extern const struct riscv_opcode riscv_opcodes[];
|
||||
extern const struct riscv_opcode riscv_insn_types[];
|
||||
|
Reference in New Issue
Block a user