* builtins.c (expand_builtin_setjmp): Only call convert_memory_address
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Oct 2001 22:59:15 +0000 (22:59 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 23 Oct 2001 22:59:15 +0000 (22:59 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@46448 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/calls.c
gcc/except.c
gcc/explow.c
gcc/expr.c
gcc/function.c
gcc/stmt.c

index 36e9e69..59580c5 100644 (file)
@@ -1,3 +1,23 @@
+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.
+
 2001-10-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * darwin-protos.h (constructor_section, destructor_section,
index fe12792..2ff203e 100644 (file)
@@ -456,7 +456,8 @@ expand_builtin_setjmp_setup (buf_addr, receiver_label)
     setjmp_alias_set = new_alias_set ();
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  buf_addr = convert_memory_address (Pmode, buf_addr);
+  if (GET_MODE (buf_addr) != Pmode)
+    buf_addr = convert_memory_address (Pmode, buf_addr);
 #endif
 
   buf_addr = force_reg (Pmode, force_operand (buf_addr, NULL_RTX));
@@ -642,8 +643,10 @@ expand_builtin_longjmp (buf_addr, value)
     setjmp_alias_set = new_alias_set ();
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  buf_addr = convert_memory_address (Pmode, buf_addr);
+  if (GET_MODE (buf_addr) != Pmode)
+    buf_addr = convert_memory_address (Pmode, buf_addr);
 #endif
+
   buf_addr = force_reg (Pmode, buf_addr);
 
   /* We used to store value in static_chain_rtx, but that fails if pointers
@@ -3104,7 +3107,8 @@ expand_builtin_alloca (arglist, target)
   result = allocate_dynamic_stack_space (op0, target, BITS_PER_UNIT);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  result = convert_memory_address (ptr_mode, result);
+  if (GET_MODE (result) != ptr_mode)
+    result = convert_memory_address (ptr_mode, result);
 #endif
 
   return result;
index 4969cd1..a0c451c 100644 (file)
@@ -1673,21 +1673,19 @@ rtx_for_function_call (fndecl, exp)
     {
       rtx funaddr;
       push_temp_slots ();
-      funaddr = funexp =
-       expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
+      funaddr = funexp
+       expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0);
       pop_temp_slots ();       /* FUNEXP can't be BLKmode.  */
 
       /* Check the function is executable.  */
       if (current_function_check_memory_usage)
        {
 #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);
+         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, Pmode);
+                            VOIDmode, 1, funaddr, ptr_mode);
        }
       emit_queue ();
     }
index 788f54e..0a33b18 100644 (file)
@@ -2944,10 +2944,11 @@ rtx
 expand_builtin_frob_return_addr (addr_tree)
      tree addr_tree;
 {
-  rtx addr = expand_expr (addr_tree, NULL_RTX, Pmode, 0);
+  rtx addr = expand_expr (addr_tree, NULL_RTX, ptr_mode, 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  addr = convert_memory_address (Pmode, addr);
+  if (GET_MODE (addr) != Pmode)
+    addr = convert_memory_address (Pmode, addr);
 #endif
 
 #ifdef RETURN_ADDR_OFFSET
@@ -2971,8 +2972,11 @@ expand_builtin_eh_return (stackadj_tree, handler_tree)
   handler = expand_expr (handler_tree, cfun->eh->ehr_handler, VOIDmode, 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  stackadj = convert_memory_address (Pmode, stackadj);
-  handler = convert_memory_address (Pmode, handler);
+  if (GET_MODE (stackadj) != Pmode)
+    stackadj = convert_memory_address (Pmode, stackadj);
+
+  if (GET_MODE (handler) != Pmode)
+    handler = convert_memory_address (Pmode, handler);
 #endif
 
   if (! cfun->eh->ehr_label)
index 533fe57..d0735aa 100644 (file)
@@ -472,7 +472,7 @@ memory_address (mode, x)
     return x;
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  if (GET_MODE (x) == ptr_mode)
+  if (GET_MODE (x) != Pmode)
     x = convert_memory_address (Pmode, x);
 #endif
 
@@ -1318,16 +1318,12 @@ allocate_dynamic_stack_space (size, target, known_align)
       enum machine_mode mode = STACK_SIZE_MODE;
       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
-
+      /* 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 = Pmode;
+       mode = insn_data[(int) CODE_FOR_allocate_stack].operand[1].mode;
 
       pred = insn_data[(int) CODE_FOR_allocate_stack].operand[1].predicate;
       if (pred && ! ((*pred) (size, mode)))
@@ -1461,7 +1457,11 @@ probe_stack_range (first, size)
      HOST_WIDE_INT first;
      rtx size;
 {
-  /* First see if the front end has set up a function for us to call to
+  /* 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)
     {
index 77503d3..3eebaa2 100644 (file)
@@ -3732,13 +3732,12 @@ expand_assignment (to, from, want_value, suggest_reg)
            abort ();
 
          if (GET_MODE (offset_rtx) != ptr_mode)
-           {
+           offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
+
 #ifdef POINTERS_EXTEND_UNSIGNED
-             offset_rtx = convert_memory_address (ptr_mode, offset_rtx);
-#else
-             offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
+         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
             to call force_reg for that case.  Avoid that case.  */
@@ -4637,7 +4636,8 @@ store_constructor (exp, target, align, cleared, size)
                offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-             offset_rtx = convert_memory_address (Pmode, offset_rtx);
+             if (GET_MODE (offset_rtx) != Pmode)
+               offset_rtx = convert_memory_address (Pmode, offset_rtx);
 #endif
 
              to_rtx = offset_address (to_rtx, offset_rtx,
@@ -7044,7 +7044,8 @@ expand_expr (exp, target, tmode, modifier)
              offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-           offset_rtx = convert_memory_address (ptr_mode, offset_rtx);
+           if (GET_MODE (offset_rtx) != Pmode)
+             offset_rtx = convert_memory_address (Pmode, offset_rtx);
 #endif
 
            /* A constant address in OP0 can have VOIDmode, we must not try
@@ -9057,7 +9058,8 @@ expand_expr_unaligned (exp, palign)
              offset_rtx = convert_to_mode (ptr_mode, offset_rtx, 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-           offset_rtx = convert_memory_address (ptr_mode, offset_rtx);
+           if (GET_MODE (offset_rtx) != Pmode)
+             offset_rtx = convert_memory_address (Pmode, offset_rtx);
 #endif
 
            op0 = offset_address (op0, offset_rtx,
index 08b3fdc..f4d0fff 100644 (file)
@@ -5018,8 +5018,15 @@ assign_parms (fndecl)
       if (parm == function_result_decl)
        {
          tree result = DECL_RESULT (fndecl);
-         rtx x = gen_rtx_MEM (DECL_MODE (result), DECL_RTL (parm));
+         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 1d84eea..4943397 100644 (file)
@@ -707,7 +707,8 @@ expand_computed_goto (exp)
   rtx x = expand_expr (exp, NULL_RTX, VOIDmode, 0);
 
 #ifdef POINTERS_EXTEND_UNSIGNED
-  x = convert_memory_address (Pmode, x);
+  if (GET_MODE (x) != Pmode)
+    x = convert_memory_address (Pmode, x);
 #endif
 
   emit_queue ();