Skip to content

Commit 3486cd0

Browse files
committed
arcv: dis: apex: Add APEX operand identifier support.
Introduce APEX-specific operand identifier masks and shift constants for RD, RS1, and RS2 fields (APEX_OP_MASK_RD/RS1/RS2 and APEX_OP_SH_RD/RS1/RS2) to allow easy extraction of operands from instruction words. Extend print_insn_args() to handle APEX operand specifier 'M', mapping 'd', 's', and 't' to RD, RS1, and RS2 respectively, using the new operand identifier macros. This enables proper disassembly of APEX instructions in the RISC-V disassembler. Signed-off-by: Alex Turjan <turjan@synopsys.com>
1 parent 9b2620d commit 3486cd0

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

include/opcode/riscv.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,4 +712,11 @@ struct apex_insn
712712
#define ARCV_APEX_OFFSET_XI (ARCV_APEX_OFFSET_XS + 64) /* 256 + 64 = 320 */
713713
#define ARCV_APEX_OFFSET_XC (ARCV_APEX_OFFSET_XI + 32) /* 320 + 32 = 352 */
714714

715+
#define APEX_OP_MASK_RS2 0x1f
716+
#define APEX_OP_SH_RS2 20
717+
#define APEX_OP_MASK_RS1 0x1f
718+
#define APEX_OP_SH_RS1 15
719+
#define APEX_OP_MASK_RD 0x1f
720+
#define APEX_OP_SH_RD 7
721+
715722
#endif /* _RISCV_H_ */

opcodes/riscv-dis.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,24 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info
416416
}
417417
break;
418418

419+
case 'M': /* APEX */
420+
switch (*++oparg)
421+
{
422+
case 'd':
423+
print (info->stream, dis_style_register, "%s",
424+
riscv_gpr_names[(l >> APEX_OP_SH_RD) & APEX_OP_MASK_RD]);
425+
break;
426+
case 's':
427+
print (info->stream, dis_style_register, "%s",
428+
riscv_gpr_names[(l >> APEX_OP_SH_RS1) & APEX_OP_MASK_RS1]);
429+
break;
430+
case 't':
431+
print (info->stream, dis_style_register, "%s",
432+
riscv_gpr_names[(l >> APEX_OP_SH_RS2) & APEX_OP_MASK_RS2]);
433+
break;
434+
}
435+
break;
436+
419437
case 'V': /* RVV */
420438
switch (*++oparg)
421439
{

0 commit comments

Comments
 (0)