Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 1 | From 8711bdfe27bce04d35ba93a1d18ccccd61371829 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 2 | From: Mahesh Bodapati <mbodapat@xilinx.com> |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 3 | Date: Thu, 12 Jan 2017 16:41:43 +0530 |
| 4 | Subject: [PATCH 09/54] [Patch, microblaze]: Fix atomic side effects. In |
| 5 | atomic_compare_and_swapsi, add side effects to prevent incorrect assumptions |
| 6 | during optimization. Previously, the outputs were considered unused; this |
| 7 | generated assembly code with undefined side effects after invocation of the |
| 8 | atomic. |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 9 | |
| 10 | Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com> |
| 11 | Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com> |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 12 | --- |
| 13 | gcc/config/microblaze/microblaze.md | 3 +++ |
| 14 | gcc/config/microblaze/sync.md | 21 +++++++++++++-------- |
| 15 | 2 files changed, 16 insertions(+), 8 deletions(-) |
| 16 | |
| 17 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 18 | index f698e54..93f5fa2 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 19 | --- a/gcc/config/microblaze/microblaze.md |
| 20 | +++ b/gcc/config/microblaze/microblaze.md |
| 21 | @@ -41,6 +41,9 @@ |
| 22 | (UNSPEC_CMP 104) ;; signed compare |
| 23 | (UNSPEC_CMPU 105) ;; unsigned compare |
| 24 | (UNSPEC_TLS 106) ;; jump table |
| 25 | + (UNSPECV_CAS_BOOL 201) ;; compare and swap (bool) |
| 26 | + (UNSPECV_CAS_VAL 202) ;; compare and swap (val) |
| 27 | + (UNSPECV_CAS_MEM 203) ;; compare and swap (mem) |
| 28 | ]) |
| 29 | |
| 30 | (define_c_enum "unspec" [ |
| 31 | diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 32 | index b34bd54..8e694e9 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 33 | --- a/gcc/config/microblaze/sync.md |
| 34 | +++ b/gcc/config/microblaze/sync.md |
| 35 | @@ -18,14 +18,19 @@ |
| 36 | ;; <http://www.gnu.org/licenses/>. |
| 37 | |
| 38 | (define_insn "atomic_compare_and_swapsi" |
| 39 | - [(match_operand:SI 0 "register_operand" "=&d") ;; bool output |
| 40 | - (match_operand:SI 1 "register_operand" "=&d") ;; val output |
| 41 | - (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory |
| 42 | - (match_operand:SI 3 "register_operand" "d") ;; expected value |
| 43 | - (match_operand:SI 4 "register_operand" "d") ;; desired value |
| 44 | - (match_operand:SI 5 "const_int_operand" "") ;; is_weak |
| 45 | - (match_operand:SI 6 "const_int_operand" "") ;; mod_s |
| 46 | - (match_operand:SI 7 "const_int_operand" "") ;; mod_f |
| 47 | + [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output |
| 48 | + (unspec_volatile:SI |
| 49 | + [(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory |
| 50 | + (match_operand:SI 3 "register_operand" "d") ;; expected value |
| 51 | + (match_operand:SI 4 "register_operand" "d")] ;; desired value |
| 52 | + UNSPECV_CAS_BOOL)) |
| 53 | + (set (match_operand:SI 1 "register_operand" "=&d") ;; val output |
| 54 | + (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL)) |
| 55 | + (set (match_dup 2) |
| 56 | + (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM)) |
| 57 | + (match_operand:SI 5 "const_int_operand" "") ;; is_weak |
| 58 | + (match_operand:SI 6 "const_int_operand" "") ;; mod_s |
| 59 | + (match_operand:SI 7 "const_int_operand" "") ;; mod_f |
| 60 | (clobber (match_scratch:SI 8 "=&d"))] |
| 61 | "" |
| 62 | { |
| 63 | -- |
Brad Bishop | 26bdd44 | 2019-08-16 17:08:17 -0400 | [diff] [blame] | 64 | 2.7.4 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 65 | |