This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix SH Interrupt Handler ICE


"Dhananjay R. Deshpande" wrote:
> OK. This also requires operand0 to be matched with "general_movdst_operand"
> instead of "register_operand".
...
> Also fpu_switch insn is enabled only for TARGET_SH4. I had to change it to
> TARGET_SH3E to generate push/pop fpscr on SH3E target also.

OK so far.
 

> > Incidentally, immediately after the fpu_switch pattern in sh.md, there
> > is a splitter that does generates a post-increment read of
> > fpscr; to get
> > code to generate a pop, just substitute stack_pointer_rtx for
> > operands[0].
> > Note that the REG_INC note will take care of the hit_stack attribute.
> 
> I was unable to generate pop with this split pattern by substituting
> stack_pointer_rtx for operand[0]. The split pattern doesn't match with standard
> pop pattern generated. I had to add a similar pattern which matches default pop
> rtx. Similar split pattern for push is added.

To emit rtl that is missing a REG_INC note and relying on a splitter to add that
note later is dangerous, as new optimizations might be introduced that run before
the splitter is being run.

It appears that my previous email was a bit too vague on this point.  I didn't
mean to duplicate the entire splitter, but just the code inside that does the
code generation.  That can either be used directly in sh.c, or be wrapped in
define_expands like this:

(define_expand "pop_fpscr"
  [(const_int 0)]
  "TARGET_SH3E"
  "
{
  rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
                                        gen_rtx (MEM, PSImode,
                                                 gen_rtx (POST_INC, Pmode,
                                                          stack_pointer_rtx))));
  REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, stack_pointer_rtx, NULL_RTX);
  DONE;
}")

(define_expand "push_fpscr"
  [(const_int 0)]
  "TARGET_SH3E"
  "
{
  rtx insn = emit_insn (gen_fpu_switch (gen_rtx (MEM, PSImode,
                                                 gen_rtx (PRE_DEC, Pmode,
                                                          stack_pointer_rtx)),
                                        get_fpscr_rtx ()));
  REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, stack_pointer_rtx, NULL_RTX);
  DONE;
}")

	
-- 
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]