Skip to content

Commit 8b0167f

Browse files
atanasyantstellar
authored andcommitted
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 ------------------------------------------------------------------------
1 parent 6851dcc commit 8b0167f

File tree

2 files changed

+69
-69
lines changed

2 files changed

+69
-69
lines changed

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,8 +3426,8 @@ bool MipsAsmParser::expandLoadDoubleImmToGPR(MCInst &Inst, SMLoc IDLoc,
34263426

34273427
getStreamer().SwitchSection(ReadOnlySection);
34283428
getStreamer().EmitLabel(Sym, IDLoc);
3429-
getStreamer().EmitIntValue(HiImmOp64, 4);
3430-
getStreamer().EmitIntValue(LoImmOp64, 4);
3429+
getStreamer().EmitValueToAlignment(8);
3430+
getStreamer().EmitIntValue(ImmOp64, 8);
34313431
getStreamer().SwitchSection(CS);
34323432

34333433
if (emitPartialAddress(TOut, IDLoc, Sym))
@@ -3510,8 +3510,8 @@ bool MipsAsmParser::expandLoadDoubleImmToFPR(MCInst &Inst, bool Is64FPU,
35103510

35113511
getStreamer().SwitchSection(ReadOnlySection);
35123512
getStreamer().EmitLabel(Sym, IDLoc);
3513-
getStreamer().EmitIntValue(HiImmOp64, 4);
3514-
getStreamer().EmitIntValue(LoImmOp64, 4);
3513+
getStreamer().EmitValueToAlignment(8);
3514+
getStreamer().EmitIntValue(ImmOp64, 8);
35153515
getStreamer().SwitchSection(CS);
35163516

35173517
if (emitPartialAddress(TOut, IDLoc, Sym))

llvm/test/MC/Mips/macro-li.d.s

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ li.d $4, 0.0
1717
# N32-N64: daddiu $4, $zero, 0 # encoding: [0x00,0x00,0x04,0x64]
1818

1919
li.d $4, 1.12345
20-
# ALL: .section .rodata,"a",@progbits
21-
# ALL: [[LABEL:\$tmp[0-9]+]]:
22-
# ALL: .4byte 1072822694
23-
# ALL: .4byte 3037400872
24-
# ALL: .text
20+
# ALL: .section .rodata,"a",@progbits
21+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
22+
# ALL-NEXT: .p2align 3
23+
# ALL-NEXT: .8byte 4607738388174016296
24+
# ALL-NEXT: .text
2525
# O32-N32-NO-PIC: lui $1, %hi([[LABEL]]) # encoding: [A,A,0x01,0x3c]
2626
# O32-N32-NO-PIC: # fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
2727
# O32-N32-NO-PIC: addiu $1, $1, %lo([[LABEL]]) # encoding: [A,A,0x21,0x24]
@@ -61,11 +61,11 @@ li.d $4, 1.0
6161
# N32-N64: dsll $4, $4, 46 # encoding: [0xbc,0x23,0x04,0x00]
6262

6363
li.d $4, 12345678910
64-
# ALL: .section .rodata,"a",@progbits
65-
# ALL: [[LABEL:\$tmp[0-9]+]]:
66-
# ALL: .4byte 1107754720
67-
# ALL: .4byte 3790602240
68-
# ALL: .text
64+
# ALL: .section .rodata,"a",@progbits
65+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
66+
# ALL-NEXT: .p2align 3
67+
# ALL-NEXT: .8byte 4757770298180239360
68+
# ALL-NEXT: .text
6969
# O32-N32-NO-PIC: lui $1, %hi([[LABEL]]) # encoding: [A,A,0x01,0x3c]
7070
# O32-N32-NO-PIC: # fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
7171
# O32-N32-NO-PIC: addiu $1, $1, %lo([[LABEL]]) # encoding: [A,A,0x21,0x24]
@@ -93,11 +93,11 @@ li.d $4, 12345678910
9393
# N32-N64: ld $4, 0($1) # encoding: [0x00,0x00,0x24,0xdc]
9494

9595
li.d $4, 12345678910.0
96-
# ALL: .section .rodata,"a",@progbits
97-
# ALL: [[LABEL:\$tmp[0-9]+]]:
98-
# ALL: .4byte 1107754720
99-
# ALL: .4byte 3790602240
100-
# ALL: .text
96+
# ALL: .section .rodata,"a",@progbits
97+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
98+
# ALL-NEXT: .p2align 3
99+
# ALL-NEXT: .8byte 4757770298180239360
100+
# ALL-NEXT: .text
101101
# O32-N32-NO-PIC: lui $1, %hi([[LABEL]]) # encoding: [A,A,0x01,0x3c]
102102
# O32-N32-NO-PIC: # fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
103103
# O32-N32-NO-PIC: addiu $1, $1, %lo([[LABEL]]) # encoding: [A,A,0x21,0x24]
@@ -125,11 +125,11 @@ li.d $4, 12345678910.0
125125
# N32-N64: ld $4, 0($1) # encoding: [0x00,0x00,0x24,0xdc]
126126

127127
li.d $4, 0.4
128-
# ALL: .section .rodata,"a",@progbits
129-
# ALL: [[LABEL:\$tmp[0-9]+]]:
130-
# ALL: .4byte 1071225241
131-
# ALL: .4byte 2576980378
132-
# ALL: .text
128+
# ALL: .section .rodata,"a",@progbits
129+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
130+
# ALL-NEXT: .p2align 3
131+
# ALL-NEXT: .8byte 4600877379321698714
132+
# ALL-NEXT: .text
133133
# O32-N32-NO-PIC: lui $1, %hi([[LABEL]]) # encoding: [A,A,0x01,0x3c]
134134
# O32-N32-NO-PIC: # fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
135135
# O32-N32-NO-PIC: addiu $1, $1, %lo([[LABEL]]) # encoding: [A,A,0x21,0x24]
@@ -163,11 +163,11 @@ li.d $4, 1.5
163163
# N32-N64: dsll $4, $4, 46 # encoding: [0xbc,0x23,0x04,0x00]
164164

165165
li.d $4, 12345678910.12345678910
166-
# ALL: .section .rodata,"a",@progbits
167-
# ALL: [[LABEL:\$tmp[0-9]+]]:
168-
# ALL: .4byte 1107754720
169-
# ALL: .4byte 3790666967
170-
# ALL: .text
166+
# ALL: .section .rodata,"a",@progbits
167+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
168+
# ALL-NEXT: .p2align 3
169+
# ALL-NEXT: .8byte 4757770298180304087
170+
# ALL-NEXT: .text
171171
# O32-N32-NO-PIC: lui $1, %hi([[LABEL]]) # encoding: [A,A,0x01,0x3c]
172172
# O32-N32-NO-PIC: # fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
173173
# O32-N32-NO-PIC: addiu $1, $1, %lo([[LABEL]]) # encoding: [A,A,0x21,0x24]
@@ -196,11 +196,11 @@ li.d $4, 12345678910.12345678910
196196

197197

198198
li.d $4, 12345678910123456789.12345678910
199-
# ALL: .section .rodata,"a",@progbits
200-
# ALL: [[LABEL:\$tmp[0-9]+]]:
201-
# ALL: .4byte 1139108501
202-
# ALL: .4byte 836738583
203-
# ALL: .text
199+
# ALL: .section .rodata,"a",@progbits
200+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
201+
# ALL-NEXT: .p2align 3
202+
# ALL-NEXT: .8byte 4892433759227321879
203+
# ALL-NEXT: .text
204204
# O32-N32-NO-PIC: lui $1, %hi([[LABEL]]) # encoding: [A,A,0x01,0x3c]
205205
# O32-N32-NO-PIC: # fixup A - offset: 0, value: %hi([[LABEL]]), kind: fixup_Mips_HI16
206206
# O32-N32-NO-PIC: addiu $1, $1, %lo([[LABEL]]) # encoding: [A,A,0x21,0x24]
@@ -248,11 +248,11 @@ li.d $f4, 0.0
248248
# N32-N64: dmtc1 $1, $f4 # encoding: [0x00,0x20,0xa1,0x44]
249249

250250
li.d $f4, 1.12345
251-
# ALL: .section .rodata,"a",@progbits
252-
# ALL: [[LABEL:\$tmp[0-9]+]]:
253-
# ALL: .4byte 1072822694
254-
# ALL: .4byte 3037400872
255-
# ALL: .text
251+
# ALL: .section .rodata,"a",@progbits
252+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
253+
# ALL-NEXT: .p2align 3
254+
# ALL-NEXT: .8byte 4607738388174016296
255+
# ALL-NEXT: .text
256256
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
257257
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
258258
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]
@@ -293,11 +293,11 @@ li.d $f4, 1.0
293293
# N32-N64: dmtc1 $1, $f4 # encoding: [0x00,0x20,0xa1,0x44]
294294

295295
li.d $f4, 12345678910
296-
# ALL: .section .rodata,"a",@progbits
297-
# ALL: [[LABEL:\$tmp[0-9]+]]:
298-
# ALL: .4byte 1107754720
299-
# ALL: .4byte 3790602240
300-
# ALL: .text
296+
# ALL: .section .rodata,"a",@progbits
297+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
298+
# ALL-NEXT: .p2align 3
299+
# ALL-NEXT: .8byte 4757770298180239360
300+
# ALL-NEXT: .text
301301
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
302302
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
303303
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]
@@ -316,11 +316,11 @@ li.d $f4, 12345678910
316316
# ALL: # fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
317317

318318
li.d $f4, 12345678910.0
319-
# ALL: .section .rodata,"a",@progbits
320-
# ALL: [[LABEL:\$tmp[0-9]+]]:
321-
# ALL: .4byte 1107754720
322-
# ALL: .4byte 3790602240
323-
# ALL: .text
319+
# ALL: .section .rodata,"a",@progbits
320+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
321+
# ALL-NEXT: .p2align 3
322+
# ALL-NEXT: .8byte 4757770298180239360
323+
# ALL-NEXT: .text
324324
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
325325
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
326326
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]
@@ -339,11 +339,11 @@ li.d $f4, 12345678910.0
339339
# ALL: # fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
340340

341341
li.d $f4, 0.4
342-
# ALL: .section .rodata,"a",@progbits
343-
# ALL: [[LABEL:\$tmp[0-9]+]]:
344-
# ALL: .4byte 1071225241
345-
# ALL: .4byte 2576980378
346-
# ALL: .text
342+
# ALL: .section .rodata,"a",@progbits
343+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
344+
# ALL-NEXT: .p2align 3
345+
# ALL-NEXT: .8byte 4600877379321698714
346+
# ALL-NEXT: .text
347347
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
348348
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
349349
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]
@@ -384,11 +384,11 @@ li.d $f4, 2.5
384384
# N32-N64: dmtc1 $1, $f4 # encoding: [0x00,0x20,0xa1,0x44]
385385

386386
li.d $f4, 2.515625
387-
# ALL: .section .rodata,"a",@progbits
388-
# ALL: [[LABEL:\$tmp[0-9]+]]:
389-
# ALL: .4byte 1074012160
390-
# ALL: .4byte 0
391-
# ALL: .text
387+
# ALL: .section .rodata,"a",@progbits
388+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
389+
# ALL-NEXT: .p2align 3
390+
# ALL-NEXT: .8byte 4612847102706319360
391+
# ALL-NEXT: .text
392392
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
393393
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
394394
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]
@@ -407,11 +407,11 @@ li.d $f4, 2.515625
407407
# ALL: # fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
408408

409409
li.d $f4, 12345678910.12345678910
410-
# ALL: .section .rodata,"a",@progbits
411-
# ALL: [[LABEL:\$tmp[0-9]+]]:
412-
# ALL: .4byte 1107754720
413-
# ALL: .4byte 3790666967
414-
# ALL: .text
410+
# ALL: .section .rodata,"a",@progbits
411+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
412+
# ALL-NEXT: .p2align 3
413+
# ALL-NEXT: .8byte 4757770298180304087
414+
# ALL-NEXT: .text
415415
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
416416
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
417417
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]
@@ -430,11 +430,11 @@ li.d $f4, 12345678910.12345678910
430430
# ALL: # fixup A - offset: 0, value: %lo([[LABEL]]), kind: fixup_Mips_LO16
431431

432432
li.d $f4, 12345678910123456789.12345678910
433-
# ALL: .section .rodata,"a",@progbits
434-
# ALL: [[LABEL:\$tmp[0-9]+]]:
435-
# ALL: .4byte 1139108501
436-
# ALL: .4byte 836738583
437-
# ALL: .text
433+
# ALL: .section .rodata,"a",@progbits
434+
# ALL-NEXT: [[LABEL:\$tmp[0-9]+]]:
435+
# ALL-NEXT: .p2align 3
436+
# ALL-NEXT: .8byte 4892433759227321879
437+
# ALL-NEXT: .text
438438
# O32-N32-PIC: lw $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0x8f]
439439
# O32-N32-PIC: # fixup A - offset: 0, value: %got([[LABEL]]), kind: fixup_Mips_GOT
440440
# N64-PIC: ld $1, %got([[LABEL]])($gp) # encoding: [A,A,0x81,0xdf]

0 commit comments

Comments
 (0)