2015-06-02 18:34:10 +08:00
|
|
|
# RUN: llvm-mc %s -triple=mipsel-unknown-linux -show-encoding -mcpu=mips32r2 | \
|
|
|
|
# RUN: FileCheck %s
|
|
|
|
|
|
|
|
# Check that the IAS expands macro instructions in the same way as GAS.
|
|
|
|
|
|
|
|
# Load immediate, done by MipsAsmParser::expandLoadImm():
|
|
|
|
li $5, 123
|
2015-04-28 22:06:35 +08:00
|
|
|
# CHECK: ori $5, $zero, 123 # encoding: [0x7b,0x00,0x05,0x34]
|
2015-06-02 18:34:10 +08:00
|
|
|
li $6, -2345
|
2015-04-28 22:06:35 +08:00
|
|
|
# CHECK: addiu $6, $zero, -2345 # encoding: [0xd7,0xf6,0x06,0x24]
|
2015-06-02 18:34:10 +08:00
|
|
|
li $7, 65538
|
2015-04-28 22:06:35 +08:00
|
|
|
# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c]
|
|
|
|
# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34]
|
2015-06-02 18:34:10 +08:00
|
|
|
li $8, ~7
|
2015-04-28 22:06:35 +08:00
|
|
|
# CHECK: addiu $8, $zero, -8 # encoding: [0xf8,0xff,0x08,0x24]
|
2015-06-02 18:34:10 +08:00
|
|
|
li $9, 0x10000
|
2015-04-28 22:06:35 +08:00
|
|
|
# CHECK: lui $9, 1 # encoding: [0x01,0x00,0x09,0x3c]
|
|
|
|
# CHECK-NOT: ori $9, $9, 0 # encoding: [0x00,0x00,0x29,0x35]
|
2015-06-02 18:34:10 +08:00
|
|
|
li $10, ~(0x101010)
|
2015-05-15 17:42:11 +08:00
|
|
|
# CHECK: lui $10, 65519 # encoding: [0xef,0xff,0x0a,0x3c]
|
|
|
|
# CHECK: ori $10, $10, 61423 # encoding: [0xef,0xef,0x4a,0x35]
|
2014-06-18 21:55:18 +08:00
|
|
|
|
2015-06-02 18:34:10 +08:00
|
|
|
# Load address, done by MipsAsmParser::expandLoadAddressReg()
|
|
|
|
# and MipsAsmParser::expandLoadAddressImm():
|
|
|
|
la $4, 20
|
2015-05-13 21:56:16 +08:00
|
|
|
# CHECK: ori $4, $zero, 20 # encoding: [0x14,0x00,0x04,0x34]
|
2015-06-02 18:34:10 +08:00
|
|
|
la $7, 65538
|
Initial assembler implementation of Mips load address macro
This patch provides initial implementation of load address
macro instruction for Mips. We have implemented two kinds
of expansions with their variations depending on the size
of immediate operand:
1) load address with immediate value directly:
* la d,j => addiu d,$zero,j (for -32768 <= j <= 65535)
* la d,j => lui d,hi16(j)
ori d,d,lo16(j) (for any other 32 bit value of j)
2) load load address with register offset value
* la d,j(s) => addiu d,s,j (for -32768 <= j <= 65535)
* la d,j(s) => lui d,hi16(j) (for any other 32 bit value of j)
ori d,d,lo16(j)
addu d,d,s
This patch does not cover the case when the address is loaded
from the value of the label or function.
Contributer: Vladimir Medic
llvm-svn: 165561
2012-10-10 07:29:45 +08:00
|
|
|
# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c]
|
|
|
|
# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34]
|
2015-06-02 18:34:10 +08:00
|
|
|
la $4, 20($5)
|
2015-05-13 21:56:16 +08:00
|
|
|
# CHECK: ori $4, $5, 20 # encoding: [0x14,0x00,0xa4,0x34]
|
2015-06-02 18:34:10 +08:00
|
|
|
la $7, 65538($8)
|
Initial assembler implementation of Mips load address macro
This patch provides initial implementation of load address
macro instruction for Mips. We have implemented two kinds
of expansions with their variations depending on the size
of immediate operand:
1) load address with immediate value directly:
* la d,j => addiu d,$zero,j (for -32768 <= j <= 65535)
* la d,j => lui d,hi16(j)
ori d,d,lo16(j) (for any other 32 bit value of j)
2) load load address with register offset value
* la d,j(s) => addiu d,s,j (for -32768 <= j <= 65535)
* la d,j(s) => lui d,hi16(j) (for any other 32 bit value of j)
ori d,d,lo16(j)
addu d,d,s
This patch does not cover the case when the address is loaded
from the value of the label or function.
Contributer: Vladimir Medic
llvm-svn: 165561
2012-10-10 07:29:45 +08:00
|
|
|
# CHECK: lui $7, 1 # encoding: [0x01,0x00,0x07,0x3c]
|
|
|
|
# CHECK: ori $7, $7, 2 # encoding: [0x02,0x00,0xe7,0x34]
|
|
|
|
# CHECK: addu $7, $7, $8 # encoding: [0x21,0x38,0xe8,0x00]
|
2015-06-02 18:34:10 +08:00
|
|
|
la $8, symbol
|
2014-08-14 18:29:17 +08:00
|
|
|
# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
|
2015-05-21 18:04:39 +08:00
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
2014-08-14 18:29:17 +08:00
|
|
|
# CHECK: ori $8, $8, %lo(symbol) # encoding: [A,A,0x08,0x35]
|
2015-05-21 18:04:39 +08:00
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
2015-06-02 18:34:10 +08:00
|
|
|
|
|
|
|
# LW/SW and LDC1/SDC1 of symbol address, done by MipsAsmParser::expandMemInst():
|
|
|
|
.set noat
|
|
|
|
lw $10, symbol($4)
|
2013-03-22 08:05:30 +08:00
|
|
|
# CHECK: lui $10, %hi(symbol) # encoding: [A,A,0x0a,0x3c]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
|
|
|
# CHECK: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01]
|
|
|
|
# CHECK: lw $10, %lo(symbol)($10) # encoding: [A,A,0x4a,0x8d]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
2015-06-02 18:34:10 +08:00
|
|
|
.set at
|
|
|
|
sw $10, symbol($9)
|
2013-03-22 08:05:30 +08:00
|
|
|
# CHECK: lui $1, %hi(symbol) # encoding: [A,A,0x01,0x3c]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
|
|
|
# CHECK: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
|
|
|
|
# CHECK: sw $10, %lo(symbol)($1) # encoding: [A,A,0x2a,0xac]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
2015-06-02 18:34:10 +08:00
|
|
|
|
[mips] [IAS] Fix LW with relative label operands.
Summary:
Previously, MCSymbolRefExpr::create() was called with a StringRef of the symbol
name, which it would then search for in the Symbols StringMap (from MCContext).
However, relative labels (which are temporary symbols) are apparently not stored
in the Symbols StringMap, so we end up creating a new {$,.L}tmp symbol
({$,.L}tmp00, {$,.L}tmp10 etc.) each time we create an MCSymbolRefExpr by
passing in the symbol name as a StringRef.
Fortunately, there is a version of MCSymbolRefExpr::create() which takes an
MCSymbol* and we already have an MCSymbol* at that point, so we can just pass
that in instead of the StringRef.
I also removed the local StringRef calls to MCSymbolRefExpr::create() from
expandMemInst(), as those cases can be handled by evaluateRelocExpr() anyway.
Reviewers: dsanders
Reviewed By: dsanders
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9938
llvm-svn: 239897
2015-06-17 18:43:45 +08:00
|
|
|
lw $8, 1f
|
|
|
|
# CHECK: lui $8, %hi($tmp0) # encoding: [A,A,0x08,0x3c]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16
|
|
|
|
# CHECK: lw $8, %lo($tmp0)($8) # encoding: [A,A,0x08,0x8d]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16
|
|
|
|
|
2015-06-02 18:34:10 +08:00
|
|
|
lw $10, 655483($4)
|
2013-03-22 08:05:30 +08:00
|
|
|
# CHECK: lui $10, 10 # encoding: [0x0a,0x00,0x0a,0x3c]
|
|
|
|
# CHECK: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01]
|
|
|
|
# CHECK: lw $10, 123($10) # encoding: [0x7b,0x00,0x4a,0x8d]
|
2015-06-02 18:34:10 +08:00
|
|
|
sw $10, 123456($9)
|
2013-03-22 08:05:30 +08:00
|
|
|
# CHECK: lui $1, 2 # encoding: [0x02,0x00,0x01,0x3c]
|
|
|
|
# CHECK: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
|
|
|
|
# CHECK: sw $10, 57920($1) # encoding: [0x40,0xe2,0x2a,0xac]
|
Initial assembler implementation of Mips load address macro
This patch provides initial implementation of load address
macro instruction for Mips. We have implemented two kinds
of expansions with their variations depending on the size
of immediate operand:
1) load address with immediate value directly:
* la d,j => addiu d,$zero,j (for -32768 <= j <= 65535)
* la d,j => lui d,hi16(j)
ori d,d,lo16(j) (for any other 32 bit value of j)
2) load load address with register offset value
* la d,j(s) => addiu d,s,j (for -32768 <= j <= 65535)
* la d,j(s) => lui d,hi16(j) (for any other 32 bit value of j)
ori d,d,lo16(j)
addu d,d,s
This patch does not cover the case when the address is loaded
from the value of the label or function.
Contributer: Vladimir Medic
llvm-svn: 165561
2012-10-10 07:29:45 +08:00
|
|
|
|
2015-06-02 18:34:10 +08:00
|
|
|
lw $8, symbol
|
2015-04-08 21:52:41 +08:00
|
|
|
# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
|
|
|
# CHECK-NOT: move $8, $8 # encoding: [0x21,0x40,0x00,0x01]
|
|
|
|
# CHECK: lw $8, %lo(symbol)($8) # encoding: [A,A,0x08,0x8d]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
2015-06-02 18:34:10 +08:00
|
|
|
sw $8, symbol
|
2015-04-08 21:52:41 +08:00
|
|
|
# CHECK: lui $1, %hi(symbol) # encoding: [A,A,0x01,0x3c]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
|
|
|
|
# CHECK-NOT: move $1, $1 # encoding: [0x21,0x08,0x20,0x00]
|
|
|
|
# CHECK: sw $8, %lo(symbol)($1) # encoding: [A,A,0x28,0xac]
|
|
|
|
# CHECK: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
|
|
|
|
|
2015-06-02 18:34:10 +08:00
|
|
|
ldc1 $f0, symbol
|
2014-06-18 22:49:56 +08:00
|
|
|
# CHECK: lui $1, %hi(symbol)
|
|
|
|
# CHECK: ldc1 $f0, %lo(symbol)($1)
|
2015-06-02 18:34:10 +08:00
|
|
|
sdc1 $f0, symbol
|
2014-06-18 22:49:56 +08:00
|
|
|
# CHECK: lui $1, %hi(symbol)
|
|
|
|
# CHECK: sdc1 $f0, %lo(symbol)($1)
|
2015-06-11 18:36:10 +08:00
|
|
|
|
|
|
|
# Test BNE with an immediate as the 2nd operand.
|
|
|
|
bne $2, 0, 1332
|
|
|
|
# CHECK: bnez $2, 1332 # encoding: [0x4d,0x01,0x40,0x14]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
bne $2, 123, 1332
|
|
|
|
# CHECK: ori $1, $zero, 123 # encoding: [0x7b,0x00,0x01,0x34]
|
|
|
|
# CHECK: bne $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x14]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
bne $2, -2345, 1332
|
|
|
|
# CHECK: addiu $1, $zero, -2345 # encoding: [0xd7,0xf6,0x01,0x24]
|
|
|
|
# CHECK: bne $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x14]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
bne $2, 65538, 1332
|
|
|
|
# CHECK: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
|
|
|
|
# CHECK: ori $1, $1, 2 # encoding: [0x02,0x00,0x21,0x34]
|
|
|
|
# CHECK: bne $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x14]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
bne $2, ~7, 1332
|
|
|
|
# CHECK: addiu $1, $zero, -8 # encoding: [0xf8,0xff,0x01,0x24]
|
|
|
|
# CHECK: bne $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x14]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
bne $2, 0x10000, 1332
|
|
|
|
# CHECK: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
|
|
|
|
# CHECK: bne $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x14]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
# Test BEQ with an immediate as the 2nd operand.
|
|
|
|
beq $2, 0, 1332
|
|
|
|
# CHECK: beqz $2, 1332 # encoding: [0x4d,0x01,0x40,0x10]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
beq $2, 123, 1332
|
|
|
|
# CHECK: ori $1, $zero, 123 # encoding: [0x7b,0x00,0x01,0x34]
|
|
|
|
# CHECK: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
beq $2, -2345, 1332
|
|
|
|
# CHECK: addiu $1, $zero, -2345 # encoding: [0xd7,0xf6,0x01,0x24]
|
|
|
|
# CHECK: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
beq $2, 65538, 1332
|
|
|
|
# CHECK: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
|
|
|
|
# CHECK: ori $1, $1, 2 # encoding: [0x02,0x00,0x21,0x34]
|
|
|
|
# CHECK: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
beq $2, ~7, 1332
|
|
|
|
# CHECK: addiu $1, $zero, -8 # encoding: [0xf8,0xff,0x01,0x24]
|
|
|
|
# CHECK: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
|
|
|
|
|
|
|
beq $2, 0x10000, 1332
|
|
|
|
# CHECK: lui $1, 1 # encoding: [0x01,0x00,0x01,0x3c]
|
|
|
|
# CHECK: beq $2, $1, 1332 # encoding: [0x4d,0x01,0x41,0x10]
|
|
|
|
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
|
[mips] [IAS] Fix LW with relative label operands.
Summary:
Previously, MCSymbolRefExpr::create() was called with a StringRef of the symbol
name, which it would then search for in the Symbols StringMap (from MCContext).
However, relative labels (which are temporary symbols) are apparently not stored
in the Symbols StringMap, so we end up creating a new {$,.L}tmp symbol
({$,.L}tmp00, {$,.L}tmp10 etc.) each time we create an MCSymbolRefExpr by
passing in the symbol name as a StringRef.
Fortunately, there is a version of MCSymbolRefExpr::create() which takes an
MCSymbol* and we already have an MCSymbol* at that point, so we can just pass
that in instead of the StringRef.
I also removed the local StringRef calls to MCSymbolRefExpr::create() from
expandMemInst(), as those cases can be handled by evaluateRelocExpr() anyway.
Reviewers: dsanders
Reviewed By: dsanders
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9938
llvm-svn: 239897
2015-06-17 18:43:45 +08:00
|
|
|
|
|
|
|
1:
|
|
|
|
add $4, $4, $4
|