From: David Hildenbrand <david@redhat.com>
To: Thomas Huth <thuth@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
David Miller <dmiller423@gmail.com>,
qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Cc: pasic@linux.ibm.com, borntraeger@linux.ibm.com,
farman@linux.ibm.com, cohuck@redhat.com
Subject: Re: [PATCH v7 3/4] tests/tcg/s390x: Tests for Miscellaneous-Instruction-Extensions Facility 3
Date: Mon, 28 Feb 2022 11:39:41 +0100 [thread overview]
Message-ID: <6d3f8708-d5b1-8abc-7d00-deb4e014ad52@redhat.com> (raw)
In-Reply-To: <3853fa79-4578-be7b-4a2f-5b31cdd5c4c7@redhat.com>
On 28.02.22 11:14, Thomas Huth wrote:
> On 24/02/2022 00.43, Richard Henderson wrote:
>> On 2/23/22 12:31, David Miller wrote:
>>> +#define F_EPI "stg %%r0, %[res] " : [res] "+m" (res) : : "r0", "r2", "r3"
>>> +
>>> +#define F_PRO asm ( \
>>> + "llihf %%r0,801\n" \
>>> + "lg %%r2, %[a]\n" \
>>> + "lg %%r3, %[b] " \
>>> + : : [a] "m" (a), \
>>> + [b] "m" (b) \
>>> + : "r2", "r3")
>>> +
>>> +#define FbinOp(S, ASM) uint64_t S(uint64_t a, uint64_t b) \
>>> +{ uint64_t res = 0; F_PRO; ASM; return res; }
>>> +
>>> +/* AND WITH COMPLEMENT */
>>> +FbinOp(_ncrk, asm("ncrk %%r0, %%r3, %%r2\n" F_EPI))
>>> +FbinOp(_ncgrk, asm("ncgrk %%r0, %%r3, %%r2\n" F_EPI))
>>
>> Better written as
>>
>> asm("ncrk %0, %3, %2" : "=&r"(res) : "r"(a), "r"(b) : "cc");
>
> I agree with Richard, especially since it's kind of "dangerous" to chain
> multiple asm() statements (without "volatile") and hoping that the compiler
> keeps the values in the registers in between (without reordering the
> statements).
>
> Anyway, since I'll be away for most the rest of the week and we already have
> soft-freeze next week, I'd like to get this fixed for my pull request that I
> plan later for today or tomorrow, so I now went ahead and modified the code
> to look like this:
>
> #define FbinOp(S, ASM) uint64_t S(uint64_t a, uint64_t b) \
> { \
> uint64_t res = 0; \
> asm ("llihf %[res],801\n" ASM \
> : [res]"=&r"(res) : [a]"r"(a), [b]"r"(b) : "cc"); \
> return res; \
> }
>
> /* AND WITH COMPLEMENT */
> FbinOp(_ncrk, ".insn rrf, 0xB9F50000, %[res], %[b], %[a], 0\n")
> FbinOp(_ncgrk, ".insn rrf, 0xB9E50000, %[res], %[b], %[a], 0\n")
>
> /* NAND */
> FbinOp(_nnrk, ".insn rrf, 0xB9740000, %[res], %[b], %[a], 0\n")
> FbinOp(_nngrk, ".insn rrf, 0xB9640000, %[res], %[b], %[a], 0\n")
>
> /* NOT XOR */
> FbinOp(_nxrk, ".insn rrf, 0xB9770000, %[res], %[b], %[a], 0\n")
> FbinOp(_nxgrk, ".insn rrf, 0xB9670000, %[res], %[b], %[a], 0\n")
>
> /* NOR */
> FbinOp(_nork, ".insn rrf, 0xB9760000, %[res], %[b], %[a], 0\n")
> FbinOp(_nogrk, ".insn rrf, 0xB9660000, %[res], %[b], %[a], 0\n")
>
> /* OR WITH COMPLEMENT */
> FbinOp(_ocrk, ".insn rrf, 0xB9750000, %[res], %[b], %[a], 0\n")
> FbinOp(_ocgrk, ".insn rrf, 0xB9650000, %[res], %[b], %[a], 0\n")
>
> Full patch can be seen here:
>
> https://gitlab.com/thuth/qemu/-/commit/38af118ea2fef0c473
>
> I hope that's ok for everybody?
Fine with me.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-02-28 10:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 22:31 [PATCH v7 0/4] s390x: Add partial z15 support and tests David Miller
2022-02-23 22:31 ` [PATCH v7 1/4] s390x/tcg: Implement Miscellaneous-Instruction-Extensions Facility 3 for the s390x David Miller
2022-02-23 23:32 ` Richard Henderson
2022-02-23 22:31 ` [PATCH v7 2/4] s390x/cpumodel: Bump up QEMU model to a stripped-down IBM z15 GA1 David Miller
2022-02-23 22:31 ` [PATCH v7 3/4] tests/tcg/s390x: Tests for Miscellaneous-Instruction-Extensions Facility 3 David Miller
2022-02-23 23:43 ` Richard Henderson
2022-02-23 23:44 ` Richard Henderson
2022-02-28 10:14 ` Thomas Huth
2022-02-28 10:39 ` David Hildenbrand [this message]
2022-02-28 17:59 ` Richard Henderson
2022-02-28 18:31 ` David Miller
2022-03-01 10:24 ` Thomas Huth
2022-03-01 17:02 ` David Miller
2022-02-23 22:31 ` [PATCH v7 4/4] tests/tcg/s390x: changed to using .insn for tests requiring z15 David Miller
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=6d3f8708-d5b1-8abc-7d00-deb4e014ad52@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=dmiller423@gmail.com \
--cc=farman@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.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.
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).