2004-02-14 Richard Sandiford <rsandifo@redhat.com>
+ * config/mips/mips-protos.h (mips_load_got_page): Delete.
+ (mips_load_got_global): Delete.
+ (mips_gotoff_page): Declare.
+ * config/mips/mips.md (UNSPEC_LOAD_GOT): New constant.
+ (*xgot_lo[sd]i, *got_disp[sd]i, *got_page[sd]i): Build an
+ UNSPEC_LOAD_GOT pattern rather than a MEM.
+ (*load_got[sd]i): New patterns.
+ * config/mips/mips.c (mips_got_alias_set, mips_load_got): Delete.
+ (mips_load_got_page, mips_load_got_global): Delete.
+ (mips_gotoff_page): New function.
+ (override_options): Don't initialize mips_got_alias_set.
+
+2004-02-14 Richard Sandiford <rsandifo@redhat.com>
+
* config/mips/mips.h (MASK_DEBUG_[ABEFI], TARGET_DEBUG_[ABEFI]_MODE)
(TARGET_MIPS4100, TARGET_MIPS4300, TARGET_MIPS4KC, TARGET_MIPS5KC)
(TARGET_SB1, TUNE_SB1, TUNE_SR71K, BIGGEST_MAX_ARGS_IN_REGISTERS)
extern int mips_fetch_insns (rtx);
extern bool mips_legitimate_address_p (enum machine_mode, rtx, int);
extern bool mips_legitimize_address (rtx *, enum machine_mode);
+extern rtx mips_gotoff_page (rtx);
extern rtx mips_gotoff_global (rtx);
-extern rtx mips_load_got_page (rtx);
-extern rtx mips_load_got_global (rtx, rtx);
extern bool mips_legitimize_move (enum machine_mode, rtx, rtx);
extern int m16_uimm3_b (rtx, enum machine_mode);
static rtx mips_split_symbol (rtx, rtx);
static rtx mips_unspec_address (rtx, enum mips_symbol_type);
static rtx mips_unspec_offset_high (rtx, rtx, rtx, enum mips_symbol_type);
-static rtx mips_load_got (rtx, rtx, enum mips_symbol_type);
static rtx mips_add_offset (rtx, HOST_WIDE_INT);
static unsigned int mips_build_shift (struct mips_integer_op *, HOST_WIDE_INT);
static unsigned int mips_build_lower (struct mips_integer_op *,
/* Map GCC register number to debugger register number. */
int mips_dbx_regno[FIRST_PSEUDO_REGISTER];
-/* An alias set for the GOT. */
-static GTY(()) int mips_got_alias_set;
-
/* A copy of the original flag_delayed_branch: see override_options. */
static int mips_flag_delayed_branch;
}
-/* Return a memory reference for the GOT slot whose offset is given by
- mips_unspec_address (ADDR, SYMBOL_TYPE). Register BASE contains the
- high part of the offset plus $gp. */
+/* Return the offset of a GOT page entry for local address ADDR. */
-static rtx
-mips_load_got (rtx base, rtx addr, enum mips_symbol_type symbol_type)
+rtx
+mips_gotoff_page (rtx addr)
{
- rtx mem, offset;
-
- offset = mips_unspec_address (addr, symbol_type);
- mem = gen_rtx_MEM (ptr_mode, gen_rtx_LO_SUM (Pmode, base, offset));
- set_mem_alias_set (mem, mips_got_alias_set);
-
- /* GOT entries are constant and references to them can't trap. */
- RTX_UNCHANGING_P (mem) = 1;
- MEM_NOTRAP_P (mem) = 1;
-
- return mem;
+ return mips_unspec_address (addr, SYMBOL_GOTOFF_PAGE);
}
}
-/* Fetch the high part of local_got_operand ADDR from the GOT. */
-
-rtx
-mips_load_got_page (rtx addr)
-{
- return mips_load_got (pic_offset_table_rtx, addr, SYMBOL_GOTOFF_PAGE);
-}
-
-
-/* Fetch the address of global_got_operand ADDR from the GOT. BASE is a
- register that holds the address _gp + %got_hi(ADDR). */
-
-rtx
-mips_load_got_global (rtx base, rtx addr)
-{
- return mips_load_got (base, addr, SYMBOL_GOTOFF_GLOBAL);
-}
-
-
/* Return a legitimate address for REG + OFFSET. This function will
create a temporary register if OFFSET is not a SMALL_OPERAND. */
/* Function to allocate machine-dependent function status. */
init_machine_status = &mips_init_machine_status;
- /* Create a unique alias set for GOT references. */
- mips_got_alias_set = new_alias_set ();
-
if (TARGET_EXPLICIT_RELOCS || mips_split_addresses)
{
mips_split_p[SYMBOL_GENERAL] = true;
(UNSPEC_SDR 25)
(UNSPEC_LOADGP 26)
(UNSPEC_LOAD_CALL 27)
+ (UNSPEC_LOAD_GOT 28)
(UNSPEC_ADDRESS_FIRST 100)
"TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
"#"
"&& reload_completed"
- [(set (match_dup 0) (match_dup 3))]
- { operands[3] = mips_load_got_global (operands[1], operands[2]); }
+ [(set (match_dup 0)
+ (unspec:SI [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
+ { operands[3] = mips_gotoff_global (operands[2]); }
[(set_attr "got" "load")])
(define_insn_and_split "*xgot_hidi"
"TARGET_EXPLICIT_RELOCS && TARGET_XGOT"
"#"
"&& reload_completed"
- [(set (match_dup 0) (match_dup 3))]
- { operands[3] = mips_load_got_global (operands[1], operands[2]); }
+ [(set (match_dup 0)
+ (unspec:DI [(match_dup 1) (match_dup 3)] UNSPEC_LOAD_GOT))]
+ { operands[3] = mips_gotoff_global (operands[2]); }
[(set_attr "got" "load")])
;; Insns to fetch a global symbol from a normal GOT.
"TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
"#"
"&& reload_completed"
- [(set (match_dup 0) (match_dup 2))]
- { operands[2] = mips_load_got_global (pic_offset_table_rtx, operands[1]); }
+ [(set (match_dup 0)
+ (unspec:SI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
+{
+ operands[2] = pic_offset_table_rtx;
+ operands[3] = mips_gotoff_global (operands[1]);
+}
[(set_attr "got" "load")])
(define_insn_and_split "*got_dispdi"
"TARGET_EXPLICIT_RELOCS && !TARGET_XGOT"
"#"
"&& reload_completed"
- [(set (match_dup 0) (match_dup 2))]
- { operands[2] = mips_load_got_global (pic_offset_table_rtx, operands[1]); }
+ [(set (match_dup 0)
+ (unspec:DI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
+{
+ operands[2] = pic_offset_table_rtx;
+ operands[3] = mips_gotoff_global (operands[1]);
+}
[(set_attr "got" "load")])
;; Insns for loading the high part of a local symbol.
"TARGET_EXPLICIT_RELOCS"
"#"
"&& reload_completed"
- [(set (match_dup 0) (match_dup 2))]
- { operands[2] = mips_load_got_page (operands[1]); }
+ [(set (match_dup 0)
+ (unspec:SI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
+{
+ operands[2] = pic_offset_table_rtx;
+ operands[3] = mips_gotoff_page (operands[1]);
+}
[(set_attr "got" "load")])
(define_insn_and_split "*got_pagedi"
"TARGET_EXPLICIT_RELOCS"
"#"
"&& reload_completed"
- [(set (match_dup 0) (match_dup 2))]
- { operands[2] = mips_load_got_page (operands[1]); }
+ [(set (match_dup 0)
+ (unspec:DI [(match_dup 2) (match_dup 3)] UNSPEC_LOAD_GOT))]
+{
+ operands[2] = pic_offset_table_rtx;
+ operands[3] = mips_gotoff_page (operands[1]);
+}
[(set_attr "got" "load")])
+;; Lower-level instructions for loading an address from the GOT.
+;; We could use MEMs, but an unspec gives more optimization
+;; opportunities.
+
+(define_insn "*load_gotsi"
+ [(set (match_operand:SI 0 "register_operand" "=d")
+ (unspec:SI [(match_operand:SI 1 "register_operand" "d")
+ (match_operand:SI 2 "immediate_operand" "")]
+ UNSPEC_LOAD_GOT))]
+ "TARGET_ABICALLS"
+ "lw\t%0,%R2(%1)"
+ [(set_attr "type" "load")
+ (set_attr "length" "4")])
+
+(define_insn "*load_gotdi"
+ [(set (match_operand:DI 0 "register_operand" "=d")
+ (unspec:DI [(match_operand:DI 1 "register_operand" "d")
+ (match_operand:DI 2 "immediate_operand" "")]
+ UNSPEC_LOAD_GOT))]
+ "TARGET_ABICALLS"
+ "ld\t%0,%R2(%1)"
+ [(set_attr "type" "load")
+ (set_attr "length" "4")])
+
;; Instructions for adding the low 16 bits of an address to a register.
;; Operand 2 is the address: print_operand works out which relocation
;; should be applied.