Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 1 | From 602713d07d2e1b3a33a7f097baff270266aa4254 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 |
Andrew Geissler | 10fa149 | 2020-12-11 16:25:29 -0600 | [diff] [blame^] | 4 | Subject: [PATCH 08/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> |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 12 | |
| 13 | Conflicts: |
| 14 | gcc/config/microblaze/microblaze.md |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 15 | --- |
| 16 | gcc/config/microblaze/microblaze.md | 3 +++ |
| 17 | gcc/config/microblaze/sync.md | 21 +++++++++++++-------- |
| 18 | 2 files changed, 16 insertions(+), 8 deletions(-) |
| 19 | |
| 20 | diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 21 | index 7049acd1dcd..eba2776ae56 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 22 | --- a/gcc/config/microblaze/microblaze.md |
| 23 | +++ b/gcc/config/microblaze/microblaze.md |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 24 | @@ -43,6 +43,9 @@ |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 25 | (UNSPEC_TLS 106) ;; jump table |
Andrew Geissler | 84ad7c5 | 2020-06-27 00:00:16 -0500 | [diff] [blame] | 26 | (UNSPEC_SET_TEXT 107) ;; set text start |
| 27 | (UNSPEC_TEXT 108) ;; data text relative |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 28 | + (UNSPECV_CAS_BOOL 201) ;; compare and swap (bool) |
| 29 | + (UNSPECV_CAS_VAL 202) ;; compare and swap (val) |
| 30 | + (UNSPECV_CAS_MEM 203) ;; compare and swap (mem) |
| 31 | ]) |
| 32 | |
| 33 | (define_c_enum "unspec" [ |
| 34 | diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 35 | index 76f530b9d3b..24cd67e1fdb 100644 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 36 | --- a/gcc/config/microblaze/sync.md |
| 37 | +++ b/gcc/config/microblaze/sync.md |
| 38 | @@ -18,14 +18,19 @@ |
| 39 | ;; <http://www.gnu.org/licenses/>. |
| 40 | |
| 41 | (define_insn "atomic_compare_and_swapsi" |
| 42 | - [(match_operand:SI 0 "register_operand" "=&d") ;; bool output |
| 43 | - (match_operand:SI 1 "register_operand" "=&d") ;; val output |
| 44 | - (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory |
| 45 | - (match_operand:SI 3 "register_operand" "d") ;; expected value |
| 46 | - (match_operand:SI 4 "register_operand" "d") ;; desired value |
| 47 | - (match_operand:SI 5 "const_int_operand" "") ;; is_weak |
| 48 | - (match_operand:SI 6 "const_int_operand" "") ;; mod_s |
| 49 | - (match_operand:SI 7 "const_int_operand" "") ;; mod_f |
| 50 | + [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output |
| 51 | + (unspec_volatile:SI |
| 52 | + [(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory |
| 53 | + (match_operand:SI 3 "register_operand" "d") ;; expected value |
| 54 | + (match_operand:SI 4 "register_operand" "d")] ;; desired value |
| 55 | + UNSPECV_CAS_BOOL)) |
| 56 | + (set (match_operand:SI 1 "register_operand" "=&d") ;; val output |
| 57 | + (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL)) |
| 58 | + (set (match_dup 2) |
| 59 | + (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM)) |
| 60 | + (match_operand:SI 5 "const_int_operand" "") ;; is_weak |
| 61 | + (match_operand:SI 6 "const_int_operand" "") ;; mod_s |
| 62 | + (match_operand:SI 7 "const_int_operand" "") ;; mod_f |
| 63 | (clobber (match_scratch:SI 8 "=&d"))] |
| 64 | "" |
| 65 | { |
| 66 | -- |
Andrew Geissler | a9ff2b3 | 2020-10-16 10:11:54 -0500 | [diff] [blame] | 67 | 2.17.1 |
Brad Bishop | 286d45c | 2018-10-02 15:21:57 -0400 | [diff] [blame] | 68 | |