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