[PATCH] ARM: fix thumb1 nop decoding

Amaury de la Vieuville amaury.dlv at gmail.com
Fri Jun 21 08:39:29 PDT 2013


Hi rengolin, t.p.northover,

In thumb1, NOP is a pseudo-instruction equivalent to mov r8, r8.
However the disassembler should not use this alias.

http://llvm-reviews.chandlerc.com/D1021

Files:
  lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
  test/MC/ARM/thumb-nop.s
  test/MC/ARM/thumb.s
  test/MC/Disassembler/ARM/thumb1.txt

Index: lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
===================================================================
--- lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
+++ lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
@@ -243,15 +243,6 @@
     return;
   }
 
-  // Thumb1 NOP
-  if (Opcode == ARM::tMOVr && MI->getOperand(0).getReg() == ARM::R8 &&
-      MI->getOperand(1).getReg() == ARM::R8) {
-    O << "\tnop";
-    printPredicateOperand(MI, 2, O);
-    printAnnotation(O, Annot);
-    return;
-  }
-
   // Combine 2 GPRs from disassember into a GPRPair to match with instr def.
   // ldrexd/strexd require even/odd GPR pair. To enforce this constraint,
   // a single GPRPair reg operand is used in the .td file to replace the two
Index: test/MC/ARM/thumb-nop.s
===================================================================
--- test/MC/ARM/thumb-nop.s
+++ test/MC/ARM/thumb-nop.s
@@ -5,5 +5,5 @@
 
         nop
 
-@ CHECK-V6: nop                            @ encoding: [0xc0,0x46]
+@ CHECK-V6: mov r8, r8                     @ encoding: [0xc0,0x46]
 @ CHECK-V7: nop                            @ encoding: [0x00,0xbf]
Index: test/MC/ARM/thumb.s
===================================================================
--- test/MC/ARM/thumb.s
+++ test/MC/ARM/thumb.s
@@ -42,7 +42,7 @@
 @ CHECK: bkpt  #2                       @ encoding: [0x02,0xbe]
 
         nop
-@ CHECK: nop @ encoding: [0xc0,0x46]
+@ CHECK: mov r8, r8 @ encoding: [0xc0,0x46]
 
         cpsie aif
 @ CHECK: cpsie aif                      @ encoding: [0x67,0xb6]
Index: test/MC/Disassembler/ARM/thumb1.txt
===================================================================
--- test/MC/Disassembler/ARM/thumb1.txt
+++ test/MC/Disassembler/ARM/thumb1.txt
@@ -279,9 +279,11 @@
 #------------------------------------------------------------------------------
 # CHECK: mov r3, r4
 # CHECK: movs r1, r3
+# CHECK: mov r8, r8
 
 0x23 0x46
 0x19 0x00
+0xc0 0x46
 
 
 #------------------------------------------------------------------------------
@@ -310,14 +312,6 @@
 
 
 #------------------------------------------------------------------------------
-# NOP
-#------------------------------------------------------------------------------
-# CHECK: nop
-
-0xc0 0x46
-
-
-#------------------------------------------------------------------------------
 # ORR
 #------------------------------------------------------------------------------
 # CHECK: orrs  r3, r4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1021.1.patch
Type: text/x-patch
Size: 2435 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130621/5667a468/attachment.bin>


More information about the llvm-commits mailing list