aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2010-12-20 11:11:12 -0800
committerRichard Henderson <rth@gcc.gnu.org>2010-12-20 11:11:12 -0800
commit5385594074b33ef05ad5eb5a02b902b7be02f529 (patch)
treedecf7775a18fab3902aa2555a6df53ddb22a5a85 /gcc
parentc02a5ccbdf231861265f03f2e75dc7dc3665215b (diff)
downloadgcc-5385594074b33ef05ad5eb5a02b902b7be02f529.zip
gcc-5385594074b33ef05ad5eb5a02b902b7be02f529.tar.gz
gcc-5385594074b33ef05ad5eb5a02b902b7be02f529.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/mn10300/mn10300.c27
-rw-r--r--gcc/config/mn10300/mn10300.md115
3 files changed, 57 insertions, 94 deletions
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 <rth@redhat.com>
+
+ * 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 <scliu@faraday-tech.com>
Mingfeng Wu <mingfeng@faraday-tech.com>
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)]
- "" "")