[PATCH 1/2] RISC-V: Support extension Zicfiss and Zicfilp
Jan Beulich
jbeulich@suse.com
Fri Jan 10 12:46:27 GMT 2025
On 10.01.2025 11:17, Kito Cheng wrote:
> --- a/opcodes/riscv-opc.c
> +++ b/opcodes/riscv-opc.c
> @@ -381,15 +381,46 @@ match_cm_jalt (const struct riscv_opcode *op, insn_t insn)
> && EXTRACT_ZCMT_INDEX (insn) < 256;
> }
>
> -/* The order of overloaded instructions matters. Label arguments and
> - register arguments look the same. Instructions that can have either
> - for arguments must apear in the correct order in this table for the
> - assembler to pick the right one. In other words, entries with
> - immediate operands must apear after the same instruction with
> - registers.
>
> - Because of the lookup algorithm used, entries with the same opcode
> - name must be contiguous. */
I don't think this comment should be removed.
> +static int
> +match_rs1_x1x5_opcode (const struct riscv_opcode *op,
> + insn_t insn)
> +{
> + int rs1 = (insn & MASK_RS1) >> OP_SH_RS1;
> + return match_opcode (op, insn) && (rs1 == 1 || rs1 == 5);
> +}
> +
> +static int
> +match_rs2_x1x5_opcode (const struct riscv_opcode *op,
> + insn_t insn)
> +{
> + int rs2 = (insn & MASK_RS2) >> OP_SH_RS2;
> + return match_opcode (op, insn) && (rs2 == 1 || rs2 == 5);
> +}
> +
> +static int
> +match_c_mop_1 (const struct riscv_opcode *op,
> + insn_t insn)
> +{
> + int n = EXTRACT_C_MOP_N (insn) ;
> + return match_opcode (op, insn) && n == 1;
> +}
> +
> +static int
> +match_c_mop_5 (const struct riscv_opcode *op,
> + insn_t insn)
> +{
> + int n = EXTRACT_C_MOP_N (insn) ;
> + return match_opcode (op, insn) && n == 5;
> +}
> +
> +static int
> +match_rd_x1x5_opcode (const struct riscv_opcode *op,
> + insn_t insn)
> +{
> + int rd = (insn & MASK_RD) >> OP_SH_RD;
> + return match_opcode (op, insn) && (rd == 1 || rd == 5);
> +}
>
> const struct riscv_opcode riscv_opcodes[] =
> {
> @@ -546,6 +577,10 @@ const struct riscv_opcode riscv_opcodes[] =
> {"or", 0, INSN_CLASS_C, "Cs,Cw,Ct", MATCH_C_OR, MASK_C_OR, match_opcode, INSN_ALIAS },
> {"or", 0, INSN_CLASS_C, "Cs,Ct,Cw", MATCH_C_OR, MASK_C_OR, match_opcode, INSN_ALIAS },
> {"or", 0, INSN_CLASS_I, "d,s,t", MATCH_OR, MASK_OR, match_opcode, 0 },
> +
> +/* Zicfilp instructions. */
> +{"lpad", 0, INSN_CLASS_ZICFILP, "u", MATCH_LPAD, MASK_LPAD, match_opcode, 0 },
Can the MATCH_* please be padded enough to match adjacent table entries?
Jan
More information about the Binutils
mailing list