[mips] Add assembler support for the "la $reg,symbol" pseudo-instruction.

Summary:
This pseudo-instruction allows the programmer to load an address from a symbolic expression into a register.

Patch by David Chisnall.
His work was sponsored by: DARPA, AFRL

I've made some minor changes to the original, such as improving the formatting and adding some comments, and I've also added a test case.

Reviewers: dsanders

Reviewed By: dsanders

Differential Revision: http://reviews.llvm.org/D4808

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Toma Tabacu
2014-08-14 10:29:17 +00:00
parent 74ad5958ee
commit cb43f81fc5
2 changed files with 111 additions and 6 deletions

View File

@@ -17,6 +17,22 @@
# 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]
# CHECK: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
# fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
# CHECK: ori $8, $8, %lo(symbol) # encoding: [A,A,0x08,0x35]
# fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
# CHECK: .set mips64
# CHECK: lui $8, %highest(symbol) # encoding: [A,A,0x08,0x3c]
# fixup A - offset: 0, value: symbol@HIGHEST, kind: fixup_Mips_HIGHEST
# CHECK: ori $8, $8, %higher(symbol) # encoding: [A,A,0x08,0x35]
# fixup A - offset: 0, value: symbol@HIGHER, kind: fixup_Mips_HIGHER
# CHECK: dsll $8, $8, 16 # encoding: [0x38,0x44,0x08,0x00]
# CHECK: ori $8, $8, %hi(symbol) # encoding: [A,A,0x08,0x35]
# fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16
# CHECK: dsll $8, $8, 16 # encoding: [0x38,0x44,0x08,0x00]
# CHECK: ori $8, $8, %lo(symbol) # encoding: [A,A,0x08,0x35]
# fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16
# CHECK: .set mips32r2
# 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]
@@ -48,6 +64,10 @@
la $7,65538
la $a0, 20($a1)
la $7,65538($8)
la $t0, symbol
.set mips64
la $t0, symbol
.set mips32r2
.set noat
lw $t2, symbol($a0)