target/10205: Incorrect code generated for H8300 "normal" mode

Kazu Hirata kazu@cs.umass.edu
Fri Mar 28 14:31:00 GMT 2003


Hi Dhananjay,

> The patch below fixes this. If it is OK, it should be applied to
> both mainline and 3.3 branch.

Actually, I have come up with a basically identical patch, which I am
asking the submitter to test in private mail.  When he responds, I'll
add your name in the ChangeLog entry.  Mine looks like this, but I
like your POINTER_SIZE approach.

Kazu Hirata

Index: h8300.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/h8300/h8300.c,v
retrieving revision 1.221
diff -c -r1.221 h8300.c
*** h8300.c	22 Mar 2003 15:22:37 -0000	1.221
--- h8300.c	28 Mar 2003 03:33:36 -0000
***************
*** 1715,1723 ****
       int from, to;
  {
    int offset = 0;
  
    if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
!     offset = UNITS_PER_WORD + frame_pointer_needed * UNITS_PER_WORD;
    else if (from == RETURN_ADDRESS_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
      offset = frame_pointer_needed * UNITS_PER_WORD;
    else
--- 1715,1726 ----
       int from, to;
  {
    int offset = 0;
+   /* The number of bytes that the return address takes on the stack.  */
+   int pc_size = (((TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE)
+ 		 ? (UNITS_PER_WORD / 2) : UNITS_PER_WORD);
  
    if (from == ARG_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
!     offset = pc_size + frame_pointer_needed * UNITS_PER_WORD;
    else if (from == RETURN_ADDRESS_POINTER_REGNUM && to == FRAME_POINTER_REGNUM)
      offset = frame_pointer_needed * UNITS_PER_WORD;
    else
***************
*** 1734,1744 ****
        offset += round_frame_size (get_frame_size ());
  
        if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
! 	offset += UNITS_PER_WORD;	/* Skip saved PC */
      }
- 
-   if ((TARGET_H8300H || TARGET_H8300S) && TARGET_NORMAL_MODE)
-     offset -= 2;
  
    return offset;
  }
--- 1737,1744 ----
        offset += round_frame_size (get_frame_size ());
  
        if (from == ARG_POINTER_REGNUM && to == STACK_POINTER_REGNUM)
! 	offset += pc_size;	/* Skip saved PC */
      }
  
    return offset;
  }



More information about the Gcc-patches mailing list