mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-22 02:17:36 -04:00
There is no reason to have __ashlti3(), __ashrti3(), and __lshrti3() implemented in assembler. Convert them all to C, which allows the compiler to optimize the code if newer instructions allow that. Reviewed-by: Juergen Christ <jchrist@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/export.h>
|
|
#include <linux/types.h>
|
|
#include "tishift.h"
|
|
|
|
union ti {
|
|
__int128_t val;
|
|
struct {
|
|
u64 high;
|
|
u64 low;
|
|
};
|
|
};
|
|
|
|
noinstr __int128_t __ashlti3(__int128_t a, int shift)
|
|
{
|
|
union ti ti = { .val = a };
|
|
|
|
if (!shift)
|
|
return ti.val;
|
|
if (shift < 64) {
|
|
ti.high = (ti.high << shift) | (ti.low >> (64 - shift));
|
|
ti.low = ti.low << shift;
|
|
} else {
|
|
ti.high = ti.low << (shift - 64);
|
|
ti.low = 0;
|
|
}
|
|
return ti.val;
|
|
}
|
|
EXPORT_SYMBOL(__ashlti3);
|
|
|
|
noinstr __int128_t __ashrti3(__int128_t a, int shift)
|
|
{
|
|
union ti ti = { .val = a };
|
|
|
|
if (!shift)
|
|
return ti.val;
|
|
if (shift < 64) {
|
|
ti.low = (ti.low >> shift) | (ti.high << (64 - shift));
|
|
ti.high = (int64_t)ti.high >> shift;
|
|
} else {
|
|
ti.low = (int64_t)ti.high >> (shift - 64);
|
|
ti.high = (int64_t)ti.high >> 63;
|
|
}
|
|
return ti.val;
|
|
}
|
|
EXPORT_SYMBOL(__ashrti3);
|
|
|
|
noinstr __int128_t __lshrti3(__int128_t a, int shift)
|
|
{
|
|
union ti ti = { .val = a };
|
|
|
|
if (!shift)
|
|
return ti.val;
|
|
if (shift < 64) {
|
|
ti.low = (ti.low >> shift) | (ti.high << (64 - shift));
|
|
ti.high = ti.high >> shift;
|
|
} else {
|
|
ti.low = ti.high >> (shift - 64);
|
|
ti.high = 0;
|
|
}
|
|
return ti.val;
|
|
}
|
|
EXPORT_SYMBOL(__lshrti3);
|