[GAS][ARM]Generate unpredictable warning for pc used in data processing instructions...
authorRenlin Li <renlin.li@arm.com>
Wed, 19 Oct 2016 10:18:56 +0000 (11:18 +0100)
committerRenlin Li <renlin.li@arm.com>
Wed, 19 Oct 2016 10:27:35 +0000 (11:27 +0100)
gas/

2016-10-19  Renlin Li  <renlin.li@arm.com>

* config/tc-arm.c (encode_arm_shift): Generate unpredictable warning
for register-shifted register instructions.
* testsuite/gas/arm/shift-bad-pc.d: New.
* testsuite/gas/arm/shift-bad-pc.l: New.
* testsuite/gas/arm/shift-bad-pc.s: New.

gas/ChangeLog
gas/config/tc-arm.c
gas/testsuite/gas/arm/shift-bad-pc.d [new file with mode: 0644]
gas/testsuite/gas/arm/shift-bad-pc.l [new file with mode: 0644]
gas/testsuite/gas/arm/shift-bad-pc.s [new file with mode: 0644]

index e5df7830f646e43e76777ab222716ed7fb91602c..2e3adbe6c1486fded7bc27f03bf6248b4f40c55e 100644 (file)
@@ -1,3 +1,11 @@
+2016-10-19  Renlin Li  <renlin.li@arm.com>
+
+       * config/tc-arm.c (encode_arm_shift): Generate unpredictable warning
+       for register-shifted register instructions.
+       * testsuite/gas/arm/shift-bad-pc.d: New.
+       * testsuite/gas/arm/shift-bad-pc.l: New.
+       * testsuite/gas/arm/shift-bad-pc.s: New.
+
 2016-10-17  Cupertino Miranda  <cmiranda@synopsys.com>
 
        * testsuite/arc/dis-inv.d: Fixed matching.
index 526131c5eae1ac8705b47f42e98badc96b9c9f48..73f8396396ff85276dc5bc92f79764d6d194b3d3 100644 (file)
@@ -7427,6 +7427,21 @@ encode_arm_vfp_reg (int reg, enum vfp_reg_pos pos)
 static void
 encode_arm_shift (int i)
 {
+  /* register-shifted register.  */
+  if (inst.operands[i].immisreg)
+    {
+      int index;
+      for (index = 0; index <= i; ++index)
+       {
+         gas_assert (inst.operands[index].present);
+         if (inst.operands[index].isreg && inst.operands[index].reg == REG_PC)
+           as_warn (UNPRED_REG ("r15"));
+       }
+
+      if (inst.operands[i].imm == REG_PC)
+       as_warn (UNPRED_REG ("r15"));
+    }
+
   if (inst.operands[i].shift_kind == SHIFT_RRX)
     inst.instruction |= SHIFT_ROR << 5;
   else
diff --git a/gas/testsuite/gas/arm/shift-bad-pc.d b/gas/testsuite/gas/arm/shift-bad-pc.d
new file mode 100644 (file)
index 0000000..17edcd3
--- /dev/null
@@ -0,0 +1,3 @@
+# name: pc used in instructions with register-shifted register
+# as:
+# error-output: shift-bad-pc.l
diff --git a/gas/testsuite/gas/arm/shift-bad-pc.l b/gas/testsuite/gas/arm/shift-bad-pc.l
new file mode 100644 (file)
index 0000000..55a3295
--- /dev/null
@@ -0,0 +1,56 @@
+.*shift-bad-pc.s: Assembler messages:
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:20: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
+.*shift-bad-pc.s:21: Warning: using r15 results in unpredictable behaviour
diff --git a/gas/testsuite/gas/arm/shift-bad-pc.s b/gas/testsuite/gas/arm/shift-bad-pc.s
new file mode 100644 (file)
index 0000000..43fca39
--- /dev/null
@@ -0,0 +1,21 @@
+       .syntax unified
+
+       .macro insn4 rd rn rm rs
+         .irp insn, and, eor, sub, rsb, add, adc, sbc, rsc, orr, bic
+           \insn pc,  \rn, \rm, lsr \rs
+           \insn \rd,  pc, \rm, lsr \rs
+           \insn \rd, \rn,  pc, lsr \rs
+           \insn \rd, \rn, \rm, lsr pc
+         .endr
+       .endm
+
+       .macro insn3 rn rm rs
+         .irp insn, tst, teq, cmp, cmn, mvn
+           \insn pc,  \rm, lsr \rs
+           \insn \rn,  pc, lsr \rs
+           \insn \rn, \rm, lsr pc
+         .endr
+       .endm
+
+       insn4 r0 r1 r2 r3
+       insn3 r0 r1 r2
This page took 0.042099 seconds and 4 git commands to generate.