OSDN Git Service

Backport from mainline
[pf3gnuchains/gcc-fork.git] / gcc / config / m32c / prologue.md
1 ;; Machine Descriptions for R8C/M16C/M32C
2 ;; Copyright (C) 2005, 2007, 2008
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by Red Hat.
5 ;;
6 ;; This file is part of GCC.
7 ;;
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 3, or (at your
11 ;; option) any later version.
12 ;;
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16 ;; License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
21
22 ;; Prologue and epilogue patterns
23
24 (define_expand "prologue"
25   [(const_int 1)]
26   ""
27   "m32c_emit_prologue(); DONE;"
28   )
29
30 ; For the next two, operands[0] is the amount of stack space we want
31 ; to reserve.
32
33 ; We assume dwarf2out will process each set in sequence.
34 (define_insn "prologue_enter_16"
35   [(set (mem:HI (plus:HI (reg:HI SP_REGNO) (const_int -2)))
36         (reg:HI FB_REGNO))
37    (set (reg:HI FB_REGNO)
38         (plus:HI (reg:HI SP_REGNO) (const_int -2)))
39    (set (reg:HI SP_REGNO)
40         (minus:HI (reg:HI SP_REGNO)
41                    (match_operand 0 "const_int_operand" "i")))
42    ]
43   "TARGET_A16"
44   {
45     /* This is due to binutils bug gas/4659.  */
46     if (INTVAL (operands[0]) == 2)
47       return "enter\t#0";
48     return "enter\t%0-2";
49   }
50   [(set_attr "flags" "x")]
51   )
52
53 (define_insn "prologue_enter_24"
54   [(set (mem:SI (plus:PSI (reg:PSI SP_REGNO) (const_int -4)))
55         (reg:SI FB_REGNO))
56    (set (reg:PSI FB_REGNO)
57         (plus:PSI (reg:PSI SP_REGNO) (const_int -4)))
58    (set (reg:PSI SP_REGNO)
59         (minus:PSI (reg:PSI SP_REGNO)
60                    (match_operand 0 "const_int_operand" "i")))
61    ]
62   "TARGET_A24"
63   {
64     /* This is due to binutils bug gas/4659.  */
65     if (INTVAL (operands[0]) == 4)
66       return "enter\t#0";
67     return "enter\t%0-4";
68   }
69   [(set_attr "flags" "x")]
70   )
71
72 ; Just a comment, for debugging the assembler output.
73 (define_insn "prologue_end"
74   [(unspec_volatile [(const_int 0)] UNS_PROLOGUE_END)]
75   ""
76   "; end of prologue"
77   [(set_attr "flags" "n")]
78   )
79
80
81
82 (define_expand "epilogue"
83   [(const_int 1)]
84   ""
85   "m32c_emit_epilogue(); DONE;"
86   )
87
88 (define_expand "eh_return"
89   [(match_operand:PSI 0 "" "")]
90   ""
91   "m32c_emit_eh_epilogue(operands[0]);
92    emit_barrier ();
93    DONE;"
94   )
95
96 (define_insn "eh_epilogue"
97   [(set (pc)
98         (unspec_volatile [(match_operand 0 "m32c_r1_operand" "")
99                           (match_operand 1 "m32c_r0_operand" "")
100                           ] UNS_EH_EPILOGUE))
101    (return)]
102   ""
103   "jmp.a\t__m32c_eh_return"
104   [(set_attr "flags" "x")]
105   )
106
107 (define_insn "epilogue_exitd_16"
108   [(set (reg:HI SP_REGNO)
109         (plus:HI (reg:HI FB_REGNO)
110               (const_int 2)))
111    (set (reg:HI FB_REGNO)
112         (mem:HI (reg:HI FB_REGNO)))
113    (return)
114    ]
115   "TARGET_A16"
116   "exitd"
117   [(set_attr "flags" "x")]
118   )
119
120 (define_insn "epilogue_reit_16"
121   [(set (reg:HI SP_REGNO)
122         (plus:HI (reg:HI SP_REGNO)
123               (const_int 4)))
124    (return)
125    ]
126   "TARGET_A16"
127   "reit"
128   [(set_attr "flags" "x")]
129   )
130
131 (define_insn "epilogue_exitd_24"
132   [(set (reg:PSI SP_REGNO)
133         (plus:PSI (reg:PSI FB_REGNO)
134               (const_int 4)))
135    (set (reg:PSI FB_REGNO)
136         (mem:PSI (reg:PSI FB_REGNO)))
137    (return)
138    ]
139   "TARGET_A24"
140   "exitd"
141   [(set_attr "flags" "x")]
142   )
143
144 (define_insn "epilogue_reit_24"
145   [(set (reg:PSI SP_REGNO)
146         (plus:PSI (reg:PSI SP_REGNO)
147               (const_int 6)))
148    (return)
149    ]
150   "TARGET_A24"
151   "reit"
152   [(set_attr "flags" "x")]
153   )
154
155 (define_insn "epilogue_freit"
156   [(unspec [(const_int 0)] UNS_FREIT)
157    (return)
158    ]
159   ""
160   "freit"
161   [(set_attr "flags" "x")]
162   )
163
164 (define_insn "epilogue_rts"
165   [(return)
166    ]
167   ""
168   "rts"
169   [(set_attr "flags" "x")]
170   )
171
172 (define_insn "epilogue_start"
173   [(unspec_volatile [(const_int 0)] UNS_EPILOGUE_START)]
174   ""
175   "; start of epilogue"
176   [(set_attr "flags" "n")]
177   )
178
179
180 ; These are used by the prologue/epilogue code.
181
182 (define_insn "pushm"
183   [(unspec [(match_operand 0 "const_int_operand" "i")] UNS_PUSHM)]
184   ""
185   "pushm\t%p0"
186   [(set_attr "flags" "n")]
187   )
188
189 (define_insn "popm"
190   [(unspec [(match_operand 0 "const_int_operand" "i")] UNS_POPM)]
191   ""
192   "popm\t%p0"
193   [(set_attr "flags" "n")]
194   )
195
196 (define_insn "fset_b"
197   [(unspec [(const_int 0)] UNS_FSETB)]
198   ""
199   "fset\tB"
200   [(set_attr "flags" "n")]
201   )
202