Debian Codegraph @

gcc/config/h8300/movepush.md

raw
1 ;; ----------------------------------------------------------------------
2 ;; MOVE INSTRUCTIONS
3 ;; ----------------------------------------------------------------------
4
5 ;; movqi
6
7 (define_insn_and_split "*movqi"
8 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m")
9 (match_operand:QI 1 "general_operand_src" " I,r>,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,n,m,r"))]
10 "!TARGET_H8300SX && h8300_move_ok (operands[0], operands[1])"
11 "#"
12 "&& reload_completed"
13 [(parallel [(set (match_dup 0) (match_dup 1))
14 (clobber (reg:CC CC_REG))])])
15
16 (define_insn "*movqi<cczn>"
17 [(set (match_operand:QI 0 "general_operand_dst" "=r,r ,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m")
18 (match_operand:QI 1 "general_operand_src" " I,r>,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,n,m,r"))
19 (clobber (reg:CC CC_REG))]
20 "!TARGET_H8300SX && h8300_move_ok (operands[0], operands[1])"
21 "@
22 sub.b %X0,%X0
23 mov.b %R1,%X0
24 mov.b %X1,%R0
25 mov.b %X1,%R0
26 mov.b %X1,%R0
27 mov.b %X1,%R0
28 mov.b %X1,%R0
29 mov.b %X1,%R0
30 mov.b %X1,%R0
31 mov.b %X1,%R0
32 mov.b %R1,%X0
33 mov.b %R1,%X0
34 mov.b %X1,%R0"
35 [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))])
36
37 (define_insn_and_split "*movqi_h8sx"
38 [(set (match_operand:QI 0 "general_operand_dst" "=Zz,rQ")
39 (match_operand:QI 1 "general_operand_src" "P4>X,rQi"))]
40 "TARGET_H8300SX"
41 "#"
42 "&& reload_completed"
43 [(parallel [(set (match_dup 0) (match_dup 1))
44 (clobber (reg:CC CC_REG))])])
45
46 (define_insn "*movqi_h8sx<cczn>"
47 [(set (match_operand:QI 0 "general_operand_dst" "=Zz,rQ")
48 (match_operand:QI 1 "general_operand_src" "P4>X,rQi"))
49 (clobber (reg:CC CC_REG))]
50 "TARGET_H8300SX"
51 "@
52 mov.b %X1:4,%X0
53 mov.b %X1,%X0"
54 [(set_attr "length_table" "mov_imm4,movb")])
55
56 (define_expand "mov<mode>"
57 [(set (match_operand:QHSIF 0 "general_operand_dst" "")
58 (match_operand:QHSIF 1 "general_operand_src" ""))]
59 ""
60 {
61 enum machine_mode mode = <MODE>mode;
62 if (!TARGET_H8300SX)
63 {
64 /* Other H8 chips, except the H8/SX family can only handle a
65 single memory operand, which is checked by h8300_move_ok.
66
67 We could perhaps have h8300_move_ok handle the H8/SX better
68 and just remove the !TARGET_H8300SX conditional. */
69 if (!h8300_move_ok (operands[0], operands[1]))
70 operands[1] = copy_to_mode_reg (mode, operand1);
71 }
72 })
73
74 (define_insn_and_split "movstrictqi"
75 [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r"))
76 (match_operand:QI 1 "general_operand_src" "I,rmi>"))]
77 ""
78 "#"
79 "&& reload_completed"
80 [(parallel [(set (strict_low_part (match_dup 0)) (match_dup 1))
81 (clobber (reg:CC CC_REG))])])
82
83
84 (define_insn "*movstrictqi<cczn>"
85 [(set (strict_low_part (match_operand:QI 0 "general_operand_dst" "+r,r"))
86 (match_operand:QI 1 "general_operand_src" "I,rmi>"))
87 (clobber (reg:CC CC_REG))]
88 ""
89 "@
90 sub.b %X0,%X0
91 mov.b %X1,%X0"
92 [(set_attr "length" "2,*")
93 (set_attr "length_table" "*,movb")])
94
95 ;; movhi
96
97 (define_insn_and_split "*movhi"
98 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m")
99 (match_operand:HI 1 "general_operand_src" "I,r>,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,i,m,r"))]
100 "!TARGET_H8300SX
101 && h8300_move_ok (operands[0], operands[1])"
102 "#"
103 "&& reload_completed"
104 [(parallel [(set (match_dup 0) (match_dup 1))
105 (clobber (reg:CC CC_REG))])])
106
107 (define_insn "*movhi<cczn>"
108 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m")
109 (match_operand:HI 1 "general_operand_src" "I,r>,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,i,m,r"))
110 (clobber (reg:CC CC_REG))]
111 "!TARGET_H8300SX
112 && h8300_move_ok (operands[0], operands[1])"
113 "@
114 sub.w %T0,%T0
115 mov.w %T1,%T0
116 mov.w %T1,%T0
117 mov.w %T1,%T0
118 mov.w %T1,%T0
119 mov.w %T1,%T0
120 mov.w %T1,%T0
121 mov.w %T1,%T0
122 mov.w %T1,%T0
123 mov.w %T1,%T0
124 mov.w %T1,%T0
125 mov.w %T1,%T0
126 mov.w %T1,%T0"
127 [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))])
128
129 (define_insn_and_split "*movhi_h8sx"
130 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Zz,Q,rQ")
131 (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi"))]
132 "TARGET_H8300SX"
133 "#"
134 "&& reload_completed"
135 [(parallel [(set (match_dup 0) (match_dup 1))
136 (clobber (reg:CC CC_REG))])])
137
138 (define_insn "*movhi_h8sx<cczn>"
139 [(set (match_operand:HI 0 "general_operand_dst" "=r,r,Zz,Q,rQ")
140 (match_operand:HI 1 "general_operand_src" "I,P3>X,P4>X,IP8>X,rQi"))
141 (clobber (reg:CC CC_REG))]
142 "TARGET_H8300SX"
143 "@
144 sub.w %T0,%T0
145 mov.w %T1:3,%T0
146 mov.w %T1:4,%T0
147 mov.w %T1,%T0
148 mov.w %T1,%T0"
149 [(set_attr "length_table" "*,*,mov_imm4,short_immediate,movw")
150 (set_attr "length" "2,2,*,*,*")])
151
152 (define_insn_and_split "movstricthi"
153 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r"))
154 (match_operand:HI 1 "general_operand_src" "I,P3>X,rmi"))]
155 ""
156 "#"
157 "&& reload_completed"
158 [(parallel [(set (strict_low_part (match_dup 0)) (match_dup 1))
159 (clobber (reg:CC CC_REG))])])
160
161 (define_insn "*movstricthi<cczn>"
162 [(set (strict_low_part (match_operand:HI 0 "general_operand_dst" "+r,r,r"))
163 (match_operand:HI 1 "general_operand_src" "I,P3>X,rmi"))
164 (clobber (reg:CC CC_REG))]
165 ""
166 "@
167 sub.w %T0,%T0
168 mov.w %T1,%T0
169 mov.w %T1,%T0"
170 [(set_attr "length" "2,2,*")
171 (set_attr "length_table" "*,*,movw")])
172
173 ;; movsi
174 (define_insn_and_split "*movsi"
175 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m,*a,*a,r")
176 (match_operand:SI 1 "general_operand_src" "I,r,i,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,>,m,r,I,r,*a"))]
177 "(TARGET_H8300S || TARGET_H8300H) && !TARGET_H8300SX
178 && h8300_move_ok (operands[0], operands[1])"
179 "#"
180 "&& reload_completed"
181 [(parallel [(set (match_dup 0) (match_dup 1))
182 (clobber (reg:CC CC_REG))])])
183
184 (define_insn "*movsi_clobber_flags"
185 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,r,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m,*a,*a, r")
186 (match_operand:SI 1 "general_operand_src" " I,r,i,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,>,m,r, I, r,*a"))
187 (clobber (reg:CC CC_REG))]
188 "(TARGET_H8300S || TARGET_H8300H) && !TARGET_H8300SX
189 && h8300_move_ok (operands[0], operands[1])"
190 {
191 switch (which_alternative)
192 {
193 case 0:
194 return "sub.l %S0,%S0";
195 case 14:
196 return "clrmac";
197 case 15:
198 return "clrmac\;ldmac %1,macl";
199 case 16:
200 return "stmac macl,%0";
201 default:
202 if (GET_CODE (operands[1]) == CONST_INT)
203 {
204 int val = INTVAL (operands[1]);
205
206 /* Look for constants which can be made by adding an 8-bit
207 number to zero in one of the two low bytes. */
208 if (val == (val & 0xff))
209 {
210 operands[1] = GEN_INT ((char) val & 0xff);
211 return "sub.l\\t%S0,%S0\;add.b\\t%1,%w0";
212 }
213
214 if (val == (val & 0xff00))
215 {
216 operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
217 return "sub.l\\t%S0,%S0\;add.b\\t%1,%x0";
218 }
219
220 /* Look for constants that can be obtained by subs, inc, and
221 dec to 0. */
222 switch (val & 0xffffffff)
223 {
224 case 0xffffffff:
225 return "sub.l\\t%S0,%S0\;subs\\t#1,%S0";
226 case 0xfffffffe:
227 return "sub.l\\t%S0,%S0\;subs\\t#2,%S0";
228 case 0xfffffffc:
229 return "sub.l\\t%S0,%S0\;subs\\t#4,%S0";
230
231 case 0x0000ffff:
232 return "sub.l\\t%S0,%S0\;dec.w\\t#1,%f0";
233 case 0x0000fffe:
234 return "sub.l\\t%S0,%S0\;dec.w\\t#2,%f0";
235
236 case 0xffff0000:
237 return "sub.l\\t%S0,%S0\;dec.w\\t#1,%e0";
238 case 0xfffe0000:
239 return "sub.l\\t%S0,%S0\;dec.w\\t#2,%e0";
240
241 case 0x00010000:
242 return "sub.l\\t%S0,%S0\;inc.w\\t#1,%e0";
243 case 0x00020000:
244 return "sub.l\\t%S0,%S0\;inc.w\\t#2,%e0";
245 }
246 }
247 }
248 return "mov.l %S1,%S0";
249 }
250 [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))])
251
252 (define_insn "*movsi_cczn"
253 [(set (reg:CCZN CC_REG)
254 (compare:CCZN
255 (match_operand:SI 1 "general_operand_src" " I,r,i,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,>,m,r")
256 (const_int 0)))
257 (set (match_operand:SI 0 "general_operand_dst" "=r,r,r,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r,r,m")
258 (match_dup 1))]
259 "(TARGET_H8300S || TARGET_H8300H) && !TARGET_H8300SX
260 && h8300_move_ok (operands[0], operands[1])"
261 "@
262 sub.l %S0,%S0
263 mov.l %S1,%S0
264 mov.l %S1,%S0
265 mov.l %S1,%S0
266 mov.l %S1,%S0
267 mov.l %S1,%S0
268 mov.l %S1,%S0
269 mov.l %S1,%S0
270 mov.l %S1,%S0
271 mov.l %S1,%S0
272 mov.l %S1,%S0
273 mov.l %S1,%S0
274 mov.l %S1,%S0
275 mov.l %S1,%S0"
276 [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))])
277
278 (define_insn_and_split "*movsi_h8sx"
279 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,Q,rQ,*a,*a,r")
280 (match_operand:SI 1 "general_operand_src" "I,P3>X,IP8>X,rQi,I,r,*a"))]
281 "TARGET_H8300SX"
282 "#"
283 "&& reload_completed"
284 [(parallel [(set (match_dup 0) (match_dup 1))
285 (clobber (reg:CC CC_REG))])])
286
287 (define_insn "*movsi_h8sx_clobber_flags"
288 [(set (match_operand:SI 0 "general_operand_dst" "=r,r,Q,rQ,*a,*a,r")
289 (match_operand:SI 1 "general_operand_src" "I,P3>X,IP8>X,rQi,I,r,*a"))
290 (clobber (reg:CC CC_REG))]
291 "TARGET_H8300SX"
292 "@
293 sub.l %S0,%S0
294 mov.l %S1:3,%S0
295 mov.l %S1,%S0
296 mov.l %S1,%S0
297 clrmac
298 clrmac\;ldmac %1,macl
299 stmac macl,%0"
300 [(set_attr "length_table" "*,*,short_immediate,movl,*,*,*")
301 (set_attr "length" "2,2,*,*,2,6,4")])
302
303 (define_insn "*movsi_h8sx_ccnz"
304 [(set (reg:CCZN CC_REG)
305 (compare:CCZN
306 (match_operand:SI 1 "general_operand_src" "I,P3>X,IP8>X,rQi")
307 (const_int 0)))
308 (set (match_operand:SI 0 "general_operand_dst" "=r,r,Q,rQ")
309 (match_dup 1))]
310 "TARGET_H8300SX"
311 "@
312 sub.l %S0,%S0
313 mov.l %S1:3,%S0
314 mov.l %S1,%S0
315 mov.l %S1,%S0"
316 [(set_attr "length_table" "*,*,short_immediate,movl")
317 (set_attr "length" "2,2,*,*")])
318
319 (define_insn_and_split "*movsf_h8sx"
320 [(set (match_operand:SF 0 "general_operand_dst" "=r,rQ")
321 (match_operand:SF 1 "general_operand_src" "G,rQi"))]
322 "TARGET_H8300SX"
323 "#"
324 "&& reload_completed"
325 [(parallel [(set (match_dup 0) (match_dup 1))
326 (clobber (reg:CC CC_REG))])])
327
328 (define_insn "*movsf_h8sx_clobber_flags"
329 [(set (match_operand:SF 0 "general_operand_dst" "=r,rQ")
330 (match_operand:SF 1 "general_operand_src" "G,rQi"))
331 (clobber (reg:CC CC_REG))]
332 "TARGET_H8300SX"
333 "@
334 sub.l %S0,%S0
335 mov.l %S1,%S0"
336 [(set_attr "length" "2,*")
337 (set_attr "length_table" "*,movl")])
338
339 (define_insn_and_split "*movsf"
340 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r")
341 (match_operand:SF 1 "general_operand_src" "G,r,im,r,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,>"))]
342 "!TARGET_H8300SX
343 && (register_operand (operands[0], SFmode)
344 || register_operand (operands[1], SFmode))"
345 "#"
346 "&& reload_completed"
347 [(parallel [(set (match_dup 0) (match_dup 1))
348 (clobber (reg:CC CC_REG))])])
349
350 (define_insn "*movsf_clobber_flags"
351 [(set (match_operand:SF 0 "general_operand_dst" "=r,r,r,m,Za,Zb,Zc,Zd,Ze,Zf,Zg,Zh,r")
352 (match_operand:SF 1 "general_operand_src" "G,r,im,r,Z0,Z1,Z2,Z3,Z4,Z5,Z6,Z7,>"))
353 (clobber (reg:CC CC_REG))]
354 "!TARGET_H8300SX
355 && (register_operand (operands[0], SFmode)
356 || register_operand (operands[1], SFmode))"
357 "@
358 sub.l %S0,%S0
359 mov.l %S1,%S0
360 mov.l %S1,%S0
361 mov.l %S1,%S0
362 mov.l %S1,%S0
363 mov.l %S1,%S0
364 mov.l %S1,%S0
365 mov.l %S1,%S0
366 mov.l %S1,%S0
367 mov.l %S1,%S0
368 mov.l %S1,%S0
369 mov.l %S1,%S0
370 mov.l %S1,%S0"
371 [(set (attr "length") (symbol_ref "compute_mov_length (operands)"))])
372
373 ;; ----------------------------------------------------------------------
374 ;; PUSH INSTRUCTIONS
375 ;; ----------------------------------------------------------------------
376
377 (define_insn_and_split "*push1_<QHI:mode>"
378 [(set (mem:QHI
379 (pre_modify:P
380 (reg:P SP_REG)
381 (plus:P (reg:P SP_REG) (const_int -4))))
382 (match_operand:QHI 0 "register_no_sp_elim_operand" "r"))]
383 ""
384 "#"
385 "&& reload_completed"
386 [(parallel [(set (mem:QHI
387 (pre_modify:P (reg:P SP_REG)
388 (plus:P (reg:P SP_REG) (const_int -4))))
389 (match_dup 0))
390 (clobber (reg:CC CC_REG))])])
391
392 (define_insn "*push1_<QHI:mode><cczn>"
393 [(set (mem:QHI
394 (pre_modify:P
395 (reg:P SP_REG)
396 (plus:P (reg:P SP_REG) (const_int -4))))
397 (match_operand:QHI 0 "register_no_sp_elim_operand" "r"))
398 (clobber (reg:CC CC_REG))]
399 ""
400 "mov.l\\t%S0,@-er7"
401 [(set_attr "length" "4")])
402