blob: 45d93ceef0fc21b2a43b726e733ca799f1dee397 [file] [log] [blame]
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001From eeeb8ecda7cb71c033c850ce36162c92c7d0b781 Mon Sep 17 00:00:00 2001
Brad Bishop286d45c2018-10-02 15:21:57 -04002From: Mahesh Bodapati <mbodapat@xilinx.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04003Date: Thu, 12 Jan 2017 16:41:43 +0530
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05004Subject: [PATCH 09/58] [Patch, microblaze]: Fix atomic side effects.
5
6In atomic_compare_and_swapsi, add side effects to prevent incorrect
7assumptions during optimization. Previously, the outputs were
8considered unused; this generated assembly code with
9undefined side effects after invocation of the atomic.
Brad Bishop286d45c2018-10-02 15:21:57 -040010
11Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
12Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Andrew Geissler84ad7c52020-06-27 00:00:16 -050013
14Conflicts:
15 gcc/config/microblaze/microblaze.md
Brad Bishop286d45c2018-10-02 15:21:57 -040016---
17 gcc/config/microblaze/microblaze.md | 3 +++
18 gcc/config/microblaze/sync.md | 21 +++++++++++++--------
19 2 files changed, 16 insertions(+), 8 deletions(-)
20
21diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050022index 7049acd1dcd..eba2776ae56 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040023--- a/gcc/config/microblaze/microblaze.md
24+++ b/gcc/config/microblaze/microblaze.md
Andrew Geissler84ad7c52020-06-27 00:00:16 -050025@@ -43,6 +43,9 @@
Brad Bishop286d45c2018-10-02 15:21:57 -040026 (UNSPEC_TLS 106) ;; jump table
Andrew Geissler84ad7c52020-06-27 00:00:16 -050027 (UNSPEC_SET_TEXT 107) ;; set text start
28 (UNSPEC_TEXT 108) ;; data text relative
Brad Bishop286d45c2018-10-02 15:21:57 -040029+ (UNSPECV_CAS_BOOL 201) ;; compare and swap (bool)
30+ (UNSPECV_CAS_VAL 202) ;; compare and swap (val)
31+ (UNSPECV_CAS_MEM 203) ;; compare and swap (mem)
32 ])
33
34 (define_c_enum "unspec" [
35diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050036index 76f530b9d3b..24cd67e1fdb 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040037--- a/gcc/config/microblaze/sync.md
38+++ b/gcc/config/microblaze/sync.md
39@@ -18,14 +18,19 @@
40 ;; <http://www.gnu.org/licenses/>.
41
42 (define_insn "atomic_compare_and_swapsi"
43- [(match_operand:SI 0 "register_operand" "=&d") ;; bool output
44- (match_operand:SI 1 "register_operand" "=&d") ;; val output
45- (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
46- (match_operand:SI 3 "register_operand" "d") ;; expected value
47- (match_operand:SI 4 "register_operand" "d") ;; desired value
48- (match_operand:SI 5 "const_int_operand" "") ;; is_weak
49- (match_operand:SI 6 "const_int_operand" "") ;; mod_s
50- (match_operand:SI 7 "const_int_operand" "") ;; mod_f
51+ [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output
52+ (unspec_volatile:SI
53+ [(match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory
54+ (match_operand:SI 3 "register_operand" "d") ;; expected value
55+ (match_operand:SI 4 "register_operand" "d")] ;; desired value
56+ UNSPECV_CAS_BOOL))
57+ (set (match_operand:SI 1 "register_operand" "=&d") ;; val output
58+ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_VAL))
59+ (set (match_dup 2)
60+ (unspec_volatile:SI [(const_int 0)] UNSPECV_CAS_MEM))
61+ (match_operand:SI 5 "const_int_operand" "") ;; is_weak
62+ (match_operand:SI 6 "const_int_operand" "") ;; mod_s
63+ (match_operand:SI 7 "const_int_operand" "") ;; mod_f
64 (clobber (match_scratch:SI 8 "=&d"))]
65 ""
66 {
67--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -0500682.17.1
Brad Bishop286d45c2018-10-02 15:21:57 -040069