From: Richard Henderson <richard.henderson@linaro.org>
To: cupertinomiranda@gmail.com, qemu-devel@nongnu.org
Cc: shahab@synopsys.com, linux-snps-arc@lists.infradead.org,
claziss@synopsys.com, cmiranda@synopsys.com
Subject: Re: [PATCH 04/27] arc: TCG and decoder glue code and helpers
Date: Tue, 6 Apr 2021 19:37:15 -0700 [thread overview]
Message-ID: <2df509f0-6c53-24cb-92ac-096e5685a0b7@linaro.org> (raw)
In-Reply-To: <20210405143138.17016-5-cupertinomiranda@gmail.com>
On 4/5/21 7:31 AM, cupertinomiranda@gmail.com wrote:
> +static inline target_ulong
> +carry_add_flag(target_ulong dest, target_ulong b, target_ulong c, uint8_t size)
> +{
> + target_ulong t1, t2, t3;
> +
> + t1 = b & c;
> + t2 = b & (~dest);
> + t3 = c & (~dest);
> + t1 = t1 | t2 | t3;
> + return (t1 >> (size - 1)) & 1;
> +}
> +
> +target_ulong helper_carry_add_flag(target_ulong dest, target_ulong b,
> + target_ulong c) {
> + return carry_add_flag(dest, b, c, TARGET_LONG_BITS);
> +}
> +
> +static inline target_ulong
> +overflow_add_flag(target_ulong dest, target_ulong b, target_ulong c,
> + uint8_t size)
> +{
> + dest >>= (size - 1);
> + b >>= (size - 1);
> + c >>= (size - 1);
> + if ((dest == 0 && b == 1 && c == 1)
> + || (dest == 1 && b == 0 && c == 0)) {
> + return 1;
> + } else {
> + return 0;
> + }
> +}
> +target_ulong helper_overflow_add_flag(target_ulong dest, target_ulong b,
> + target_ulong c) {
> + return overflow_add_flag(dest, b, c, TARGET_LONG_BITS);
> +}
> +
> +static inline target_ulong
> +overflow_sub_flag(target_ulong dest, target_ulong b, target_ulong c,
> + uint8_t size)
> +{
> + dest >>= (size - 1);
> + b >>= (size - 1);
> + c >>= (size - 1);
> + if ((dest == 1 && b == 0 && c == 1)
> + || (dest == 0 && b == 1 && c == 0)) {
> + return 1;
> + } else {
> + return 0;
> + }
> +}
> +target_ulong helper_overflow_sub_flag(target_ulong dest, target_ulong b,
> + target_ulong c) {
> + return overflow_sub_flag(dest, b, c, TARGET_LONG_BITS);
> +}
> +
> +target_ulong helper_repl_mask(target_ulong dest, target_ulong src,
> + target_ulong mask)
> +{
> + target_ulong ret = dest & (~mask);
> + ret |= (src & mask);
> +
> + return ret;
> +}
> +
> +target_ulong helper_mpymu(CPUARCState *env, target_ulong b, target_ulong c)
> +{
> + uint64_t _b = (uint64_t) b;
> + uint64_t _c = (uint64_t) c;
> +
> + return (uint32_t) ((_b * _c) >> 32);
> +}
> +
> +target_ulong helper_mpym(CPUARCState *env, target_ulong b, target_ulong c)
> +{
> + int64_t _b = (int64_t) ((int32_t) b);
> + int64_t _c = (int64_t) ((int32_t) c);
> +
> + /*
> + * fprintf(stderr, "B = 0x%llx, C = 0x%llx, result = 0x%llx\n",
> + * _b, _c, _b * _c);
> + */
> + return (_b * _c) >> 32;
> +}
All completely trivial in tcg:
tcg_gen_add2_tl,
tcg_gen_mulu2_tl,
tcg_gen_muls2_tl.
and simple arithmetic for overflow -- see gen_add_CC in arm/translate.c.
r~
next prev parent reply other threads:[~2021-04-07 2:38 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-05 14:31 *** ARC port for review *** cupertinomiranda
2021-04-05 14:31 ` [PATCH 01/27] arc: Add initial core cpu files cupertinomiranda
2021-04-07 0:47 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 02/27] arc: Decoder code cupertinomiranda
2021-04-07 1:25 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 03/27] arc: Opcode definitions table cupertinomiranda
2021-04-05 14:31 ` [PATCH 04/27] arc: TCG and decoder glue code and helpers cupertinomiranda
2021-04-07 2:37 ` Richard Henderson [this message]
2021-04-05 14:31 ` [PATCH 05/27] arc: TCG instruction generator and hand-definitions cupertinomiranda
2021-04-07 3:52 ` Richard Henderson
2021-04-07 16:47 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 06/27] arc: semfunc.c tcg code generator cupertinomiranda
2021-04-07 17:14 ` Richard Henderson
2021-04-07 18:33 ` Peter Maydell
2021-04-05 14:31 ` [PATCH 07/27] arc: TCG instruction definitions cupertinomiranda
2021-04-07 19:38 ` Richard Henderson
2021-04-08 0:20 ` Richard Henderson
2021-04-12 14:27 ` Cupertino Miranda
2021-04-05 14:31 ` [PATCH 08/27] arc: Add BCR and AUX registers implementation cupertinomiranda
2021-04-05 14:31 ` [PATCH 09/27] arc: Add IRQ and timer subsystem support cupertinomiranda
2021-04-05 14:31 ` [PATCH 10/27] arc: Add memory management unit (MMU) support cupertinomiranda
2021-04-05 14:31 ` [PATCH 11/27] arc: Add memory protection unit (MPU) support cupertinomiranda
2021-04-05 14:31 ` [PATCH 12/27] arc: Add gdbstub and XML for debugging support cupertinomiranda
2021-04-05 14:31 ` [PATCH 13/27] arc: Add Synopsys ARC emulation boards cupertinomiranda
2021-04-05 14:31 ` [PATCH 14/27] arc: Add support for ARCv2 cupertinomiranda
2021-04-07 20:30 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 15/27] tests/tcg: ARC: Add TCG instruction definition tests cupertinomiranda
2021-04-07 20:38 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 16/27] tests/acceptance: ARC: Add linux boot testing cupertinomiranda
2021-04-07 20:40 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 17/27] arcv3: Core cpu file changes cupertinomiranda
2021-04-05 14:31 ` [PATCH 18/27] arcv3: Decoder code cupertinomiranda
2021-04-07 23:07 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 19/27] arcv3: Opcode definition table cupertinomiranda
2021-04-05 14:31 ` [PATCH 20/27] arcv3: TCG, decoder glue code and helper changes cupertinomiranda
2021-04-07 23:36 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 21/27] arcv3: TCG instruction generator changes cupertinomiranda
2021-04-07 23:43 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 22/27] arcv3: TCG instruction definitions cupertinomiranda
2021-04-07 23:48 ` Richard Henderson
2021-04-05 14:31 ` [PATCH 23/27] arcv3: BCR and AUX register changes cupertinomiranda
2021-04-05 14:31 ` [PATCH 24/27] arcv3: IRQ changes and new MMUv6 WIP cupertinomiranda
2021-04-05 14:31 ` [PATCH 25/27] arcv3: gdbstub changes and new XML files cupertinomiranda
2021-04-05 14:31 ` [PATCH 26/27] arcv3: board changes cupertinomiranda
2021-04-05 14:31 ` [PATCH 27/27] arcv3: Add support for ARCv3 cupertinomiranda
2021-04-06 23:47 ` *** ARC port for review *** Richard Henderson
2021-04-12 14:25 ` Cupertino Miranda
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=2df509f0-6c53-24cb-92ac-096e5685a0b7@linaro.org \
--to=richard.henderson@linaro.org \
--cc=claziss@synopsys.com \
--cc=cmiranda@synopsys.com \
--cc=cupertinomiranda@gmail.com \
--cc=linux-snps-arc@lists.infradead.org \
--cc=qemu-devel@nongnu.org \
--cc=shahab@synopsys.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).