------- Additional Comments From dennisc at harding dot ca  2004-10-26 18:52 -------
I have found a patch for this problem that was proposed by DJ Delorie about a
year ago. His posting in the mailing list is at
http://gcc.gnu.org/ml/gcc-patches/2003-10/msg02277.html which I have copied below.

    * From: DJ Delorie <dj at redhat dot com>
    * To: gcc-patches at gcc dot gnu dot org
    * Cc: dj at redhat dot com
    * Date: Fri, 24 Oct 2003 23:10:31 -0400
    * Subject: [patch] sh-elf, -mrenesas, FUNCTION_VALUE

This file:

char bar(int);

void foo (char *f, int i)
{
  f[i] = bar(i);
}

Fails thusly:

$ ./cc1 -quiet -mrenesas -O2 -m4 dj.c
dj.c: In function `foo':

dj.c:5: internal compiler error: in emit_move_insn, at expr.c:2792


The failure is due to bar()'s return value being mispromoted, leading
to a (set (QI) (SI)).  Proposed patch follows.  Comments?


2003-10-24  DJ Delorie  <[EMAIL PROTECTED]>

        * config/sh/sh.h (FUNCTION_VALUE): Support renesas attribute.

Index: config/sh/sh.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.225
diff -p -2 -r1.225 sh.h
*** config/sh/sh.h      13 Oct 2003 21:16:32 -0000      1.225
--- config/sh/sh.h      25 Oct 2003 02:35:39 -0000
*************** extern enum reg_class reg_class_from_let
*** 1634,1646 ****
  #define FUNCTION_VALUE(VALTYPE, FUNC)                                 \
    gen_rtx (REG,                                                               \
!          ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT           \
!            && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < UNITS_PER_WORD    \
!            && (TREE_CODE (VALTYPE) == INTEGER_TYPE                    \
!                || TREE_CODE (VALTYPE) == ENUMERAL_TYPE                \
!                || TREE_CODE (VALTYPE) == BOOLEAN_TYPE                 \
!                || TREE_CODE (VALTYPE) == CHAR_TYPE                    \
!                || TREE_CODE (VALTYPE) == REAL_TYPE                    \
!                || TREE_CODE (VALTYPE) == OFFSET_TYPE))                \
!           ? (TARGET_SHMEDIA ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
           BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))
  
--- 1634,1648 ----
  #define FUNCTION_VALUE(VALTYPE, FUNC)                                 \
    gen_rtx (REG,                                                               \
!            sh_attr_renesas_p (FUNC)                                   \
!          ? TYPE_MODE (VALTYPE)                                        \
!          : ((GET_MODE_CLASS (TYPE_MODE (VALTYPE)) == MODE_INT         \
!              && GET_MODE_SIZE (TYPE_MODE (VALTYPE)) < UNITS_PER_WORD  \
!              && (TREE_CODE (VALTYPE) == INTEGER_TYPE                  \
!                  || TREE_CODE (VALTYPE) == ENUMERAL_TYPE              \
!                  || TREE_CODE (VALTYPE) == BOOLEAN_TYPE               \
!                  || TREE_CODE (VALTYPE) == CHAR_TYPE                  \
!                  || TREE_CODE (VALTYPE) == REAL_TYPE                  \
!                  || TREE_CODE (VALTYPE) == OFFSET_TYPE))              \
!             ? (TARGET_SHMEDIA ? DImode : SImode) : TYPE_MODE (VALTYPE)), \
           BASE_RETURN_VALUE_REG (TYPE_MODE (VALTYPE)))


I'm not really able to judge the nature of the patch, but I will test it as soon
as I can get GCC version 3.4.2 to recognize the -mrenesas switch again.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17717

Reply via email to