PR target/23683
authoramylaar <amylaar@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Sep 2005 12:45:48 +0000 (12:45 +0000)
committeramylaar <amylaar@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Sep 2005 12:45:48 +0000 (12:45 +0000)
* sh.c (sh_reorg, emit_load_ptr): Use gen_const_mem.
(output_stack_adjust): Use gen_tmp_stack_mem.
(sh_expand_prologue, sh_expand_epilogue): Use gen_frame_mem.
(sh_set_return_address, sh_allocate_initial_value): Likewise.
(sh_get_pr_initial_val): Likewise.
(sh_builtin_saveregs): Use gen_frame_mem and change_address.
(sh_initialize_trampoline): Likewise.  Also use adjust_address.
* sh.md (divsi_inv_m0): Use gen_const_mem.
(push_fpscr, pop_fpscr, load_ra): Use gen_frame_mem.
(movdf_i4+1): Use gen_tmp_stack_mem.
(reload_outdf+3, reload_outdf+4, fpu_switch+1): Use change_address.
(fpu_switch+2): Likewise.
(movv4sf_i, movv16sf_i): Use adjust_address.
(symGOT_load): Set MEM_NOTRAP_P bit.

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

gcc/ChangeLog
gcc/config/sh/sh.c
gcc/config/sh/sh.md

index f7768e9..53a36c8 100644 (file)
@@ -1,3 +1,21 @@
+2005-09-05  J"orn Rennecke <joern.rennecke@st.com>
+
+       PR target/23683
+       * sh.c (sh_reorg, emit_load_ptr): Use gen_const_mem.
+       (output_stack_adjust): Use gen_tmp_stack_mem.
+       (sh_expand_prologue, sh_expand_epilogue): Use gen_frame_mem.
+       (sh_set_return_address, sh_allocate_initial_value): Likewise.
+       (sh_get_pr_initial_val): Likewise.
+       (sh_builtin_saveregs): Use gen_frame_mem and change_address.
+       (sh_initialize_trampoline): Likewise.  Also use adjust_address.
+       * sh.md (divsi_inv_m0): Use gen_const_mem.
+       (push_fpscr, pop_fpscr, load_ra): Use gen_frame_mem.
+       (movdf_i4+1): Use gen_tmp_stack_mem.
+       (reload_outdf+3, reload_outdf+4, fpu_switch+1): Use change_address.
+       (fpu_switch+2): Likewise.
+       (movv4sf_i, movv16sf_i): Use adjust_address.
+       (symGOT_load): Set MEM_NOTRAP_P bit.
+
 2005-09-04  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR target/23721
index 6f1442e..8e6333b 100644 (file)
@@ -4667,7 +4667,7 @@ sh_reorg (void)
                        }
                      last_float_move = scan;
                      last_float = src;
-                     newsrc = gen_rtx_MEM (mode,
+                     newsrc = gen_const_mem (mode,
                                        (((TARGET_SH4 && ! TARGET_FMOVD)
                                          || REGNO (dst) == FPUL_REG)
                                         ? r0_inc_rtx
@@ -5199,20 +5199,20 @@ output_stack_adjust (int size, rtx reg, int epilogue_p,
 
              adj_reg = gen_rtx_REG (GET_MODE (reg), 4);
              tmp_reg = gen_rtx_REG (GET_MODE (reg), 5);
-             emit_move_insn (gen_rtx_MEM (Pmode, reg), adj_reg);
+             emit_move_insn (gen_tmp_stack_mem (Pmode, reg), adj_reg);
              emit_insn (GEN_MOV (adj_reg, GEN_INT (size)));
              emit_insn (GEN_ADD3 (adj_reg, adj_reg, reg));
-             mem = gen_rtx_MEM (Pmode, gen_rtx_PRE_DEC (Pmode, adj_reg));
+             mem = gen_tmp_stack_mem (Pmode, gen_rtx_PRE_DEC (Pmode, adj_reg));
              emit_move_insn (mem, tmp_reg);
-               emit_move_insn (tmp_reg, gen_rtx_MEM (Pmode, reg));
-               mem = gen_rtx_MEM (Pmode, gen_rtx_PRE_DEC (Pmode, adj_reg));
-               emit_move_insn (mem, tmp_reg);
-               emit_move_insn (reg, adj_reg);
-               mem = gen_rtx_MEM (Pmode, gen_rtx_POST_INC (Pmode, reg));
-               emit_move_insn (adj_reg, mem);
-               mem = gen_rtx_MEM (Pmode, gen_rtx_POST_INC (Pmode, reg));
-               emit_move_insn (tmp_reg, mem);
-               return;
+             emit_move_insn (tmp_reg, gen_tmp_stack_mem (Pmode, reg));
+             mem = gen_tmp_stack_mem (Pmode, gen_rtx_PRE_DEC (Pmode, adj_reg));
+             emit_move_insn (mem, tmp_reg);
+             emit_move_insn (reg, adj_reg);
+             mem = gen_tmp_stack_mem (Pmode, gen_rtx_POST_INC (Pmode, reg));
+             emit_move_insn (adj_reg, mem);
+             mem = gen_tmp_stack_mem (Pmode, gen_rtx_POST_INC (Pmode, reg));
+             emit_move_insn (tmp_reg, mem);
+             return;
            }
          const_reg = gen_rtx_REG (GET_MODE (reg), temp);
 
@@ -5861,10 +5861,10 @@ sh_expand_prologue (void)
 
          reg_rtx = gen_rtx_REG (mode, reg);
 
-         mem_rtx = gen_rtx_MEM (mode,
-                                gen_rtx_PLUS (Pmode,
-                                              stack_pointer_rtx,
-                                              GEN_INT (offset)));
+         mem_rtx = gen_frame_mem (mode,
+                                  gen_rtx_PLUS (Pmode,
+                                                stack_pointer_rtx,
+                                                GEN_INT (offset)));
 
          GO_IF_LEGITIMATE_ADDRESS (mode, XEXP (mem_rtx, 0), try_pre_dec);
 
@@ -5878,8 +5878,7 @@ sh_expand_prologue (void)
                    || mem_rtx == NULL_RTX
                    || reg == PR_REG || SPECIAL_REGISTER_P (reg)))
              {
-               pre_dec = gen_rtx_MEM (mode,
-                                      gen_rtx_PRE_DEC (Pmode, r0));
+               pre_dec = gen_frame_mem (mode, gen_rtx_PRE_DEC (Pmode, r0));
 
                GO_IF_LEGITIMATE_ADDRESS (mode, XEXP (pre_dec, 0),
                                          pre_dec_ok);
@@ -5927,12 +5926,12 @@ sh_expand_prologue (void)
              mem_rtx = pre_dec;
            }
          else if (sp_in_r0)
-           mem_rtx = gen_rtx_MEM (mode, r0);
+           mem_rtx = gen_frame_mem (mode, r0);
          else
-           mem_rtx = gen_rtx_MEM (mode,
-                                  gen_rtx_PLUS (Pmode,
-                                                stack_pointer_rtx,
-                                                r0));
+           mem_rtx = gen_frame_mem (mode,
+                                    gen_rtx_PLUS (Pmode,
+                                                  stack_pointer_rtx,
+                                                  r0));
 
          /* We must not use an r0-based address for target-branch
             registers or for special registers without pre-dec
@@ -5992,10 +5991,10 @@ sh_expand_prologue (void)
              {
                rtx reg_rtx = gen_rtx_REG (mode, reg);
                rtx set, note_rtx;
-               rtx mem_rtx = gen_rtx_MEM (mode,
-                                          gen_rtx_PLUS (Pmode,
-                                                        stack_pointer_rtx,
-                                                        GEN_INT (offset)));
+               rtx mem_rtx = gen_frame_mem (mode,
+                                            gen_rtx_PLUS (Pmode,
+                                                          stack_pointer_rtx,
+                                                          GEN_INT (offset)));
 
                set = gen_rtx_SET (VOIDmode, mem_rtx, reg_rtx);
                note_rtx = gen_rtx_EXPR_LIST (REG_FRAME_RELATED_EXPR, set,
@@ -6179,10 +6178,10 @@ sh_expand_epilogue (bool sibcall_p)
          offset = offset_base + entry->offset;
          reg_rtx = gen_rtx_REG (mode, reg);
 
-         mem_rtx = gen_rtx_MEM (mode,
-                                gen_rtx_PLUS (Pmode,
-                                              stack_pointer_rtx,
-                                              GEN_INT (offset)));
+         mem_rtx = gen_frame_mem (mode,
+                                  gen_rtx_PLUS (Pmode,
+                                                stack_pointer_rtx,
+                                                GEN_INT (offset)));
 
          GO_IF_LEGITIMATE_ADDRESS (mode, XEXP (mem_rtx, 0), try_post_inc);
 
@@ -6196,8 +6195,7 @@ sh_expand_epilogue (bool sibcall_p)
                        && mem_rtx == NULL_RTX)
                    || reg == PR_REG || SPECIAL_REGISTER_P (reg)))
              {
-               post_inc = gen_rtx_MEM (mode,
-                                       gen_rtx_POST_INC (Pmode, r0));
+               post_inc = gen_frame_mem (mode, gen_rtx_POST_INC (Pmode, r0));
 
                GO_IF_LEGITIMATE_ADDRESS (mode, XEXP (post_inc, 0),
                                          post_inc_ok);
@@ -6243,12 +6241,12 @@ sh_expand_epilogue (bool sibcall_p)
              offset_in_r0 += GET_MODE_SIZE (mode);
            }
          else if (sp_in_r0)
-           mem_rtx = gen_rtx_MEM (mode, r0);
+           mem_rtx = gen_frame_mem (mode, r0);
          else
-           mem_rtx = gen_rtx_MEM (mode,
-                                  gen_rtx_PLUS (Pmode,
-                                                stack_pointer_rtx,
-                                                r0));
+           mem_rtx = gen_frame_mem (mode,
+                                    gen_rtx_PLUS (Pmode,
+                                                  stack_pointer_rtx,
+                                                  r0));
 
          gcc_assert ((reg != PR_REG && !SPECIAL_REGISTER_P (reg))
                      || mem_rtx == post_inc);
@@ -6408,7 +6406,7 @@ sh_set_return_address (rtx ra, rtx tmp)
   emit_insn (GEN_MOV (tmp, GEN_INT (pr_offset)));
   emit_insn (GEN_ADD3 (tmp, tmp, hard_frame_pointer_rtx));
 
-  tmp = gen_rtx_MEM (Pmode, tmp);
+  tmp = gen_frame_mem (Pmode, tmp);
   emit_insn (GEN_MOV (tmp, ra));
 }
 
@@ -6485,8 +6483,7 @@ sh_builtin_saveregs (void)
   bufsize = (n_intregs * UNITS_PER_WORD) + (n_floatregs * UNITS_PER_WORD);
 
   if (TARGET_SHMEDIA)
-    regbuf = gen_rtx_MEM (BLKmode,
-                         gen_rtx_REG (Pmode, ARG_POINTER_REGNUM));
+    regbuf = gen_frame_mem (BLKmode, gen_rtx_REG (Pmode, ARG_POINTER_REGNUM));
   else if (n_floatregs & 1)
     {
       rtx addr;
@@ -6542,8 +6539,7 @@ sh_builtin_saveregs (void)
        {
          emit_insn (gen_addsi3 (fpregs, fpregs,
                                 GEN_INT (-2 * UNITS_PER_WORD)));
-         mem = gen_rtx_MEM (DFmode, fpregs);
-         set_mem_alias_set (mem, alias_set);
+         mem = change_address (regbuf, DFmode, fpregs);
          emit_move_insn (mem,
                          gen_rtx_REG (DFmode, BASE_ARG_REG (DFmode) + regno));
        }
@@ -6551,8 +6547,7 @@ sh_builtin_saveregs (void)
       if (regno & 1)
        {
          emit_insn (gen_addsi3 (fpregs, fpregs, GEN_INT (-UNITS_PER_WORD)));
-         mem = gen_rtx_MEM (SFmode, fpregs);
-         set_mem_alias_set (mem, alias_set);
+         mem = change_address (regbuf, SFmode, fpregs);
          emit_move_insn (mem,
                          gen_rtx_REG (SFmode, BASE_ARG_REG (SFmode) + regno
                                                - (TARGET_LITTLE_ENDIAN != 0)));
@@ -6564,8 +6559,7 @@ sh_builtin_saveregs (void)
         rtx mem;
 
        emit_insn (gen_addsi3 (fpregs, fpregs, GEN_INT (-UNITS_PER_WORD)));
-       mem = gen_rtx_MEM (SFmode, fpregs);
-       set_mem_alias_set (mem, alias_set);
+       mem = change_address (regbuf, SFmode, fpregs);
        emit_move_insn (mem,
                        gen_rtx_REG (SFmode, BASE_ARG_REG (SFmode) + regno));
       }
@@ -8502,7 +8496,7 @@ sh_allocate_initial_value (rtx hard_reg)
                    || current_function_has_nonlocal_label)))
        x = hard_reg;
       else
-       x = gen_rtx_MEM (Pmode, return_address_pointer_rtx);
+       x = gen_frame_mem (Pmode, return_address_pointer_rtx);
     }
   else
     x = NULL_RTX;
@@ -8896,6 +8890,8 @@ sh_ms_bitfield_layout_p (tree record_type ATTRIBUTE_UNUSED)
 void
 sh_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
 {
+  rtx tramp_mem = gen_frame_mem (BLKmode, tramp);
+
   if (TARGET_SHMEDIA64)
     {
       rtx tramp_templ;
@@ -8924,34 +8920,32 @@ sh_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
          insn = gen_rtx_IOR (DImode, insn, gen_int_mode (0xec000010, SImode));
          insn = force_operand (insn, NULL_RTX);
          insn = gen_lowpart (SImode, insn);
-         emit_move_insn (gen_rtx_MEM (SImode, tramp), insn);
+         emit_move_insn (change_address (tramp_mem, SImode, NULL_RTX), insn);
          insn = gen_rtx_LSHIFTRT (DImode, fnaddr, GEN_INT (38));
          insn = gen_rtx_AND (DImode, insn, mask);
          insn = force_operand (gen_rtx_IOR (DImode, movi1, insn), NULL_RTX);
          insn = gen_lowpart (SImode, insn);
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 4)), insn);
+         emit_move_insn (adjust_address (tramp_mem, SImode, 4), insn);
          insn = gen_rtx_LSHIFTRT (DImode, fnaddr, GEN_INT (22));
          insn = gen_rtx_AND (DImode, insn, mask);
          insn = force_operand (gen_rtx_IOR (DImode, shori1, insn), NULL_RTX);
          insn = gen_lowpart (SImode, insn);
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 8)), insn);
+         emit_move_insn (adjust_address (tramp_mem, SImode, 8), insn);
          insn = gen_rtx_LSHIFTRT (DImode, fnaddr, GEN_INT (6));
          insn = gen_rtx_AND (DImode, insn, mask);
          insn = force_operand (gen_rtx_IOR (DImode, shori1, insn), NULL_RTX);
          insn = gen_lowpart (SImode, insn);
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 12)),
-                         insn);
+         emit_move_insn (adjust_address (tramp_mem, SImode, 12), insn);
          insn = gen_rtx_ASHIFT (DImode, fnaddr, GEN_INT (10));
          insn = gen_rtx_AND (DImode, insn, mask);
          insn = force_operand (gen_rtx_IOR (DImode, shori1, insn), NULL_RTX);
          insn = gen_lowpart (SImode, insn);
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 16)),
-                         insn);
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 20)),
+         emit_move_insn (adjust_address (tramp_mem, SImode, 16), insn);
+         emit_move_insn (adjust_address (tramp_mem, SImode, 20),
                          GEN_INT (0x6bf10600));
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 24)),
+         emit_move_insn (adjust_address (tramp_mem, SImode, 24),
                          GEN_INT (0x4415fc10));
-         emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 28)),
+         emit_move_insn (adjust_address (tramp_mem, SImode, 28),
                          GEN_INT (0x4401fff0));
          emit_insn (gen_ic_invalidate_line (tramp));
          return;
@@ -8960,18 +8954,15 @@ sh_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
       fixed_len = TRAMPOLINE_SIZE - 2 * GET_MODE_SIZE (Pmode);
 
       tramp_templ = gen_datalabel_ref (tramp_templ);
-      dst = gen_rtx_MEM (BLKmode, tramp);
-      src = gen_rtx_MEM (BLKmode, tramp_templ);
+      dst = tramp_mem;
+      src = gen_const_mem (BLKmode, tramp_templ);
       set_mem_align (dst, 256);
       set_mem_align (src, 64);
       emit_block_move (dst, src, GEN_INT (fixed_len), BLOCK_OP_NORMAL);
 
-      emit_move_insn (gen_rtx_MEM (Pmode, plus_constant (tramp,        fixed_len)),
-                     fnaddr);
-      emit_move_insn (gen_rtx_MEM (Pmode,
-                                  plus_constant (tramp,
-                                                 fixed_len
-                                                 + GET_MODE_SIZE (Pmode))),
+      emit_move_insn (adjust_address (tramp_mem, Pmode, fixed_len), fnaddr);
+      emit_move_insn (adjust_address (tramp_mem, Pmode,
+                                     fixed_len + GET_MODE_SIZE (Pmode)),
                      cxt);
       emit_insn (gen_ic_invalidate_line (tramp));
       return;
@@ -8999,7 +8990,7 @@ sh_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
       emit_insn (gen_rotrdi3_mextr (quad0, quad0,
                                    GEN_INT (TARGET_LITTLE_ENDIAN ? 24 : 56)));
       emit_insn (gen_ashldi3_media (quad0, quad0, const2_rtx));
-      emit_move_insn (gen_rtx_MEM (DImode, tramp), quad0);
+      emit_move_insn (change_address (tramp_mem, DImode, NULL_RTX), quad0);
       emit_insn (gen_mshflo_w_x (gen_rtx_SUBREG (V4HImode, cxtload, 0),
                                 gen_rtx_SUBREG (V2HImode, cxt, 0),
                                 movishori));
@@ -9016,8 +9007,8 @@ sh_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
          emit_insn (gen_mextr4 (quad1, cxtload, ptabs));
          emit_insn (gen_mshflo_l_di (quad2, blink, cxtload));
        }
-      emit_move_insn (gen_rtx_MEM (DImode, plus_constant (tramp, 8)), quad1);
-      emit_move_insn (gen_rtx_MEM (DImode, plus_constant (tramp, 16)), quad2);
+      emit_move_insn (adjust_address (tramp_mem, DImode, 8), quad1);
+      emit_move_insn (adjust_address (tramp_mem, DImode, 16), quad2);
       emit_insn (gen_ic_invalidate_line (tramp));
       return;
     }
@@ -9026,16 +9017,14 @@ sh_initialize_trampoline (rtx tramp, rtx fnaddr, rtx cxt)
       emit_insn (gen_initialize_trampoline (tramp, cxt, fnaddr));
       return;
     }
-  emit_move_insn (gen_rtx_MEM (SImode, tramp),
+  emit_move_insn (change_address (tramp_mem, SImode, NULL_RTX),
                  gen_int_mode (TARGET_LITTLE_ENDIAN ? 0xd301d202 : 0xd202d301,
                                SImode));
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 4)),
+  emit_move_insn (adjust_address (tramp_mem, SImode, 4),
                  gen_int_mode (TARGET_LITTLE_ENDIAN ? 0x0009422b : 0x422b0009,
                                SImode));
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 8)),
-                 cxt);
-  emit_move_insn (gen_rtx_MEM (SImode, plus_constant (tramp, 12)),
-                 fnaddr);
+  emit_move_insn (adjust_address (tramp_mem, SImode, 8), cxt);
+  emit_move_insn (adjust_address (tramp_mem, SImode, 12), fnaddr);
   if (TARGET_HARVARD)
     {
       if (TARGET_USERMODE)
@@ -9557,7 +9546,7 @@ static rtx emit_load_ptr (rtx, rtx);
 static rtx
 emit_load_ptr (rtx reg, rtx addr)
 {
-  rtx mem = gen_rtx_MEM (ptr_mode, addr);
+  rtx mem = gen_const_mem (ptr_mode, addr);
 
   if (Pmode != ptr_mode)
     mem = gen_rtx_SIGN_EXTEND (Pmode, mem);
@@ -9864,7 +9853,7 @@ sh_get_pr_initial_val (void)
       && ((current_function_args_info.call_cookie
           & ~ CALL_COOKIE_RET_TRAMP (1))
          || current_function_has_nonlocal_label))
-    return gen_rtx_MEM (SImode, return_address_pointer_rtx);
+    return gen_frame_mem (SImode, return_address_pointer_rtx);
 
   /* If we haven't finished rtl generation, there might be a nonlocal label
      that we haven't seen yet.
index 0c93a4d..4662b53 100644 (file)
@@ -2169,11 +2169,11 @@ norm32: r25
   rtx scratch1 = operands[5];
   rtx mem;
 
-  mem = gen_rtx_MEM (QImode, gen_rtx_PLUS (DImode, tab_base, tab_ix));
+  mem = gen_const_mem (QImode, gen_rtx_PLUS (DImode, tab_base, tab_ix));
   emit_insn (gen_zero_extendqidi2 (scratch0, mem));
   emit_insn (gen_ashldi3_media (scratch1, tab_ix, GEN_INT (1)));
   emit_insn (gen_mulsidi3_media (scratch0, norm32, scratch0_si));
-  mem = gen_rtx_MEM (HImode, gen_rtx_PLUS (DImode, tab_base, scratch1));
+  mem = gen_const_mem (HImode, gen_rtx_PLUS (DImode, tab_base, scratch1));
   emit_insn (gen_extendhidi2 (scratch1, mem));
   emit_insn (gen_ashrdi3_media (scratch0, scratch0, GEN_INT (24)));
   emit_insn (gen_subdisi3_media (inv0, scratch1, scratch0));
@@ -4697,7 +4697,7 @@ label:
   "TARGET_SH2E"
   "
 {
-  rtx insn = emit_insn (gen_fpu_switch (gen_rtx_MEM (PSImode,
+  rtx insn = emit_insn (gen_fpu_switch (gen_frame_mem (PSImode,
                                                 gen_rtx_PRE_DEC (Pmode,
                                                          stack_pointer_rtx)),
                                        get_fpscr_rtx ()));
@@ -4711,7 +4711,7 @@ label:
   "
 {
   rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
-                                       gen_rtx_MEM (PSImode,
+                                       gen_frame_mem (PSImode,
                                                 gen_rtx_POST_INC (Pmode,
                                                          stack_pointer_rtx))));
   REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, NULL_RTX);
@@ -4834,7 +4834,7 @@ label:
   "
 {
   if (TARGET_SHCOMPACT && current_function_has_nonlocal_label)
-    operands[1] = gen_rtx_MEM (SImode, return_address_pointer_rtx);
+    operands[1] = gen_frame_mem (SImode, return_address_pointer_rtx);
 }")
 
 ;; The '?'s in the following constraints may not reflect the time taken
@@ -5736,17 +5736,19 @@ label:
     {
       emit_move_insn (stack_pointer_rtx,
                      plus_constant (stack_pointer_rtx, -8));
-      tos = gen_rtx_MEM (DFmode, stack_pointer_rtx);
+      tos = gen_tmp_stack_mem (DFmode, stack_pointer_rtx);
     }
   else
-    tos = gen_rtx_MEM (DFmode, gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx));
+    tos = gen_tmp_stack_mem (DFmode,
+                            gen_rtx_PRE_DEC (Pmode, stack_pointer_rtx));
   insn = emit_insn (gen_movdf_i4 (tos, operands[1], operands[2]));
   if (! (TARGET_SH5 && true_regnum (operands[1]) < 16))
     REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, stack_pointer_rtx, NULL_RTX);
   if (TARGET_SH5 && true_regnum (operands[0]) < 16)
-    tos = gen_rtx_MEM (DFmode, stack_pointer_rtx);
+    tos = gen_tmp_stack_mem (DFmode, stack_pointer_rtx);
   else
-    tos = gen_rtx_MEM (DFmode, gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
+    tos = gen_tmp_stack_mem (DFmode,
+                            gen_rtx_POST_INC (Pmode, stack_pointer_rtx));
   insn = emit_insn (gen_movdf_i4 (operands[0], tos, operands[2]));
   if (TARGET_SH5 && true_regnum (operands[0]) < 16)
     emit_move_insn (stack_pointer_rtx, plus_constant (stack_pointer_rtx, 8));
@@ -5902,15 +5904,16 @@ label:
 {
   int regno = true_regnum (operands[0]);
   rtx insn;
-  rtx mem2 = gen_rtx_MEM (SFmode, gen_rtx_POST_INC (Pmode, operands[1]));
-
+  rtx mem = SET_SRC (XVECEXP (PATTERN (curr_insn), 0, 0));
+  rtx mem2
+    = change_address (mem, SFmode, gen_rtx_POST_INC (Pmode, operands[1]));
   insn = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode,
                                           regno + !! TARGET_LITTLE_ENDIAN),
                                  mem2, operands[2]));
   REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, operands[1], NULL_RTX);
   insn = emit_insn (gen_movsf_ie (gen_rtx_REG (SFmode,
-                                          regno + ! TARGET_LITTLE_ENDIAN),
-                                 gen_rtx_MEM (SFmode, operands[1]),
+                                              regno + ! TARGET_LITTLE_ENDIAN),
+                                 change_address (mem, SFmode, NULL_RTX),
                                  operands[2]));
   DONE;
 }")
@@ -5927,11 +5930,10 @@ label:
 {
   int regno = true_regnum (operands[0]);
   rtx addr, insn, adjust = NULL_RTX;
-  rtx mem2 = copy_rtx (operands[1]);
+  rtx mem2 = change_address (operands[1], SFmode, NULL_RTX);
   rtx reg0 = gen_rtx_REG (SFmode, regno + !! TARGET_LITTLE_ENDIAN);
   rtx reg1 = gen_rtx_REG (SFmode, regno + ! TARGET_LITTLE_ENDIAN);
 
-  PUT_MODE (mem2, SFmode);
   operands[1] = copy_rtx (mem2);
   addr = XEXP (mem2, 0);
   if (GET_CODE (addr) != POST_INC)
@@ -6226,16 +6228,14 @@ label:
       rtx x, y;
 
       if (GET_CODE (operands[0]) == MEM)
-       x = gen_rtx_MEM (V2SFmode,
-                        plus_constant (XEXP (operands[0], 0),
-                                       i * GET_MODE_SIZE (V2SFmode)));
+       x = adjust_address (operands[0], V2SFmode,
+                           i * GET_MODE_SIZE (V2SFmode));
       else
        x = simplify_gen_subreg (V2SFmode, operands[0], V4SFmode, i * 8);
 
       if (GET_CODE (operands[1]) == MEM)
-       y = gen_rtx_MEM (V2SFmode,
-                        plus_constant (XEXP (operands[1], 0),
-                                       i * GET_MODE_SIZE (V2SFmode)));
+       y = adjust_address (operands[1], V2SFmode,
+                           i * GET_MODE_SIZE (V2SFmode));
       else
        y = simplify_gen_subreg (V2SFmode, operands[1], V4SFmode, i * 8);
 
@@ -6272,9 +6272,8 @@ label:
       rtx x,y;
 
       if (GET_CODE (operands[0]) == MEM)
-       x = gen_rtx_MEM (V2SFmode,
-                        plus_constant (XEXP (operands[0], 0),
-                                       i * GET_MODE_SIZE (V2SFmode)));
+       x = adjust_address (operands[0], V2SFmode,
+                           i * GET_MODE_SIZE (V2SFmode));
       else
        {
          x = gen_rtx_SUBREG (V2SFmode, operands[0], i * 8);
@@ -6282,9 +6281,8 @@ label:
        }
 
       if (GET_CODE (operands[1]) == MEM)
-       y = gen_rtx_MEM (V2SFmode,
-                        plus_constant (XEXP (operands[1], 0),
-                                       i * GET_MODE_SIZE (V2SFmode)));
+       y = adjust_address (operands[1], V2SFmode,
+                           i * GET_MODE_SIZE (V2SFmode));
       else
        {
          y = gen_rtx_SUBREG (V2SFmode, operands[1], i * 8);
@@ -8252,7 +8250,7 @@ label:
   ""
   "
 {
-  rtx insn;
+  rtx insn, mem;
 
   operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
   operands[3] = no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode);
@@ -8283,7 +8281,11 @@ label:
                                             operands[2],
                                             gen_rtx_REG (Pmode, PIC_REG)));
 
-  insn = emit_move_insn (operands[0], gen_rtx_MEM (Pmode, operands[3]));
+  /* N.B. This is not constant for a GOTPLT relocation.  */
+  mem = gen_rtx_MEM (Pmode, operands[3]);
+  MEM_NOTRAP_P (mem) = 1;
+  /* ??? Should we have a special alias set for the GOT?  */
+  insn = emit_move_insn (operands[0], mem);
 
   REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, XVECEXP (XEXP (operands[1],
                                                                  0), 0, 0),
@@ -9827,10 +9829,11 @@ mov.l\\t1f,r0\\n\\
   [(set (match_dup 0) (match_dup 0))]
   "
 {
-  rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
-                                       gen_rtx_MEM (PSImode,
-                                                gen_rtx_POST_INC (Pmode,
-                                                         operands[0]))));
+  rtx mem, insn;
+
+  mem = SET_SRC (PATTERN (curr_insn));
+  mem = change_address (mem, PSImode, gen_rtx_POST_INC (Pmode, operands[0]));
+  insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (), mem));
   REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, operands[0], NULL_RTX);
 }")
 
@@ -9841,10 +9844,11 @@ mov.l\\t1f,r0\\n\\
   [(set (match_dup 0) (plus:SI (match_dup 0) (const_int -4)))]
   "
 {
-  rtx insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (),
-                                       gen_rtx_MEM (PSImode,
-                                                gen_rtx_POST_INC (Pmode,
-                                                         operands[0]))));
+  rtx mem, insn;
+
+  mem = SET_SRC (PATTERN (curr_insn));
+  mem = change_address (mem, PSImode, gen_rtx_POST_INC (Pmode, operands[0]));
+  insn = emit_insn (gen_fpu_switch (get_fpscr_rtx (), mem));
   REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_INC, operands[0], NULL_RTX);
 }")