From: Richard Henderson Date: Wed, 18 Aug 2004 21:08:35 +0000 (-0700) Subject: emit-rtl.c (gen_const_mem): New. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=542a8afa8a40e0714720ce168046a3880a44d311;p=gcc.git emit-rtl.c (gen_const_mem): New. * emit-rtl.c (gen_const_mem): New. * rtl.h (gen_const_mem): Declare. * expr.c (do_tablejump): Use it. * varasm.c (force_const_mem): Likewise. * config/darwin.c (machopic_indirect_data_reference): Likewise. (machopic_legitimize_pic_address): Likewise. * config/arm/arm.c (legitimize_pic_address): Likewise. * config/i386/i386.c (legitimize_pic_address): Likewise. (legitimize_tls_address): Likewise. * config/ia64/ia64.c (ia64_expand_tls_address): Likewise. * config/ia64/ia64.md (load_fptr): Likewise. * config/m32r/m32r.c (m32r_legitimize_pic_address): Likewise. * config/pa/pa.c (legitimize_pic_address): Likewise. * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Likewise. (rs6000_emit_move): Likewise. * config/s390/s390.c (legitimize_pic_address): Likewise. (legitimize_tls_address): Likewise. * config/s390/s390.md (casesi): Likewise. * config/sh/sh.c (sh_reorg): Likewise. * config/sparc/sparc.c (legitimize_pic_address): Likewise. * config/v850/v850.md (casesi): Likewise. * config/darwin.c (machopic_indirect_call_target): Set MEM_NOTRAP_P. * config/sh/sh.c (prepare_move_operands): Remove incorrect use of MEM_READONLY_P. From-SVN: r86207 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 58420cf30ae..48597b531c2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,31 @@ +2004-08-18 Richard Henderson + + * emit-rtl.c (gen_const_mem): New. + * rtl.h (gen_const_mem): Declare. + * expr.c (do_tablejump): Use it. + * varasm.c (force_const_mem): Likewise. + * config/darwin.c (machopic_indirect_data_reference): Likewise. + (machopic_legitimize_pic_address): Likewise. + * config/arm/arm.c (legitimize_pic_address): Likewise. + * config/i386/i386.c (legitimize_pic_address): Likewise. + (legitimize_tls_address): Likewise. + * config/ia64/ia64.c (ia64_expand_tls_address): Likewise. + * config/ia64/ia64.md (load_fptr): Likewise. + * config/m32r/m32r.c (m32r_legitimize_pic_address): Likewise. + * config/pa/pa.c (legitimize_pic_address): Likewise. + * config/rs6000/rs6000.c (rs6000_legitimize_tls_address): Likewise. + (rs6000_emit_move): Likewise. + * config/s390/s390.c (legitimize_pic_address): Likewise. + (legitimize_tls_address): Likewise. + * config/s390/s390.md (casesi): Likewise. + * config/sh/sh.c (sh_reorg): Likewise. + * config/sparc/sparc.c (legitimize_pic_address): Likewise. + * config/v850/v850.md (casesi): Likewise. + + * config/darwin.c (machopic_indirect_call_target): Set MEM_NOTRAP_P. + * config/sh/sh.c (prepare_move_operands): Remove incorrect + use of MEM_READONLY_P. + 2004-08-18 Steven Bosscher * Makefile.in (OBJS-common): Add postreload-gcse.c. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index fb96c38ab52..ed6445fff0a 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -2921,10 +2921,9 @@ legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg) pic_ref = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, address); else { - pic_ref = gen_rtx_MEM (Pmode, - gen_rtx_PLUS (Pmode, pic_offset_table_rtx, - address)); - MEM_READONLY_P (pic_ref) = 1; + pic_ref = gen_const_mem (Pmode, + gen_rtx_PLUS (Pmode, pic_offset_table_rtx, + address)); } insn = emit_move_insn (reg, pic_ref); diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c index 7b6a524db8d..579daf876fa 100644 --- a/gcc/config/darwin.c +++ b/gcc/config/darwin.c @@ -386,10 +386,9 @@ machopic_indirect_data_reference (rtx orig, rtx reg) (Pmode, machopic_indirection_name (orig, /*stub_p=*/false))); - SYMBOL_REF_DECL (ptr_ref) = SYMBOL_REF_DECL (orig); + SYMBOL_REF_DECL (ptr_ref) = SYMBOL_REF_DECL (orig); - ptr_ref = gen_rtx_MEM (Pmode, ptr_ref); - MEM_READONLY_P (ptr_ref) = 1; + ptr_ref = gen_const_mem (Pmode, ptr_ref); return ptr_ref; } @@ -474,6 +473,7 @@ machopic_indirect_call_target (rtx target) XEXP (target, 0) = gen_rtx_SYMBOL_REF (mode, stub_name); SYMBOL_REF_DECL (XEXP (target, 0)) = decl; MEM_READONLY_P (target) = 1; + MEM_NOTRAP_P (target) = 1; } return target; @@ -536,9 +536,8 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg) emit_insn (mode == DImode ? gen_macho_high_di (temp_reg, asym) : gen_macho_high (temp_reg, asym)); - mem = gen_rtx_MEM (GET_MODE (orig), - gen_rtx_LO_SUM (Pmode, temp_reg, asym)); - MEM_READONLY_P (mem) = 1; + mem = gen_const_mem (GET_MODE (orig), + gen_rtx_LO_SUM (Pmode, temp_reg, asym)); emit_insn (gen_rtx_SET (VOIDmode, reg, mem)); #else /* Some other CPU -- WriteMe! but right now there are no other platform that can use dynamic-no-pic */ @@ -568,10 +567,9 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg) emit_insn (gen_rtx_SET (Pmode, hi_sum_reg, sum)); - mem = gen_rtx_MEM (GET_MODE (orig), - gen_rtx_LO_SUM (Pmode, - hi_sum_reg, offset)); - MEM_READONLY_P (mem) = 1; + mem = gen_const_mem (GET_MODE (orig), + gen_rtx_LO_SUM (Pmode, + hi_sum_reg, offset)); insn = emit_insn (gen_rtx_SET (VOIDmode, reg, mem)); REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, pic_ref, REG_NOTES (insn)); @@ -618,8 +616,7 @@ machopic_legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg) #if !defined (TARGET_TOC) emit_move_insn (reg, pic_ref); - pic_ref = gen_rtx_MEM (GET_MODE (orig), reg); - MEM_READONLY_P (pic_ref) = 1; + pic_ref = gen_const_mem (GET_MODE (orig), reg); #endif } else diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 50e56ad5dd7..9ae3972c462 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -5306,8 +5306,7 @@ legitimize_pic_address (rtx orig, rtx reg) { new = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOTPCREL); new = gen_rtx_CONST (Pmode, new); - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, new); set_mem_alias_set (new, ix86_GOT_alias_set ()); if (reg == 0) @@ -5328,8 +5327,7 @@ legitimize_pic_address (rtx orig, rtx reg) new = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOT); new = gen_rtx_CONST (Pmode, new); new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new); - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, new); set_mem_alias_set (new, ix86_GOT_alias_set ()); if (reg == 0) @@ -5508,8 +5506,7 @@ legitimize_tls_address (rtx x, enum tls_model model, int for_mov) off = gen_rtx_CONST (Pmode, off); if (pic) off = gen_rtx_PLUS (Pmode, pic, off); - off = gen_rtx_MEM (Pmode, off); - MEM_READONLY_P (off) = 1; + off = gen_const_mem (Pmode, off); set_mem_alias_set (off, ix86_GOT_alias_set ()); if (TARGET_64BIT || TARGET_GNU_TLS) diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index f786f335404..770f8327915 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -686,13 +686,11 @@ ia64_expand_tls_address (enum tls_model tls_kind, rtx op0, rtx op1) tga_op1 = gen_reg_rtx (Pmode); emit_insn (gen_load_ltoff_dtpmod (tga_op1, op1)); - tga_op1 = gen_rtx_MEM (Pmode, tga_op1); - MEM_READONLY_P (tga_op1) = 1; + tga_op1 = gen_const_mem (Pmode, tga_op1); tga_op2 = gen_reg_rtx (Pmode); emit_insn (gen_load_ltoff_dtprel (tga_op2, op1)); - tga_op2 = gen_rtx_MEM (Pmode, tga_op2); - MEM_READONLY_P (tga_op2) = 1; + tga_op2 = gen_const_mem (Pmode, tga_op2); tga_ret = emit_library_call_value (gen_tls_get_addr (), NULL_RTX, LCT_CONST, Pmode, 2, tga_op1, @@ -715,8 +713,7 @@ ia64_expand_tls_address (enum tls_model tls_kind, rtx op0, rtx op1) tga_op1 = gen_reg_rtx (Pmode); emit_insn (gen_load_ltoff_dtpmod (tga_op1, op1)); - tga_op1 = gen_rtx_MEM (Pmode, tga_op1); - MEM_READONLY_P (tga_op1) = 1; + tga_op1 = gen_const_mem (Pmode, tga_op1); tga_op2 = const0_rtx; @@ -746,8 +743,7 @@ ia64_expand_tls_address (enum tls_model tls_kind, rtx op0, rtx op1) case TLS_MODEL_INITIAL_EXEC: tmp = gen_reg_rtx (Pmode); emit_insn (gen_load_ltoff_tprel (tmp, op1)); - tmp = gen_rtx_MEM (Pmode, tmp); - MEM_READONLY_P (tmp) = 1; + tmp = gen_const_mem (Pmode, tmp); tmp = force_reg (Pmode, tmp); if (!register_operand (op0, Pmode)) diff --git a/gcc/config/ia64/ia64.md b/gcc/config/ia64/ia64.md index 8b3cfdbdbf6..4b9a4b95b32 100644 --- a/gcc/config/ia64/ia64.md +++ b/gcc/config/ia64/ia64.md @@ -718,8 +718,7 @@ "" { operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode); - operands[3] = gen_rtx_MEM (DImode, operands[2]); - MEM_READONLY_P (operands[3]) = 1; + operands[3] = gen_const_mem (DImode, operands[2]); }) (define_insn "*load_fptr_internal1" diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 191d0a73640..ca4079f5ffa 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -1993,9 +1993,7 @@ m32r_legitimize_pic_address (rtx orig, rtx reg) emit_insn (gen_pic_load_addr (address, orig)); emit_insn (gen_addsi3 (address, address, pic_offset_table_rtx)); - pic_ref = gen_rtx_MEM (Pmode, address); - - MEM_READONLY_P (pic_ref) = 1; + pic_ref = gen_const_mem (Pmode, address); insn = emit_move_insn (reg, pic_ref); current_function_uses_pic_offset_table = 1; #if 0 diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index d1ed7182e7a..be1c4bd4618 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -1013,15 +1013,13 @@ legitimize_pic_address (rtx orig, enum machine_mode mode, rtx reg) gen_rtx_PLUS (word_mode, pic_offset_table_rtx, gen_rtx_HIGH (word_mode, orig))); pic_ref - = gen_rtx_MEM (Pmode, - gen_rtx_LO_SUM (Pmode, tmp_reg, - gen_rtx_UNSPEC (Pmode, - gen_rtvec (1, orig), - UNSPEC_DLTIND14R))); + = gen_const_mem (Pmode, + gen_rtx_LO_SUM (Pmode, tmp_reg, + gen_rtx_UNSPEC (Pmode, + gen_rtvec (1, orig), + UNSPEC_DLTIND14R))); current_function_uses_pic_offset_table = 1; - MEM_NOTRAP_P (pic_ref) = 1; - MEM_READONLY_P (pic_ref) = 1; mark_reg_pointer (reg, BITS_PER_UNIT); insn = emit_move_insn (reg, pic_ref); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 7651d2a0585..13143d7aed1 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -3460,8 +3460,7 @@ rs6000_legitimize_tls_address (rtx addr, enum tls_model model) tmp1 = gen_reg_rtx (Pmode); tmp2 = gen_reg_rtx (Pmode); tmp3 = gen_reg_rtx (Pmode); - mem = gen_rtx_MEM (Pmode, tmp1); - MEM_READONLY_P (mem) = 1; + mem = gen_const_mem (Pmode, tmp1); first = emit_insn (gen_load_toc_v4_PIC_1b (tempLR, lab, gsym)); @@ -4418,10 +4417,9 @@ rs6000_emit_move (rtx dest, rtx source, enum machine_mode mode) get_pool_mode (XEXP (operands[1], 0)))) { operands[1] - = gen_rtx_MEM (mode, - create_TOC_reference (XEXP (operands[1], 0))); + = gen_const_mem (mode, + create_TOC_reference (XEXP (operands[1], 0))); set_mem_alias_set (operands[1], get_TOC_alias_set ()); - MEM_READONLY_P (operands[1]) = 1; } } break; diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 49d4a24d8c8..89c95df8aec 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -2604,8 +2604,7 @@ legitimize_pic_address (rtx orig, rtx reg) new = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOT); new = gen_rtx_CONST (Pmode, new); new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new); - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, new); emit_move_insn (reg, new); new = reg; } @@ -2620,8 +2619,7 @@ legitimize_pic_address (rtx orig, rtx reg) new = gen_rtx_CONST (Pmode, new); emit_move_insn (temp, new); - new = gen_rtx_MEM (Pmode, temp); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, temp); emit_move_insn (reg, new); new = reg; } @@ -2641,8 +2639,7 @@ legitimize_pic_address (rtx orig, rtx reg) emit_move_insn (temp, addr); new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, temp); - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, new); emit_move_insn (reg, new); new = reg; } @@ -2932,8 +2929,7 @@ legitimize_tls_address (rtx addr, rtx reg) new = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOTNTPOFF); new = gen_rtx_CONST (Pmode, new); new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new); - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, new); temp = gen_reg_rtx (Pmode); emit_move_insn (temp, new); } @@ -2947,8 +2943,7 @@ legitimize_tls_address (rtx addr, rtx reg) temp = gen_reg_rtx (Pmode); emit_move_insn (temp, new); - new = gen_rtx_MEM (Pmode, temp); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, temp); temp = gen_reg_rtx (Pmode); emit_move_insn (temp, new); } @@ -2967,8 +2962,7 @@ legitimize_tls_address (rtx addr, rtx reg) emit_move_insn (temp, new); new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, temp); - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; + new = gen_const_mem (Pmode, new); new = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, new, addr), UNSPEC_TLS_LOAD); temp = gen_reg_rtx (Pmode); @@ -2986,9 +2980,7 @@ legitimize_tls_address (rtx addr, rtx reg) emit_move_insn (temp, new); new = temp; - new = gen_rtx_MEM (Pmode, new); - MEM_READONLY_P (new) = 1; - + new = gen_const_mem (Pmode, new); new = gen_rtx_UNSPEC (Pmode, gen_rtvec (2, new, addr), UNSPEC_TLS_LOAD); temp = gen_reg_rtx (Pmode); emit_insn (gen_rtx_SET (Pmode, temp, new)); diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 0cbcc0a2574..bbfed329f36 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -6840,9 +6840,7 @@ emit_move_insn (base, gen_rtx_LABEL_REF (Pmode, operands[3])); - index = gen_rtx_MEM (Pmode, gen_rtx_PLUS (Pmode, base, index)); - MEM_READONLY_P (index) = 1; - MEM_NOTRAP_P (index) = 1; + index = gen_const_mem (Pmode, gen_rtx_PLUS (Pmode, base, index)); emit_move_insn (target, index); if (flag_pic) diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 6cfcdf94e17..254aef5e55b 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -1042,7 +1042,6 @@ prepare_move_operands (rtx operands[], enum machine_mode mode) emit_insn (gen_load_gbr (tmp2)); tmp = gen_reg_rtx (Pmode); emit_insn (gen_symTPOFF2reg (tmp, op1)); - MEM_READONLY_P (tmp) = 1; if (register_operand (op0, Pmode)) op1 = op0; @@ -4398,9 +4397,8 @@ sh_reorg (void) else { lab = add_constant (src, mode, 0); - newsrc = gen_rtx_MEM (mode, - gen_rtx_LABEL_REF (VOIDmode, lab)); - MEM_READONLY_P (newsrc) = 1; + newsrc = gen_rtx_LABEL_REF (VOIDmode, lab); + newsrc = gen_const_mem (mode, newsrc); } *patp = gen_rtx_SET (VOIDmode, dst, newsrc); INSN_CODE (scan) = -1; diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index f1f2b211ca4..ac1a4345a07 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -3805,11 +3805,10 @@ legitimize_pic_address (rtx orig, enum machine_mode mode ATTRIBUTE_UNUSED, else address = orig; - pic_ref = gen_rtx_MEM (Pmode, - gen_rtx_PLUS (Pmode, - pic_offset_table_rtx, address)); + pic_ref = gen_const_mem (Pmode, + gen_rtx_PLUS (Pmode, + pic_offset_table_rtx, address)); current_function_uses_pic_offset_table = 1; - MEM_READONLY_P (pic_ref) = 1; insn = emit_move_insn (reg, pic_ref); /* Put a REG_EQUAL note on this insn, so that it can be optimized by loop. */ diff --git a/gcc/config/v850/v850.md b/gcc/config/v850/v850.md index 900f1e31a2d..cc82079629b 100644 --- a/gcc/config/v850/v850.md +++ b/gcc/config/v850/v850.md @@ -1320,8 +1320,7 @@ /* Add the table address to the index. */ emit_insn (gen_addsi3 (reg, reg, tableaddress)); /* Load the table entry. */ - mem = gen_rtx_MEM (CASE_VECTOR_MODE, reg); - MEM_READONLY_P (mem) = 1; + mem = gen_const_mem (CASE_VECTOR_MODE, reg); if (! TARGET_BIG_SWITCH) { rtx reg2 = gen_reg_rtx (HImode); diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 1137c45986b..4d40705d1bc 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -607,6 +607,17 @@ gen_rtx_MEM (enum machine_mode mode, rtx addr) return rt; } +/* Generate a memory referring to non-trapping constant memory. */ + +rtx +gen_const_mem (enum machine_mode mode, rtx addr) +{ + rtx mem = gen_rtx_MEM (mode, addr); + MEM_READONLY_P (mem) = 1; + MEM_NOTRAP_P (mem) = 1; + return mem; +} + rtx gen_rtx_SUBREG (enum machine_mode mode, rtx reg, int offset) { diff --git a/gcc/expr.c b/gcc/expr.c index a6c7e8e580e..c0f10d914bb 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8737,9 +8737,7 @@ do_tablejump (rtx index, enum machine_mode mode, rtx range, rtx table_label, #endif index = memory_address_noforce (CASE_VECTOR_MODE, index); temp = gen_reg_rtx (CASE_VECTOR_MODE); - vector = gen_rtx_MEM (CASE_VECTOR_MODE, index); - MEM_READONLY_P (vector) = 1; - MEM_NOTRAP_P (vector) = 1; + vector = gen_const_mem (CASE_VECTOR_MODE, index); convert_move (temp, vector, 0); emit_jump_insn (gen_tablejump (temp, table_label)); diff --git a/gcc/rtl.h b/gcc/rtl.h index cebc616db36..0d0e300ca60 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2195,6 +2195,7 @@ extern rtx unlink_insn_chain (rtx, rtx); extern rtx delete_insn_and_edges (rtx); extern void delete_insn_chain_and_edges (rtx, rtx); extern rtx gen_lowpart_SUBREG (enum machine_mode, rtx); +extern rtx gen_const_mem (enum machine_mode, rtx); /* In combine.c */ extern int combine_instructions (rtx, unsigned int); diff --git a/gcc/varasm.c b/gcc/varasm.c index 5d02c570ae3..e363bf134b9 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2979,9 +2979,8 @@ force_const_mem (enum machine_mode mode, rtx x) *slot = desc; /* Construct the MEM. */ - desc->mem = def = gen_rtx_MEM (mode, symbol); + desc->mem = def = gen_const_mem (mode, symbol); set_mem_attributes (def, lang_hooks.types.type_for_mode (mode, 0), 1); - MEM_READONLY_P (def) = 1; /* If we're dropping a label to the constant pool, make sure we don't delete it. */