diff options
author | Kaz Kojima <kkojima@gcc.gnu.org> | 2005-07-20 22:55:50 +0000 |
---|---|---|
committer | Kaz Kojima <kkojima@gcc.gnu.org> | 2005-07-20 22:55:50 +0000 |
commit | 50b69666aa028b3f643d69eda72bd3729428f8ed (patch) | |
tree | 2fc78ef2238346abd04c44f78c5e10c1fbf32d42 /gcc | |
parent | cdcdee12daace5c1072620b1db280a6a51156c96 (diff) | |
download | gcc-50b69666aa028b3f643d69eda72bd3729428f8ed.zip gcc-50b69666aa028b3f643d69eda72bd3729428f8ed.tar.gz gcc-50b69666aa028b3f643d69eda72bd3729428f8ed.tar.bz2 |
sh.md (UNSPEC_SP_SET, [...]): New constants.
* config/sh/sh.md (UNSPEC_SP_SET, UNSPEC_SP_TEST): New constants.
(stack_protect_set, stack_protect_test): New expanders.
(stack_protect_set_si, stack_protect_set_si_media,
stack_protect_set_di_media, stack_protect_test_si,
stack_protect_test_si_media, stack_protect_test_di_media):
New insns.
From-SVN: r102206
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/config/sh/sh.md | 111 |
2 files changed, 120 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c190fdb..746dc85 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2005-07-20 Kaz Kojima <kkojima@gcc.gnu.org> + + * config/sh/sh.md (UNSPEC_SP_SET, UNSPEC_SP_TEST): New constants. + (stack_protect_set, stack_protect_test): New expanders. + (stack_protect_set_si, stack_protect_set_si_media, + stack_protect_set_di_media, stack_protect_test_si, + stack_protect_test_si_media, stack_protect_test_di_media): + New insns. + 2005-07-20 Andrew Pinski <pinskia@physics.uc.edu> * c-typeck.c (output_init_element): Don't copy the INTEGER_CST. diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md index ad2e0e7..0c93a4d 100644 --- a/gcc/config/sh/sh.md +++ b/gcc/config/sh/sh.md @@ -150,6 +150,8 @@ (UNSPEC_DIV_INV20 34) (UNSPEC_ASHIFTRT 35) (UNSPEC_THUNK 36) + (UNSPEC_SP_SET 40) + (UNSPEC_SP_TEST 41) ;; These are used with unspec_volatile. (UNSPECV_BLOCKAGE 0) @@ -13131,3 +13133,112 @@ mov.l\\t1f,r0\\n\\ if (!n_changes) FAIL; }") + +; Stack Protector Patterns + +(define_expand "stack_protect_set" + [(set (match_operand 0 "memory_operand" "") + (match_operand 1 "memory_operand" ""))] + "" +{ + if (TARGET_SHMEDIA) + { + if (TARGET_SHMEDIA64) + emit_insn (gen_stack_protect_set_di_media (operands[0], operands[1])); + else + emit_insn (gen_stack_protect_set_si_media (operands[0], operands[1])); + } + else + emit_insn (gen_stack_protect_set_si (operands[0], operands[1])); + + DONE; +}) + +(define_insn "stack_protect_set_si" + [(set (match_operand:SI 0 "memory_operand" "=m") + (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET)) + (set (match_scratch:SI 2 "=&r") (const_int 0))] + "!TARGET_SHMEDIA" + "mov.l\t%1, %2\;mov.l\t%2, %0\;mov\t#0, %2" + [(set_attr "type" "other") + (set_attr "length" "6")]) + +(define_insn "stack_protect_set_si_media" + [(set (match_operand:SI 0 "memory_operand" "=m") + (unspec:SI [(match_operand:SI 1 "memory_operand" "m")] UNSPEC_SP_SET)) + (set (match_scratch:SI 2 "=&r") (const_int 0))] + "TARGET_SHMEDIA" + "ld%M1.l\t%m1, %2\;st%M0.l\t%m0, %2\;movi\t0, %2" + [(set_attr "type" "other") + (set_attr "length" "12")]) + +(define_insn "stack_protect_set_di_media" + [(set (match_operand:DI 0 "memory_operand" "=m") + (unspec:DI [(match_operand:DI 1 "memory_operand" "m")] UNSPEC_SP_SET)) + (set (match_scratch:DI 2 "=&r") (const_int 0))] + "TARGET_SHMEDIA64" + "ld%M1.q\t%m1, %2\;st%M0.q\t%m0, %2\;movi\t0, %2" + [(set_attr "type" "other") + (set_attr "length" "12")]) + +(define_expand "stack_protect_test" + [(match_operand 0 "memory_operand" "") + (match_operand 1 "memory_operand" "") + (match_operand 2 "" "")] + "" +{ + if (TARGET_SHMEDIA) + { + rtx tmp = gen_reg_rtx (GET_MODE (operands[0])); + + if (TARGET_SHMEDIA64) + emit_insn (gen_stack_protect_test_di_media (tmp, operands[0], + operands[1])); + else + emit_insn (gen_stack_protect_test_si_media (tmp, operands[0], + operands[1])); + + emit_jump_insn (gen_bne_media (operands[2], tmp, const0_rtx)); + } + else + { + emit_insn (gen_stack_protect_test_si (operands[0], operands[1])); + emit_jump_insn (gen_branch_true (operands[2])); + } + + DONE; +}) + +(define_insn "stack_protect_test_si" + [(set (reg:SI T_REG) + (unspec:SI [(match_operand:SI 0 "memory_operand" "m") + (match_operand:SI 1 "memory_operand" "m")] + UNSPEC_SP_TEST)) + (set (match_scratch:SI 2 "=&r") (const_int 0)) + (set (match_scratch:SI 3 "=&r") (const_int 0))] + "!TARGET_SHMEDIA" + "mov.l\t%0, %2\;mov.l\t%1, %3\;cmp/eq\t%2, %3\;mov\t#0, %2\;mov\t#0, %3" + [(set_attr "type" "other") + (set_attr "length" "10")]) + +(define_insn "stack_protect_test_si_media" + [(set (match_operand:SI 0 "register_operand" "=&r") + (unspec:SI [(match_operand:SI 1 "memory_operand" "m") + (match_operand:SI 2 "memory_operand" "m")] + UNSPEC_SP_TEST)) + (set (match_scratch:SI 3 "=&r") (const_int 0))] + "TARGET_SHMEDIA" + "ld%M1.l\t%m1, %0\;ld%M2.l\t%m2, %3\;cmpeq\t%0, %3, %0\;movi\t0, %3" + [(set_attr "type" "other") + (set_attr "length" "16")]) + +(define_insn "stack_protect_test_di_media" + [(set (match_operand:DI 0 "register_operand" "=&r") + (unspec:DI [(match_operand:DI 1 "memory_operand" "m") + (match_operand:DI 2 "memory_operand" "m")] + UNSPEC_SP_TEST)) + (set (match_scratch:DI 3 "=&r") (const_int 0))] + "TARGET_SHMEDIA64" + "ld%M1.q\t%m1, %0\;ld%M2.q\t%m2, %3\;cmpeq\t%0, %3, %0\;movi\t0, %3" + [(set_attr "type" "other") + (set_attr "length" "16")]) |