Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / config / rs6000 / darwin.md
blob49c6caa03ceff748ab5973d84c3e653e582177a6
1 /* Machine description patterns for PowerPC running Darwin (Mac OS X).
2    Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3    Contributed by Apple Computer Inc.
5 This file is part of GCC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING.  If not, write to
19 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.  */
22 (define_insn "adddi3_high"
23   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
24         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "b")
25                  (high:DI (match_operand 2 "" ""))))]
26   "TARGET_MACHO && TARGET_64BIT"
27   "{cau|addis} %0,%1,ha16(%2)"
28   [(set_attr "length" "4")])
30 (define_insn "movdf_low_si"
31   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
32         (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
33                            (match_operand 2 "" ""))))]
34   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && !TARGET_64BIT"
35   "*
37   switch (which_alternative)
38     {
39       case 0:
40         return \"lfd %0,lo16(%2)(%1)\";
41       case 1:
42         {
43           if (TARGET_POWERPC64 && TARGET_32BIT)
44             /* Note, old assemblers didn't support relocation here.  */
45             return \"ld %0,lo16(%2)(%1)\";
46           else
47             {
48               output_asm_insn (\"{cal|la} %0,lo16(%2)(%1)\", operands);
49               output_asm_insn (\"{l|lwz} %L0,4(%0)\", operands);
50               return (\"{l|lwz} %0,0(%0)\");
51             }
52         }
53       default:
54         gcc_unreachable ();
55     }
57   [(set_attr "type" "load")
58    (set_attr "length" "4,12")])
61 (define_insn "movdf_low_di"
62   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
63         (mem:DF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
64                            (match_operand 2 "" ""))))]
65   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
66   "*
68   switch (which_alternative)
69     {
70       case 0:
71         return \"lfd %0,lo16(%2)(%1)\";
72       case 1:
73         return \"ld %0,lo16(%2)(%1)\";
74       default:
75         gcc_unreachable ();
76     }
78   [(set_attr "type" "load")
79    (set_attr "length" "4,4")])
81 (define_insn "movdf_low_st_si"
82   [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
83                            (match_operand 2 "" "")))
84         (match_operand:DF 0 "gpc_reg_operand" "f"))]
85   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
86   "stfd %0,lo16(%2)(%1)"
87   [(set_attr "type" "store")
88    (set_attr "length" "4")])
90 (define_insn "movdf_low_st_di"
91   [(set (mem:DF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
92                            (match_operand 2 "" "")))
93         (match_operand:DF 0 "gpc_reg_operand" "f"))]
94   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
95   "stfd %0,lo16(%2)(%1)"
96   [(set_attr "type" "store")
97    (set_attr "length" "4")])
99 (define_insn "movsf_low_si"
100   [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
101         (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
102                            (match_operand 2 "" ""))))]
103   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
104   "@
105    lfs %0,lo16(%2)(%1)
106    {l|lwz} %0,lo16(%2)(%1)"
107   [(set_attr "type" "load")
108    (set_attr "length" "4")])
110 (define_insn "movsf_low_di"
111   [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
112         (mem:SF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
113                            (match_operand 2 "" ""))))]
114   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
115   "@
116    lfs %0,lo16(%2)(%1)
117    {l|lwz} %0,lo16(%2)(%1)"
118   [(set_attr "type" "load")
119    (set_attr "length" "4")])
121 (define_insn "movsf_low_st_si"
122   [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
123                            (match_operand 2 "" "")))
124         (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
125   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
126   "@
127    stfs %0,lo16(%2)(%1)
128    {st|stw} %0,lo16(%2)(%1)"
129   [(set_attr "type" "store")
130    (set_attr "length" "4")])
132 (define_insn "movsf_low_st_di"
133   [(set (mem:SF (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,b")
134                            (match_operand 2 "" "")))
135         (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
136   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_64BIT"
137   "@
138    stfs %0,lo16(%2)(%1)
139    {st|stw} %0,lo16(%2)(%1)"
140   [(set_attr "type" "store")
141    (set_attr "length" "4")])
143 ;; 64-bit MachO load/store support
144 (define_insn "movdi_low"
145   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
146         (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
147                            (match_operand 2 "" ""))))]
148   "TARGET_MACHO && TARGET_64BIT"
149   "{l|ld} %0,lo16(%2)(%1)"
150   [(set_attr "type" "load")
151    (set_attr "length" "4")])
153 (define_insn "movsi_low_st"
154   [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
155                            (match_operand 2 "" "")))
156         (match_operand:SI 0 "gpc_reg_operand" "r"))]
157   "TARGET_MACHO && ! TARGET_64BIT"
158   "{st|stw} %0,lo16(%2)(%1)"
159   [(set_attr "type" "store")
160    (set_attr "length" "4")])
162 (define_insn "movdi_low_st"
163   [(set (mem:DI (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b")
164                            (match_operand 2 "" "")))
165         (match_operand:DI 0 "gpc_reg_operand" "r"))]
166   "TARGET_MACHO && TARGET_64BIT"
167   "{st|std} %0,lo16(%2)(%1)"
168   [(set_attr "type" "store")
169    (set_attr "length" "4")])
171 ;; Mach-O PIC trickery.
172 (define_expand "macho_high"
173   [(set (match_operand 0 "" "")
174         (high (match_operand 1 "" "")))]
175   "TARGET_MACHO"
177   if (TARGET_64BIT)
178     emit_insn (gen_macho_high_di (operands[0], operands[1]));
179   else
180     emit_insn (gen_macho_high_si (operands[0], operands[1]));
182   DONE;
185 (define_insn "macho_high_si"
186   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
187         (high:SI (match_operand 1 "" "")))]
188   "TARGET_MACHO && ! TARGET_64BIT"
189   "{liu|lis} %0,ha16(%1)")
190   
192 (define_insn "macho_high_di"
193   [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
194         (high:DI (match_operand 1 "" "")))]
195   "TARGET_MACHO && TARGET_64BIT"
196   "{liu|lis} %0,ha16(%1)")
198 (define_expand "macho_low"
199   [(set (match_operand 0 "" "")
200         (lo_sum (match_operand 1 "" "")
201                    (match_operand 2 "" "")))]
202    "TARGET_MACHO"
204   if (TARGET_64BIT)
205     emit_insn (gen_macho_low_di (operands[0], operands[1], operands[2]));
206   else
207     emit_insn (gen_macho_low_si (operands[0], operands[1], operands[2]));
209   DONE;
212 (define_insn "macho_low_si"
213   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
214         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
215                    (match_operand 2 "" "")))]
216    "TARGET_MACHO && ! TARGET_64BIT"
217    "@
218     {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
219     {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
221 (define_insn "macho_low_di"
222   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
223         (lo_sum:DI (match_operand:DI 1 "gpc_reg_operand" "b,!*r")
224                    (match_operand 2 "" "")))]
225    "TARGET_MACHO && TARGET_64BIT"
226    "@
227     {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
228     {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
230 (define_split
231   [(set (mem:V4SI (plus:DI (match_operand:DI 0 "gpc_reg_operand" "")
232                          (match_operand:DI 1 "short_cint_operand" "")))
233         (match_operand:V4SI 2 "register_operand" ""))
234    (clobber (match_operand:DI 3 "gpc_reg_operand" ""))]
235   "TARGET_MACHO && TARGET_64BIT"
236   [(set (match_dup 3) (plus:DI (match_dup 0) (match_dup 1)))
237    (set (mem:V4SI (match_dup 3))
238         (match_dup 2))]
239   "")
241 (define_expand "load_macho_picbase"
242   [(set (match_operand 0 "" "")
243         (unspec [(match_operand 1 "" "")]
244                    UNSPEC_LD_MPIC))]
245   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
247   if (TARGET_32BIT)
248     emit_insn (gen_load_macho_picbase_si (operands[0], operands[1]));
249   else
250     emit_insn (gen_load_macho_picbase_di (operands[0], operands[1]));
252   DONE;
255 (define_insn "load_macho_picbase_si"
256   [(set (match_operand:SI 0 "register_operand" "=l")
257         (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")]
258                    UNSPEC_LD_MPIC))]
259   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
260   "bcl 20,31,%1\\n%1:"
261   [(set_attr "type" "branch")
262    (set_attr "length" "4")])
264 (define_insn "load_macho_picbase_di"
265   [(set (match_operand:DI 0 "register_operand" "=l")
266         (unspec:DI [(match_operand:DI 1 "immediate_operand" "s")] UNSPEC_LD_MPIC))]
267   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic && TARGET_64BIT"
268   "bcl 20,31,%1\\n%1:"
269   [(set_attr "type" "branch")
270    (set_attr "length" "4")])
272 (define_expand "macho_correct_pic"
273   [(set (match_operand 0 "" "")
274         (plus (match_operand 1 "" "")
275                  (unspec [(match_operand 2 "" "")
276                              (match_operand 3 "" "")]
277                             UNSPEC_MPIC_CORRECT)))]
278   "DEFAULT_ABI == ABI_DARWIN"
280   if (TARGET_32BIT)
281     emit_insn (gen_macho_correct_pic_si (operands[0], operands[1], operands[2],
282                operands[3]));
283   else
284     emit_insn (gen_macho_correct_pic_di (operands[0], operands[1], operands[2],
285                operands[3]));
287   DONE;
290 (define_insn "macho_correct_pic_si"
291   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
292         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
293                  (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
294                              (match_operand:SI 3 "immediate_operand" "s")]
295                             UNSPEC_MPIC_CORRECT)))]
296   "DEFAULT_ABI == ABI_DARWIN"
297   "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
298   [(set_attr "length" "8")])
300 (define_insn "macho_correct_pic_di"
301   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
302         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "r")
303                  (unspec:DI [(match_operand:DI 2 "immediate_operand" "s")
304                              (match_operand:DI 3 "immediate_operand" "s")]
305                             16)))]
306   "DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT"
307   "addis %0,%1,ha16(%2-%3)\n\taddi %0,%0,lo16(%2-%3)"
308   [(set_attr "length" "8")])
310 (define_insn "*call_indirect_nonlocal_darwin64"
311   [(call (mem:SI (match_operand:DI 0 "register_operand" "c,*l,c,*l"))
312          (match_operand 1 "" "g,g,g,g"))
313    (use (match_operand:SI 2 "immediate_operand" "O,O,n,n"))
314    (clobber (match_scratch:SI 3 "=l,l,l,l"))]
315   "DEFAULT_ABI == ABI_DARWIN && TARGET_64BIT"
317   return "b%T0l";
319   [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
320    (set_attr "length" "4,4,8,8")])
322 (define_insn "*call_nonlocal_darwin64"
323   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s,s"))
324          (match_operand 1 "" "g,g"))
325    (use (match_operand:SI 2 "immediate_operand" "O,n"))
326    (clobber (match_scratch:SI 3 "=l,l"))]
327   "(DEFAULT_ABI == ABI_DARWIN)
328    && (INTVAL (operands[2]) & CALL_LONG) == 0"
330 #if TARGET_MACHO
331   return output_call(insn, operands, 0, 2);
332 #else
333   gcc_unreachable ();
334 #endif
336   [(set_attr "type" "branch,branch")
337    (set_attr "length" "4,8")])
339 (define_insn "*call_value_indirect_nonlocal_darwin64"
340   [(set (match_operand 0 "" "")
341         (call (mem:SI (match_operand:DI 1 "register_operand" "c,*l,c,*l"))
342               (match_operand 2 "" "g,g,g,g")))
343    (use (match_operand:SI 3 "immediate_operand" "O,O,n,n"))
344    (clobber (match_scratch:SI 4 "=l,l,l,l"))]
345   "DEFAULT_ABI == ABI_DARWIN"
347   return "b%T1l";
349   [(set_attr "type" "jmpreg,jmpreg,jmpreg,jmpreg")
350    (set_attr "length" "4,4,8,8")])
352 (define_insn "*call_value_nonlocal_darwin64"
353   [(set (match_operand 0 "" "")
354         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s,s"))
355               (match_operand 2 "" "g,g")))
356    (use (match_operand:SI 3 "immediate_operand" "O,n"))
357    (clobber (match_scratch:SI 4 "=l,l"))]
358   "(DEFAULT_ABI == ABI_DARWIN)
359    && (INTVAL (operands[3]) & CALL_LONG) == 0"
361 #if TARGET_MACHO
362   return output_call(insn, operands, 1, 3);
363 #else
364   gcc_unreachable ();
365 #endif
367   [(set_attr "type" "branch,branch")
368    (set_attr "length" "4,8")])
370 (define_insn "*sibcall_nonlocal_darwin64"
371   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s,s"))
372          (match_operand 1 "" ""))
373    (use (match_operand 2 "immediate_operand" "O,n"))
374    (use (match_operand:SI 3 "register_operand" "l,l"))
375    (return)]
376   "(DEFAULT_ABI == ABI_DARWIN)
377    && (INTVAL (operands[2]) & CALL_LONG) == 0"
379   return "b %z0";
381   [(set_attr "type" "branch,branch")
382    (set_attr "length" "4,8")])
384 (define_insn "*sibcall_value_nonlocal_darwin64"
385   [(set (match_operand 0 "" "")
386         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s,s"))
387               (match_operand 2 "" "")))
388    (use (match_operand:SI 3 "immediate_operand" "O,n"))
389    (use (match_operand:SI 4 "register_operand" "l,l"))
390    (return)]
391   "(DEFAULT_ABI == ABI_DARWIN)
392    && (INTVAL (operands[3]) & CALL_LONG) == 0"
393   "*
395   return \"b %z1\";
397   [(set_attr "type" "branch,branch")
398    (set_attr "length" "4,8")])
401 (define_insn "*sibcall_symbolic_64"
402   [(call (mem:SI (match_operand:DI 0 "call_operand" "s,c")) ; 64
403          (match_operand 1 "" ""))
404    (use (match_operand 2 "" ""))
405    (use (match_operand:SI 3 "register_operand" "l,l"))
406    (return)]
407   "TARGET_64BIT && DEFAULT_ABI == ABI_DARWIN"
408   "*
410   switch (which_alternative)
411     {
412       case 0:  return \"b %z0\";
413       case 1:  return \"b%T0\";
414       default:  gcc_unreachable ();
415     }
417   [(set_attr "type" "branch")
418    (set_attr "length" "4")])
420 (define_insn "*sibcall_value_symbolic_64"
421   [(set (match_operand 0 "" "")
422         (call (mem:SI (match_operand:DI 1 "call_operand" "s,c"))
423               (match_operand 2 "" "")))
424    (use (match_operand:SI 3 "" ""))
425    (use (match_operand:SI 4 "register_operand" "l,l"))
426    (return)]
427   "TARGET_64BIT && DEFAULT_ABI == ABI_DARWIN"
428   "*
430   switch (which_alternative)
431     {
432       case 0:  return \"b %z1\";
433       case 1:  return \"b%T1\";
434       default:  gcc_unreachable ();
435     }
437   [(set_attr "type" "branch")
438    (set_attr "length" "4")])