1 ;; Machine description for OpenRISC
2 ;; Copyright (C) 2018-2025 Free Software Foundation, Inc.
3 ;; Contributed by Stafford Horne
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
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; 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 ;; OpenRISC specific constraints, predicates and attributes
23 ;; -------------------------------------------------------------------------
25 (include "constraints.md")
26 (include "predicates.md")
41 (define_c_enum "unspec" [
51 (define_c_enum "unspecv" [
57 ;; Instruction scheduler
59 ; Most instructions are 4 bytes long.
60 (define_attr "length" "" (const_int 4))
63 "alu,st,ld,control,multi,fpu"
66 (define_attr "insn_support" "class1,sext,sfimm,shftimm,ror,rori" (const_string "class1"))
68 (define_attr "enabled" ""
69 (cond [(eq_attr "insn_support" "class1") (const_int 1)
70 (and (eq_attr "insn_support" "sext")
71 (ne (symbol_ref "TARGET_SEXT") (const_int 0))) (const_int 1)
72 (and (eq_attr "insn_support" "sfimm")
73 (ne (symbol_ref "TARGET_SFIMM") (const_int 0))) (const_int 1)
74 (and (eq_attr "insn_support" "shftimm")
75 (ne (symbol_ref "TARGET_SHFTIMM") (const_int 0))) (const_int 1)
76 (and (eq_attr "insn_support" "ror")
77 (ne (symbol_ref "TARGET_ROR") (const_int 0))) (const_int 1)
78 (and (eq_attr "insn_support" "rori")
79 (ne (symbol_ref "TARGET_RORI") (const_int 0))) (const_int 1)]
82 ;; Describe a user's asm statement.
83 (define_asm_attributes
84 [(set_attr "type" "multi")])
86 (define_automaton "or1k")
87 (define_cpu_unit "cpu" "or1k")
88 (define_insn_reservation "alu" 1
89 (eq_attr "type" "alu")
91 (define_insn_reservation "st" 1
94 (define_insn_reservation "ld" 3
97 (define_insn_reservation "control" 1
98 (eq_attr "type" "control")
100 (define_insn_reservation "fpu" 2
101 (eq_attr "type" "fpu")
105 ; Define delay slots for any branch
106 (define_delay (eq_attr "type" "control")
107 [(eq_attr "type" "alu,st,ld") (nil) (nil)])
109 ;; -------------------------------------------------------------------------
111 ;; -------------------------------------------------------------------------
118 ;; -------------------------------------------------------------------------
119 ;; Arithmetic instructions
120 ;; -------------------------------------------------------------------------
122 (define_insn "addsi3"
123 [(set (match_operand:SI 0 "register_operand" "=r,r")
125 (match_operand:SI 1 "register_operand" "%r,r")
126 (match_operand:SI 2 "reg_or_s16_operand" " r,I")))]
132 (define_insn "mulsi3"
133 [(set (match_operand:SI 0 "register_operand" "=r,r")
135 (match_operand:SI 1 "register_operand" "%r,r")
136 (match_operand:SI 2 "reg_or_s16_operand" " r,I")))]
142 (define_insn "divsi3"
143 [(set (match_operand:SI 0 "register_operand" "=r")
145 (match_operand:SI 1 "register_operand" "r")
146 (match_operand:SI 2 "register_operand" "r")))]
150 (define_insn "udivsi3"
151 [(set (match_operand:SI 0 "register_operand" "=r")
153 (match_operand:SI 1 "register_operand" "r")
154 (match_operand:SI 2 "register_operand" "r")))]
156 "l.divu\t%0, %1, %2")
158 (define_insn "subsi3"
159 [(set (match_operand:SI 0 "register_operand" "=r")
161 (match_operand:SI 1 "reg_or_0_operand" "rO")
162 (match_operand:SI 2 "register_operand" "r")))]
164 "l.sub\t%0, %r1, %2")
166 ;; -------------------------------------------------------------------------
167 ;; Floating Point Arithmetic instructions
168 ;; -------------------------------------------------------------------------
170 ;; Mode iterator for single/double float
171 (define_mode_iterator F [(SF "TARGET_HARD_FLOAT")
172 (DF "TARGET_DOUBLE_FLOAT")])
173 (define_mode_attr f [(SF "s") (DF "d")])
174 (define_mode_attr fr [(SF "r") (DF "d")])
175 (define_mode_attr fi [(SF "si") (DF "di")])
176 (define_mode_attr FI [(SF "SI") (DF "DI")])
178 ;; Basic arithmetic instructions
179 (define_code_iterator FOP [plus minus mult div])
180 (define_code_attr fop [(plus "add") (minus "sub") (mult "mul") (div "div")])
182 (define_insn "<fop><F:mode>3"
183 [(set (match_operand:F 0 "register_operand" "=<fr>")
184 (FOP:F (match_operand:F 1 "register_operand" "<fr>")
185 (match_operand:F 2 "register_operand" "<fr>")))]
187 "lf.<fop>.<f>\t%d0, %d1, %d2"
188 [(set_attr "type" "fpu")])
190 ;; Basic float<->int conversion
191 (define_insn "float<fi><F:mode>2"
192 [(set (match_operand:F 0 "register_operand" "=<fr>")
194 (match_operand:<FI> 1 "register_operand" "<fr>")))]
196 "lf.itof.<f>\t%d0, %d1"
197 [(set_attr "type" "fpu")])
199 (define_insn "fix_trunc<F:mode><fi>2"
200 [(set (match_operand:<FI> 0 "register_operand" "=<fr>")
202 (match_operand:F 1 "register_operand" "<fr>")))]
204 "lf.ftoi.<f>\t%d0, %d1"
205 [(set_attr "type" "fpu")])
207 ;; -------------------------------------------------------------------------
209 ;; -------------------------------------------------------------------------
211 (define_code_iterator SHIFT [ashift ashiftrt lshiftrt])
212 (define_code_attr shift_op [(ashift "ashl") (ashiftrt "ashr")
214 (define_code_attr shift_asm [(ashift "sll") (ashiftrt "sra")
217 (define_insn "<shift_op>si3"
218 [(set (match_operand:SI 0 "register_operand" "=r,r")
219 (SHIFT:SI (match_operand:SI 1 "register_operand" "r,r")
220 (match_operand:SI 2 "reg_or_u6_operand" "r,n")))]
223 l.<shift_asm>\t%0, %1, %2
224 l.<shift_asm>i\t%0, %1, %2"
225 [(set_attr "insn_support" "*,shftimm")])
227 (define_insn "rotrsi3"
228 [(set (match_operand:SI 0 "register_operand" "=r,r")
229 (rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
230 (match_operand:SI 2 "ror_reg_or_u6_operand" "r,n")))]
231 "TARGET_ROR || TARGET_RORI"
235 [(set_attr "insn_support" "ror,rori")])
237 (define_insn "andsi3"
238 [(set (match_operand:SI 0 "register_operand" "=r,r")
240 (match_operand:SI 1 "register_operand" "%r,r")
241 (match_operand:SI 2 "reg_or_u16_operand" " r,K")))]
247 (define_insn "xorsi3"
248 [(set (match_operand:SI 0 "register_operand" "=r,r")
250 (match_operand:SI 1 "register_operand" "%r,r")
251 (match_operand:SI 2 "reg_or_s16_operand" " r,I")))]
257 (define_insn "iorsi3"
258 [(set (match_operand:SI 0 "register_operand" "=r,r")
260 (match_operand:SI 1 "register_operand" "%r,r")
261 (match_operand:SI 2 "reg_or_u16_operand" " r,K")))]
267 (define_expand "one_cmplsi2"
268 [(set (match_operand:SI 0 "register_operand" "")
269 (xor:SI (match_operand:SI 1 "register_operand" "") (const_int -1)))]
273 ;; -------------------------------------------------------------------------
275 ;; -------------------------------------------------------------------------
277 (define_mode_iterator I [QI HI SI])
278 (define_mode_iterator I12 [QI HI])
280 (define_mode_attr ldst [(QI "b") (HI "h") (SI "w")])
281 (define_mode_attr zext_andi [(QI "0xff") (HI "0xffff")])
283 (define_expand "mov<I:mode>"
284 [(set (match_operand:I 0 "nonimmediate_operand" "")
285 (match_operand:I 1 "general_operand" ""))]
288 or1k_expand_move (<MODE>mode, operands[0], operands[1]);
292 ;; 8-bit, 16-bit and 32-bit moves
294 (define_insn "*mov<I:mode>_internal"
295 [(set (match_operand:I 0 "nonimmediate_operand" "=r,r,r,r, m,r")
296 (match_operand:I 1 "input_operand" " r,M,K,I,rO,m"))]
297 "register_operand (operands[0], <I:MODE>mode)
298 || reg_or_0_operand (operands[1], <I:MODE>mode)"
305 l.l<I:ldst>z\t%0, %1"
306 [(set_attr "type" "alu,alu,alu,alu,st,ld")])
308 ;; Hi/Low moves for constant and symbol loading
310 (define_insn "movsi_high"
311 [(set (match_operand:SI 0 "register_operand" "=r")
312 (high:SI (match_operand:SI 1 "high_operand" "")))]
315 [(set_attr "type" "alu")])
317 (define_insn "*movsi_lo_sum_iori"
318 [(set (match_operand:SI 0 "register_operand" "=r")
319 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
320 (match_operand:SI 2 "losum_ior_operand" "")))]
323 [(set_attr "type" "alu")])
325 (define_insn "*movsi_lo_sum_addi"
326 [(set (match_operand:SI 0 "register_operand" "=r")
327 (lo_sum:SI (match_operand:SI 1 "register_operand" "r")
328 (match_operand:SI 2 "losum_add_operand" "")))]
330 "l.addi\t%0, %1, %L2"
331 [(set_attr "type" "alu")])
334 ;; ??? The clobber that emit_move_multi_word emits is arguably incorrect.
335 ;; Consider gcc.c-torture/execute/20030222-1.c, where a reg-reg DImode
336 ;; move gets register allocated to a no-op move. At which point the
337 ;; we actively clobber the input.
339 (define_expand "movdi"
340 [(set (match_operand:DI 0 "nonimmediate_operand" "")
341 (match_operand:DI 1 "general_operand" ""))]
344 if (MEM_P (operands[0]) && !const0_operand(operands[1], DImode))
345 operands[1] = force_reg (DImode, operands[1]);
348 (define_insn_and_split "*movdi"
349 [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,o,r")
350 (match_operand:DI 1 "general_operand" " r,o,rO,n"))]
351 "register_operand (operands[0], DImode)
352 || reg_or_0_operand (operands[1], DImode)"
357 rtx l0 = operand_subword (operands[0], 0, 0, DImode);
358 rtx l1 = operand_subword (operands[1], 0, 0, DImode);
359 rtx h0 = operand_subword (operands[0], 1, 0, DImode);
360 rtx h1 = operand_subword (operands[1], 1, 0, DImode);
362 if (reload_completed && reg_overlap_mentioned_p (l0, h1))
364 gcc_assert (!reg_overlap_mentioned_p (h0, l1));
365 emit_move_insn (h0, h1);
366 emit_move_insn (l0, l1);
370 emit_move_insn (l0, l1);
371 emit_move_insn (h0, h1);
376 ;; -------------------------------------------------------------------------
378 ;; -------------------------------------------------------------------------
380 ;; Zero extension can always be done with AND or an extending load.
382 (define_insn "zero_extend<mode>si2"
383 [(set (match_operand:SI 0 "register_operand" "=r,r")
384 (zero_extend:SI (match_operand:I12 1 "reg_or_mem_operand" "r,m")))]
387 l.andi\t%0, %1, <zext_andi>
390 ;; Sign extension in registers is an optional extension, but the
391 ;; extending load is always available. If SEXT is not available,
392 ;; force the middle-end to do the expansion to shifts.
394 (define_insn "extend<mode>si2"
395 [(set (match_operand:SI 0 "register_operand" "=r,r")
396 (sign_extend:SI (match_operand:I12 1 "reg_or_mem_operand" "r,m")))]
402 (define_insn "*extend<mode>si2_mem"
403 [(set (match_operand:SI 0 "register_operand" "=r")
404 (sign_extend:SI (match_operand:I12 1 "memory_operand" "m")))]
406 "l.l<ldst>s\t%0, %1")
408 ;; -------------------------------------------------------------------------
409 ;; Compare instructions
410 ;; -------------------------------------------------------------------------
412 ;; OpenRISC supports these integer comparisons:
414 ;; l.sfeq[i] - equality, r r or r i
415 ;; l.sfne[i] - not equal, r r or r i
416 ;; l.sflt{s,u}[i] - less than, signed or unsigned, r r or r i
417 ;; l.sfle{s,u}[i] - less than or equal, signed or unsigned, r r or r i
418 ;; l.sfgt{s,u}[i] - greater than, signed or unsigned, r r or r i
419 ;; l.sfge{s,u}[i] - greater than or equal, signed or unsigned, r r or r i
421 ;; EQ,NE,LT,LTU,LE,LEU,GT,GTU,GE,GEU
422 ;; We iterate through all of these
425 (define_code_iterator intcmpcc [ne eq lt ltu gt gtu ge le geu leu])
426 (define_code_attr insn [(ne "ne") (eq "eq") (lt "lts") (ltu "ltu")
427 (gt "gts") (gtu "gtu") (ge "ges") (le "les")
428 (geu "geu") (leu "leu")])
430 (define_insn "*sf_insn"
431 [(set (reg:BI SR_F_REGNUM)
432 (intcmpcc:BI (match_operand:SI 0 "reg_or_0_operand" "rO,rO")
433 (match_operand:SI 1 "reg_or_s16_operand" "r,I")))]
437 l.sf<insn>i\t%r0, %1"
438 [(set_attr "insn_support" "*,sfimm")])
440 ;; Support FP comparisons too
442 ;; The OpenRISC FPU supports these comparisons:
444 ;; lf.sfeq.{d,s} - equality, r r, double or single precision
445 ;; lf.sfge.{d,s} - greater than or equal, r r, double or single precision
446 ;; lf.sfgt.{d,s} - greater than, r r, double or single precision
447 ;; lf.sfle.{d,s} - less than or equal, r r, double or single precision
448 ;; lf.sflt.{d,s} - less than, r r, double or single precision
449 ;; lf.sfne.{d,s} - not equal, r r, double or single precision
451 ;; Double precision is only supported on some hardware. Only register/register
452 ;; comparisons are supported. All comparisons are signed.
454 (define_code_iterator fpcmpcc [ne eq lt gt ge le uneq unle unlt ungt unge
456 (define_code_attr fpcmpinsn [(ne "ne") (eq "eq") (lt "lt") (gt "gt") (ge "ge")
457 (le "le") (uneq "ueq") (unle "ule") (unlt "ult")
458 (ungt "ugt") (unge "uge") (unordered "un")])
461 (define_insn "*sf_fp_insn"
462 [(set (reg:BI SR_F_REGNUM)
463 (fpcmpcc:BI (match_operand:F 0 "register_operand" "<fr>")
464 (match_operand:F 1 "register_operand" "<fr>")))]
466 "lf.sf<fpcmpinsn>.<f>\t%d0, %d1"
467 [(set_attr "type" "fpu")])
470 ;; -------------------------------------------------------------------------
471 ;; Conditional Store instructions
472 ;; -------------------------------------------------------------------------
474 (define_expand "cstoresi4"
475 [(set (match_operand:SI 0 "register_operand" "")
477 (match_operator 1 "comparison_operator"
478 [(match_operand:SI 2 "reg_or_0_operand" "")
479 (match_operand:SI 3 "reg_or_s16_operand" "")])
484 or1k_expand_compare (operands + 1);
485 PUT_MODE (operands[1], SImode);
486 emit_insn (gen_rtx_SET (operands[0], operands[1]));
490 ;; Support FP cstores too
491 (define_expand "cstore<F:mode>4"
492 [(set (match_operand:SI 0 "register_operand" "")
494 (match_operator 1 "fp_comparison_operator"
495 [(match_operand:F 2 "register_operand" "")
496 (match_operand:F 3 "register_operand" "")])
501 or1k_expand_compare (operands + 1);
502 PUT_MODE (operands[1], SImode);
503 emit_insn (gen_rtx_SET (operands[0], operands[1]));
507 ;; Being able to "copy" SR_F to a general register is helpful for
508 ;; the atomic insns, wherein the usual usage is to test the success
509 ;; of the compare-and-swap. Representing the operation in this way,
510 ;; rather than exposing the cmov immediately, allows the optimizers
511 ;; to propagate the use of SR_F directly into a branch.
513 (define_expand "sne_sr_f"
514 [(set (match_operand:SI 0 "register_operand" "=r")
515 (ne:SI (reg:BI SR_F_REGNUM) (const_int 0)))]
518 (define_insn_and_split "*scc"
519 [(set (match_operand:SI 0 "register_operand" "=r")
520 (match_operator:SI 1 "equality_comparison_operator"
521 [(reg:BI SR_F_REGNUM) (const_int 0)]))]
525 [(set (match_dup 0) (const_int 1))
527 (if_then_else:SI (match_dup 1)
532 (define_expand "mov<I:mode>cc"
533 [(set (match_operand:I 0 "register_operand" "")
534 (if_then_else:I (match_operand 1 "comparison_operator" "")
535 (match_operand:I 2 "reg_or_0_operand" "")
536 (match_operand:I 3 "reg_or_0_operand" "")))]
539 rtx xops[3] = { operands[1], XEXP (operands[1], 0), XEXP (operands[1], 1) };
540 or1k_expand_compare (xops);
541 operands[1] = xops[0];
544 (define_insn_and_split "*cmov<I:mode>"
545 [(set (match_operand:I 0 "register_operand" "=r")
547 (match_operator 3 "equality_comparison_operator"
548 [(reg:BI SR_F_REGNUM) (const_int 0)])
549 (match_operand:I 1 "reg_or_0_operand" "rO")
550 (match_operand:I 2 "reg_or_0_operand" "rO")))]
553 return (GET_CODE (operands[3]) == NE
554 ? "l.cmov\t%0, %r1, %r2"
555 : "l.cmov\t%0, %r2, %r1");
561 rtx label = gen_rtx_LABEL_REF (VOIDmode, gen_label_rtx ());
563 /* Generated a *cbranch pattern. */
564 if (rtx_equal_p (operands[0], operands[2]))
566 PUT_CODE (operands[3], (GET_CODE (operands[3]) == NE) ? EQ : NE);
567 x = gen_rtx_IF_THEN_ELSE (VOIDmode, operands[3], label, pc_rtx);
568 emit_jump_insn (gen_rtx_SET (pc_rtx, x));
569 emit_move_insn (operands[0], operands[1]);
573 x = gen_rtx_IF_THEN_ELSE (VOIDmode, operands[3], label, pc_rtx);
574 emit_move_insn (operands[0], operands[1]);
575 emit_jump_insn (gen_rtx_SET (pc_rtx, x));
576 emit_move_insn (operands[0], operands[2]);
579 emit_label (XEXP (label, 0));
583 ;; -------------------------------------------------------------------------
584 ;; Branch instructions
585 ;; -------------------------------------------------------------------------
587 (define_expand "cbranchsi4"
590 (match_operator 0 "comparison_operator"
591 [(match_operand:SI 1 "reg_or_0_operand" "")
592 (match_operand:SI 2 "reg_or_s16_operand" "")])
593 (label_ref (match_operand 3 "" ""))
597 or1k_expand_compare (operands);
600 ;; Support FP branching
602 (define_expand "cbranch<F:mode>4"
605 (match_operator 0 "fp_comparison_operator"
606 [(match_operand:F 1 "register_operand" "")
607 (match_operand:F 2 "register_operand" "")])
608 (label_ref (match_operand 3 "" ""))
612 or1k_expand_compare (operands);
615 (define_insn "*cbranch"
618 (match_operator 1 "equality_comparison_operator"
619 [(reg:BI SR_F_REGNUM) (const_int 0)])
620 (label_ref (match_operand 0 "" ""))
624 return (GET_CODE (operands[1]) == NE
628 [(set_attr "type" "control")])
630 ;; -------------------------------------------------------------------------
632 ;; -------------------------------------------------------------------------
635 [(set (pc) (label_ref (match_operand 0 "" "")))]
638 [(set_attr "type" "control")])
640 (define_insn "indirect_jump"
641 [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
644 [(set_attr "type" "control")])
646 ;; -------------------------------------------------------------------------
647 ;; Prologue & Epilogue
648 ;; -------------------------------------------------------------------------
650 (define_expand "prologue"
654 or1k_expand_prologue ();
658 ;; Expand epilogue as RTL
659 (define_expand "epilogue"
663 or1k_expand_epilogue ();
664 emit_jump_insn (gen_simple_return ());
668 (define_expand "sibcall_epilogue"
672 or1k_expand_epilogue ();
673 /* Placing a USE of LR here, rather than as a REG_USE on the
674 sibcall itself, means that LR is not unnecessarily live
675 within the function itself, which would force creation of
677 emit_insn (gen_rtx_USE (VOIDmode, gen_rtx_REG (Pmode, LR_REGNUM)));
681 (define_expand "simple_return"
682 [(parallel [(simple_return) (use (match_dup 0))])]
685 operands[0] = gen_rtx_REG (Pmode, LR_REGNUM);
688 (define_insn "*simple_return"
690 (use (match_operand:SI 0 "register_operand" "r"))]
693 [(set_attr "type" "control")])
695 (define_expand "eh_return"
696 [(use (match_operand 0 "general_operand"))]
699 or1k_expand_eh_return (operands[0]);
703 ;; This is a placeholder, during RA, in order to create the PIC regiter.
704 ;; We do this so that we don't unconditionally mark the LR register as
705 ;; clobbered. It is replaced during prologue generation with the proper
706 ;; set_got pattern below. This works because the set_got_tmp insn is the
707 ;; first insn in the stream and that it isn't moved during RA.
708 (define_insn "set_got_tmp"
709 [(set (match_operand:SI 0 "register_operand" "=t")
710 (unspec_volatile:SI [(const_int 0)] UNSPECV_SET_GOT))]
716 ;; The insn to initialize the GOT.
717 (define_insn "set_got"
718 [(set (match_operand:SI 0 "register_operand" "=t")
719 (unspec:SI [(const_int 0)] UNSPEC_SET_GOT))
720 (clobber (reg:SI LR_REGNUM))]
724 " l.movhi\t%0, gotpchi(_GLOBAL_OFFSET_TABLE_-4)\;"
725 "l.ori\t%0, %0, gotpclo(_GLOBAL_OFFSET_TABLE_+0)\;"
726 "l.add\t%0, %0, r9");
728 [(set_attr "length" "16")
729 (set_attr "type" "multi")])
731 ;; Block memory operations from being scheduled across frame (de)allocation.
732 (define_insn "frame_addsi3"
733 [(set (match_operand:SI 0 "register_operand" "=r,r")
735 (match_operand:SI 1 "register_operand" "%r,r")
736 (match_operand:SI 2 "reg_or_s16_operand" " r,I")))
737 (clobber (mem:BLK (scratch)))]
743 ;; -------------------------------------------------------------------------
745 ;; -------------------------------------------------------------------------
747 ;; Note that MULT stands in for the non-existant NAND rtx_code.
748 (define_code_iterator FETCHOP [plus minus ior xor and mult])
750 (define_code_attr fetchop_name
758 (define_code_attr fetchop_pred
759 [(plus "reg_or_s16_operand")
760 (minus "register_operand")
761 (ior "reg_or_u16_operand")
762 (xor "reg_or_s16_operand")
763 (and "reg_or_u16_operand")
764 (mult "reg_or_u16_operand")])
766 (define_expand "mem_thread_fence"
767 [(match_operand:SI 0 "const_int_operand" "")] ;; model
770 memmodel model = memmodel_base (INTVAL (operands[0]));
771 if (model != MEMMODEL_RELAXED)
772 emit_insn (gen_msync ());
776 (define_expand "msync"
777 [(set (match_dup 0) (unspec:BLK [(match_dup 0)] UNSPEC_MSYNC))]
780 operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode));
781 MEM_VOLATILE_P (operands[0]) = 1;
784 (define_insn "*msync"
785 [(set (match_operand:BLK 0 "" "")
786 (unspec:BLK [(match_dup 0)] UNSPEC_MSYNC))]
790 (define_insn "load_locked_si"
791 [(set (match_operand:SI 0 "register_operand" "=r")
793 [(match_operand:SI 1 "memory_operand" "m")] UNSPECV_LL))]
796 [(set_attr "type" "ld")])
798 (define_insn "store_conditional_si"
799 [(set (reg:BI SR_F_REGNUM)
800 (unspec_volatile:BI [(const_int 0)] UNSPECV_SC))
801 (set (match_operand:SI 0 "memory_operand" "=m")
802 (match_operand:SI 1 "reg_or_0_operand" "rO"))]
805 [(set_attr "type" "st")])
807 (define_expand "atomic_compare_and_swapsi"
808 [(match_operand:SI 0 "register_operand") ;; bool output
809 (match_operand:SI 1 "register_operand") ;; val output
810 (match_operand:SI 2 "memory_operand") ;; memory
811 (match_operand:SI 3 "reg_or_s16_operand") ;; expected
812 (match_operand:SI 4 "reg_or_0_operand") ;; desired
813 (match_operand:SI 5 "const_int_operand") ;; is_weak
814 (match_operand:SI 6 "const_int_operand") ;; mod_s
815 (match_operand:SI 7 "const_int_operand")] ;; mod_f
818 or1k_expand_atomic_compare_and_swap (operands);
822 (define_expand "atomic_compare_and_swap<mode>"
823 [(match_operand:SI 0 "register_operand") ;; bool output
824 (match_operand:I12 1 "register_operand") ;; val output
825 (match_operand:I12 2 "memory_operand") ;; memory
826 (match_operand:I12 3 "register_operand") ;; expected
827 (match_operand:I12 4 "reg_or_0_operand") ;; desired
828 (match_operand:SI 5 "const_int_operand") ;; is_weak
829 (match_operand:SI 6 "const_int_operand") ;; mod_s
830 (match_operand:SI 7 "const_int_operand")] ;; mod_f
833 or1k_expand_atomic_compare_and_swap_qihi (operands);
837 (define_expand "atomic_exchangesi"
838 [(match_operand:SI 0 "register_operand") ;; output
839 (match_operand:SI 1 "memory_operand") ;; memory
840 (match_operand:SI 2 "reg_or_0_operand") ;; input
841 (match_operand:SI 3 "const_int_operand")] ;; model
844 or1k_expand_atomic_exchange (operands);
848 (define_expand "atomic_exchange<mode>"
849 [(match_operand:I12 0 "register_operand") ;; output
850 (match_operand:I12 1 "memory_operand") ;; memory
851 (match_operand:I12 2 "reg_or_0_operand") ;; input
852 (match_operand:SI 3 "const_int_operand")] ;; model
855 or1k_expand_atomic_exchange_qihi (operands);
859 (define_expand "atomic_<fetchop_name>si"
860 [(match_operand:SI 0 "memory_operand") ;; memory
861 (FETCHOP:SI (match_dup 0)
862 (match_operand:SI 1 "<fetchop_pred>")) ;; operand
863 (match_operand:SI 2 "const_int_operand")] ;; model
866 or1k_expand_atomic_op (<CODE>, operands[0], operands[1], NULL, NULL);
870 (define_expand "atomic_<fetchop_name><mode>"
871 [(match_operand:I12 0 "memory_operand") ;; memory
872 (FETCHOP:I12 (match_dup 0)
873 (match_operand:I12 1 "register_operand")) ;; operand
874 (match_operand:SI 2 "const_int_operand")] ;; model
877 or1k_expand_atomic_op_qihi (<CODE>, operands[0], operands[1], NULL, NULL);
881 (define_expand "atomic_fetch_<fetchop_name>si"
882 [(match_operand:SI 0 "register_operand" "") ;; output
883 (match_operand:SI 1 "memory_operand" "") ;; memory
884 (FETCHOP:SI (match_dup 1)
885 (match_operand:SI 2 "<fetchop_pred>" "")) ;; operand
886 (match_operand:SI 3 "const_int_operand" "")] ;; model
889 or1k_expand_atomic_op (<CODE>, operands[1], operands[2], operands[0], NULL);
893 (define_expand "atomic_fetch_<fetchop_name><mode>"
894 [(match_operand:I12 0 "register_operand" "") ;; output
895 (match_operand:I12 1 "memory_operand" "") ;; memory
896 (FETCHOP:I12 (match_dup 1)
897 (match_operand:I12 2 "<fetchop_pred>" "")) ;; operand
898 (match_operand:SI 3 "const_int_operand" "")] ;; model
901 or1k_expand_atomic_op_qihi (<CODE>, operands[1], operands[2],
906 (define_expand "atomic_<fetchop_name>_fetchsi"
907 [(match_operand:SI 0 "register_operand" "") ;; output
908 (match_operand:SI 1 "memory_operand" "") ;; memory
909 (FETCHOP:SI (match_dup 1)
910 (match_operand:SI 2 "<fetchop_pred>" "")) ;; operand
911 (match_operand:SI 3 "const_int_operand" "")] ;; model
914 or1k_expand_atomic_op (<CODE>, operands[1], operands[2], NULL, operands[0]);
918 (define_expand "atomic_<fetchop_name>_fetch<mode>"
919 [(match_operand:I12 0 "register_operand" "") ;; output
920 (match_operand:I12 1 "memory_operand" "") ;; memory
921 (FETCHOP:I12 (match_dup 1)
922 (match_operand:I12 2 "<fetchop_pred>" "")) ;; operand
923 (match_operand:SI 3 "const_int_operand" "")] ;; model
926 or1k_expand_atomic_op_qihi (<CODE>, operands[1], operands[2],
931 ;; -------------------------------------------------------------------------
933 ;; -------------------------------------------------------------------------
935 ;; Leave these to last, as the modeless operand for call_value
936 ;; interferes with normal patterns.
938 (define_expand "call"
939 [(call (match_operand 0) (match_operand 1))]
942 or1k_expand_call (NULL, operands[0], operands[1], false);
946 (define_expand "sibcall"
947 [(call (match_operand 0) (match_operand 1))]
950 or1k_expand_call (NULL, operands[0], operands[1], true);
954 (define_expand "call_value"
955 [(set (match_operand 0) (call (match_operand 1) (match_operand 2)))]
958 or1k_expand_call (operands[0], operands[1], operands[2], false);
962 (define_expand "sibcall_value"
963 [(set (match_operand 0) (call (match_operand 1) (match_operand 2)))]
966 or1k_expand_call (operands[0], operands[1], operands[2], true);
971 [(call (mem:SI (match_operand:SI 0 "call_insn_operand" "r,s"))
973 (clobber (reg:SI LR_REGNUM))]
974 "!SIBLING_CALL_P (insn)"
978 [(set_attr "type" "control")])
980 (define_insn "*sibcall"
981 [(call (mem:SI (match_operand:SI 0 "call_insn_operand" "c,s"))
983 "SIBLING_CALL_P (insn)"
987 [(set_attr "type" "control")])
989 (define_insn "*call_value"
990 [(set (match_operand 0)
991 (call (mem:SI (match_operand:SI 1 "call_insn_operand" "r,s"))
993 (clobber (reg:SI LR_REGNUM))]
994 "!SIBLING_CALL_P (insn)"
998 [(set_attr "type" "control")])
1000 (define_insn "*sibcall_value"
1001 [(set (match_operand 0)
1002 (call (mem:SI (match_operand:SI 1 "call_insn_operand" "c,s"))
1003 (match_operand 2)))]
1004 "SIBLING_CALL_P (insn)"
1008 [(set_attr "type" "control")])