Skip to content

Commit

Permalink
ARM: Issue a warning when the MRRC and MRRC2 instructions are used wi…
Browse files Browse the repository at this point in the history
…th the same destination registers.

	* config/tc-arm.c (do_co_reg2c): Added constraint.
	* testsuite/gas/arm/dest-unpredictable.s: New.
	* testsuite/gas/arm/dest-unpredictable.l: New.
	* testsuite/gas/arm/dest-unpredictable.d: New.
  • Loading branch information
TamarChristinaArm authored and nickclifton committed Aug 19, 2016
1 parent 0646e07 commit 873f10f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gas/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2016-08-19 Tamar Christina <[email protected]>

* config/tc-arm.c (do_co_reg2c): Added constraint.
* testsuite/gas/arm/dest-unpredictable.s: New.
* testsuite/gas/arm/dest-unpredictable.l: New.
* testsuite/gas/arm/dest-unpredictable.d: New.

2016-08-19 Nick Clifton <[email protected]>

* testsuite/gas/i386/ilp32/x86-64-unwind.d: Adjust expected
Expand Down
8 changes: 8 additions & 0 deletions gas/config/tc-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -8691,6 +8691,14 @@ do_co_reg2c (void)
constraint (Rn == REG_PC, BAD_PC);
}

/* Only check the MRRC{2} variants. */
if ((inst.instruction & 0x0FF00000) == 0x0C500000)
{
/* If Rd == Rn, error that the operation is
unpredictable (example MRRC p3,#1,r1,r1,c4). */
constraint (Rd == Rn, BAD_OVERLAP);
}

inst.instruction |= inst.operands[0].reg << 8;
inst.instruction |= inst.operands[1].imm << 4;
inst.instruction |= Rd << 12;
Expand Down
2 changes: 2 additions & 0 deletions gas/testsuite/gas/arm/dest-unpredictable.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# name: Unpredictable MRRC and MRRC2 instructions. - ARM
# error-output: dest-unpredictable.l
5 changes: 5 additions & 0 deletions gas/testsuite/gas/arm/dest-unpredictable.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[^:]*: Assembler messages:
[^:]*:6: Error: registers may not be the same -- `mrrc p0,#1,r1,r1,c4'
[^:]*:7: Error: registers may not be the same -- `mrrc2 p0,#1,r1,r1,c4'
[^:]*:20: Error: registers may not be the same -- `mrrc p0,#1,r1,r1,c4'
[^:]*:21: Error: registers may not be the same -- `mrrc2 p0,#1,r1,r1,c4'
29 changes: 29 additions & 0 deletions gas/testsuite/gas/arm/dest-unpredictable.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.syntax unified

.arm

@ warnings
mrrc p0,#1,r1,r1,c4 @ unpredictable
mrrc2 p0,#1,r1,r1,c4 @ ditto

@ normal
mrrc p0,#1,r1,r2,c4 @ predictable
mrrc2 p0,#1,r1,r2,c4 @ ditto
mcrr p0,#1,r1,r2,c4 @ ditto
mcrr2 p0,#1,r1,r2,c4 @ ditto
mcrr p0,#1,r1,r1,c4 @ ditto
mcrr2 p0,#1,r1,r1,c4 @ ditto

.thumb

@ warnings
mrrc p0,#1,r1,r1,c4 @ unpredictable
mrrc2 p0,#1,r1,r1,c4 @ ditto

@ normal
mrrc p0,#1,r1,r2,c4 @ predictable
mrrc2 p0,#1,r1,r2,c4 @ ditto
mcrr p0,#1,r1,r2,c4 @ ditto
mcrr2 p0,#1,r1,r2,c4 @ ditto
mcrr p0,#1,r1,r1,c4 @ ditto
mcrr2 p0,#1,r1,r1,c4 @ ditto

0 comments on commit 873f10f

Please sign in to comment.