diff options
author | Richard Sandiford <rsandifo@redhat.com> | 2003-02-12 09:42:54 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@redhat.com> | 2003-02-12 09:42:54 +0000 |
commit | b7c4aa74db7ae2421953b9088b94c3b7e9312b52 (patch) | |
tree | e941b381c6e9bd8524d0a77a297ebb260eeeb3c4 | |
parent | 2aa40b5d06b60c1af66f9d6f328b334792c05b3a (diff) |
* config/mips/mips.c (mips_legitimize_const_move): New, extracted
from mips_legitimize_move. Legitimize constant pool references.
(mips_legitimize_move): Call mips_legitimize_const_move. Attach
a REG_EQUAL note to the last instruction.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/mips-3_4-rewrite-branch@62761 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog.rewrite | 7 | ||||
-rw-r--r-- | gcc/config/mips/mips.c | 89 |
2 files changed, 66 insertions, 30 deletions
diff --git a/gcc/ChangeLog.rewrite b/gcc/ChangeLog.rewrite index 0eba5315bb2..85d15d9496e 100644 --- a/gcc/ChangeLog.rewrite +++ b/gcc/ChangeLog.rewrite @@ -1,3 +1,10 @@ +2003-02-12 Richard Sandiford <rsandifo@redhat.com> + + * config/mips/mips.c (mips_legitimize_const_move): New, extracted + from mips_legitimize_move. Legitimize constant pool references. + (mips_legitimize_move): Call mips_legitimize_const_move. Attach + a REG_EQUAL note to the last instruction. + 2003-02-11 Richard Sandiford <rsandifo@redhat.com> * config/mips/mips-protos.h (mips_simplify_dwarf_addr): Declare. diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 081ba6b13f7..d0b43c9295f 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -209,6 +209,8 @@ static rtx mips_emit_high PARAMS ((rtx, rtx)); static bool mips_legitimize_symbol PARAMS ((rtx, rtx *, int)); static rtx mips_reloc PARAMS ((rtx, int)); static rtx mips_lui_reloc PARAMS ((rtx, int)); +static void mips_legitimize_const_move PARAMS ((enum machine_mode, + rtx, rtx)); static int m16_check_op PARAMS ((rtx, int, int, int)); static void block_move_loop PARAMS ((rtx, rtx, unsigned int, @@ -1903,6 +1905,61 @@ mips_legitimize_address (xloc, mode) } +/* Subroutine of mips_legitimize_move. Move constant SRC into register + DEST given that SRC satisfies immediate_operand but doesn't satisfy + move_operand. */ + +static void +mips_legitimize_const_move (mode, dest, src) + enum machine_mode mode; + rtx dest, src; +{ + rtx temp; + + temp = no_new_pseudos ? dest : 0; + + /* If generating PIC, the high part of an address is loaded from the GOT. */ + if (GET_CODE (src) == HIGH) + { + mips_emit_high (dest, XEXP (src, 0)); + return; + } + + /* Fetch global symbols from the GOT. */ + if (TARGET_EXPLICIT_RELOCS + && GET_CODE (src) == SYMBOL_REF + && mips_classify_symbol (src) == SYMBOL_GOT_GLOBAL) + { + if (flag_pic == 1) + src = mips_load_got16 (src, RELOC_GOT_DISP); + else + src = mips_load_got32 (temp, src, RELOC_GOT_HI, RELOC_GOT_LO); + emit_insn (gen_rtx_SET (VOIDmode, dest, src)); + return; + } + + /* Try handling the source operand as a symbolic address. */ + if (mips_legitimize_symbol (temp, &src, false)) + { + emit_insn (gen_rtx_SET (VOIDmode, dest, src)); + return; + } + + src = force_const_mem (mode, src); + + /* When using explicit relocs, constant pool references are sometimes + not legitimate addresses. mips_legitimize_symbol must be able to + deal with all such cases. */ + if (GET_CODE (src) == MEM && !memory_operand (src, VOIDmode)) + { + src = copy_rtx (src); + if (!mips_legitimize_symbol (temp, &XEXP (src, 0), false)) + abort (); + } + emit_move_insn (dest, src); +} + + /* If (set DEST SRC) is not a valid instruction, emit an equivalent sequence that is valid. */ @@ -1919,36 +1976,8 @@ mips_legitimize_move (mode, dest, src) if (CONSTANT_P (src) && !move_operand (src, mode)) { - /* If generating PIC, the high part of an address is loaded from - the GOT. */ - if (GET_CODE (src) == HIGH) - { - mips_emit_high (dest, XEXP (src, 0)); - return true; - } - - /* Fetch global symbols from the GOT. */ - if (TARGET_EXPLICIT_RELOCS - && GET_CODE (src) == SYMBOL_REF - && mips_classify_symbol (src) == SYMBOL_GOT_GLOBAL) - { - if (flag_pic == 1) - src = mips_load_got16 (src, RELOC_GOT_DISP); - else - src = mips_load_got32 (dest, src, RELOC_GOT_HI, RELOC_GOT_LO); - emit_insn (gen_rtx_SET (VOIDmode, dest, src)); - return true; - } - - /* Try handling the source operand as a symbolic address. */ - if (mips_legitimize_symbol (no_new_pseudos ? dest : 0, &src, false)) - { - emit_insn (gen_rtx_SET (VOIDmode, dest, src)); - return true; - } - - src = force_const_mem (mode, src); - emit_move_insn (dest, src); + mips_legitimize_const_move (mode, dest, src); + set_unique_reg_note (get_last_insn (), REG_EQUAL, copy_rtx (src)); return true; } return false; |