From: Andi Kleen <andi@firstfloor.org>
To: gcc-patches@gcc.gnu.org
Cc: Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 2/2] Support __ATOMIC_HLE_RELEASE for __atomic_clear/store_n
Date: Sat, 12 Jan 2013 15:29:00 -0000 [thread overview]
Message-ID: <1358004522-16358-2-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1358004522-16358-1-git-send-email-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
__atomic_clear and __atomic_store_n didn't have code to generate
the TSX HLE RELEASE prefix. Add this plus test cases.
Right now it would need another target hook to check for someone
passing __ATOMIC_HLE_ACQUIRE to store/clear. I just ignore this
for now.
Passes bootstrap/test on x86_64.
Ok for release branch / trunk ?
gcc/:
2013-01-11 Andi Kleen <ak@linux.intel.com>
PR target/55948
* builtins.c (expand_builtin_atomic_clear): Add comment.
* config/i386/sync.md (UNSPEC_MOVA_RELEASE): Add.
(atomic_store_hle_release<mode>): Add
(atomic_store<mode>): Check for HLE RELEASE.
gcc/testsuite/:
2013-01-11 Andi Kleen <ak@linux.intel.com>
PR target/55948
* gcc.target/i386/hle-clear-rel.c: New file
* testsuite/gcc.target/i386/hle-store-rel.c: New file.
---
gcc/builtins.c | 2 ++
gcc/config/i386/sync.md | 16 ++++++++++++++++
gcc/testsuite/gcc.target/i386/hle-clear-rel.c | 9 +++++++++
gcc/testsuite/gcc.target/i386/hle-store-rel.c | 9 +++++++++
4 files changed, 36 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/i386/hle-clear-rel.c
create mode 100644 gcc/testsuite/gcc.target/i386/hle-store-rel.c
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 2b615a1..c283869 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5556,6 +5556,8 @@ expand_builtin_atomic_clear (tree exp)
return const0_rtx;
}
+ /* need target hook there to check for not hle acquire */
+
if (HAVE_atomic_clear)
{
emit_insn (gen_atomic_clear (mem, model));
diff --git a/gcc/config/i386/sync.md b/gcc/config/i386/sync.md
index 8d22a5e..9eae57f 100644
--- a/gcc/config/i386/sync.md
+++ b/gcc/config/i386/sync.md
@@ -23,6 +23,7 @@
UNSPEC_SFENCE
UNSPEC_MFENCE
UNSPEC_MOVA ; For __atomic support
+ UNSPEC_MOVA_RELEASE
UNSPEC_LDA
UNSPEC_STA
])
@@ -194,6 +195,14 @@
DONE;
})
+(define_insn "atomic_store_hle_release<mode>"
+ [(set (match_operand:ATOMIC 0 "memory_operand")
+ (unspec:ATOMIC [(match_operand:ATOMIC 1 "register_operand")
+ (match_operand:SI 2 "const_int_operand")]
+ UNSPEC_MOVA_RELEASE))]
+ ""
+ "%K2mov{<imodesuffix>}\t{%1, %0|%0, %1}")
+
(define_expand "atomic_store<mode>"
[(set (match_operand:ATOMIC 0 "memory_operand")
(unspec:ATOMIC [(match_operand:ATOMIC 1 "register_operand")
@@ -214,6 +223,13 @@
}
else
{
+ if (model & IX86_HLE_RELEASE)
+ {
+ emit_insn (gen_atomic_store_hle_release<mode> (operands[0], operands[1],
+ operands[2]));
+ DONE;
+ }
+
/* For seq-cst stores, when we lack MFENCE, use XCHG. */
if (model == MEMMODEL_SEQ_CST && !(TARGET_64BIT || TARGET_SSE2))
{
diff --git a/gcc/testsuite/gcc.target/i386/hle-clear-rel.c b/gcc/testsuite/gcc.target/i386/hle-clear-rel.c
new file mode 100644
index 0000000..913f6d0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/hle-clear-rel.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-mhle" } */
+/* { dg-final { scan-assembler "\[ \n\t\]+\(xrelease\|\.byte\[ \t\]+0xf3\)\[ \t\n\]+mov" } } */
+
+void
+hle_clear (int *p, int v)
+{
+ __atomic_clear (p, __ATOMIC_RELEASE | __ATOMIC_HLE_RELEASE);
+}
diff --git a/gcc/testsuite/gcc.target/i386/hle-store-rel.c b/gcc/testsuite/gcc.target/i386/hle-store-rel.c
new file mode 100644
index 0000000..7295d33
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/hle-store-rel.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-mhle" } */
+/* { dg-final { scan-assembler "\[ \n\t\]+\(xrelease\|\.byte\[ \t\]+0xf3\)\[ \t\n\]+mov" } } */
+
+void
+hle_store (int *p, int v)
+{
+ __atomic_store_n (p, v, __ATOMIC_RELEASE | __ATOMIC_HLE_RELEASE);
+}
--
1.7.10.4
next prev parent reply other threads:[~2013-01-12 15:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-12 15:29 [PATCH 1/2] Document HLE / RTM intrinsics Andi Kleen
2013-01-12 15:29 ` Andi Kleen [this message]
2013-01-12 17:02 ` Bernhard Reutner-Fischer
2013-01-12 17:20 ` Andi Kleen
2013-01-14 14:44 ` Richard Biener
2013-01-14 18:22 ` Andi Kleen
2013-01-20 18:50 ` [PING] " Andi Kleen
2013-01-26 22:55 ` [PING^2] " Andi Kleen
2013-02-14 21:34 ` [PING^3] " Andi Kleen
2013-01-27 18:16 ` Florian Weimer
2013-01-27 21:22 ` Andi Kleen
2013-01-13 19:59 [PATCH 2/2] Support __ATOMIC_HLE_RELEASE for __atomic_clear/store_n Uros Bizjak
2013-01-13 20:36 ` Andi Kleen
2013-01-13 20:59 ` Uros Bizjak
2013-01-13 22:13 ` Andi Kleen
2013-01-13 22:23 ` Uros Bizjak
2013-01-13 22:29 ` Andi Kleen
2013-01-14 16:48 ` Uros Bizjak
2013-01-14 18:06 ` Andi Kleen
2013-01-14 18:41 ` Uros Bizjak
2013-01-14 19:02 ` Andi Kleen
2013-01-14 19:21 ` Uros Bizjak
2013-01-14 19:25 ` Uros Bizjak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358004522-16358-2-git-send-email-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).