From: David Holsgrove Date: Wed, 26 Jun 2013 23:55:52 +0000 (+0000) Subject: Add sync_compare_and_swapsi and sync_test_and_setsi. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8eedc3ebe72acf248e30b328368a3ca2d11b0466;p=gcc.git Add sync_compare_and_swapsi and sync_test_and_setsi. 2013-06-16 David Holsgrove Add sync_compare_and_swapsi and sync_test_and_setsi. * gcc/config/microblaze/sync.md: New file. * gcc/config/microblaze/microblaze.md: Add UNSPEC_SYNC_CAS, UNSPEC_SYNC_XCHG and include sync.md. * gcc/config/microblaze/microblaze.c: Add print_operand 'y'. * gcc/config/microblaze/constraints.md: Add memory_contraint 'Q' which is a single register. From-SVN: r200443 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5f56b6161f6..de980128eb6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2013-06-16 David Holsgrove + + * gcc/config/microblaze/sync.md: New file. + * gcc/config/microblaze/microblaze.md: Add UNSPEC_SYNC_CAS, + UNSPEC_SYNC_XCHG and include sync.md. + * gcc/config/microblaze/microblaze.c: Add print_operand 'y'. + * gcc/config/microblaze/constraints.md: Add memory_contraint + 'Q' which is a single register. + 2013-06-26 Thomas Schwinge * config/i386/gnu.h [TARGET_LIBC_PROVIDES_SSP] diff --git a/gcc/config/microblaze/constraints.md b/gcc/config/microblaze/constraints.md index c6fbc987819..c9c164962cd 100644 --- a/gcc/config/microblaze/constraints.md +++ b/gcc/config/microblaze/constraints.md @@ -70,3 +70,8 @@ "Double word operand." (and (match_code "mem") (match_test "double_memory_operand (op, GET_MODE (op))"))) + +(define_memory_constraint "Q" + "Memory operand which is a single register." + (and (match_code "mem") + (match_test "GET_CODE ( XEXP (op, 0)) == REG"))) diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index c121c2baec3..ea2b033becb 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -2118,6 +2118,7 @@ microblaze_initial_elimination_offset (int from, int to) 't' print 't' for EQ, 'f' for NE 'm' Print 1<. + + +(define_insn "sync_compare_and_swapsi" + [(set (match_operand:SI 0 "register_operand" "=&d") ;; retval + (match_operand:SI 1 "nonimmediate_operand" "+Q")) ;; mem + (set (match_dup 1) + (unspec + [(match_operand:SI 2 "register_operand" "d") ;; oldval + (match_operand:SI 3 "register_operand" "d")] ;; newval + UNSPEC_SYNC_CAS)) + (clobber (match_scratch:SI 4 "=&d"))] ;; scratch + "" + { + output_asm_insn ("addc \tr0,r0,r0", operands); + output_asm_insn ("lwx \t%0,%y1,r0", operands); + output_asm_insn ("addic\t%4,r0,0", operands); + output_asm_insn ("bnei \t%4,.-8", operands); + output_asm_insn ("cmp \t%4,%0,%2", operands); + output_asm_insn ("bnei \t%4,.+16", operands); + output_asm_insn ("swx \t%3,%y1,r0", operands); + output_asm_insn ("addic\t%4,r0,0", operands); + output_asm_insn ("bnei \t%4,.-28", operands); + return ""; + } +) + +(define_insn "sync_test_and_setsi" + [(set (match_operand:SI 0 "register_operand" "=&d") ;; retval + (match_operand:SI 1 "nonimmediate_operand" "+Q")) ;; mem + (set (match_dup 1) + (unspec + [(match_operand:SI 2 "register_operand" "d")] ;; value + UNSPEC_SYNC_XCHG)) + (clobber (match_scratch:SI 3 "=&d"))] ;; scratch + "" + { + output_asm_insn ("addc \tr0,r0,r0", operands); + output_asm_insn ("lwx \t%0,%y1,r0", operands); + output_asm_insn ("addic\t%3,r0,0", operands); + output_asm_insn ("bnei \t%3,.-8", operands); + output_asm_insn ("swx \t%2,%y1,r0", operands); + output_asm_insn ("addic\t%3,r0,0", operands); + output_asm_insn ("bnei \t%3,.-20", operands); + return ""; + } +)