From: Richard Henderson Date: Mon, 20 Dec 2010 19:11:12 +0000 (-0800) Subject: mn10300: Cleanup PIC unspec generation X-Git-Tag: upstream/12.2.0~87581 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5385594074b33ef05ad5eb5a02b902b7be02f529;p=platform%2Fupstream%2Fgcc.git mn10300: Cleanup PIC unspec generation * config/mn10300/mn10300.c (mn10300_legitimize_pic_address): Generate UNSPEC patterns by hand, with the proper mode; use gen_const_mem. * config/mn10300/mn10300.md (call, call_value): Generate UNSPEC_PLT by hand, with the proper mode. (symGOT2reg, symGOT2reg_i, symGOTOFF2reg): Remove. (symGOTOFF2reg_i, sym2PIC, sym2PLT): Remove. From-SVN: r168093 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ee139cc..dd2d71e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-12-20 Richard Henderson + + * config/mn10300/mn10300.c (mn10300_legitimize_pic_address): Generate + UNSPEC patterns by hand, with the proper mode; use gen_const_mem. + * config/mn10300/mn10300.md (call, call_value): Generate UNSPEC_PLT + by hand, with the proper mode. + (symGOT2reg, symGOT2reg_i, symGOTOFF2reg): Remove. + (symGOTOFF2reg_i, sym2PIC, sym2PLT): Remove. + 2010-12-20 Sanjin Liu Mingfeng Wu diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c index a4e0bc4..23b198a 100644 --- a/gcc/config/mn10300/mn10300.c +++ b/gcc/config/mn10300/mn10300.c @@ -1867,26 +1867,39 @@ mn10300_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, rtx mn10300_legitimize_pic_address (rtx orig, rtx reg) { + rtx x; + if (GET_CODE (orig) == LABEL_REF || (GET_CODE (orig) == SYMBOL_REF && (CONSTANT_POOL_ADDRESS_P (orig) || ! MN10300_GLOBAL_P (orig)))) { - if (reg == 0) + if (reg == NULL) reg = gen_reg_rtx (Pmode); - emit_insn (gen_symGOTOFF2reg (reg, orig)); - return reg; + x = gen_rtx_UNSPEC (SImode, gen_rtvec (1, orig), UNSPEC_GOTOFF); + x = gen_rtx_CONST (SImode, x); + emit_move_insn (reg, x); + + x = emit_insn (gen_addsi3 (reg, reg, pic_offset_table_rtx)); } else if (GET_CODE (orig) == SYMBOL_REF) { - if (reg == 0) + if (reg == NULL) reg = gen_reg_rtx (Pmode); - emit_insn (gen_symGOT2reg (reg, orig)); - return reg; + x = gen_rtx_UNSPEC (SImode, gen_rtvec (1, orig), UNSPEC_GOT); + x = gen_rtx_CONST (SImode, x); + x = gen_rtx_PLUS (SImode, pic_offset_table_rtx, x); + x = gen_const_mem (SImode, x); + + x = emit_move_insn (reg, x); } - return orig; + else + return orig; + + set_unique_reg_note (x, REG_EQUAL, orig); + return reg; } /* Return zero if X references a SYMBOL_REF or LABEL_REF whose symbol diff --git a/gcc/config/mn10300/mn10300.md b/gcc/config/mn10300/mn10300.md index 1028357..3fad021 100644 --- a/gcc/config/mn10300/mn10300.md +++ b/gcc/config/mn10300/mn10300.md @@ -2133,33 +2133,32 @@ [(call (match_operand:QI 0 "general_operand") (match_operand:SI 1 "general_operand"))] "" - " { - if (flag_pic && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF) + rtx fn = XEXP (operands[0], 0); + + if (flag_pic && GET_CODE (fn) == SYMBOL_REF) { - if (MN10300_GLOBAL_P (XEXP (operands[0], 0))) + if (MN10300_GLOBAL_P (fn)) { /* The PLT code won't run on AM30, but then, there's no shared library support for AM30 either, so we just assume the linker is going to adjust all @PLT relocs to the actual symbols. */ emit_use (pic_offset_table_rtx); - XEXP (operands[0], 0) = gen_sym2PLT (XEXP (operands[0], 0)); + fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PLT); } else - XEXP (operands[0], 0) = gen_sym2PIC (XEXP (operands[0], 0)); + fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PIC); } - if (! call_address_operand (XEXP (operands[0], 0), VOIDmode)) - XEXP (operands[0], 0) = force_reg (SImode, XEXP (operands[0], 0)); - emit_call_insn (gen_call_internal (XEXP (operands[0], 0), operands[1])); - DONE; -}") + if (! call_address_operand (fn, VOIDmode)) + fn = force_reg (SImode, fn); + + XEXP (operands[0], 0) = fn; +}) -;; NB: Mode on match_operand 0 deliberately omitted in -;; order to be able to match UNSPECs in PIC mode. -(define_insn "call_internal" - [(call (mem:QI (match_operand 0 "call_address_operand" "a,S")) - (match_operand:SI 1 "general_operand" "g,g"))] +(define_insn "*call_internal" + [(call (mem:QI (match_operand:SI 0 "call_address_operand" "a,S")) + (match_operand:SI 1 "" ""))] "" "@ calls %C0 @@ -2181,36 +2180,33 @@ (call (match_operand:QI 1 "general_operand") (match_operand:SI 2 "general_operand")))] "" - " { - if (flag_pic && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF) + rtx fn = XEXP (operands[1], 0); + + if (flag_pic && GET_CODE (fn) == SYMBOL_REF) { - if (MN10300_GLOBAL_P (XEXP (operands[1], 0))) + if (MN10300_GLOBAL_P (fn)) { /* The PLT code won't run on AM30, but then, there's no shared library support for AM30 either, so we just assume the linker is going to adjust all @PLT relocs to the actual symbols. */ emit_use (pic_offset_table_rtx); - XEXP (operands[1], 0) = gen_sym2PLT (XEXP (operands[1], 0)); + fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PLT); } else - XEXP (operands[1], 0) = gen_sym2PIC (XEXP (operands[1], 0)); + fn = gen_rtx_UNSPEC (SImode, gen_rtvec (1, fn), UNSPEC_PIC); } - if (! call_address_operand (XEXP (operands[1], 0), VOIDmode)) - XEXP (operands[1], 0) = force_reg (SImode, XEXP (operands[1], 0)); - emit_call_insn (gen_call_value_internal (operands[0], - XEXP (operands[1], 0), - operands[2])); - DONE; -}") + if (! call_address_operand (fn, VOIDmode)) + fn = force_reg (SImode, fn); + + XEXP (operands[1], 0) = fn; +}) -;; NB: Mode on match_operands 0 and 1 deliberately omitted -;; in order to be able to match UNSPECs in PIC mode. (define_insn "call_value_internal" - [(set (match_operand 0 "register_operand" "=dax,dax") - (call (mem:QI (match_operand 1 "call_address_operand" "a,S")) - (match_operand:SI 2 "general_operand" "g,g")))] + [(set (match_operand 0 "" "") + (call (mem:QI (match_operand:SI 1 "call_address_operand" "a,S")) + (match_operand:SI 2 "" "")))] "" "@ calls %C1 @@ -3119,58 +3115,3 @@ "" "operands[3] = gen_rtx_SYMBOL_REF (VOIDmode, GOT_SYMBOL_NAME);" ) - -(define_expand "symGOT2reg" - [(match_operand:SI 0 "") - (match_operand:SI 1 "")] - "" - " -{ - rtx insn = emit_insn (gen_symGOT2reg_i (operands[0], operands[1])); - - MEM_READONLY_P (SET_SRC (PATTERN (insn))) = 1; - - set_unique_reg_note (insn, REG_EQUAL, operands[1]); - - DONE; -}") - -(define_expand "symGOT2reg_i" - [(set (match_operand:SI 0 "") - (mem:SI (plus:SI (reg:SI PIC_REG) - (const (unspec [(match_operand:SI 1 "")] - UNSPEC_GOT)))))] - "" - "") - -(define_expand "symGOTOFF2reg" - [(match_operand:SI 0 "") (match_operand:SI 1 "")] - "" - " -{ - rtx insn = emit_insn (gen_symGOTOFF2reg_i (operands[0], operands[1])); - - set_unique_reg_note (insn, REG_EQUAL, operands[1]); - - DONE; -}") - -(define_expand "symGOTOFF2reg_i" - [(set (match_operand:SI 0 "") - (const (unspec [(match_operand:SI 1 "")] UNSPEC_GOTOFF))) - (parallel [(set (match_dup 0) - (plus:SI (match_dup 0) - (reg:SI PIC_REG))) - (clobber (reg:CC CC_REG)) - ]) - ] - "" - "") - -(define_expand "sym2PIC" - [(unspec [(match_operand:SI 0 "")] UNSPEC_PIC)] - "" "") - -(define_expand "sym2PLT" - [(unspec [(match_operand:SI 0 "")] UNSPEC_PLT)] - "" "")