• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llvm-mc -triple mips64-unknown-linux -target-abi o32 -filetype=obj -o - %s | \
2# RUN:   llvm-objdump -d -r - | FileCheck -check-prefixes=ALL,O32 %s
3
4# RUN: llvm-mc -triple mips64-unknown-unknown -target-abi o32 %s | \
5# RUN:   FileCheck -check-prefixes=ALL,ASM %s
6
7# RUN: llvm-mc -triple mips64-unknown-linux -target-abi n32 -filetype=obj -o - %s | \
8# RUN:   llvm-objdump -d -r - | \
9# RUN:   FileCheck -check-prefixes=ALL,NXX,N32 %s
10
11# RUN: llvm-mc -triple mips64-unknown-unknown -target-abi n32 %s | \
12# RUN:   FileCheck -check-prefixes=ALL,ASM %s
13
14# RUN: llvm-mc -triple mips64-unknown-linux %s -filetype=obj -o - | \
15# RUN:   llvm-objdump -d -r - | \
16# RUN:   FileCheck -check-prefixes=ALL,NXX,N64 %s
17
18# RUN: llvm-mc -triple mips64-unknown-unknown %s | \
19# RUN:   FileCheck -check-prefixes=ALL,ASM %s
20
21        .text
22        .option pic2
23t1:
24        .cpsetup $25, 8, __cerror
25        nop
26        .cpreturn
27        nop
28
29# ALL-LABEL: t1:
30
31# O32-NOT: __cerror
32
33# NXX-NEXT: sd       $gp, 8($sp)
34# NXX-NEXT: lui      $gp, 0
35# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
36# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16  __cerror
37# NXX-NEXT: addiu    $gp, $gp, 0
38# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
39# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16  __cerror
40# N64-NEXT: daddu    $gp, $gp, $25
41
42# ASM-NEXT: .cpsetup $25, 8, __cerror
43
44# ALL-NEXT: nop
45
46# ASM-NEXT: .cpreturn
47# NXX-NEXT: ld $gp, 8($sp)
48
49# ALL-NEXT: nop
50
51t2:
52        .cpsetup $25, $2, __cerror
53        nop
54        .cpreturn
55        nop
56
57# ALL-LABEL: t2:
58
59# O32-NOT: __cerror
60
61# NXX-NEXT: move     $2, $gp
62# NXX-NEXT: lui      $gp, 0
63# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
64# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16  __cerror
65# NXX-NEXT: addiu    $gp, $gp, 0
66# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
67# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16  __cerror
68# N64-NEXT: daddu    $gp, $gp, $25
69
70# ASM-NEXT: .cpsetup $25, $2, __cerror
71
72# ALL-NEXT: nop
73
74# ASM-NEXT: .cpreturn
75# NXX-NEXT: move $gp, $2
76
77# ALL-NEXT: nop
78
79# .cpsetup with local labels (PR22518):
80
81# The '1:' label isn't emitted in all cases but we still want a label to match
82# so we force one here.
83
84t3:
85        nop
861:
87        .cpsetup $25, $2, 1b
88        nop
89        sub $3, $3, $2
90
91# ALL-LABEL: t3:
92# ALL-NEXT:  nop
93
94# O32-NEXT:   nop
95# O32-NEXT:   sub $3, $3, $2
96
97# NXX-NEXT: move     $2, $gp
98# NXX-NEXT: lui      $gp, 0
99# N32-NEXT: {{^ *0+}}38: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
100# N64-NEXT: {{^ *0+}}40: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16 .text
101# NXX-NEXT: addiu    $gp, $gp, 0
102# N32-NEXT: {{^ *0+}}3c: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
103# N64-NEXT: {{^ *0+}}44: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16 .text
104# N64-NEXT: daddu    $gp, $gp, $25
105# NXX-NEXT: nop
106# NXX-NEXT: sub $3, $3, $2
107
108# ASM: $tmp0:
109# ASM-NEXT: .cpsetup $25, $2, $tmp0
110
111# Ensure we have at least one instruction between labels so that the labels
112# we're matching aren't removed.
113        nop
114# ALL-NEXT: nop
115
116        .option pic0
117t4:
118        nop
119        .cpsetup $25, 8, __cerror
120        nop
121        .cpreturn
122        nop
123
124# Testing that .cpsetup expands to nothing in this case
125# by checking that the next instruction after the first
126# nop is also a 'nop'.
127
128# ALL-LABEL: t4:
129
130# NXX-NEXT: nop
131# NXX-NEXT: nop
132# NXX-NEXT: nop
133
134# ASM-NEXT: nop
135# ASM-NEXT: .cpsetup $25, 8, __cerror
136# ASM-NEXT: nop
137# ASM-NEXT: .cpreturn
138# ASM-NEXT: nop
139
140# Test that we accept constant expressions.
141        .option pic2
142t5:
143        .cpsetup $25, ((8*4) - (3*8)), __cerror
144        nop
145
146# ALL-LABEL: t5:
147
148# O32-NOT: __cerror
149
150# NXX-NEXT: sd       $gp, 8($sp)
151# NXX-NEXT: lui      $gp, 0
152# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
153# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16  __cerror
154# NXX-NEXT: addiu    $gp, $gp, 0
155# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
156# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16  __cerror
157# N64-NEXT: daddu    $gp, $gp, $25
158
159# ASM-NEXT: .cpsetup $25, 8, __cerror
160
161# ALL-NEXT: nop
162
163t1b:
164IMM_8 = 8
165        .cpsetup $25, IMM_8, __cerror
166        nop
167        .cpreturn
168        nop
169
170# ALL-LABEL: t1b:
171# ASM-NEXT: IMM_8 = 8
172
173# O32-NOT: __cerror
174
175# NXX-NEXT: sd       $gp, 8($sp)
176# NXX-NEXT: lui      $gp, 0
177# N32-NEXT: R_MIPS_HI16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
178# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_HI16  __cerror
179# NXX-NEXT: addiu    $gp, $gp, 0
180# N32-NEXT: R_MIPS_LO16/R_MIPS_NONE/R_MIPS_NONE __gnu_local_gp
181# N64-NEXT: R_MIPS_GPREL16/R_MIPS_SUB/R_MIPS_LO16  __cerror
182# N64-NEXT: daddu    $gp, $gp, $25
183
184# ASM-NEXT: .cpsetup $25, 8, __cerror
185
186# ALL-NEXT: nop
187
188# ASM-NEXT: .cpreturn
189# NXX-NEXT: ld $gp, 8($sp)
190
191# ALL-NEXT: nop
192
193