blob: db730f438fb03e9cc2383ccf1a6a9f357c02bb10 [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From 8711bdfe27bce04d35ba93a1d18ccccd61371829 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
4Subject: [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 Bishop286d45c2018-10-02 15:21:57 -04009
10Signed-off-by: Kirk Meyer <kirk.meyer@sencore.com>
11Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040012---
13 gcc/config/microblaze/microblaze.md | 3 +++
14 gcc/config/microblaze/sync.md | 21 +++++++++++++--------
15 2 files changed, 16 insertions(+), 8 deletions(-)
16
17diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Brad Bishop26bdd442019-08-16 17:08:17 -040018index f698e54..93f5fa2 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040019--- 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" [
31diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md
Brad Bishop26bdd442019-08-16 17:08:17 -040032index b34bd54..8e694e9 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040033--- 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 Bishop26bdd442019-08-16 17:08:17 -0400642.7.4
Brad Bishop286d45c2018-10-02 15:21:57 -040065