From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] inline llsc atomics when compiling for sh4a
Date: Mon, 18 May 2015 00:28:46 -0400 [thread overview]
Message-ID: <20150518042846.GA15416@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150518023402.GS17573@brightrain.aerifal.cx>
On Sun, May 17, 2015 at 10:34:02PM -0400, Rich Felker wrote:
> Another idea is letting the compiler simplify, with something like the
> following, which could actually be used cross-platform for all
> llsc-type archs:
>
> static inline int __sh_cas_llsc(volatile int *p, int t, int s)
> {
> do old = llsc_start(p);
> while (*p == t && !llsc_end(p, s));
> return old;
> }
>
> Here llsc_start and llsc_end would be inline functions using asm with
> appropriate constraints. Unfortunately I don't see a way to model
> using the value of the truth flag "t" as the output of the asm for
> llsc_end, though. I suspect this would be a problem on a number of
> other archs too; the asm would have to waste an instruction (or
> several) converting the flag to an integer. Unless there's a solution
> to that problem, it makes an approach like this less appealing.
Indeed, I can't find a way to make it work without two useless
instructions. This is what I get (for an extern function a_cas based
on the above approach):
a_cas:
.align 2
.L4:
#APP
synco ; mov.li @r4, r0
#NO_APP
cmp/eq r0,r5
bf/s .L7
mov r0,r1
mov r6,r0
#APP
mov.co r0, @r4 ; movt r2
#NO_APP
tst r2,r2
bt .L4
.L7:
rts
mov r1,r0
Both the movt (which I had to write) and the tst (which the compiler
generated) are useless. It's a shame, because otherwise this approach
is really clean and elegant.
Rich
next prev parent reply other threads:[~2015-05-18 4:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-17 18:55 Bobby Bingham
2015-05-18 2:34 ` Rich Felker
2015-05-18 4:28 ` Rich Felker [this message]
2015-05-18 22:56 ` Bobby Bingham
2015-05-19 0:30 ` Rich Felker
2015-05-19 2:12 ` Rich Felker
2015-05-19 4:52 ` Rich Felker
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=20150518042846.GA15416@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).