Skip to content

Commit fa437bd

Browse files
artemiy-volkovShahab Vahedi
authored andcommitted
opcodes/arc: validate the {pop,push}dl_s operand
As opposed to {push,pop}l_s, the {push,pop}dl_s instructions require an even-numbered register as their operand, since only those can be used to designate a register pair. This commit introduces a new operand type and uses it for these two instructions. Signed-off-by: Artemiy Volkov <artemiy@synopsys.com>
1 parent c127ebf commit fa437bd

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

opcodes/arc-operands.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ARC_OPERAND(RA_CHK, 6, 0, 0, ARC_OPERAND_IR, insert_ra_chk, 0)
3939
ARC_OPERAND(RB, 6, 12, 0, ARC_OPERAND_IR, insert_rb, extract_rb)
4040
ARC_OPERAND(RB_CHK, 6, 12, 0, ARC_OPERAND_IR, insert_rb_chk, extract_rb)
4141
ARC_OPERAND(RBB_S, 6, 12, 0, ARC_OPERAND_IR, insert_rbb, extract_rbb)
42+
ARC_OPERAND(RBB_S_CHK, 6, 12, 0, ARC_OPERAND_IR, insert_rbb_chk, extract_rbb)
4243
ARC_OPERAND(RC, 6, 6, 0, ARC_OPERAND_IR, 0, 0)
4344
ARC_OPERAND(RC_CHK, 6, 6, 0, ARC_OPERAND_IR, 0, 0)
4445
ARC_OPERAND(RBdup, 6, 12, 0, ARC_OPERAND_IR | ARC_OPERAND_DUPLICATE, insert_rb, extract_rb)

opcodes/arc64-tbl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6570,7 +6570,7 @@
65706570
{ "pop_s", 0x0000C0D1, 0x0000F8FF, ARC_OPCODE_ARC32, POP, NONE, { BLINK_S }, { C_AA_AB }},
65716571

65726572
/* popdl_s b 11000bbb1101BBB1. */
6573-
{ "popdl_s", 0x0000C0D1, 0x0000F8F1, ARC_OPCODE_ARC64, ARITH, NONE, { RBB_S }, { 0 }},
6573+
{ "popdl_s", 0x0000C0D1, 0x0000F8F1, ARC_OPCODE_ARC64, ARITH, NONE, { RBB_S_CHK }, { 0 }},
65746574

65756575
/* popl_s b 11000bbb1100BBB1. */
65766576
{ "popl_s", 0x0000C0C1, 0x0000F8F1, ARC_OPCODE_ARC64, ARITH, NONE, { RBB_S }, { 0 }},
@@ -6636,7 +6636,7 @@
66366636
{ "push_s", 0x0000C0F1, 0x0000F8FF, ARC_OPCODE_ARC32, PUSH, NONE, { BLINK_S }, { C_AA_AW }},
66376637

66386638
/* pushdl_s b 11000bbb1111BBB1. */
6639-
{ "pushdl_s", 0x0000C0F1, 0x0000F8F1, ARC_OPCODE_ARC64, ARITH, NONE, { RBB_S }, { 0 }},
6639+
{ "pushdl_s", 0x0000C0F1, 0x0000F8F1, ARC_OPCODE_ARC64, ARITH, NONE, { RBB_S_CHK }, { 0 }},
66406640

66416641
/* pushl_s b 11000bbb1110BBB1. */
66426642
{ "pushl_s", 0x0000C0E1, 0x0000F8F1, ARC_OPCODE_ARC64, ARITH, NONE, { RBB_S }, { 0 }},

opcodes/arcxx-opc.inc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ insert_rb (unsigned long long insn,
5454
return insn | ((value & 0x07) << 24) | (((value >> 3) & 0x07) << 12);
5555
}
5656

57-
/* Insert RB register into a push(d)l/pop(d)l instruction. */
57+
/* Insert RB register into a pushl/popl instruction. */
5858

5959
static unsigned long long
6060
insert_rbb (unsigned long long insn,
@@ -64,6 +64,19 @@ insert_rbb (unsigned long long insn,
6464
return insn | ((value & 0x07) << 8) | (((value >> 3) & 0x07) << 1);
6565
}
6666

67+
/* Insert RB register pair into a pushdl/popdl instruction. */
68+
69+
static unsigned long long
70+
insert_rbb_chk (unsigned long long insn,
71+
long long value,
72+
const char **errmsg)
73+
{
74+
if (value & 0x01)
75+
*errmsg = _("cannot use odd number source register");
76+
77+
return insert_rbb(insn, value, errmsg);
78+
}
79+
6780
/* Insert RB register with checks. */
6881

6982
static unsigned long long

0 commit comments

Comments
 (0)