[PATCH] D41185: [ARM] Fix endianness of Thumb .inst.w directive

Oliver Stannard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 4 05:58:20 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL321799: [ARM] Fix endianness of Thumb .inst.w directive (authored by olista01, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41185?vs=126759&id=128610#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41185

Files:
  llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/trunk/test/MC/ARM/inst-directive.s


Index: llvm/trunk/test/MC/ARM/inst-directive.s
===================================================================
--- llvm/trunk/test/MC/ARM/inst-directive.s
+++ llvm/trunk/test/MC/ARM/inst-directive.s
@@ -1,5 +1,8 @@
 @ RUN: llvm-mc %s -triple=armv7-linux-gnueabi -filetype=obj -o - \
-@ RUN:   | llvm-readobj -s -sd | FileCheck %s
+@ RUN:   | llvm-readobj -s -sd | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
+
+@ RUN: llvm-mc %s -triple=armebv7-linux-gnueabi -filetype=obj -o - \
+@ RUN:   | llvm-readobj -s -sd | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
 
 	.syntax unified
 
@@ -19,7 +22,8 @@
 @ CHECK: Section {
 @ CHECK:   Name: .inst.arm_inst
 @ CHECK:   SectionData (
-@ CHECK-NEXT:     0000: FEDE0000
+@ CHECK-LE-NEXT:     0000: FEDE0000
+@ CHECK-BE-NEXT:     0000: 0000DEFE
 @ CHECK-NEXT:   )
 
 @-------------------------------------------------------------------------------
@@ -38,7 +42,8 @@
 @ CHECK: Section {
 @ CHECK:   Name: .inst.thumb_inst_n
 @ CHECK:   SectionData (
-@ CHECK-NEXT:     0000: FEDE
+@ CHECK-LE-NEXT:     0000: FEDE
+@ CHECK-BE-NEXT:     0000: DEFE
 @ CHECK-NEXT:   )
 
 @-------------------------------------------------------------------------------
@@ -52,12 +57,13 @@
 	.global	thumb_inst_w
 	.type	thumb_inst_w,%function
 thumb_inst_w:
-	.inst.w 0x00000000
+	.inst.w 0x12345678
 
 @ CHECK: Section {
 @ CHECK:   Name: .inst.thumb_inst_w
 @ CHECK:   SectionData (
-@ CHECK-NEXT:     0000: 00000000
+@ CHECK-LE-NEXT:     0000: 34127856
+@ CHECK-BE-NEXT:     0000: 12345678
 @ CHECK-NEXT:   )
 
 @-------------------------------------------------------------------------------
@@ -76,6 +82,7 @@
 @ CHECK: Section {
 @ CHECK:   Name: .inst.thumb_inst_inst
 @ CHECK:   SectionData (
-@ CHECK-NEXT:     0000: 40F20000 C0F20000
+@ CHECK-LE-NEXT:     0000: 40F20000 C0F20000
+@ CHECK-BE-NEXT:     0000: F2400000 F2C00000
 @ CHECK-NEXT:   )
 
Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
===================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -512,9 +512,11 @@
 
       assert(IsThumb);
       EmitThumbMappingSymbol();
+      // Thumb wide instructions are emitted as a pair of 16-bit words of the
+      // appropriate endianness.
       for (unsigned II = 0, IE = Size; II != IE; II = II + 2) {
-        const unsigned I0 = LittleEndian ? II + 0 : (Size - II - 1);
-        const unsigned I1 = LittleEndian ? II + 1 : (Size - II - 2);
+        const unsigned I0 = LittleEndian ? II + 0 : II + 1;
+        const unsigned I1 = LittleEndian ? II + 1 : II + 0;
         Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
         Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT);
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41185.128610.patch
Type: text/x-patch
Size: 2823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180104/7af69bdc/attachment.bin>


More information about the llvm-commits mailing list