1 ;; C-SKY FPUV2 instruction descriptions.
2 ;; Copyright (C) 2018-2022 Free Software Foundation, Inc.
3 ;; Contributed by C-SKY Microsystems and Mentor Graphics.
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; GCC is distributed in the hope that it will be useful, but
13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 ;; General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>. */
21 ;; -------------------------------------------------------------------------
22 ;; Float Abs instructions
23 ;; -------------------------------------------------------------------------
25 (define_insn "*fpuv2_abssf2"
26 [(set (match_operand:SF 0 "register_operand" "=v,a,r")
27 (abs:SF (match_operand:SF 1 "register_operand" "v, 0,r")))]
28 "CSKY_ISA_FEATURE (fpv2_sf)"
33 [(set_attr "length" "4,2,4")])
35 (define_insn "*fpuv2_absdf2"
36 [(set (match_operand:DF 0 "register_operand" "=v")
37 (abs:DF (match_operand:DF 1 "register_operand" "v")))]
38 "CSKY_ISA_FEATURE (fpv2_df)"
42 ;; -------------------------------------------------------------------------
43 ;; Float Neg instructions
44 ;; -------------------------------------------------------------------------
46 (define_insn "*fpuv2_negsf2"
47 [(set (match_operand:SF 0 "register_operand" "=v")
48 (neg:SF (match_operand:SF 1 "register_operand" "v")))]
49 "CSKY_ISA_FEATURE (fpv2_sf)"
52 (define_insn "*fpuv2_negdf2"
53 [(set (match_operand:DF 0 "register_operand" "=v")
54 (neg:DF (match_operand:DF 1 "register_operand" "v")))]
55 "CSKY_ISA_FEATURE (fpv2_df)"
59 ;; -------------------------------------------------------------------------
60 ;; Float Sqrt instructions
61 ;; -------------------------------------------------------------------------
63 (define_insn "*fpuv2_sqrtsf2"
64 [(set (match_operand:SF 0 "register_operand" "=v")
65 (sqrt:SF (match_operand:SF 1 "register_operand" "v")))]
66 "CSKY_ISA_FEATURE (fpv2_sf)"
69 (define_insn "*fpuv2_sqrtdf2"
70 [(set (match_operand:DF 0 "register_operand" "=v")
71 (sqrt:DF (match_operand:DF 1 "register_operand" "v")))]
72 "CSKY_ISA_FEATURE (fpv2_divd)"
76 ;; -------------------------------------------------------------------------
77 ;; Float Add instructions
78 ;; -------------------------------------------------------------------------
80 (define_insn "*fpuv2_addsf3"
81 [(set (match_operand:SF 0 "register_operand" "=v")
82 (plus:SF (match_operand:SF 1 "register_operand" "v")
83 (match_operand:SF 2 "register_operand" "v")))]
84 "CSKY_ISA_FEATURE (fpv2_sf)"
87 (define_insn "*fpuv2_adddf3"
88 [(set (match_operand:DF 0 "register_operand" "=v")
89 (plus:DF (match_operand:DF 1 "register_operand" "v")
90 (match_operand:DF 2 "register_operand" "v")))]
91 "CSKY_ISA_FEATURE (fpv2_df)"
95 ;; -------------------------------------------------------------------------
96 ;; Float Sub instructions
97 ;; -------------------------------------------------------------------------
99 (define_insn "*fpuv2_subsf3"
100 [(set (match_operand:SF 0 "register_operand" "=v")
101 (minus:SF (match_operand:SF 1 "register_operand" "v")
102 (match_operand:SF 2 "register_operand" "v")))]
103 "CSKY_ISA_FEATURE (fpv2_sf)"
106 (define_insn "*fpuv2_subdf3"
107 [(set (match_operand:DF 0 "register_operand" "=v")
108 (minus:DF (match_operand:DF 1 "register_operand" "v")
109 (match_operand:DF 2 "register_operand" "v")))]
110 "CSKY_ISA_FEATURE (fpv2_df)"
114 ;; -------------------------------------------------------------------------
115 ;; Float Mul instructions
116 ;; -------------------------------------------------------------------------
118 (define_insn "*fpv2_mulsf3"
119 [(set (match_operand:SF 0 "register_operand" "=v")
120 (mult:SF (match_operand:SF 1 "register_operand" "v")
121 (match_operand:SF 2 "register_operand" "v")))]
122 "CSKY_ISA_FEATURE (fpv2_sf)"
125 (define_insn "*fpv2_muldf3"
126 [(set (match_operand:DF 0 "register_operand" "=v")
127 (mult:DF (match_operand:DF 1 "register_operand" "v")
128 (match_operand:DF 2 "register_operand" "v")))]
129 "CSKY_ISA_FEATURE (fpv2_df)"
132 (define_insn "*fpuv2_nmulsf3_1"
133 [(set (match_operand:SF 0 "register_operand" "=v")
134 (mult:SF (neg:SF (match_operand:SF 1 "register_operand" "%v"))
135 (match_operand:SF 2 "register_operand" "v")))]
136 "CSKY_ISA_FEATURE (fpv2_sf) && !flag_rounding_math"
137 "fnmuls\t%0, %1, %2")
139 (define_insn "*fpuv2_nmulsf3_2"
140 [(set (match_operand:SF 0 "register_operand" "=v")
141 (neg:SF (mult:SF (match_operand:SF 1 "register_operand" "v")
142 (match_operand:SF 2 "register_operand" "v"))))]
143 "CSKY_ISA_FEATURE (fpv2_sf)"
144 "fnmuls\t%0, %1, %2")
146 (define_insn "*fpuv2_nmuldf3_1"
147 [(set (match_operand:DF 0 "register_operand" "=v")
148 (mult:DF (neg:DF (match_operand:DF 1 "register_operand" "%v"))
149 (match_operand:DF 2 "register_operand" "v")))]
150 "CSKY_ISA_FEATURE (fpv2_df) && !flag_rounding_math"
151 "fnmuld\t%0, %1, %2")
153 (define_insn "*fpuv2_nmuldf3_2"
154 [(set (match_operand:DF 0 "register_operand" "=v")
155 (neg:DF (mult:DF (match_operand:DF 1 "register_operand" "v")
156 (match_operand:DF 2 "register_operand" "v"))))]
157 "CSKY_ISA_FEATURE (fpv2_df)"
158 "fnmuld\t%0, %1, %2")
161 ;; -------------------------------------------------------------------------
162 ;; Float Div instructions
163 ;; -------------------------------------------------------------------------
165 (define_insn "*fpuv2_divsf3"
166 [(set (match_operand:SF 0 "register_operand" "=v")
167 (div:SF (match_operand:SF 1 "register_operand" "v")
168 (match_operand:SF 2 "register_operand" "v")))]
169 "CSKY_ISA_FEATURE (fpv2_sf)"
172 (define_insn "*fpuv2_1_divsf3"
173 [(set (match_operand:SF 0 "register_operand" "=v")
174 (div:SF (match_operand:SF 1 "csky_const_float1_operand" "i")
175 (match_operand:SF 2 "register_operand" "v")))]
176 "CSKY_ISA_FEATURE (fpv2_sf)"
179 (define_insn "*fpuv2_divdf3"
180 [(set (match_operand:DF 0 "register_operand" "=v")
181 (div:DF (match_operand:DF 1 "register_operand" "v")
182 (match_operand:DF 2 "register_operand" "v")))]
183 "CSKY_ISA_FEATURE (fpv2_divd)"
186 (define_insn "*fpuv2_1_divdf3"
187 [(set (match_operand:DF 0 "register_operand" "=v")
188 (div:DF (match_operand:DF 1 "csky_const_float1_operand" "i")
189 (match_operand:DF 2 "register_operand" "v")))]
190 "CSKY_ISA_FEATURE (fpv2_divd)"
194 ;; -------------------------------------------------------------------------
195 ;; Float add(sub) with mult instructions
196 ;; -------------------------------------------------------------------------
198 ;; vrz <= vrz + vrx * vry
199 (define_insn "*fpuv2_fmacs"
200 [(set (match_operand:SF 0 "register_operand" "=v")
201 (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "v")
202 (match_operand:SF 2 "register_operand" "v"))
203 (match_operand:SF 3 "register_operand" "0")))]
204 "CSKY_ISA_FEATURE (fpv2_sf)"
207 (define_insn "*fpuv2_fmacd"
208 [(set (match_operand:DF 0 "register_operand" "=v")
209 (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "v")
210 (match_operand:DF 2 "register_operand" "v"))
211 (match_operand:DF 3 "register_operand" "0")))]
212 "CSKY_ISA_FEATURE (fpv2_df)"
215 ;; vrz <= vrz - vrx * vry
216 (define_insn "*fpuv2_fnmacs"
217 [(set (match_operand:SF 0 "register_operand" "=v")
218 (minus:SF (match_operand:SF 1 "register_operand" "0")
219 (mult:SF (match_operand:SF 2 "register_operand" "v")
220 (match_operand:SF 3 "register_operand" "v"))))]
221 "CSKY_ISA_FEATURE (fpv2_sf)"
222 "fnmacs\t%0, %2, %3")
224 (define_insn "*fpuv2_fnmacd"
225 [(set (match_operand:DF 0 "register_operand" "=v")
226 (minus:DF (match_operand:DF 1 "register_operand" "0")
227 (mult:DF (match_operand:DF 2 "register_operand" "v")
228 (match_operand:DF 3 "register_operand" "v"))))]
229 "CSKY_ISA_FEATURE (fpv2_df)"
230 "fnmacd\t%0, %2, %3")
232 ;; vrz <= vrx * vry - vrz
233 (define_insn "*fpuv2_fmscs"
234 [(set (match_operand:SF 0 "register_operand" "=v")
235 (minus:SF (mult:SF (match_operand:SF 1 "register_operand" "v")
236 (match_operand:SF 2 "register_operand" "v"))
237 (match_operand:SF 3 "register_operand" "0")))]
238 "CSKY_ISA_FEATURE (fpv2_sf)"
241 (define_insn "*fpuv2_fmscd"
242 [(set (match_operand:DF 0 "register_operand" "=v")
243 (minus:DF (mult:DF (match_operand:DF 1 "register_operand" "v")
244 (match_operand:DF 2 "register_operand" "v"))
245 (match_operand:DF 3 "register_operand" "0")))]
246 "CSKY_ISA_FEATURE (fpv2_df)"
249 ;; vrz = - (vrz + vrx * vry)
250 (define_insn "*fpuv2_fnmscs_1"
251 [(set (match_operand:SF 0 "register_operand" "=v")
252 (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "register_operand" "%v"))
253 (match_operand:SF 2 "register_operand" "v"))
254 (match_operand:SF 3 "register_operand" "0")))]
255 "CSKY_ISA_FEATURE (fpv2_sf)"
256 "fnmscs\t%0, %1, %2")
258 (define_insn "*fpuv2_fnmscs_2"
259 [(set (match_operand:SF 0 "register_operand" "=v")
260 (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "register_operand" "v")
261 (match_operand:SF 2 "register_operand" "v"))
262 (match_operand:SF 3 "register_operand" "0"))))]
263 "CSKY_ISA_FEATURE (fpv2_sf)"
264 "fnmscs\t%0, %1, %2")
266 (define_insn "*fpuv2_fnmscd_1"
267 [(set (match_operand:DF 0 "register_operand" "=v")
268 (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "register_operand" "%v"))
269 (match_operand:DF 2 "register_operand" "v"))
270 (match_operand:DF 3 "register_operand" "0")))]
271 "CSKY_ISA_FEATURE (fpv2_df)"
272 "fnmscd\t%0, %1, %2")
274 (define_insn "*fpuv2_fnmscd_2"
275 [(set (match_operand:DF 0 "register_operand" "=v")
276 (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "register_operand" "v")
277 (match_operand:DF 2 "register_operand" "v"))
278 (match_operand:DF 3 "register_operand" "0"))))]
279 "CSKY_ISA_FEATURE (fpv2_df)"
280 "fnmscd\t%0, %1, %2")
283 ;; -------------------------------------------------------------------------
284 ;; Float compare instructions
285 ;; -------------------------------------------------------------------------
287 (define_insn "*fpuv2_unordered"
288 [(set (reg:CC 33) (unordered:CC (match_operand:SF 0 "register_operand" "v")
289 (match_operand:SF 1 "register_operand" "v")))]
290 "CSKY_ISA_FEATURE (fpv2_sf)"
293 (define_insn "*fpuv2_unordered_zero"
294 [(set (reg:CC 33) (unordered:CC (match_operand:SF 0 "register_operand" "v")
295 (match_operand:SF 1 "csky_const_float0_operand" "i")))]
296 "CSKY_ISA_FEATURE (fpv2_sf)"
299 (define_insn "*fpuv2_ne"
300 [(set (reg:CC 33) (ne:CC (match_operand:SF 0 "register_operand" "v")
301 (match_operand:SF 1 "register_operand" "v")))]
302 "CSKY_ISA_FEATURE (fpv2_sf)"
305 (define_insn "*fpuv2_gt"
306 [(set (reg:CC 33) (gt:CC (match_operand:SF 0 "register_operand" "v")
307 (match_operand:SF 1 "register_operand" "v")))]
308 "CSKY_ISA_FEATURE (fpv2_sf)"
311 (define_insn "*fpuv2_ge"
312 [(set (reg:CC 33) (ge:CC (match_operand:SF 0 "register_operand" "v")
313 (match_operand:SF 1 "register_operand" "v")))]
314 "CSKY_ISA_FEATURE (fpv2_sf)"
317 (define_insn "*fpuv2_lt"
318 [(set (reg:CC 33) (lt:CC (match_operand:SF 0 "register_operand" "v")
319 (match_operand:SF 1 "register_operand" "v")))]
320 "CSKY_ISA_FEATURE (fpv2_sf)"
323 (define_insn "*fpuv2_le"
324 [(set (reg:CC 33) (le:CC (match_operand:SF 0 "register_operand" "v")
325 (match_operand:SF 1 "register_operand" "v")))]
326 "CSKY_ISA_FEATURE (fpv2_sf)"
329 (define_insn "*fpuv2_gez"
330 [(set (reg:CC 33) (ge:CC (match_operand:SF 0 "register_operand" "v")
331 (match_operand:SF 1 "csky_const_float0_operand" "i")))]
332 "CSKY_ISA_FEATURE (fpv2_sf)"
335 (define_insn "*fpuv2_nez"
336 [(set (reg:CC 33) (ne:CC (match_operand:SF 0 "register_operand" "v")
337 (match_operand:SF 1 "csky_const_float0_operand" "i")))]
338 "CSKY_ISA_FEATURE (fpv2_sf)"
341 (define_insn "*fpuv2_dunordered"
342 [(set (reg:CC 33) (unordered:CC (match_operand:DF 0 "register_operand" "v")
343 (match_operand:DF 1 "register_operand" "v")))]
344 "CSKY_ISA_FEATURE (fpv2_df)"
347 (define_insn "*fpuv2_dunordered_zero"
348 [(set (reg:CC 33) (unordered:CC (match_operand:DF 0 "register_operand" "v")
349 (match_operand:DF 1 "csky_const_float0_operand" "i")))]
350 "CSKY_ISA_FEATURE (fpv2_df)"
353 (define_insn "*fpuv2_dne"
354 [(set (reg:CC 33) (ne:CC (match_operand:DF 0 "register_operand" "v")
355 (match_operand:DF 1 "register_operand" "v")))]
356 "CSKY_ISA_FEATURE (fpv2_df)"
359 (define_insn "*fpuv2_dgt"
360 [(set (reg:CC 33) (gt:CC (match_operand:DF 0 "register_operand" "v")
361 (match_operand:DF 1 "register_operand" "v")))]
362 "CSKY_ISA_FEATURE (fpv2_df)"
365 (define_insn "*fpuv2_dge"
366 [(set (reg:CC 33) (ge:CC (match_operand:DF 0 "register_operand" "v")
367 (match_operand:DF 1 "register_operand" "v")))]
368 "CSKY_ISA_FEATURE (fpv2_df)"
371 (define_insn "*fpuv2_dlt"
372 [(set (reg:CC 33) (lt:CC (match_operand:DF 0 "register_operand" "v")
373 (match_operand:DF 1 "register_operand" "v")))]
374 "CSKY_ISA_FEATURE (fpv2_df)"
377 (define_insn "*fpuv2_dle"
378 [(set (reg:CC 33) (le:CC (match_operand:DF 0 "register_operand" "v")
379 (match_operand:DF 1 "register_operand" "v")))]
380 "CSKY_ISA_FEATURE (fpv2_df)"
383 (define_insn "*fpuv2_dgez"
384 [(set (reg:CC 33) (ge:CC (match_operand:DF 0 "register_operand" "v")
385 (match_operand:DF 1 "csky_const_float0_operand" "i")))]
386 "CSKY_ISA_FEATURE (fpv2_df)"
389 (define_insn "*fpuv2_dnez"
390 [(set (reg:CC 33) (ne:CC (match_operand:DF 0 "register_operand" "v")
391 (match_operand:DF 1 "csky_const_float0_operand" "i")))]
392 "CSKY_ISA_FEATURE (fpv2_df)"
396 ;; -------------------------------------------------------------------------
397 ;; Float convert instructions
398 ;; -------------------------------------------------------------------------
401 (define_insn "*fpuv2_extendsfdf2"
402 [(set (match_operand:DF 0 "register_operand" "=v")
403 (float_extend:DF (match_operand:SF 1 "register_operand" "v")))]
404 "CSKY_ISA_FEATURE (fpv2_df)"
408 (define_insn "*fpuv2_truncdfsf2"
409 [(set (match_operand:SF 0 "register_operand" "=v")
410 (float_truncate:SF (match_operand:DF 1 "register_operand" "v")))]
411 "CSKY_ISA_FEATURE (fpv2_df)"
415 (define_insn "*fpuv2_floatsisf2"
416 [(set (match_operand:SF 0 "register_operand" "=v")
417 (float:SF (match_operand:SI 1 "register_operand" "v")))]
418 "CSKY_ISA_FEATURE (fpv2_sf)"
422 (define_insn "*fpuv2_floatsidf2"
423 [(set (match_operand:DF 0 "register_operand" "=v")
424 (float:DF (match_operand:SI 1 "register_operand" "v")))]
425 "CSKY_ISA_FEATURE (fpv2_df)"
429 (define_insn "*fpuv2_floatunssisf2"
430 [(set (match_operand:SF 0 "register_operand" "=v")
431 (unsigned_float:SF (match_operand:SI 1 "register_operand" "v")))]
432 "CSKY_ISA_FEATURE (fpv2_sf)"
436 (define_insn "*fpuv2_floatunssidf2"
437 [(set (match_operand:DF 0 "register_operand" "=v")
438 (unsigned_float:DF (match_operand:SI 1 "register_operand" "v")))]
439 "CSKY_ISA_FEATURE (fpv2_df)"
443 (define_insn "*fpuv2_fix_truncsfsi2"
444 [(set (match_operand:SI 0 "register_operand" "=v")
445 (fix:SI (fix:SF (match_operand:SF 1 "register_operand" "v"))))]
446 "CSKY_ISA_FEATURE (fpv2_sf)"
450 (define_insn "*fpuv2_fix_truncdfsi2"
451 [(set (match_operand:SI 0 "register_operand" "=v")
452 (fix:SI (fix:DF (match_operand:DF 1 "register_operand" "v"))))]
453 "CSKY_ISA_FEATURE (fpv2_df)"
457 (define_insn "*fpuv2_fixuns_truncsfsi2"
458 [(set (match_operand:SI 0 "register_operand" "=v")
459 (unsigned_fix:SI (fix:SF (match_operand:SF 1 "register_operand" "v"))))]
460 "CSKY_ISA_FEATURE (fpv2_sf)"
464 (define_insn "*fpuv2_fixuns_truncdfsi2"
465 [(set (match_operand:SI 0 "register_operand" "=v")
466 (unsigned_fix:SI (fix:DF (match_operand:DF 1 "register_operand" "v"))))]
467 "CSKY_ISA_FEATURE (fpv2_df)"
471 ;; -------------------------------------------------------------------------
472 ;; Float mov instructions
473 ;; -------------------------------------------------------------------------
475 (define_insn "*fpuv2_movsf"
476 [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r, r,m,v,r,Q,v,v,v")
477 (match_operand:SF 1 "general_operand" " r,m,mF,r,r,v,v,Q,v,W"))]
478 "CSKY_ISA_FEATURE (fpv2_sf)"
479 "* return csky_output_move(insn, operands, SFmode);"
482 (define_insn "*fpuv2_movdf"
483 [(set (match_operand:DF 0 "nonimmediate_operand" "=r, v,?r,Q,v,v,v,r, r,Y")
484 (match_operand:DF 1 "general_operand" " r,?r, v,v,Q,v,m,Y,YF,r"))]
485 "CSKY_ISA_FEATURE (fpv2_df)"
486 "* return csky_output_movedouble(operands, DFmode);"
487 [(set (attr "length")
488 (symbol_ref "csky_get_movedouble_length (operands)"))]