[llvm-branch-commits] [llvm] 8b0167f - Merging r374598:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 8 12:27:24 PST 2019


Author: Simon Atanasyan
Date: 2019-11-08T12:17:54-08:00
New Revision: 8b0167fdee5f6556f18a4d912b679ef0af268e13

URL: https://github.com/llvm/llvm-project/commit/8b0167fdee5f6556f18a4d912b679ef0af268e13
DIFF: https://github.com/llvm/llvm-project/commit/8b0167fdee5f6556f18a4d912b679ef0af268e13.diff

LOG: Merging r374598:

------------------------------------------------------------------------
r374598 | atanasyan | 2019-10-11 14:51:33 -0700 (Fri, 11 Oct 2019) | 12 lines

[mips] Store 64-bit `li.d' operand as a single 8-byte value

Now assembler generates two consecutive `.4byte` directives to store
64-bit `li.d' operand. The first directive stores high 4-byte of the
value. The second directive stores low 4-byte of the value. But on
64-bit system we load this value at once and get wrong result if the
system is little-endian.

This patch fixes the bug. It stores the `li.d' operand as a single
8-byte value.

Differential Revision: https://reviews.llvm.org/D68778
------------------------------------------------------------------------

Added: 
    

Modified: 
    llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
    llvm/test/MC/Mips/macro-li.d.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 56f47dc8b8dd..fd867acd234f 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -3426,8 +3426,8 @@ bool MipsAsmParser::expandLoadDoubleImmToGPR(MCInst &Inst, SMLoc IDLoc,
 
   getStreamer().SwitchSection(ReadOnlySection);
   getStreamer().EmitLabel(Sym, IDLoc);
-  getStreamer().EmitIntValue(HiImmOp64, 4);
-  getStreamer().EmitIntValue(LoImmOp64, 4);
+  getStreamer().EmitValueToAlignment(8);
+  getStreamer().EmitIntValue(ImmOp64, 8);
   getStreamer().SwitchSection(CS);
 
   if (emitPartialAddress(TOut, IDLoc, Sym))
@@ -3510,8 +3510,8 @@ bool MipsAsmParser::expandLoadDoubleImmToFPR(MCInst &Inst, bool Is64FPU,
 
   getStreamer().SwitchSection(ReadOnlySection);
   getStreamer().EmitLabel(Sym, IDLoc);
-  getStreamer().EmitIntValue(HiImmOp64, 4);
-  getStreamer().EmitIntValue(LoImmOp64, 4);
+  getStreamer().EmitValueToAlignment(8);
+  getStreamer().EmitIntValue(ImmOp64, 8);
   getStreamer().SwitchSection(CS);
 
   if (emitPartialAddress(TOut, IDLoc, Sym))

diff  --git a/llvm/test/MC/Mips/macro-li.d.s b/llvm/test/MC/Mips/macro-li.d.s
index 8af82ec608e0..6fc873e12dc5 100644
--- a/llvm/test/MC/Mips/macro-li.d.s
+++ b/llvm/test/MC/Mips/macro-li.d.s
@@ -17,11 +17,11 @@ li.d	$4, 0.0
 # N32-N64: daddiu  $4, $zero, 0                # encoding: [0x00,0x00,0x04,0x64]
 
 li.d	$4, 1.12345
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1072822694
-# ALL:	.4byte	3037400872
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4607738388174016296
+# ALL-NEXT:	.text
 # O32-N32-NO-PIC:  lui     $1, %hi([[LABEL]])         # encoding: [A,A,0x01,0x3c]
 # O32-N32-NO-PIC:                                     #   fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
 # O32-N32-NO-PIC:  addiu   $1, $1, %lo([[LABEL]])     # encoding: [A,A,0x21,0x24]
@@ -61,11 +61,11 @@ li.d	$4, 1.0
 # N32-N64: dsll    $4, $4, 46                         # encoding: [0xbc,0x23,0x04,0x00]
 
 li.d	$4, 12345678910
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1107754720
-# ALL:	.4byte	3790602240
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4757770298180239360
+# ALL-NEXT:	.text
 # O32-N32-NO-PIC:  lui     $1, %hi([[LABEL]])         # encoding: [A,A,0x01,0x3c]
 # O32-N32-NO-PIC:                                     #   fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
 # O32-N32-NO-PIC:  addiu   $1, $1, %lo([[LABEL]])     # encoding: [A,A,0x21,0x24]
@@ -93,11 +93,11 @@ li.d	$4, 12345678910
 # N32-N64:         ld      $4, 0($1)                  # encoding: [0x00,0x00,0x24,0xdc]
 
 li.d	$4, 12345678910.0
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1107754720
-# ALL:	.4byte	3790602240
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4757770298180239360
+# ALL-NEXT:	.text
 # O32-N32-NO-PIC:  lui     $1, %hi([[LABEL]])         # encoding: [A,A,0x01,0x3c]
 # O32-N32-NO-PIC:                                     #   fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
 # O32-N32-NO-PIC:  addiu   $1, $1, %lo([[LABEL]])     # encoding: [A,A,0x21,0x24]
@@ -125,11 +125,11 @@ li.d	$4, 12345678910.0
 # N32-N64:         ld      $4, 0($1)                  # encoding: [0x00,0x00,0x24,0xdc]
 
 li.d	$4, 0.4
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1071225241
-# ALL:	.4byte	2576980378
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4600877379321698714
+# ALL-NEXT:	.text
 # O32-N32-NO-PIC:  lui     $1, %hi([[LABEL]])         # encoding: [A,A,0x01,0x3c]
 # O32-N32-NO-PIC:                                     #   fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
 # O32-N32-NO-PIC:  addiu   $1, $1, %lo([[LABEL]])     # encoding: [A,A,0x21,0x24]
@@ -163,11 +163,11 @@ li.d	$4, 1.5
 # N32-N64: dsll    $4, $4, 46                         # encoding: [0xbc,0x23,0x04,0x00]
 
 li.d	$4, 12345678910.12345678910
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1107754720
-# ALL:	.4byte	3790666967
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4757770298180304087
+# ALL-NEXT:	.text
 # O32-N32-NO-PIC:  lui     $1, %hi([[LABEL]])         # encoding: [A,A,0x01,0x3c]
 # O32-N32-NO-PIC:                                     #   fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
 # O32-N32-NO-PIC:  addiu   $1, $1, %lo([[LABEL]])     # encoding: [A,A,0x21,0x24]
@@ -196,11 +196,11 @@ li.d	$4, 12345678910.12345678910
 
 
 li.d	$4, 12345678910123456789.12345678910
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1139108501
-# ALL:	.4byte	836738583
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4892433759227321879
+# ALL-NEXT:	.text
 # O32-N32-NO-PIC:  lui     $1, %hi([[LABEL]])         # encoding: [A,A,0x01,0x3c]
 # O32-N32-NO-PIC:                                     #   fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
 # O32-N32-NO-PIC:  addiu   $1, $1, %lo([[LABEL]])     # encoding: [A,A,0x21,0x24]
@@ -248,11 +248,11 @@ li.d	$f4, 0.0
 # N32-N64:        dmtc1   $1, $f4            # encoding: [0x00,0x20,0xa1,0x44]
 
 li.d	$f4, 1.12345
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1072822694
-# ALL:	.4byte	3037400872
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4607738388174016296
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]
@@ -293,11 +293,11 @@ li.d	$f4, 1.0
 # N32-N64:        dmtc1   $1, $f4            # encoding: [0x00,0x20,0xa1,0x44]
 
 li.d	$f4, 12345678910
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1107754720
-# ALL:	.4byte	3790602240
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4757770298180239360
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]
@@ -316,11 +316,11 @@ li.d	$f4, 12345678910
 # ALL:                                                #   fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
 
 li.d	$f4, 12345678910.0
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1107754720
-# ALL:	.4byte	3790602240
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4757770298180239360
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]
@@ -339,11 +339,11 @@ li.d	$f4, 12345678910.0
 # ALL:                                                #   fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
 
 li.d	$f4, 0.4
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1071225241
-# ALL:	.4byte	2576980378
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4600877379321698714
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]
@@ -384,11 +384,11 @@ li.d	$f4, 2.5
 # N32-N64:        dmtc1   $1, $f4            # encoding: [0x00,0x20,0xa1,0x44]
 
 li.d	$f4, 2.515625
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1074012160
-# ALL:	.4byte	0
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4612847102706319360
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]
@@ -407,11 +407,11 @@ li.d	$f4, 2.515625
 # ALL:                                                #   fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
 
 li.d	$f4, 12345678910.12345678910
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1107754720
-# ALL:	.4byte	3790666967
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4757770298180304087
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]
@@ -430,11 +430,11 @@ li.d	$f4, 12345678910.12345678910
 # ALL:                                                #   fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
 
 li.d	$f4, 12345678910123456789.12345678910
-# ALL:	.section	.rodata,"a", at progbits
-# ALL:  [[LABEL:\$tmp[0-9]+]]:
-# ALL:	.4byte	1139108501
-# ALL:	.4byte	836738583
-# ALL:	.text
+# ALL:      .section  .rodata,"a", at progbits
+# ALL-NEXT:  [[LABEL:\$tmp[0-9]+]]:
+# ALL-NEXT:	.p2align 3
+# ALL-NEXT:	.8byte 4892433759227321879
+# ALL-NEXT:	.text
 # O32-N32-PIC:     lw      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0x8f]
 # O32-N32-PIC:                                        #   fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
 # N64-PIC:         ld      $1, %got([[LABEL]])($gp)   # encoding: [A,A,0x81,0xdf]


        


More information about the llvm-branch-commits mailing list