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]

Fix POINTERS_EXTEND_UNSIGNED bugs


This fixes a number of such.  Tested on sparc64-wrs-vxworks, one of
the few systems that uses it, and sanity-checked on alphaev56-dec-osf4.0c.

Tue Oct 23 13:05:53 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.

	* builtins.c (expand_builtin_setjmp): Only call convert_memory_address
	if needed.
	(expand_builtin_longjmp, expand_builtin_alloca): Likewise.
	* except.c (expand_builtin_frob_return_addr): Likewise.
	(expand_builtin_eh_return): Likewise.
	* stmt.c (expand_computed_goto): Likewise.
	* explow.c (memory_address): Likewise.
	(allocate_dynamic_stack_space): Clean up predicate testing.
	(probe_stack_range): Convert SIZE to Pmode.
	* calls.c (rtx_for_function_call): Only call convert_memory_address
	if needed.
	Pass function call operand as ptr_mode, not Pmode.
	* expr.c (expand_assignment): Clean up calls to convert_memory
	address by only doing so when needed and making offsets Pmode.
	(store_constructor, expand_expr, expand_expr_unaligned): Likewise.
	* function.c (assign_parms): Ensure address in MEM for RESULT_DECL
	is in Pmode, not ptr_mode.

*** builtins.c	2001/10/23 18:51:00	1.123
--- builtins.c	2001/10/23 21:35:54
*************** expand_builtin_setjmp_setup (buf_addr, r
*** 457,461 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   buf_addr = convert_memory_address (Pmode, buf_addr);
  #endif
  
--- 457,462 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (buf_addr) != Pmode)
!     buf_addr = convert_memory_address (Pmode, buf_addr);
  #endif
  
*************** expand_builtin_longjmp (buf_addr, value)
*** 643,648 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   buf_addr = convert_memory_address (Pmode, buf_addr);
  #endif
    buf_addr = force_reg (Pmode, buf_addr);
  
--- 644,651 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (buf_addr) != Pmode)
!     buf_addr = convert_memory_address (Pmode, buf_addr);
  #endif
+ 
    buf_addr = force_reg (Pmode, buf_addr);
  
*************** expand_builtin_alloca (arglist, target)
*** 3105,3109 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   result = convert_memory_address (ptr_mode, result);
  #endif
  
--- 3108,3113 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (result) != ptr_mode)
!     result = convert_memory_address (ptr_mode, result);
  #endif
  
*** calls.c	2001/10/23 19:11:48	1.206
--- calls.c	2001/10/23 21:36:22
*************** rtx_for_function_call (fndecl, exp)
*** 1674,1679 ****
        rtx funaddr;
        push_temp_slots ();
!       funaddr = funexp =
! 	expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
        pop_temp_slots ();	/* FUNEXP can't be BLKmode.  */
  
--- 1674,1679 ----
        rtx funaddr;
        push_temp_slots ();
!       funaddr = funexp
! 	= expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
        pop_temp_slots ();	/* FUNEXP can't be BLKmode.  */
  
*************** rtx_for_function_call (fndecl, exp)
*** 1682,1692 ****
  	{
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	  /* It might be OK to convert funexp in place, but there's
! 	     a lot going on between here and when it happens naturally
! 	     that this seems safer.  */
! 	  funaddr = convert_memory_address (Pmode, funexp);
  #endif
  	  emit_library_call (chkr_check_exec_libfunc, LCT_CONST_MAKE_BLOCK,
! 			     VOIDmode, 1, funaddr, Pmode);
  	}
        emit_queue ();
--- 1682,1690 ----
  	{
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	  if (GET_MODE (funexp) != ptr_mode)
! 	    funaddr = convert_memory_address (ptr_mode, funexp);
  #endif
  	  emit_library_call (chkr_check_exec_libfunc, LCT_CONST_MAKE_BLOCK,
! 			     VOIDmode, 1, funaddr, ptr_mode);
  	}
        emit_queue ();
*** except.c	2001/10/22 14:43:27	1.196
--- except.c	2001/10/23 21:36:55
*************** expand_builtin_frob_return_addr (addr_tr
*** 2945,2952 ****
       tree addr_tree;
  {
!   rtx addr = expand_expr (addr_tree, NULL_RTX, Pmode, 0);
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   addr = convert_memory_address (Pmode, addr);
  #endif
  
--- 2945,2953 ----
       tree addr_tree;
  {
!   rtx addr = expand_expr (addr_tree, NULL_RTX, ptr_mode, 0);
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (addr) != Pmode)
!     addr = convert_memory_address (Pmode, addr);
  #endif
  
*************** expand_builtin_eh_return (stackadj_tree,
*** 2972,2977 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   stackadj = convert_memory_address (Pmode, stackadj);
!   handler = convert_memory_address (Pmode, handler);
  #endif
  
--- 2973,2981 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (stackadj) != Pmode)
!     stackadj = convert_memory_address (Pmode, stackadj);
! 
!   if (GET_MODE (handler) != Pmode)
!     handler = convert_memory_address (Pmode, handler);
  #endif
  
*** explow.c	2001/10/11 03:15:32	1.79
--- explow.c	2001/10/23 21:37:02
*************** memory_address (mode, x)
*** 473,477 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (x) == ptr_mode)
      x = convert_memory_address (Pmode, x);
  #endif
--- 473,477 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (x) != Pmode)
      x = convert_memory_address (Pmode, x);
  #endif
*************** allocate_dynamic_stack_space (size, targ
*** 1319,1332 ****
        insn_operand_predicate_fn pred;
  
!       pred = insn_data[(int) CODE_FOR_allocate_stack].operand[0].predicate;
!       if (pred && ! ((*pred) (target, Pmode)))
! #ifdef POINTERS_EXTEND_UNSIGNED
! 	target = convert_memory_address (Pmode, target);
! #else
! 	target = copy_to_mode_reg (Pmode, target);
! #endif
! 
        if (mode == VOIDmode)
! 	mode = Pmode;
  
        pred = insn_data[(int) CODE_FOR_allocate_stack].operand[1].predicate;
--- 1319,1328 ----
        insn_operand_predicate_fn pred;
  
!       /* We don't have to check against the predicate for operand 0 since
! 	 TARGET is known to be a pseudo of the proper mode, which must
! 	 be valid for the operand.  For operand 1, convert to the
! 	 proper mode and validate.  */
        if (mode == VOIDmode)
! 	mode = insn_data[(int) CODE_FOR_allocate_stack].operand[1].mode;
  
        pred = insn_data[(int) CODE_FOR_allocate_stack].operand[1].predicate;
*************** probe_stack_range (first, size)
*** 1462,1466 ****
       rtx size;
  {
!   /* First see if the front end has set up a function for us to call to
       check the stack.  */
    if (stack_check_libfunc != 0)
--- 1458,1466 ----
       rtx size;
  {
!   /* First ensure SIZE is Pmode.  */
!   if (GET_MODE (size) != VOIDmode && GET_MODE (size) != Pmode)
!     size = convert_to_mode (Pmode, size, 1);
! 
!   /* Next see if the front end has set up a function for us to call to
       check the stack.  */
    if (stack_check_libfunc != 0)
*** expr.c	2001/10/23 18:51:02	1.363
--- expr.c	2001/10/23 21:39:09
*************** expand_assignment (to, from, want_value,
*** 3733,3743 ****
  
  	  if (GET_MODE (offset_rtx) != ptr_mode)
! 	    {
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	      offset_rtx = convert_memory_address (ptr_mode, offset_rtx);
! #else
! 	      offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
  #endif
- 	    }
  
  	  /* A constant address in TO_RTX can have VOIDmode, we must not try
--- 3733,3742 ----
  
  	  if (GET_MODE (offset_rtx) != ptr_mode)
! 	    offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
! 
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	  if (GET_MODE (offset_rtx) != Pmode)
! 	    offset_rtx = convert_memory_address (Pmode, offset_rtx);
  #endif
  
  	  /* A constant address in TO_RTX can have VOIDmode, we must not try
*************** store_constructor (exp, target, align, c
*** 4638,4642 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	      offset_rtx = convert_memory_address (Pmode, offset_rtx);
  #endif
  
--- 4637,4642 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	      if (GET_MODE (offset_rtx) != Pmode)
! 		offset_rtx = convert_memory_address (Pmode, offset_rtx);
  #endif
  
*************** expand_expr (exp, target, tmode, modifie
*** 7045,7049 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	    offset_rtx = convert_memory_address (ptr_mode, offset_rtx);
  #endif
  
--- 7045,7050 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	    if (GET_MODE (offset_rtx) != Pmode)
! 	      offset_rtx = convert_memory_address (Pmode, offset_rtx);
  #endif
  
*************** expand_expr_unaligned (exp, palign)
*** 9058,9062 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	    offset_rtx = convert_memory_address (ptr_mode, offset_rtx);
  #endif
  
--- 9059,9064 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
! 	    if (GET_MODE (offset_rtx) != Pmode)
! 	      offset_rtx = convert_memory_address (Pmode, offset_rtx);
  #endif
  
*** stmt.c	2001/10/18 21:34:14	1.221
--- stmt.c	2001/10/23 21:42:05
*************** expand_computed_goto (exp)
*** 708,712 ****
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   x = convert_memory_address (Pmode, x);
  #endif
  
--- 708,713 ----
  
  #ifdef POINTERS_EXTEND_UNSIGNED
!   if (GET_MODE (x) != Pmode)
!     x = convert_memory_address (Pmode, x);
  #endif
  
*** function.c	2001/10/19 19:42:45	1.316
--- function.c	2001/10/23 20:07:03
*************** assign_parms (fndecl)
*** 5018,5023 ****
  	{
  	  tree result = DECL_RESULT (fndecl);
! 	  rtx x = gen_rtx_MEM (DECL_MODE (result), DECL_RTL (parm));
  
  	  set_mem_attributes (x, result, 1);
  	  SET_DECL_RTL (result, x);
--- 5019,5031 ----
  	{
  	  tree result = DECL_RESULT (fndecl);
! 	  rtx addr = DECL_RTL (parm);
! 	  rtx x;
  
+ #ifdef POINTERS_EXTEND_UNSIGNED
+ 	  if (GET_MODE (addr) != Pmode)
+ 	    addr = convert_memory_address (Pmode, addr);
+ #endif
+ 
+ 	  x = gen_rtx_MEM (DECL_MODE (result), addr);
  	  set_mem_attributes (x, result, 1);
  	  SET_DECL_RTL (result, x);


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