1 ;; ----------------------------------------------------------------------
2 ;; PROLOGUE/EPILOGUE-RELATED INSTRUCTIONS
3 ;; ----------------------------------------------------------------------
5 (define_expand "push_h8300hs_advanced"
6 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
7 (match_operand:SI 0 "register_operand" ""))]
8 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
11 (define_expand "push_h8300hs_normal"
12 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
13 (match_operand:SI 0 "register_operand" ""))]
14 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
17 (define_expand "pop_h8300hs_advanced"
18 [(set (match_operand:SI 0 "register_operand" "")
19 (mem:SI (post_inc:SI (reg:SI SP_REG))))]
20 "TARGET_H8300H && TARGET_H8300S && !TARGET_NORMAL_MODE"
23 (define_expand "pop_h8300hs_normal"
24 [(set (match_operand:SI 0 "register_operand" "")
25 (mem:SI (post_inc:HI (reg:HI SP_REG))))]
26 "TARGET_H8300H && TARGET_H8300S && TARGET_NORMAL_MODE"
29 (define_insn "ldm_h8300sx"
30 [(match_parallel 0 "h8300_ldm_parallel"
31 [(set (match_operand:SI 1 "register_operand" "")
32 (match_operand:SI 2 "memory_operand" ""))])]
35 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
36 XVECLEN (operands[0], 0) - 2));
37 return "ldm.l\t@er7+,%S1-%S3";
39 [(set_attr "length" "4")])
41 (define_insn "stm_h8300sx"
42 [(match_parallel 0 "h8300_stm_parallel"
43 [(set (match_operand:SI 1 "memory_operand" "")
44 (match_operand:SI 2 "register_operand" ""))])]
47 operands[3] = SET_SRC (XVECEXP (operands[0], 0,
48 XVECLEN (operands[0], 0) - 2));
49 return "stm.l\t%S2-%S3,@-er7";
51 [(set_attr "length" "4")])
53 (define_insn "return_h8sx"
54 [(match_parallel 0 "h8300_return_parallel"
56 (set (match_operand:SI 1 "register_operand" "")
57 (match_operand:SI 2 "memory_operand" ""))])]
60 operands[3] = SET_DEST (XVECEXP (operands[0], 0,
61 XVECLEN (operands[0], 0) - 2));
62 if (h8300_current_function_interrupt_function_p ()
63 || h8300_current_function_monitor_function_p ())
64 return "rte/l\t%S1-%S3";
66 return "rts/l\t%S1-%S3";
68 [(set_attr "can_delay" "no")
69 (set_attr "length" "2")])
71 (define_expand "return"
73 "h8300_can_use_return_insn_p ()"
76 (define_insn "*return_1"
80 if (h8300_current_function_interrupt_function_p ()
81 || h8300_current_function_monitor_function_p ())
86 [(set_attr "can_delay" "no")
87 (set_attr "length" "2")])
89 (define_expand "prologue"
93 h8300_expand_prologue ();
97 (define_expand "epilogue"
101 h8300_expand_epilogue (false);
105 (define_insn "monitor_prologue"
106 [(unspec_volatile [(const_int 0)] UNSPEC_MONITOR)]
109 if (TARGET_H8300H && TARGET_NORMAL_MODE)
110 return "subs\\t#2,er7\;mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr";
111 else if (TARGET_H8300H)
112 return "mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr";
113 else if (TARGET_H8300S && TARGET_NEXR )
114 return "mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
115 else if (TARGET_H8300S && TARGET_NEXR && TARGET_NORMAL_MODE)
116 return "subs\\t#2,er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
117 else if (TARGET_H8300S && TARGET_NORMAL_MODE)
118 return "subs\\t#2,er7\;stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(6,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
119 else if (TARGET_H8300S)
120 return "stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(6,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr";
123 [(set_attr "length" "20")])
125 (define_expand "sibcall_epilogue"
129 h8300_expand_epilogue (true);