mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 05:51:53 -06:00
qemu/int128: Add int128_lshift
Add left-shift to match the existing right-shift. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 20200815013145.539409-2-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
512c65e62e
commit
5be4dd043f
1 changed files with 16 additions and 0 deletions
|
@ -63,6 +63,11 @@ static inline Int128 int128_rshift(Int128 a, int n)
|
||||||
return a >> n;
|
return a >> n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Int128 int128_lshift(Int128 a, int n)
|
||||||
|
{
|
||||||
|
return a << n;
|
||||||
|
}
|
||||||
|
|
||||||
static inline Int128 int128_add(Int128 a, Int128 b)
|
static inline Int128 int128_add(Int128 a, Int128 b)
|
||||||
{
|
{
|
||||||
return a + b;
|
return a + b;
|
||||||
|
@ -217,6 +222,17 @@ static inline Int128 int128_rshift(Int128 a, int n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Int128 int128_lshift(Int128 a, int n)
|
||||||
|
{
|
||||||
|
uint64_t l = a.lo << (n & 63);
|
||||||
|
if (n >= 64) {
|
||||||
|
return int128_make128(0, l);
|
||||||
|
} else if (n > 0) {
|
||||||
|
return int128_make128(l, (a.hi << n) | (a.lo >> (64 - n)));
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
static inline Int128 int128_add(Int128 a, Int128 b)
|
static inline Int128 int128_add(Int128 a, Int128 b)
|
||||||
{
|
{
|
||||||
uint64_t lo = a.lo + b.lo;
|
uint64_t lo = a.lo + b.lo;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue