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]

Implicit fractional conversion bug/missing feature


I'm very new in porting gcc for new architectures. Currently I'm
working on the port of an architecture not "byte addressable" but
word32 addressable (BITS_PER_UNIT=32), like the c4x.
I discovered a potential problem or a feature that I don't understand
in convert.c. That tries to convert a mode that have
precision<BITS_PER_UNIT to the mode itself with a higher precision.

What I did:
I defined a new fractional mode of precision BITS_PER_UNIT/2 and
storage layout obviously of 1 (32 bit).
by putting in my xx-modes.def the following line
FRACTIONAL_INT_MODE (PQ, 16, 1);
The problem arise when I attempt to support my short int/pointer
hardware 16 bit operators and registers by setting 
SHORT_TYPE_SIZE=(BITS_PER_WORD/2) and Pmode=PQmode.
In this way gcc understand that short int and pointers have to use PQmode.
Note that I have also 32 bit integer/floating operators usually
dedicated to number crunching.
and so INT_TYPE_SIZE=BITS_PER_WORD associated with the predefined QImode.

Problem:
I would have expected that my gcc cross compiler used the two previous
modes (QImode,PQmode) without problems (short int/pointer operations
in PQmode and others with QI and QF modes) like in the case of two
modes that have different storage layout size(i.e HI QI).
What I've got is a segmentation fault for stack overflow because of
function convert_to_integer calls recursively itself via convert
function trying to do an impossible conversion.
I know that my architecture doesn't fit very well in what gcc expects.
But maybe this patch can be useful to correct this bug (in case of) or
to support new integer modes and c-types that have precision < storage
layout precision.
best regards

Andrea.
Index: convert.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/convert.c,v
retrieving revision 1.57
diff -c -3 -p -r1.57 convert.c
*** convert.c	17 Feb 2005 23:56:38 -0000	1.57
--- convert.c	18 Mar 2005 10:32:45 -0000
*************** convert_to_integer (tree type, tree expr
*** 437,444 ****
--- 437,448 ----
  	 than the number of bits in its mode, do the conversion to the
  	 type corresponding to its mode, then do a nop conversion
  	 to TYPE.  */
+ #ifdef NO_IMPLICIT_FRACTIONAL_CONVERSION
+       else if (TREE_CODE (type) == ENUMERAL_TYPE)
+ #else
        else if (TREE_CODE (type) == ENUMERAL_TYPE
  	       || outprec != GET_MODE_BITSIZE (TYPE_MODE (type)))
+ #endif
  	return build1 (NOP_EXPR, type,
  		       convert (lang_hooks.types.type_for_mode
  				(TYPE_MODE (type), TYPE_UNSIGNED (type)),

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