darwin.md revision 1.5 1 1.1 mrg /* Machine description patterns for PowerPC running Darwin (Mac OS X).
2 1.5 mrg Copyright (C) 2004-2015 Free Software Foundation, Inc.
3 1.1 mrg Contributed by Apple Computer Inc.
4 1.1 mrg
5 1.1 mrg This file is part of GCC.
6 1.1 mrg
7 1.1 mrg GNU CC is free software; you can redistribute it and/or modify
8 1.1 mrg it under the terms of the GNU General Public License as published by
9 1.1 mrg the Free Software Foundation; either version 3, or (at your option)
10 1.1 mrg any later version.
11 1.1 mrg
12 1.1 mrg GNU CC is distributed in the hope that it will be useful,
13 1.1 mrg but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 mrg GNU General Public License for more details.
16 1.1 mrg
17 1.1 mrg You should have received a copy of the GNU General Public License
18 1.1 mrg ;; along with GCC; see the file COPYING3. If not see
19 1.1 mrg ;; <http://www.gnu.org/licenses/>. */
20 1.1 mrg
21 1.1 mrg (define_insn "adddi3_high"
22 1.1 mrg [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
23 1.1 mrg (plus:DI (match_operand:DI 1 "gpc_reg_operand" "b")
24 1.1 mrg (high:DI (match_operand 2 "" ""))))]
25 1.1 mrg "TARGET_MACHO && TARGET_64BIT"
26 1.3 mrg "addis %0,%1,ha16(%2)"
27 1.1 mrg [(set_attr "length" "4")])
28 1.1 mrg
29 1.1 mrg (define_insn "movdf_low_si"
30 1.1 mrg [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
31 1.1 mrg (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
32 1.1 mrg (match_operand 2 "" ""))))]
33 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_64BIT"
34 1.1 mrg "*
35 1.1 mrg {
36 1.1 mrg switch (which_alternative)
37 1.1 mrg {
38 1.1 mrg case 0:
39 1.1 mrg return \"lfd %0,lo16(%2)(%1)\";
40 1.1 mrg case 1:
41 1.1 mrg {
42 1.1 mrg if (TARGET_POWERPC64 && TARGET_32BIT)
43 1.1 mrg /* Note, old assemblers didn't support relocation here. */
44 1.1 mrg return \"ld %0,lo16(%2)(%1)\";
45 1.1 mrg else
46 1.1 mrg {
47 1.3 mrg output_asm_insn (\"la %0,lo16(%2)(%1)\", operands);
48 1.3 mrg output_asm_insn (\"lwz %L0,4(%0)\", operands);
49 1.3 mrg return (\"lwz %0,0(%0)\");
50 1.1 mrg }
51 1.1 mrg }
52 1.1 mrg default:
53 1.1 mrg gcc_unreachable ();
54 1.1 mrg }
55 1.1 mrg }"
56 1.1 mrg [(set_attr "type" "load")
57 1.1 mrg (set_attr "length" "4,12")])
58 1.1 mrg
59 1.1 mrg
60 1.1 mrg (define_insn "movdf_low_di"
61 1.1 mrg [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
62 1.1 mrg (mem:DF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
63 1.1 mrg (match_operand 2 "" ""))))]
64 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
65 1.1 mrg "*
66 1.1 mrg {
67 1.1 mrg switch (which_alternative)
68 1.1 mrg {
69 1.1 mrg case 0:
70 1.1 mrg return \"lfd %0,lo16(%2)(%1)\";
71 1.1 mrg case 1:
72 1.1 mrg return \"ld %0,lo16(%2)(%1)\";
73 1.1 mrg default:
74 1.1 mrg gcc_unreachable ();
75 1.1 mrg }
76 1.1 mrg }"
77 1.1 mrg [(set_attr "type" "load")
78 1.1 mrg (set_attr "length" "4,4")])
79 1.1 mrg
80 1.1 mrg (define_insn "movdf_low_st_si"
81 1.1 mrg [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
82 1.1 mrg (match_operand 2 "" "")))
83 1.1 mrg (match_operand:DF 0 "gpc_reg_operand" "f"))]
84 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
85 1.1 mrg "stfd %0,lo16(%2)(%1)"
86 1.1 mrg [(set_attr "type" "store")
87 1.1 mrg (set_attr "length" "4")])
88 1.1 mrg
89 1.1 mrg (define_insn "movdf_low_st_di"
90 1.1 mrg [(set (mem:DF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
91 1.1 mrg (match_operand 2 "" "")))
92 1.1 mrg (match_operand:DF 0 "gpc_reg_operand" "f"))]
93 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
94 1.1 mrg "stfd %0,lo16(%2)(%1)"
95 1.1 mrg [(set_attr "type" "store")
96 1.1 mrg (set_attr "length" "4")])
97 1.1 mrg
98 1.1 mrg (define_insn "movsf_low_si"
99 1.1 mrg [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
100 1.1 mrg (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
101 1.1 mrg (match_operand 2 "" ""))))]
102 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
103 1.1 mrg "@
104 1.1 mrg lfs %0,lo16(%2)(%1)
105 1.3 mrg lwz %0,lo16(%2)(%1)"
106 1.1 mrg [(set_attr "type" "load")
107 1.1 mrg (set_attr "length" "4")])
108 1.1 mrg
109 1.1 mrg (define_insn "movsf_low_di"
110 1.1 mrg [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
111 1.1 mrg (mem:SF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
112 1.1 mrg (match_operand 2 "" ""))))]
113 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
114 1.1 mrg "@
115 1.1 mrg lfs %0,lo16(%2)(%1)
116 1.3 mrg lwz %0,lo16(%2)(%1)"
117 1.1 mrg [(set_attr "type" "load")
118 1.1 mrg (set_attr "length" "4")])
119 1.1 mrg
120 1.1 mrg (define_insn "movsf_low_st_si"
121 1.1 mrg [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
122 1.1 mrg (match_operand 2 "" "")))
123 1.1 mrg (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
124 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
125 1.1 mrg "@
126 1.1 mrg stfs %0,lo16(%2)(%1)
127 1.3 mrg stw %0,lo16(%2)(%1)"
128 1.1 mrg [(set_attr "type" "store")
129 1.1 mrg (set_attr "length" "4")])
130 1.1 mrg
131 1.1 mrg (define_insn "movsf_low_st_di"
132 1.1 mrg [(set (mem:SF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
133 1.1 mrg (match_operand 2 "" "")))
134 1.1 mrg (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
135 1.1 mrg "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
136 1.1 mrg "@
137 1.1 mrg stfs %0,lo16(%2)(%1)
138 1.3 mrg stw %0,lo16(%2)(%1)"
139 1.1 mrg [(set_attr "type" "store")
140 1.1 mrg (set_attr "length" "4")])
141 1.1 mrg
142 1.1 mrg ;; 64-bit MachO load/store support
143 1.1 mrg (define_insn "movdi_low"
144 1.3 mrg [(set (match_operand:DI 0 "gpc_reg_operand" "=r,*!d")
145 1.3 mrg (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
146 1.1 mrg (match_operand 2 "" ""))))]
147 1.1 mrg "TARGET_MACHO && TARGET_64BIT"
148 1.3 mrg "@
149 1.3 mrg ld %0,lo16(%2)(%1)
150 1.3 mrg lfd %0,lo16(%2)(%1)"
151 1.1 mrg [(set_attr "type" "load")
152 1.1 mrg (set_attr "length" "4")])
153 1.1 mrg
154 1.1 mrg (define_insn "movsi_low_st"
155 1.1 mrg [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
156 1.1 mrg (match_operand 2 "" "")))
157 1.1 mrg (match_operand:SI 0 "gpc_reg_operand" "r"))]
158 1.1 mrg "TARGET_MACHO && ! TARGET_64BIT"
159 1.3 mrg "stw %0,lo16(%2)(%1)"
160 1.1 mrg [(set_attr "type" "store")
161 1.1 mrg (set_attr "length" "4")])
162 1.1 mrg
163 1.1 mrg (define_insn "movdi_low_st"
164 1.3 mrg [(set (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
165 1.1 mrg (match_operand 2 "" "")))
166 1.3 mrg (match_operand:DI 0 "gpc_reg_operand" "r,*!d"))]
167 1.1 mrg "TARGET_MACHO && TARGET_64BIT"
168 1.3 mrg "@
169 1.3 mrg std %0,lo16(%2)(%1)
170 1.3 mrg stfd %0,lo16(%2)(%1)"
171 1.1 mrg [(set_attr "type" "store")
172 1.1 mrg (set_attr "length" "4")])
173 1.1 mrg
174 1.1 mrg ;; Mach-O PIC trickery.
175 1.1 mrg (define_expand "macho_high"
176 1.1 mrg [(set (match_operand 0 "" "")
177 1.1 mrg (high (match_operand 1 "" "")))]
178 1.1 mrg "TARGET_MACHO"
179 1.1 mrg {
180 1.1 mrg if (TARGET_64BIT)
181 1.1 mrg emit_insn (gen_macho_high_di (operands[0], operands[1]));
182 1.1 mrg else
183 1.1 mrg emit_insn (gen_macho_high_si (operands[0], operands[1]));
184 1.1 mrg
185 1.1 mrg DONE;
186 1.1 mrg })
187 1.1 mrg
188 1.1 mrg (define_insn "macho_high_si"
189 1.1 mrg [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
190 1.1 mrg (high:SI (match_operand 1 "" "")))]
191 1.1 mrg "TARGET_MACHO && ! TARGET_64BIT"
192 1.3 mrg "lis %0,ha16(%1)")
193 1.1 mrg
194 1.1 mrg
195 1.1 mrg (define_insn "macho_high_di"
196 1.1 mrg [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
197 1.1 mrg (high:DI (match_operand 1 "" "")))]
198 1.1 mrg "TARGET_MACHO && TARGET_64BIT"
199 1.3 mrg "lis %0,ha16(%1)")
200 1.1 mrg
201 1.1 mrg (define_expand "macho_low"
202 1.1 mrg [(set (match_operand 0 "" "")
203 1.1 mrg (lo_sum (match_operand 1 "" "")
204 1.1 mrg (match_operand 2 "" "")))]
205 1.1 mrg "TARGET_MACHO"
206 1.1 mrg {
207 1.1 mrg if (TARGET_64BIT)
208 1.1 mrg emit_insn (gen_macho_low_di (operands[0], operands[1], operands[2]));
209 1.1 mrg else
210 1.1 mrg emit_insn (gen_macho_low_si (operands[0], operands[1], operands[2]));
211 1.1 mrg
212 1.1 mrg DONE;
213 1.1 mrg })
214 1.1 mrg
215 1.1 mrg (define_insn "macho_low_si"
216 1.5 mrg [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
217 1.5 mrg (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
218 1.1 mrg (match_operand 2 "" "")))]
219 1.1 mrg "TARGET_MACHO && ! TARGET_64BIT"
220 1.5 mrg "la %0,lo16(%2)(%1)")
221 1.1 mrg
222 1.1 mrg (define_insn "macho_low_di"
223 1.5 mrg [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
224 1.5 mrg (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
225 1.1 mrg (match_operand 2 "" "")))]
226 1.1 mrg "TARGET_MACHO && TARGET_64BIT"
227 1.5 mrg "la %0,lo16(%2)(%1)")
228 1.1 mrg
229 1.1 mrg (define_split
230 1.1 mrg [(set (mem:V4SI (plus:DI (match_operand:DI 0 "gpc_reg_operand" "")
231 1.1 mrg (match_operand:DI 1 "short_cint_operand" "")))
232 1.1 mrg (match_operand:V4SI 2 "register_operand" ""))
233 1.1 mrg (clobber (match_operand:DI 3 "gpc_reg_operand" ""))]
234 1.1 mrg "TARGET_MACHO && TARGET_64BIT"
235 1.1 mrg [(set (match_dup 3) (plus:DI (match_dup 0) (match_dup 1)))
236 1.1 mrg (set (mem:V4SI (match_dup 3))
237 1.1 mrg (match_dup 2))]
238 1.1 mrg "")
239 1.1 mrg
240 1.1 mrg (define_expand "load_macho_picbase"
241 1.1 mrg [(set (reg:SI 65)
242 1.1 mrg (unspec [(match_operand 0 "" "")]
243 1.1 mrg UNSPEC_LD_MPIC))]
244 1.1 mrg "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
245 1.1 mrg {
246 1.1 mrg if (TARGET_32BIT)
247 1.1 mrg emit_insn (gen_load_macho_picbase_si (operands[0]));
248 1.1 mrg else
249 1.1 mrg emit_insn (gen_load_macho_picbase_di (operands[0]));
250 1.1 mrg
251 1.1 mrg DONE;
252 1.1 mrg })
253 1.1 mrg
254 1.1 mrg (define_insn "load_macho_picbase_si"
255 1.1 mrg [(set (reg:SI 65)
256 1.1 mrg (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
257 1.1 mrg (pc)] UNSPEC_LD_MPIC))]
258 1.1 mrg "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
259 1.5 mrg {
260 1.5 mrg #if TARGET_MACHO
261 1.5 mrg machopic_should_output_picbase_label (); /* Update for new func. */
262 1.5 mrg #else
263 1.5 mrg gcc_unreachable ();
264 1.5 mrg #endif
265 1.5 mrg return "bcl 20,31,%0\\n%0:";
266 1.5 mrg }
267 1.1 mrg [(set_attr "type" "branch")
268 1.1 mrg (set_attr "length" "4")])
269 1.1 mrg
270 1.1 mrg (define_insn "load_macho_picbase_di"
271 1.1 mrg [(set (reg:DI 65)
272 1.1 mrg (unspec:DI [(match_operand:DI 0 "immediate_operand" "s")
273 1.1 mrg (pc)] UNSPEC_LD_MPIC))]
274 1.1 mrg "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT"
275 1.5 mrg {
276 1.5 mrg #if TARGET_MACHO
277 1.5 mrg machopic_should_output_picbase_label (); /* Update for new func. */
278 1.5 mrg #else
279 1.5 mrg gcc_unreachable ();
280 1.5 mrg #endif
281 1.5 mrg return "bcl 20,31,%0\\n%0:";
282 1.5 mrg }
283 1.1 mrg [(set_attr "type" "branch")
284 1.1 mrg (set_attr "length" "4")])
285 1.1 mrg
286 1.1 mrg (define_expand "macho_correct_pic"
287 1.1 mrg [(set (match_operand 0 "" "")
288 1.1 mrg (plus (match_operand 1 "" "")
289 1.1 mrg (unspec [(match_operand 2 "" "")
290 1.1 mrg (match_operand 3 "" "")]
291 1.1 mrg UNSPEC_MPIC_CORRECT)))]
292 1.1 mrg "DEFAULT_ABI == ABI_DARWIN"
293 1.1 mrg {
294 1.1 mrg if (TARGET_32BIT)
295 1.1 mrg emit_insn (gen_macho_correct_pic_si (operands[0], operands[1], operands[2],
296 1.1 mrg operands[3]));
297 1.1 mrg else
298 1.1 mrg emit_insn (gen_macho_correct_pic_di (operands[0], operands[1], operands[2],
299 1.1 mrg operands[3]));
300 1.1 mrg
301 1.1 mrg DONE;
302 1.1 mrg })
303 1.1 mrg
304 1.1 mrg (define_insn "macho_correct_pic_si"
305 1.1 mrg [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
306 1.1 mrg (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
307 1.1 mrg (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
308 1.1 mrg (match_operand:SI 3 "immediate_operand" "s")]
309 1.1 mrg UNSPEC_MPIC_CORRECT)))]
310 1.1 mrg "DEFAULT_ABI == ABI_DARWIN"
311 1.1 mrg "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
312 1.1 mrg [(set_attr "length" "8")])
313 1.1 mrg
314 1.1 mrg (define_insn "macho_correct_pic_di"
315 1.1 mrg [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
316 1.1 mrg (plus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
317 1.1 mrg (unspec:DI [(match_operand:DI 2 "immediate_operand" "s")
318 1.1 mrg (match_operand:DI 3 "immediate_operand" "s")]
319 1.1 mrg 16)))]
320 1.1 mrg "DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT"
321 1.1 mrg "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
322 1.1 mrg [(set_attr "length" "8")])
323 1.1 mrg
324 1.1 mrg (define_insn "*call_indirect_nonlocal_darwin64"
325 1.1 mrg [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l,c,*l"))
326 1.1 mrg (match_operand 1 "" "g,g,g,g"))
327 1.1 mrg (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
328 1.1 mrg (clobber (reg:SI 65))]
329 1.1 mrg "DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT"
330 1.1 mrg {
331 1.1 mrg return "b%T0l";
332 1.1 mrg }
333 1.1 mrg [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
334 1.1 mrg (set_attr "length" "4,4,8,8")])
335 1.1 mrg
336 1.1 mrg (define_insn "*call_nonlocal_darwin64"
337 1.1 mrg [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s,s"))
338 1.1 mrg (match_operand 1 "" "g,g"))
339 1.1 mrg (use (match_operand:SI 2 "immediate_operand" "O,n"))
340 1.1 mrg (clobber (reg:SI 65))]
341 1.1 mrg "(DEFAULT_ABI == ABI_DARWIN)
342 1.1 mrg && (INTVAL (operands[2]) & CALL_LONG) == 0"
343 1.1 mrg {
344 1.1 mrg #if TARGET_MACHO
345 1.1 mrg return output_call(insn, operands, 0, 2);
346 1.1 mrg #else
347 1.1 mrg gcc_unreachable ();
348 1.1 mrg #endif
349 1.1 mrg }
350 1.1 mrg [(set_attr "type" "branch,branch")
351 1.1 mrg (set_attr "length" "4,8")])
352 1.1 mrg
353 1.1 mrg (define_insn "*call_value_indirect_nonlocal_darwin64"
354 1.1 mrg [(set (match_operand 0 "" "")
355 1.1 mrg (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l,c,*l"))
356 1.1 mrg (match_operand 2 "" "g,g,g,g")))
357 1.1 mrg (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
358 1.1 mrg (clobber (reg:SI 65))]
359 1.1 mrg "DEFAULT_ABI == ABI_DARWIN"
360 1.1 mrg {
361 1.1 mrg return "b%T1l";
362 1.1 mrg }
363 1.1 mrg [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
364 1.1 mrg (set_attr "length" "4,4,8,8")])
365 1.1 mrg
366 1.1 mrg (define_insn "*call_value_nonlocal_darwin64"
367 1.1 mrg [(set (match_operand 0 "" "")
368 1.1 mrg (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s,s"))
369 1.1 mrg (match_operand 2 "" "g,g")))
370 1.1 mrg (use (match_operand:SI 3 "immediate_operand" "O,n"))
371 1.1 mrg (clobber (reg:SI 65))]
372 1.1 mrg "(DEFAULT_ABI == ABI_DARWIN)
373 1.1 mrg && (INTVAL (operands[3]) & CALL_LONG) == 0"
374 1.1 mrg {
375 1.1 mrg #if TARGET_MACHO
376 1.1 mrg return output_call(insn, operands, 1, 3);
377 1.1 mrg #else
378 1.1 mrg gcc_unreachable ();
379 1.1 mrg #endif
380 1.1 mrg }
381 1.1 mrg [(set_attr "type" "branch,branch")
382 1.1 mrg (set_attr "length" "4,8")])
383 1.5 mrg
384 1.5 mrg (define_expand "reload_macho_picbase"
385 1.5 mrg [(set (reg:SI 65)
386 1.5 mrg (unspec [(match_operand 0 "" "")]
387 1.5 mrg UNSPEC_RELD_MPIC))]
388 1.5 mrg "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
389 1.5 mrg {
390 1.5 mrg if (TARGET_32BIT)
391 1.5 mrg emit_insn (gen_reload_macho_picbase_si (operands[0]));
392 1.5 mrg else
393 1.5 mrg emit_insn (gen_reload_macho_picbase_di (operands[0]));
394 1.5 mrg
395 1.5 mrg DONE;
396 1.5 mrg })
397 1.5 mrg
398 1.5 mrg (define_insn "reload_macho_picbase_si"
399 1.5 mrg [(set (reg:SI 65)
400 1.5 mrg (unspec:SI [(match_operand:SI 0 "immediate_operand" "s")
401 1.5 mrg (pc)] UNSPEC_RELD_MPIC))]
402 1.5 mrg "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
403 1.5 mrg {
404 1.5 mrg #if TARGET_MACHO
405 1.5 mrg if (machopic_should_output_picbase_label ())
406 1.5 mrg {
407 1.5 mrg static char tmp[64];
408 1.5 mrg const char *cnam = machopic_get_function_picbase ();
409 1.5 mrg snprintf (tmp, 64, "bcl 20,31,%s\\n%s:\\n%%0:", cnam, cnam);
410 1.5 mrg return tmp;
411 1.5 mrg }
412 1.5 mrg else
413 1.5 mrg #else
414 1.5 mrg gcc_unreachable ();
415 1.5 mrg #endif
416 1.5 mrg return "bcl 20,31,%0\\n%0:";
417 1.5 mrg }
418 1.5 mrg [(set_attr "type" "branch")
419 1.5 mrg (set_attr "length" "4")])
420 1.5 mrg
421 1.5 mrg (define_insn "reload_macho_picbase_di"
422 1.5 mrg [(set (reg:DI 65)
423 1.5 mrg (unspec:DI [(match_operand:DI 0 "immediate_operand" "s")
424 1.5 mrg (pc)] UNSPEC_RELD_MPIC))]
425 1.5 mrg "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT"
426 1.5 mrg {
427 1.5 mrg #if TARGET_MACHO
428 1.5 mrg if (machopic_should_output_picbase_label ())
429 1.5 mrg {
430 1.5 mrg static char tmp[64];
431 1.5 mrg const char *cnam = machopic_get_function_picbase ();
432 1.5 mrg snprintf (tmp, 64, "bcl 20,31,%s\\n%s:\\n%%0:", cnam, cnam);
433 1.5 mrg return tmp;
434 1.5 mrg }
435 1.5 mrg else
436 1.5 mrg #else
437 1.5 mrg gcc_unreachable ();
438 1.5 mrg #endif
439 1.5 mrg return "bcl 20,31,%0\\n%0:";
440 1.5 mrg }
441 1.5 mrg [(set_attr "type" "branch")
442 1.5 mrg (set_attr "length" "4")])
443 1.5 mrg
444 1.5 mrg ;; We need to restore the PIC register, at the site of nonlocal label.
445 1.5 mrg
446 1.5 mrg (define_insn_and_split "nonlocal_goto_receiver"
447 1.5 mrg [(unspec_volatile [(const_int 0)] UNSPECV_NLGR)]
448 1.5 mrg "TARGET_MACHO && flag_pic"
449 1.5 mrg "#"
450 1.5 mrg "&& reload_completed"
451 1.5 mrg [(const_int 0)]
452 1.5 mrg {
453 1.5 mrg #if TARGET_MACHO
454 1.5 mrg if (crtl->uses_pic_offset_table)
455 1.5 mrg {
456 1.5 mrg static unsigned n = 0;
457 1.5 mrg rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, MACHOPIC_FUNCTION_BASE_NAME);
458 1.5 mrg rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
459 1.5 mrg rtx tmplrtx;
460 1.5 mrg char tmplab[20];
461 1.5 mrg
462 1.5 mrg ASM_GENERATE_INTERNAL_LABEL(tmplab, "Lnlgr", ++n);
463 1.5 mrg tmplrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
464 1.5 mrg
465 1.5 mrg emit_insn (gen_reload_macho_picbase (tmplrtx));
466 1.5 mrg emit_move_insn (picreg, gen_rtx_REG (Pmode, LR_REGNO));
467 1.5 mrg emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplrtx));
468 1.5 mrg }
469 1.5 mrg else
470 1.5 mrg /* Not using PIC reg, no reload needed. */
471 1.5 mrg emit_note (NOTE_INSN_DELETED);
472 1.5 mrg #else
473 1.5 mrg gcc_unreachable ();
474 1.5 mrg #endif
475 1.5 mrg DONE;
476 1.5 mrg })
477