Skip to content

Commit b91877f

Browse files
committed
arc: Put DBNZ instruction to a separate class
DBNZ instruction decrements its source register operand, and if the result is non-zero it branches to the location defined by a signed half-word displacement operand. DBNZ instruction is in BRANCH class as other branch instrucitons like B, Bcc, etc. However, DBNZ is the only branch instruction that stores a branch offset in the second operand. Thus it must be placed in a distinct class and treated differently. For example, current logic of arc_insn_get_branch_target in GDB assumes that a branch offset is always stored in the first operand for BRANCH class and it's wrong for DBNZ. include/ChangeLog: 2024-02-14 Yuriy Kolerov <ykolerov@synopsys.com> * opcode/arc.h (enum insn_class_t): Add DBNZ class. opcodes/ChangeLog: 2024-02-14 Yuriy Kolerov <ykolerov@synopsys.com> * arc-tbl.h (dbnz): Use "DBNZ" class. * arc-dis.c (arc_opcode_to_insn_type): Handle "DBNZ" class. gas/ChangeLog: 2024-02-14 Yuriy Kolerov <ykolerov@synopsys.com> * config/tc-arc.c (is_br_jmp_insn_p): Add check against "DBNZ".
1 parent e7006ef commit b91877f

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

gas/config/tc-arc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ enum arc_rlx_types
114114
|| (op)->insn_class == BBIT0 \
115115
|| (op)->insn_class == BBIT1 \
116116
|| (op)->insn_class == BI \
117+
|| (op)->insn_class == DBNZ \
117118
|| (op)->insn_class == EI \
118119
|| (op)->insn_class == ENTER \
119120
|| (op)->insn_class == JLI \

include/opcode/arc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ typedef enum
5252
BRANCH,
5353
BRCC,
5454
CONTROL,
55+
DBNZ,
5556
DIVREM,
5657
DMA,
5758
DPI,

opcodes/arc-dis.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ arc_opcode_to_insn_type (const struct arc_opcode *opcode)
979979
case BI:
980980
case BIH:
981981
case BRCC:
982+
case DBNZ:
982983
case EI:
983984
case JLI:
984985
case JUMP:

opcodes/arc-tbl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3656,7 +3656,7 @@
36563656
{ "daddh22", 0x36F77F80, 0xFFFF7FE0, ARC_OPCODE_ARCv2EM, FLOAT, DPA, { ZA, LIMM, LIMMdup }, { C_F, C_CC }},
36573657

36583658
/* dbnz<.d> b,s13 00100bbb1000110N0BBBssssssSSSSSS. */
3659-
{ "dbnz", 0x208C0000, 0xF8FE8000, ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS, BRANCH, NONE, { RB, SIMM13_A16_20}, { C_DNZ_D }},
3659+
{ "dbnz", 0x208C0000, 0xF8FE8000, ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS, DBNZ, NONE, { RB, SIMM13_A16_20}, { C_DNZ_D }},
36603660

36613661
/* dexcl1<.f> a,b,c 00110bbb00011000FBBBCCCCCCAAAAAA. */
36623662
{ "dexcl1", 0x30180000, 0xF8FF0000, ARC_OPCODE_ARC700 | ARC_OPCODE_ARCv2EM, FLOAT, DPX, { RA, RB, RC }, { C_F }},

0 commit comments

Comments
 (0)