1 # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding \
2 # RUN: -mcpu=mips32r2 | FileCheck -check-prefix=O32 %s
3 # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding \
4 # RUN: -mcpu=mips32r6 | FileCheck -check-prefix=O32 %s
6 # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding \
7 # RUN: -mattr=+xgot -mcpu=mips32r2 \
8 # RUN: | FileCheck -check-prefixes=XGOT,XO32 %s
10 # RUN: llvm-mc %s -triple=mipsn32 -show-encoding \
11 # RUN: -mcpu=mips64r2 | FileCheck -check-prefix=N32 %s
13 # RUN: llvm-mc %s -triple=mipsn32 -show-encoding \
14 # RUN: -mattr=+xgot -mcpu=mips64r2 \
15 # RUN: | FileCheck -check-prefixes=XGOT,XN32 %s
17 # N64 should be acceptable too but we cannot convert la to dla yet.
21 # O32: lw $5, %got(symbol)($gp) # encoding: [0x8f,0x85,A,A]
22 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
24 # XGOT: lui $5, %got_hi(symbol) # encoding: [0x3c,0x05,A,A]
25 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol), kind: fixup_Mips_GOT_HI16
26 # XGOT: addu $5, $5, $gp # encoding: [0x00,0xbc,0x28,0x21]
27 # XGOT: lw $5, %got_lo(symbol)($5) # encoding: [0x8c,0xa5,A,A]
28 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
30 # N32: lw $5, %got_disp(symbol)($gp) # encoding: [0x8f,0x85,A,A]
31 # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
34 # O32: lw $5, %got(symbol)($gp) # encoding: [0x8f,0x85,A,A]
35 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
36 # O32: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
38 # XGOT: lui $5, %got_hi(symbol) # encoding: [0x3c,0x05,A,A]
39 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol), kind: fixup_Mips_GOT_HI16
40 # XGOT: addu $5, $5, $gp # encoding: [0x00,0xbc,0x28,0x21]
41 # XGOT: lw $5, %got_lo(symbol)($5) # encoding: [0x8c,0xa5,A,A]
42 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
43 # XGOT: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
45 # N32: lw $5, %got_disp(symbol)($gp) # encoding: [0x8f,0x85,A,A]
46 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
47 # N32: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
50 # O32: lw $1, %got(symbol)($gp) # encoding: [0x8f,0x81,A,A]
51 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
52 # O32: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
54 # XGOT: lui $1, %got_hi(symbol) # encoding: [0x3c,0x01,A,A]
55 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol), kind: fixup_Mips_GOT_HI16
56 # XGOT: addu $1, $1, $gp # encoding: [0x00,0x3c,0x08,0x21]
57 # XGOT: lw $1, %got_lo(symbol)($1) # encoding: [0x8c,0x21,A,A]
58 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
59 # XGOT: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
61 # N32: lw $1, %got_disp(symbol)($gp) # encoding: [0x8f,0x81,A,A]
62 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
63 # N32: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
66 # O32: lw $5, %got(symbol)($gp) # encoding: [0x8f,0x85,A,A]
67 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
68 # O32: addiu $5, $5, 8 # encoding: [0x24,0xa5,0x00,0x08]
70 # XGOT: lui $5, %got_hi(symbol+8) # encoding: [0x3c,0x05,A,A]
71 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol+8), kind: fixup_Mips_GOT_HI16
72 # XGOT: addu $5, $5, $gp # encoding: [0x00,0xbc,0x28,0x21]
73 # XGOT: lw $5, %got_lo(symbol)($5) # encoding: [0x8c,0xa5,A,A]
74 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
75 # XGOT: addiu $5, $5, 8 # encoding: [0x24,0xa5,0x00,0x08]
77 # N32: lw $5, %got_disp(symbol)($gp) # encoding: [0x8f,0x85,A,A]
78 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
79 # N32: addiu $5, $5, 8 # encoding: [0x24,0xa5,0x00,0x08]
82 # O32: lw $5, %got(symbol)($gp) # encoding: [0x8f,0x85,A,A]
83 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
84 # O32: addiu $5, $5, 8 # encoding: [0x24,0xa5,0x00,0x08]
85 # O32: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
87 # XGOT: lui $5, %got_hi(symbol+8) # encoding: [0x3c,0x05,A,A]
88 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol+8), kind: fixup_Mips_GOT_HI16
89 # XGOT: addu $5, $5, $gp # encoding: [0x00,0xbc,0x28,0x21]
90 # XGOT: lw $5, %got_lo(symbol)($5) # encoding: [0x8c,0xa5,A,A]
91 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
92 # XGOT: addiu $5, $5, 8 # encoding: [0x24,0xa5,0x00,0x08]
93 # XGOT: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
95 # N32: lw $5, %got_disp(symbol)($gp) # encoding: [0x8f,0x85,A,A]
96 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
97 # N32: addiu $5, $5, 8 # encoding: [0x24,0xa5,0x00,0x08]
98 # N32: addu $5, $5, $6 # encoding: [0x00,0xa6,0x28,0x21]
101 # O32: lw $1, %got(symbol)($gp) # encoding: [0x8f,0x81,A,A]
102 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
103 # O32: addiu $1, $1, 8 # encoding: [0x24,0x21,0x00,0x08]
104 # O32: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
106 # XGOT: lui $1, %got_hi(symbol+8) # encoding: [0x3c,0x01,A,A]
107 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol+8), kind: fixup_Mips_GOT_HI16
108 # XGOT: addu $1, $1, $gp # encoding: [0x00,0x3c,0x08,0x21]
109 # XGOT: lw $1, %got_lo(symbol)($1) # encoding: [0x8c,0x21,A,A]
110 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
111 # XGOT: addiu $1, $1, 8 # encoding: [0x24,0x21,0x00,0x08]
112 # XGOT: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
114 # N32: lw $1, %got_disp(symbol)($gp) # encoding: [0x8f,0x81,A,A]
115 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
116 # N32: addiu $1, $1, 8 # encoding: [0x24,0x21,0x00,0x08]
117 # N32: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
120 # O32: lw $5, %got($tmp0)($gp) # encoding: [0x8f,0x85,A,A]
121 # O32: # fixup A - offset: 0, value: %got($tmp0), kind: fixup_Mips_GOT
122 # O32: addiu $5, $5, %lo($tmp0) # encoding: [0x24,0xa5,A,A]
123 # O32: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
125 # XO32: lw $5, %got($tmp0)($gp) # encoding: [0x8f,0x85,A,A]
126 # XO32: # fixup A - offset: 0, value: %got($tmp0), kind: fixup_Mips_GOT
127 # XO32: addiu $5, $5, %lo($tmp0) # encoding: [0x24,0xa5,A,A]
128 # XO32: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
130 # N32: lw $5, %got_disp(.Ltmp0)($gp) # encoding: [0x8f,0x85,A,A]
131 # N32: # fixup A - offset: 0, value: %got_disp(.Ltmp0), kind: fixup_Mips_GOT_DISP
133 ## FIXME: GAS generates R_MIPS_GOT_PAGE / R_MIPS_GOT_OFST pair of relocations
134 ## in case of using N32 ABI + XGOT.
135 # XN32: lw $5, %got_disp(.Ltmp0)($gp) # encoding: [0x8f,0x85,A,A]
136 # XN32: # fixup A - offset: 0, value: %got_disp(.Ltmp0), kind: fixup_Mips_GOT_DISP
139 # PIC expansions involving $25 are special.
141 # O32: lw $25, %call16(symbol)($gp) # encoding: [0x8f,0x99,A,A]
142 # O32: # fixup A - offset: 0, value: %call16(symbol), kind: fixup_Mips_CALL16
144 # XGOT: lui $25, %call_hi(symbol) # encoding: [0x3c,0x19,A,A]
145 # XGOT: # fixup A - offset: 0, value: %call_hi(symbol), kind: fixup_Mips_CALL_HI16
146 # XGOT: addu $25, $25, $gp # encoding: [0x03,0x3c,0xc8,0x21]
147 # XGOT: lw $25, %call_lo(symbol)($25) # encoding: [0x8f,0x39,A,A]
148 # XGOT: # fixup A - offset: 0, value: %call_lo(symbol), kind: fixup_Mips_CALL_LO16
150 # N32: lw $25, %call16(symbol)($gp) # encoding: [0x8f,0x99,A,A]
151 # N32: # fixup A - offset: 0, value: %call16(symbol), kind: fixup_Mips_CALL16
154 # O32: lw $25, %got(symbol)($gp) # encoding: [0x8f,0x99,A,A]
155 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
156 # O32: addu $25, $25, $6 # encoding: [0x03,0x26,0xc8,0x21]
158 # XGOT: lui $25, %got_hi(symbol) # encoding: [0x3c,0x19,A,A]
159 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol), kind: fixup_Mips_GOT_HI16
160 # XGOT: addu $25, $25, $gp # encoding: [0x03,0x3c,0xc8,0x21]
161 # XGOT: lw $25, %got_lo(symbol)($25) # encoding: [0x8f,0x39,A,A]
162 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
163 # XGOT: addu $25, $25, $6 # encoding: [0x03,0x26,0xc8,0x21]
165 # N32: lw $25, %got_disp(symbol)($gp) # encoding: [0x8f,0x99,A,A]
166 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
167 # N32: addu $25, $25, $6 # encoding: [0x03,0x26,0xc8,0x21]
170 # O32: lw $1, %got(symbol)($gp) # encoding: [0x8f,0x81,A,A]
171 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
172 # O32: addu $25, $1, $25 # encoding: [0x00,0x39,0xc8,0x21]
174 # XGOT: lui $1, %got_hi(symbol) # encoding: [0x3c,0x01,A,A]
175 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol), kind: fixup_Mips_GOT_HI16
176 # XGOT: addu $1, $1, $gp # encoding: [0x00,0x3c,0x08,0x21]
177 # XGOT: lw $1, %got_lo(symbol)($1) # encoding: [0x8c,0x21,A,A]
178 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
179 # XGOT: addu $25, $1, $25 # encoding: [0x00,0x39,0xc8,0x21]
181 # N32: lw $1, %got_disp(symbol)($gp) # encoding: [0x8f,0x81,A,A]
182 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
183 # N32: addu $25, $1, $25 # encoding: [0x00,0x39,0xc8,0x21]
186 # O32: lw $25, %got(symbol)($gp) # encoding: [0x8f,0x99,A,A]
187 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
188 # O32: addiu $25, $25, 8 # encoding: [0x27,0x39,0x00,0x08]
190 # XGOT: lui $25, %got_hi(symbol+8) # encoding: [0x3c,0x19,A,A]
191 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol+8), kind: fixup_Mips_GOT_HI16
192 # XGOT: addu $25, $25, $gp # encoding: [0x03,0x3c,0xc8,0x21]
193 # XGOT: lw $25, %got_lo(symbol)($25) # encoding: [0x8f,0x39,A,A]
194 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
195 # XGOT: addiu $25, $25, 8 # encoding: [0x27,0x39,0x00,0x08]
197 # N32: lw $25, %got_disp(symbol)($gp) # encoding: [0x8f,0x99,A,A]
198 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
199 # N32: addiu $25, $25, 8 # encoding: [0x27,0x39,0x00,0x08]
202 # O32: lw $25, %got(symbol)($gp) # encoding: [0x8f,0x99,A,A]
203 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
204 # O32: addiu $25, $25, 8 # encoding: [0x27,0x39,0x00,0x08]
205 # O32: addu $25, $25, $6 # encoding: [0x03,0x26,0xc8,0x21]
207 # XGOT: lui $25, %got_hi(symbol+8) # encoding: [0x3c,0x19,A,A]
208 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol+8), kind: fixup_Mips_GOT_HI16
209 # XGOT: addu $25, $25, $gp # encoding: [0x03,0x3c,0xc8,0x21]
210 # XGOT: lw $25, %got_lo(symbol)($25) # encoding: [0x8f,0x39,A,A]
211 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
212 # XGOT: addiu $25, $25, 8 # encoding: [0x27,0x39,0x00,0x08]
213 # XGOT: addu $25, $25, $6 # encoding: [0x03,0x26,0xc8,0x21]
215 # N32: lw $25, %got_disp(symbol)($gp) # encoding: [0x8f,0x99,A,A]
216 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
217 # N32: addiu $25, $25, 8 # encoding: [0x27,0x39,0x00,0x08]
218 # N32: addu $25, $25, $6 # encoding: [0x03,0x26,0xc8,0x21]
220 la $
25, symbol+
8($
25)
221 # O32: lw $1, %got(symbol)($gp) # encoding: [0x8f,0x81,A,A]
222 # O32: # fixup A - offset: 0, value: %got(symbol), kind: fixup_Mips_GOT
223 # O32: addiu $1, $1, 8 # encoding: [0x24,0x21,0x00,0x08]
224 # O32: addu $25, $1, $25 # encoding: [0x00,0x39,0xc8,0x21]
226 # XGOT: lui $1, %got_hi(symbol+8) # encoding: [0x3c,0x01,A,A]
227 # XGOT: # fixup A - offset: 0, value: %got_hi(symbol+8), kind: fixup_Mips_GOT_HI16
228 # XGOT: addu $1, $1, $gp # encoding: [0x00,0x3c,0x08,0x21]
229 # XGOT: lw $1, %got_lo(symbol)($1) # encoding: [0x8c,0x21,A,A]
230 # XGOT: # fixup A - offset: 0, value: %got_lo(symbol), kind: fixup_Mips_GOT_LO16
231 # XGOT: addiu $1, $1, 8 # encoding: [0x24,0x21,0x00,0x08]
232 # XGOT: addu $25, $1, $25 # encoding: [0x00,0x39,0xc8,0x21]
234 # N32: lw $1, %got_disp(symbol)($gp) # encoding: [0x8f,0x81,A,A]
235 # N32: # fixup A - offset: 0, value: %got_disp(symbol), kind: fixup_Mips_GOT_DISP
236 # N32: addiu $1, $1, 8 # encoding: [0x24,0x21,0x00,0x08]
237 # N32: addu $25, $1, $25 # encoding: [0x00,0x39,0xc8,0x21]
240 # O32: lw $25, %got($tmp1)($gp) # encoding: [0x8f,0x99,A,A]
241 # O32: # fixup A - offset: 0, value: %got($tmp1), kind: fixup_Mips_GOT
242 # O32: addiu $25, $25, %lo($tmp1) # encoding: [0x27,0x39,A,A]
243 # O32: # fixup A - offset: 0, value: %lo($tmp1), kind: fixup_Mips_LO16
245 # XO32: lw $25, %got($tmp1)($gp) # encoding: [0x8f,0x99,A,A]
246 # XO32: # fixup A - offset: 0, value: %got($tmp1), kind: fixup_Mips_GOT
247 # XO32: addiu $25, $25, %lo($tmp1) # encoding: [0x27,0x39,A,A]
248 # XO32: # fixup A - offset: 0, value: %lo($tmp1), kind: fixup_Mips_LO16
250 # N32: lw $25, %got_disp(.Ltmp1)($gp) # encoding: [0x8f,0x99,A,A]
251 # N32: # fixup A - offset: 0, value: %got_disp(.Ltmp1), kind: fixup_Mips_GOT_DISP
253 ## FIXME: GAS generates R_MIPS_GOT_PAGE / R_MIPS_GOT_OFST pair of relocations
254 ## in case of using N32 ABI + XGOT.
255 # XN32: lw $25, %got_disp(.Ltmp1)($gp) # encoding: [0x8f,0x99,A,A]
256 # XN32: # fixup A - offset: 0, value: %got_disp(.Ltmp1), kind: fixup_Mips_GOT_DISP