• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -show-encoding |\
2# RUN:   FileCheck %s -check-prefixes=ALL,MIPS,O32
3
4# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 -show-encoding |\
5# RUN:   FileCheck %s -check-prefixes=ALL,MIPS,N32
6
7# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -show-encoding |\
8# RUN:   FileCheck %s -check-prefixes=ALL,MIPS,N64
9
10# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=micromips -show-encoding |\
11# RUN:   FileCheck %s -check-prefixes=ALL,MM,O32-MM
12
13# Repeat the tests but using ELF output. An initial version of this patch did
14# this as the output different depending on whether it went through
15# MCAsmStreamer or MCELFStreamer. This ensures that the assembly expansion and
16# direct objection emission match.
17
18# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -filetype=obj | \
19# RUN:   llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-O32
20# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n32 -filetype=obj | \
21# RUN:   llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-N32
22# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -filetype=obj | \
23# RUN:   llvm-objdump -d -r - | FileCheck %s -check-prefixes=ELF-N64
24
25  .weak weak_label
26
27  .text
28  .option pic2
29
30  .ent local_label
31local_label:
32  .frame  $sp, 0, $ra
33  .set noreorder
34
35  jal local_label
36  nop
37
38# Expanding "jal local_label":
39# O32: lw     $25, %got(local_label)($gp)   # encoding: [0x8f,0x99,A,A]
40# O32:                                      #   fixup A - offset: 0, value: %got(local_label), kind:   fixup_Mips_GOT
41# O32: addiu  $25, $25, %lo(local_label)    # encoding: [0x27,0x39,A,A]
42# O32:                                      #   fixup A - offset: 0, value: %lo(local_label), kind:   fixup_Mips_LO16
43# ELF-O32:      8f 99 00 00 lw $25, 0($gp)
44# ELF-O32-NEXT:                 R_MIPS_GOT16 .text
45# ELF-O32-NEXT: 27 39 00 00 addiu $25, $25, 0
46# ELF-O32-NEXT:                 R_MIPS_LO16 .text
47
48# N32: lw  $25, %got_disp(local_label)($gp) # encoding: [0x8f,0x99,A,A]
49# N32:                                      #   fixup A - offset: 0, value: %got_disp(local_label), kind:   fixup_Mips_GOT_DISP
50
51# ELF-N32:      8f 99 00 00 lw $25, 0($gp)
52# ELF-N32-NEXT:                 R_MIPS_GOT_DISP local_label
53
54# N64: ld  $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A]
55# N64:                                      #   fixup A - offset: 0, value: %got_disp(local_label), kind:   fixup_Mips_GOT_DISP
56
57# ELF-N64:      df 99 00 00 ld $25, 0($gp)
58# ELF-N64-NEXT:                 R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE local_label
59
60# O32-MM: lw    $25, %got(local_label)($gp)      # encoding: [0xff,0x3c,A,A]
61# O32-MM:                                        #   fixup A - offset: 0, value: %got(local_label), kind:   fixup_MICROMIPS_GOT16
62# O32-MM: addiu $25, $25, %lo(local_label)       # encoding: [0x33,0x39,A,A]
63# O32-MM:                                        #   fixup A - offset: 0, value: %lo(local_label), kind:   fixup_MICROMIPS_LO16
64
65# MIPS: jalr $25      # encoding: [0x03,0x20,0xf8,0x09]
66# MM:   jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
67# ALL:  nop           # encoding: [0x00,0x00,0x00,0x00]
68
69  jal weak_label
70  nop
71
72# Expanding "jal weak_label":
73# O32: lw  $25, %call16(weak_label)($gp) # encoding: [0x8f,0x99,A,A]
74# O32:                                   #   fixup A - offset: 0, value: %call16(weak_label), kind:   fixup_Mips_CALL16
75
76# ELF-O32:      8f 99 00 00 lw $25, 0($gp)
77# ELF-O32-NEXT:                 R_MIPS_CALL16 weak_label
78
79# N32: lw  $25, %call16(weak_label)($gp) # encoding: [0x8f,0x99,A,A]
80# N32:                                   #   fixup A - offset: 0, value: %call16(weak_label), kind:   fixup_Mips_CALL16
81
82# ELF-N32:      8f 99 00 00 lw $25, 0($gp)
83# ELF-N32-NEXT:                 R_MIPS_CALL16 weak_label
84
85# N64: ld  $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A]
86# N64:                                   #   fixup A - offset: 0, value: %call16(weak_label), kind:   fixup_Mips_CALL16
87
88# ELF-N64:      df 99 00 00 ld $25, 0($gp)
89# ELF-N64-NEXT:                 R_MIPS_CALL16/R_MIPS_NONE/R_MIPS_NONE weak_label
90
91# O32-MM: lw  $25, %call16(weak_label)($gp) # encoding: [0xff,0x3c,A,A]
92# O32-MM:                                   #   fixup A - offset: 0, value: %call16(weak_label), kind:   fixup_MICROMIPS_CALL16
93
94# MIPS: jalr $25      # encoding: [0x03,0x20,0xf8,0x09]
95# MM:   jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
96# ALL:  nop           # encoding: [0x00,0x00,0x00,0x00]
97
98  jal global_label
99  nop
100
101# Expanding "jal global_label":
102# O32: lw  $25, %call16(global_label)($gp) # encoding: [0x8f,0x99,A,A]
103# O32:                                     #   fixup A - offset: 0, value: %call16(global_label), kind:   fixup_Mips_CALL16
104
105# ELF-O32:      8f 99 00 00 lw $25, 0($gp)
106# ELF-O32-NEXT:                 R_MIPS_CALL16 global_label
107
108# N32: lw  $25, %call16(global_label)($gp) # encoding: [0x8f,0x99,A,A]
109# N32:                                     #   fixup A - offset: 0, value: %call16(global_label), kind:   fixup_Mips_CALL16
110
111# ELF-N32:      8f 99 00 00 lw $25, 0($gp)
112# ELF-N32-NEXT:                 R_MIPS_CALL16 global_label
113
114# N64: ld  $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A]
115# N64:                                     #   fixup A - offset: 0, value: %call16(global_label), kind:   fixup_Mips_CALL16
116
117# ELF-N64:      df 99 00 00 ld $25, 0($gp)
118# ELF-N64-NEXT:                 R_MIPS_CALL16/R_MIPS_NONE/R_MIPS_NONE global_label
119
120# O32-MM: lw  $25, %call16(global_label)($gp) # encoding: [0xff,0x3c,A,A]
121# O32-MM:                                     #   fixup A - offset: 0, value: %call16(global_label), kind: fixup_MICROMIPS_CALL16
122
123# MIPS: jalr $25      # encoding: [0x03,0x20,0xf8,0x09]
124# MM:   jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
125# ALL:  nop           # encoding: [0x00,0x00,0x00,0x00]
126
127  jal .text
128  nop
129
130# Expanding "jal .text":
131# O32: lw	$25, %got(.text)($gp)   # encoding: [0x8f,0x99,A,A]
132# O32-NEXT:                                       #   fixup A - offset: 0, value: %got(.text), kind: fixup_Mips_GOT
133
134# ELF-O32:      8f 99 00 00 lw $25, 0($gp)
135# ELF-O32-NEXT:                 R_MIPS_GOT16 .text
136
137# N32: lw	$25, %got_disp(.text)($gp) # encoding: [0x8f,0x99,A,A]
138# N32-NEXT:                                       #   fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP
139
140# ELF-N32:      8f 99 00 00 lw $25, 0($gp)
141# ELF-N32-NEXT:                 R_MIPS_GOT_DISP .text
142
143# N64: ld	$25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A]
144# N64-NEXT:                                       #   fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP
145
146# ELF-N64:      df 99 00 00 ld $25, 0($gp)
147# ELF-N64-NEXT:                 R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE	.text
148
149# O32-MM: lw    $25, %got(.text)($gp)      # encoding: [0xff,0x3c,A,A]
150# O32-MM-NEXT:                                  #   fixup A - offset: 0, value: %got(.text), kind: fixup_MICROMIPS_GOT16
151# O32-MM-NEXT: addiu $25, $25, %lo(.text)       # encoding: [0x33,0x39,A,A]
152# O32-MM-NEXT:                                  #   fixup A - offset: 0, value: %lo(.text), kind: fixup_MICROMIPS_LO16
153
154# MIPS: jalr $25      # encoding: [0x03,0x20,0xf8,0x09]
155# MM:   jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
156# ALL:  nop           # encoding: [0x00,0x00,0x00,0x00]
157
158  # local labels ($tmp symbols)
159  jal 1f
160  nop
161
162# Expanding "jal 1f":
163# O32: lw     $25, %got($tmp0)($gp)   # encoding: [0x8f,0x99,A,A]
164# O32:                                #   fixup A - offset: 0, value: %got($tmp0), kind:   fixup_Mips_GOT
165# O32: addiu  $25, $25, %lo($tmp0)    # encoding: [0x27,0x39,A,A]
166# O32:                                #   fixup A - offset: 0, value: %lo($tmp0), kind:   fixup_Mips_LO16
167
168# ELF-O32:      8f 99 00 00 lw $25, 0($gp)
169# ELF-O32-NEXT:                 R_MIPS_GOT16 .text
170# ELF-O32-NEXT: 27 39 00 58 	addiu	$25, $25, 88
171# ELF-O32-NEXT:                 R_MIPS_LO16 .text
172
173# N32: lw  $25, %got_disp($tmp0)($gp) # encoding: [0x8f,0x99,A,A]
174# N32:                                #   fixup A - offset: 0, value: %got_disp($tmp0), kind:   fixup_Mips_GOT_DISP
175
176# ELF-N32:      8f 99 00 00 lw $25, 0($gp)
177# ELF-N32-NEXT:                 R_MIPS_GOT_DISP .Ltmp0
178
179# N64: ld  $25, %got_disp(.Ltmp0)($gp) # encoding: [0xdf,0x99,A,A]
180# N64:                                 #   fixup A - offset: 0, value: %got_disp(.Ltmp0), kind:   fixup_Mips_GOT_DISP
181
182# ELF-N64:      df 99 00 00 ld $25, 0($gp)
183# ELF-N64-NEXT:                 R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE .Ltmp0
184
185# O32-MM: lw    $25, %got($tmp0)($gp)    # encoding: [0xff,0x3c,A,A]
186# O32-MM:                                #   fixup A - offset: 0, value: %got($tmp0), kind: fixup_MICROMIPS_GOT16
187# O32-MM: addiu $25, $25, %lo($tmp0)     # encoding: [0x33,0x39,A,A]
188# O32-MM:                                #   fixup A - offset: 0, value: %lo($tmp0), kind: fixup_MICROMIPS_LO16
189
190# MIPS: jalr $25      # encoding: [0x03,0x20,0xf8,0x09]
191# MM:   jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
192# ALL:  nop           # encoding: [0x00,0x00,0x00,0x00]
193
194  .local forward_local
195  jal forward_local
196  nop
197
198# Expanding "jal forward_local":
199# O32-FIXME: lw     $25, %got(forward_local)($gp)                    # encoding: [0x8f,0x99,A,A]
200# O32-FIXME:                                                         #   fixup A - offset: 0, value: %got(forward_local), kind:   fixup_Mips_GOT
201# O32-FIXME: addiu  $25, $25, %lo(forward_local)                     # encoding: [0x27,0x39,A,A]
202# O32-FIXME::                                                         #   fixup A - offset: 0, value: %lo(forward_local), kind:   fixup_Mips_LO16
203
204# ELF-O32:      8f 99 00 00 lw $25, 0($gp)
205# ELF-O32-NEXT:                 R_MIPS_GOT16 .text
206# ELF-O32-NEXT: 27 39 00 64 	addiu	$25, $25, 100
207# ELF-O32-NEXT:                 R_MIPS_LO16 .text
208
209# N32-FIXME: lw  $25, %got_disp(forward_local)($gp)            # encoding: [0x8f,0x99,A,A]
210# N32-FIXME:                                                   #   fixup A - offset: 0, value: %got_disp(forward_local), kind:   fixup_Mips_GOT_DISP
211
212# ELF-N32:      8f 99 00 00 lw $25, 0($gp)
213# ELF-N32-NEXT:                 R_MIPS_GOT_DISP forward_local
214
215# N64-FIXME: ld  $25, %got_disp(forward_local)($gp)            # encoding: [0xdf,0x99,A,A]
216# N64-FIXME:                                                   #   fixup A - offset: 0, value: %got_disp(forward_local), kind:   fixup_Mips_GOT_DISP
217
218# ELF-N64:      df 99 00 00 ld $25, 0($gp)
219# ELF-N64-NEXT:                 R_MIPS_GOT_DISP/R_MIPS_NONE/R_MIPS_NONE forward_local
220
221# O32-MM-FIXME: lw    $25, %got(forward_local)($gp)            # encoding: [0xff,0x3c,A,A]
222# O32-MM-FIXME:                                                #   fixup A - offset: 0, value: %got(forward_local), kind:   fixup_MICROMIPS_GOT16
223# O32-MM-FIXME: addiu $25, $25, %lo(forward_local)             # encoding: [0x33,0x39,A,A]
224# O32-MM-FIXME:                                                #   fixup A - offset: 0, value: %lo(forward_local), kind:   fixup_MICROMIPS_LO16
225
226# MIPS: jalr $25      # encoding: [0x03,0x20,0xf8,0x09]
227# MM:   jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
228# ALL:  nop           # encoding: [0x00,0x00,0x00,0x00]
229
230  .end local_label
231
2321:
233  nop
234  add $8, $8, $8
235  nop
236forward_local:
237