public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Koakuma via B4 Relay <devnull+koachan.protonmail.com@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Andreas Larsson <andreas@gaisler.com>,
	Andy Lutomirski <luto@kernel.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>
Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, Koakuma <koachan@protonmail.com>
Subject: Re: [PATCH] sparc/vdso: Add helper function for 64-bit right shift on 32-bit target
Date: Sun, 04 Aug 2024 17:44:44 +0200	[thread overview]
Message-ID: <871q3470nn.ffs@tglx> (raw)
In-Reply-To: <20240804-sparc-shr64-v1-1-25050968339a@protonmail.com>

On Sun, Aug 04 2024 at 10:39, Koakuma via wrote:
> From: Koakuma <koachan@protonmail.com>
>
> Add helper function for 64-bit right shift on 32-bit target so that
> clang does not emit a runtime library call.
>
> Signed-off-by: Koakuma <koachan@protonmail.com>
> ---
> Hi~
>
> This adds a small function to do 64-bit right shifts for use in vDSO
> code, needed so that clang does not emit a call to runtime library.
> ---
>  arch/sparc/vdso/vclock_gettime.c |  8 ++++----
>  include/vdso/math64.h            | 28 ++++++++++++++++++++++++++++

> --- a/include/vdso/math64.h
> +++ b/include/vdso/math64.h
> @@ -21,6 +21,34 @@ __iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
>  	return ret;
>  }
>  
> +#if BITS_PER_LONG == 32
> +/* This is to prevent the compiler from emitting a call to __lshrdi3. */
> +static __always_inline u64
> +__shr64(u64 val, int amt)
> +{
> +	u32 mask = (1U << amt) - 1;
> +	u32 lo = val;
> +	u32 hi = val >> 32;
> +	u32 mi;
> +
> +	if (amt >= 32)
> +		return hi >> (amt - 32);
> +
> +
> +	mi = (hi & mask) << (32 - amt);
> +	hi >>= amt;
> +	lo = (lo >> amt) | mi;
> +
> +	return ((u64) hi) << 32 | lo;
> +}
> +#else
> +static __always_inline u64
> +__shr64(u64 val, int amt)
> +{
> +	return val >> amt;
> +}

Why does this sparc'ism need to be in generic code?

Thanks,

        tglx

  reply	other threads:[~2024-08-04 15:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-04  3:39 [PATCH] sparc/vdso: Add helper function for 64-bit right shift on 32-bit target Koakuma via B4 Relay
2024-08-04 15:44 ` Thomas Gleixner [this message]
2024-08-04 17:30   ` Koakuma
2024-08-04 19:16     ` Thomas Gleixner
2024-08-06  2:02       ` Koakuma

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=871q3470nn.ffs@tglx \
    --to=tglx@linutronix.de \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=devnull+koachan.protonmail.com@kernel.org \
    --cc=justinstitt@google.com \
    --cc=koachan@protonmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luto@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=vincenzo.frascino@arm.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