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]

Re: recog_data bug in regclass found by SunOS4 build


On Tue, Sep 14, 1999 at 01:30:22PM -0700, Jim Wilson wrote:
> Casting to int solves this problem, but you might want to check to see if
> the same problem exists elsewhere.

After some discussion with Jim, I've decided to go with this
approach.  It fixes the one problem case, as well as trying
to subvert the problem before it happens again.  It's still
possible to run into problems on ROMP or Irix3 (though none
exist currently); I sincerely hope the set of people that
care is now empty.


r~


        * recog.h (struct recog_data): Make dup_num, operand_address_p,
        n_operands, n_dups, n_alternatives `char' instead of `unsigned char'.
        (struct insn_data): Likewise with n_operands, n_dups,
        n_alternatives, output_format.
        * regclass.c (scan_one_insn): Cast n_operands to int before
        arithmetic inside comparison.

Index: recog.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/recog.h,v
retrieving revision 1.22
diff -c -p -d -r1.22 recog.h
*** recog.h	1999/09/14 04:19:29	1.22
--- recog.h	1999/09/14 23:19:59
*************** struct recog_data
*** 156,176 ****
  
    /* Gives the operand number that was duplicated in the Nth
       duplicate-appearance of an operand.  */
!   unsigned char dup_num[MAX_DUP_OPERANDS];
  
  #ifndef REGISTER_CONSTRAINTS
    /* Nonzero if operand N should be an address.  */
!   unsigned char operand_address_p[MAX_RECOG_OPERANDS];
  #endif
  
    /* The number of operands of the insn.  */
!   unsigned char n_operands;
  
    /* The number of MATCH_DUPs in the insn.  */
!   unsigned char n_dups;
  
    /* The number of alternatives in the constraints for the insn.  */
!   unsigned char n_alternatives;
  };
  
  extern struct recog_data recog_data;
--- 156,186 ----
  
    /* Gives the operand number that was duplicated in the Nth
       duplicate-appearance of an operand.  */
!   char dup_num[MAX_DUP_OPERANDS];
  
  #ifndef REGISTER_CONSTRAINTS
    /* Nonzero if operand N should be an address.  */
!   char operand_address_p[MAX_RECOG_OPERANDS];
  #endif
  
+   /* ??? Note that these are `char' instead of `unsigned char' to (try to)
+      avoid certain lossage from K&R C, wherein `unsigned char' default 
+      promotes to `unsigned int' instead of `int' as in ISO C.  As of 1999,
+      the most common places to bootstrap from K&R C are SunOS and HPUX,
+      both of which have signed characters by default.  The only other
+      supported natives that have both K&R C and unsigned characters are
+      ROMP and Irix 3, and neither have been seen for a while, but do
+      continue to consider unsignedness when performing arithmetic inside
+      a comparison.  */
+ 
    /* The number of operands of the insn.  */
!   char n_operands;
  
    /* The number of MATCH_DUPs in the insn.  */
!   char n_dups;
  
    /* The number of alternatives in the constraints for the insn.  */
!   char n_alternatives;
  };
  
  extern struct recog_data recog_data;
*************** struct insn_data
*** 225,234 ****
    insn_gen_fn genfun;
    const struct insn_operand_data *operand;
  
!   unsigned char n_operands;
!   unsigned char n_dups;
!   unsigned char n_alternatives;
!   unsigned char output_format;
  };
  
  extern const struct insn_data insn_data[];
--- 235,244 ----
    insn_gen_fn genfun;
    const struct insn_operand_data *operand;
  
!   char n_operands;
!   char n_dups;
!   char n_alternatives;
!   char output_format;
  };
  
  extern const struct insn_data insn_data[];
Index: regclass.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/regclass.c,v
retrieving revision 1.58
diff -c -p -d -r1.58 regclass.c
*** regclass.c	1999/09/12 01:51:01	1.58
--- regclass.c	1999/09/14 23:22:12
*************** scan_one_insn (insn, pass)
*** 901,907 ****
       have been initialized.  We must do this even if one operand
       is a constant--see addsi3 in m68k.md.  */
  
!   for (i = 0; i < recog_data.n_operands - 1; i++)
      if (constraints[i][0] == '%')
        {
  	const char *xconstraints[MAX_RECOG_OPERANDS];
--- 901,907 ----
       have been initialized.  We must do this even if one operand
       is a constant--see addsi3 in m68k.md.  */
  
!   for (i = 0; i < (int) recog_data.n_operands - 1; i++)
      if (constraints[i][0] == '%')
        {
  	const char *xconstraints[MAX_RECOG_OPERANDS];


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