This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ARM PATCH: Allow R13 as second argument to CMP
- From: mitchell at codesourcery dot com (Mark Mitchell)
- To: binutils at sources dot redhat dot com
- Date: Mon, 23 Feb 2009 20:33:07 -0800 (PST)
- Subject: ARM PATCH: Allow R13 as second argument to CMP
- Reply-to: mark at codesourcery dot com
I made an error in implementing checks for invalid use of R13 and R15
a few months back. In particular, I disallowed:
cmp r0, r13
which is in fact deprecated, but not documented as UNPREDICTABLE in
the ARM documentation.
This patch, approved by Paul Brook off-list, fixes the problem.
Applied, after testing on arm-none-eabi.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2009-02-23 Mark Mitchell <mark@codesourcery.com>
* config/tc-arm.c (warn_deprecated_sp): New macro.
(do_t_mov_cmp): Permit R13 as the second
argument to "cmp.n".
2009-02-23 Mark Mitchell <mark@codesourcery.com>
* gas/arm/thumb2_bad_reg.s: Update to allow R13 as second argument
for CMP.
* gas/arm/thumb2_bad_reg.l: Adjust accordingly.
Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.375
diff -c -5 -p -r1.375 tc-arm.c
*** config/tc-arm.c 6 Feb 2009 12:51:52 -0000 1.375
--- config/tc-arm.c 24 Feb 2009 04:28:58 -0000
*************** parse_operands (char *str, const unsigne
*** 6138,6147 ****
--- 6138,6155 ----
inst.error = (reg == REG_SP) ? BAD_SP : BAD_PC; \
return; \
} \
while (0)
+ /* If REG is R13 (the stack pointer), warn that its use is
+ deprecated. */
+ #define warn_deprecated_sp(reg) \
+ do \
+ if (warn_on_deprecated && reg == REG_SP) \
+ as_warn (_("use of r13 is deprecated")); \
+ while (0)
+
/* Functions for operand encoding. ARM, then Thumb. */
#define rotate_left(v, n) (v << n | v >> (32 - n))
/* If VAL can be encoded in the immediate field of an ARM instruction,
*************** do_t_mov_cmp (void)
*** 9688,9698 ****
}
if (opcode == T_MNEM_cmp)
{
constraint (Rn == REG_PC, BAD_PC);
! reject_bad_reg (Rm);
}
else if (opcode == T_MNEM_mov
|| opcode == T_MNEM_movs)
{
if (inst.operands[1].isreg)
--- 9696,9717 ----
}
if (opcode == T_MNEM_cmp)
{
constraint (Rn == REG_PC, BAD_PC);
! if (narrow)
! {
! /* In the Thumb-2 ISA, use of R13 as Rm is deprecated,
! but valid. */
! warn_deprecated_sp (Rm);
! /* R15 was documented as a valid choice for Rm in ARMv6,
! but as UNPREDICTABLE in ARMv7. ARM's proprietary
! tools reject R15, so we do too. */
! constraint (Rm == REG_PC, BAD_PC);
! }
! else
! reject_bad_reg (Rm);
}
else if (opcode == T_MNEM_mov
|| opcode == T_MNEM_movs)
{
if (inst.operands[1].isreg)
Index: testsuite/gas/arm/thumb2_bad_reg.l
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/thumb2_bad_reg.l,v
retrieving revision 1.1
diff -c -5 -p -r1.1 thumb2_bad_reg.l
*** testsuite/gas/arm/thumb2_bad_reg.l 29 Jan 2009 11:56:19 -0000 1.1
--- testsuite/gas/arm/thumb2_bad_reg.l 24 Feb 2009 04:28:58 -0000
***************
*** 74,83 ****
--- 74,87 ----
[^:]*:[0-9]+: Error: r15 not allowed here -- `cmn.w r15,r0'
[^:]*:[0-9]+: Error: r13 not allowed here -- `cmn.w r0,r13'
[^:]*:[0-9]+: Error: r15 not allowed here -- `cmn.w r0,r15'
[^:]*:[0-9]+: Error: r15 not allowed here -- `cmp.w r15,#1'
[^:]*:[0-9]+: Error: r15 not allowed here -- `cmp r15,r0'
+ [^:]*:[0-9]+: Warning: use of r13 is deprecated
+ [^:]*:[0-9]+: Error: r15 not allowed here -- `cmp r0,r15'
+ [^:]*:[0-9]+: Warning: use of r13 is deprecated
+ [^:]*:[0-9]+: Error: r15 not allowed here -- `cmp.n r0,r15'
[^:]*:[0-9]+: Error: r15 not allowed here -- `cmp.w r15,r0'
[^:]*:[0-9]+: Error: r13 not allowed here -- `cmp.w r0,r13'
[^:]*:[0-9]+: Error: r15 not allowed here -- `cmp.w r0,r15'
[^:]*:[0-9]+: Error: r13 not allowed here -- `eor r13,r0,#1'
[^:]*:[0-9]+: Error: r15 not allowed here -- `eor r15,r0,#1'
Index: testsuite/gas/arm/thumb2_bad_reg.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/thumb2_bad_reg.s,v
retrieving revision 1.1
diff -c -5 -p -r1.1 thumb2_bad_reg.s
*** testsuite/gas/arm/thumb2_bad_reg.s 29 Jan 2009 11:56:19 -0000 1.1
--- testsuite/gas/arm/thumb2_bad_reg.s 24 Feb 2009 04:28:58 -0000
*************** test:
*** 112,121 ****
--- 112,125 ----
cmp.w r13, #1 @ OK
cmp.w r15, #1
@ CMP (register)
cmp r13, r0 @ OK
cmp r15, r0
+ cmp r0, r13 @ Deprecated
+ cmp r0, r15
+ cmp.n r0, r13 @ Deprecated
+ cmp.n r0, r15
cmp.w r13, r0 @ OK
cmp.w r15, r0
cmp.w r0, r13
cmp.w r0, r15
@ EOR (immediate)