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]

PATCH: GEN_INT_MODE (1/~4)


> >> > Maybe it's only me, but isn't GEN_INT (trunc_int_for_mode (...))
> >> > common enough to have a shorter name?
> >> Yes.  Care to whip up a patch?  ;-)
> > Absolutely.  What would an appropriate name be?  How about
> > GEN_INT_MODE(c, mode)?

Richard Henderson <rth@redhat.com> writes:
> Sounds ok.

Alexandre Oliva <aoliva@redhat.com> writes:
> Sounds good to me.

So here it is.  Bootstrapped and checked on powerpc-unknown-linux-gnu
without regressions.  I don't have CVS write privileges.

Separate patches for rs6000, i386, and sparc back ends to follow.

2002-03-15  Lars Brinkhoff  <lars@nocrew.org>

	* rtl.h (GEN_INT_MODE): New macro.
	* combine.c (make_extraction, simplify_comparison), expmed.c
	(store_bit_field, expand_mult_highpart, expand_divmod), expr.c
	(convert_modes, store_field), optabs.c (expand_fix),
	simplify-rtx.c (neg_const_int, simplify_unary_real):
	Use it instead of GEN_INT (trunc_int_for_mode (...)).

Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.334
diff -c -3 -p -r1.334 rtl.h
*** rtl.h	2002/03/06 10:17:21	1.334
--- rtl.h	2002/03/15 15:47:21
*************** extern rtx gen_lowpart_SUBREG PARAMS ((e
*** 1668,1673 ****
--- 1668,1676 ----
     and without prototypes.  */
  #define GEN_INT(N)  gen_rtx_CONST_INT (VOIDmode, (HOST_WIDE_INT) (N))
  
+ /* Convenience macro.  */
+ #define GEN_INT_MODE(N, MODE)  GEN_INT (trunc_int_for_mode ((N), (MODE)))
+ 
  /* Virtual registers are used during RTL generation to refer to locations into
     the stack frame when the actual location isn't known until RTL generation
     is complete.  The routine instantiate_virtual_regs replaces these with
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.273
diff -c -3 -p -r1.273 combine.c
*** combine.c	2002/03/10 17:14:02	1.273
--- combine.c	2002/03/15 15:47:01
*************** make_extraction (mode, inner, pos, pos_r
*** 6033,6039 ****
  	return new;
  
        if (GET_CODE (new) == CONST_INT)
! 	return GEN_INT (trunc_int_for_mode (INTVAL (new), mode));
  
        /* If we know that no extraneous bits are set, and that the high
  	 bit is not set, convert the extraction to the cheaper of
--- 6033,6039 ----
  	return new;
  
        if (GET_CODE (new) == CONST_INT)
! 	return GEN_INT_MODE (INTVAL (new), mode);
  
        /* If we know that no extraneous bits are set, and that the high
  	 bit is not set, convert the extraction to the cheaper of
*************** simplify_comparison (code, pop0, pop1)
*** 10792,10798 ****
  	      unsigned HOST_WIDE_INT temp = const_op & GET_MODE_MASK (mode);
  
  	      temp >>= INTVAL (XEXP (op0, 1));
! 	      op1 = GEN_INT (trunc_int_for_mode (temp, mode));
  	      op0 = XEXP (op0, 0);
  	      continue;
  	    }
--- 10792,10798 ----
  	      unsigned HOST_WIDE_INT temp = const_op & GET_MODE_MASK (mode);
  
  	      temp >>= INTVAL (XEXP (op0, 1));
! 	      op1 = GEN_INT_MODE (temp, mode);
  	      op0 = XEXP (op0, 0);
  	      continue;
  	    }
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.112
diff -c -3 -p -r1.112 expmed.c
*** expmed.c	2002/03/13 02:03:36	1.112
--- expmed.c	2002/03/15 15:47:06
*************** store_bit_field (str_rtx, bitsize, bitnu
*** 656,662 ****
  		value1 = gen_lowpart (maxmode, value1);
  	    }
  	  else if (GET_CODE (value) == CONST_INT)
! 	    value1 = GEN_INT (trunc_int_for_mode (INTVAL (value), maxmode));
  	  else if (!CONSTANT_P (value))
  	    /* Parse phase is supposed to make VALUE's data type
  	       match that of the component reference, which is a type
--- 656,662 ----
  		value1 = gen_lowpart (maxmode, value1);
  	    }
  	  else if (GET_CODE (value) == CONST_INT)
! 	    value1 = GEN_INT_MODE (INTVAL (value), maxmode);
  	  else if (!CONSTANT_P (value))
  	    /* Parse phase is supposed to make VALUE's data type
  	       match that of the component reference, which is a type
*************** expand_mult_highpart (mode, op0, cnst1, 
*** 2789,2795 ****
    if (size > HOST_BITS_PER_WIDE_INT)
      abort ();
  
!   op1 = GEN_INT (trunc_int_for_mode (cnst1, mode));
  
    wide_op1
      = immed_double_const (cnst1,
--- 2789,2795 ----
    if (size > HOST_BITS_PER_WIDE_INT)
      abort ();
  
!   op1 = GEN_INT_MODE (cnst1, mode);
  
    wide_op1
      = immed_double_const (cnst1,
*************** expand_divmod (rem_flag, code, mode, op0
*** 3273,3279 ****
  		if (rem_flag && d < 0)
  		  {
  		    d = abs_d;
! 		    op1 = GEN_INT (trunc_int_for_mode (abs_d, compute_mode));
  		  }
  
  		if (d == 1)
--- 3273,3279 ----
  		if (rem_flag && d < 0)
  		  {
  		    d = abs_d;
! 		    op1 = GEN_INT_MODE (abs_d, compute_mode);
  		  }
  
  		if (d == 1)
*************** expand_divmod (rem_flag, code, mode, op0
*** 3312,3319 ****
  			t1 = copy_to_mode_reg (compute_mode, op0);
  			do_cmp_and_jump (t1, const0_rtx, GE,
  					 compute_mode, label);
! 			expand_inc (t1, GEN_INT (trunc_int_for_mode
! 						 (abs_d - 1, compute_mode)));
  			emit_label (label);
  			quotient = expand_shift (RSHIFT_EXPR, compute_mode, t1,
  						 build_int_2 (lgup, 0),
--- 3312,3319 ----
  			t1 = copy_to_mode_reg (compute_mode, op0);
  			do_cmp_and_jump (t1, const0_rtx, GE,
  					 compute_mode, label);
! 			expand_inc (t1, GEN_INT_MODE (abs_d - 1,
! 						      compute_mode));
  			emit_label (label);
  			quotient = expand_shift (RSHIFT_EXPR, compute_mode, t1,
  						 build_int_2 (lgup, 0),
*************** expand_divmod (rem_flag, code, mode, op0
*** 3853,3860 ****
  	    t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0,
  			       build_int_2 (pre_shift, 0), NULL_RTX, unsignedp);
  	    quotient = expand_mult (compute_mode, t1,
! 				    GEN_INT (trunc_int_for_mode
! 					     (ml, compute_mode)),
  				    NULL_RTX, 0);
  
  	    insn = get_last_insn ();
--- 3853,3859 ----
  	    t1 = expand_shift (RSHIFT_EXPR, compute_mode, op0,
  			       build_int_2 (pre_shift, 0), NULL_RTX, unsignedp);
  	    quotient = expand_mult (compute_mode, t1,
! 				    GEN_INT_MODE (ml, compute_mode),
  				    NULL_RTX, 0);
  
  	    insn = get_last_insn ();
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.428
diff -c -3 -p -r1.428 expr.c
*** expr.c	2002/03/13 13:00:25	1.428
--- expr.c	2002/03/15 15:47:16
*************** convert_modes (mode, oldmode, x, unsigne
*** 1352,1358 ****
  	      && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
  	    val |= (HOST_WIDE_INT) (-1) << width;
  
! 	  return GEN_INT (trunc_int_for_mode (val, mode));
  	}
  
        return gen_lowpart (mode, x);
--- 1352,1358 ----
  	      && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
  	    val |= (HOST_WIDE_INT) (-1) << width;
  
! 	  return GEN_INT_MODE (val, mode);
  	}
  
        return gen_lowpart (mode, x);
*************** store_field (target, bitsize, bitpos, mo
*** 5145,5152 ****
  
  	      if (unsignedp)
  		return expand_and (tmode, temp,
! 				   GEN_INT (trunc_int_for_mode (width_mask,
! 								tmode)),
  				   NULL_RTX);
  
  	      count = build_int_2 (GET_MODE_BITSIZE (tmode) - bitsize, 0);
--- 5145,5151 ----
  
  	      if (unsignedp)
  		return expand_and (tmode, temp,
! 				   GEN_INT_MODE (width_mask, tmode),
  				   NULL_RTX);
  
  	      count = build_int_2 (GET_MODE_BITSIZE (tmode) - bitsize, 0);
Index: optabs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/optabs.c,v
retrieving revision 1.126
diff -c -3 -p -r1.126 optabs.c
*** optabs.c	2002/03/08 02:57:12	1.126
--- optabs.c	2002/03/15 15:47:19
*************** expand_fix (to, from, unsignedp)
*** 4560,4568 ****
  				 NULL_RTX, 0, OPTAB_LIB_WIDEN);
  	  expand_fix (to, target, 0);
  	  target = expand_binop (GET_MODE (to), xor_optab, to,
! 				 GEN_INT (trunc_int_for_mode
! 					  ((HOST_WIDE_INT) 1 << (bitsize - 1),
! 					   GET_MODE (to))),
  				 to, 1, OPTAB_LIB_WIDEN);
  
  	  if (target != to)
--- 4560,4568 ----
  				 NULL_RTX, 0, OPTAB_LIB_WIDEN);
  	  expand_fix (to, target, 0);
  	  target = expand_binop (GET_MODE (to), xor_optab, to,
! 				 GEN_INT_MODE
! 				 ((HOST_WIDE_INT) 1 << (bitsize - 1),
! 				  GET_MODE (to)),
  				 to, 1, OPTAB_LIB_WIDEN);
  
  	  if (target != to)
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.98
diff -c -3 -p -r1.98 simplify-rtx.c
*** simplify-rtx.c	2002/03/07 13:38:22	1.98
--- simplify-rtx.c	2002/03/15 15:47:23
*************** neg_const_int (mode, i)
*** 114,120 ****
       enum machine_mode mode;
       rtx i;
  {
!   return GEN_INT (trunc_int_for_mode (- INTVAL (i), mode));
  }
  
  
--- 114,120 ----
       enum machine_mode mode;
       rtx i;
  {
!   return GEN_INT_MODE (- INTVAL (i), mode);
  }
  
  
*************** simplify_unary_real (p)
*** 376,382 ****
  	default:
  	  abort ();
  	}
!       args->result = GEN_INT (trunc_int_for_mode (i, args->mode));
      }
    else
      {
--- 376,382 ----
  	default:
  	  abort ();
  	}
!       args->result = GEN_INT_MODE (i, args->mode);
      }
    else
      {


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