[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 05/35] int128: Add int128_make128
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH v4 05/35] int128: Add int128_make128 |
Date: |
Fri, 16 Sep 2016 10:46:27 -0700 |
Allows Int128 to be used more generally, rather than having to
begin with 64-bit inputs and accumulate.
Signed-off-by: Richard Henderson <address@hidden>
---
include/qemu/int128.h | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index 08f1db1..67440fa 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -10,6 +10,11 @@ static inline Int128 int128_make64(uint64_t a)
return a;
}
+static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
+{
+ return (unsigned __int128)hi << 64 | lo;
+}
+
static inline uint64_t int128_get64(Int128 a)
{
uint64_t r = a;
@@ -146,6 +151,11 @@ static inline Int128 int128_make64(uint64_t a)
return (Int128) { a, 0 };
}
+static inline Int128 int128_make128(uint64_t lo, uint64_t hi)
+{
+ return (Int128) { lo, hi };
+}
+
static inline uint64_t int128_get64(Int128 a)
{
assert(!a.hi);
@@ -195,9 +205,9 @@ static inline Int128 int128_rshift(Int128 a, int n)
}
h = a.hi >> (n & 63);
if (n >= 64) {
- return (Int128) { h, h >> 63 };
+ return int128_make128(h, h >> 63);
} else {
- return (Int128) { (a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h };
+ return int128_make128((a.lo >> n) | ((uint64_t)a.hi << (64 - n)), h);
}
}
@@ -211,18 +221,18 @@ static inline Int128 int128_add(Int128 a, Int128 b)
*
* So the carry is lo < a.lo.
*/
- return (Int128) { lo, (uint64_t)a.hi + b.hi + (lo < a.lo) };
+ return int128_make128(lo, (uint64_t)a.hi + b.hi + (lo < a.lo));
}
static inline Int128 int128_neg(Int128 a)
{
uint64_t lo = -a.lo;
- return (Int128) { lo, ~(uint64_t)a.hi + !lo };
+ return int128_make128(lo, ~(uint64_t)a.hi + !lo);
}
static inline Int128 int128_sub(Int128 a, Int128 b)
{
- return (Int128){ a.lo - b.lo, (uint64_t)a.hi - b.hi - (a.lo < b.lo) };
+ return int128_make128(a.lo - b.lo, (uint64_t)a.hi - b.hi - (a.lo < b.lo));
}
static inline bool int128_nonneg(Int128 a)
--
2.5.5
- [Qemu-devel] [PATCH v4 00/35] cmpxchg-based emulation of atomics, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 01/35] atomics: add atomic_xor, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 02/35] atomics: add atomic_op_fetch variants, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 04/35] int128: Use __int128 if available, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 03/35] exec: Avoid direct references to Int128 parts, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 05/35] int128: Add int128_make128,
Richard Henderson <=
- [Qemu-devel] [PATCH v4 07/35] HACK: Always enable parallel_cpus, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 08/35] cputlb: Replace SHIFT with DATA_SIZE, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 10/35] cputlb: Remove includes from softmmu_template.h, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 09/35] cputlb: Move probe_write out of softmmu_template.h, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 12/35] cputlb: Tidy some macros, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 16/35] tcg: Emit barriers with parallel_cpus, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 11/35] cputlb: Move most of iotlb code out of line, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 17/35] target-i386: emulate LOCK'ed cmpxchg using cmpxchg helpers, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 19/35] target-i386: emulate LOCK'ed INC using atomic helper, Richard Henderson, 2016/09/16
- [Qemu-devel] [PATCH v4 15/35] tcg: Add CONFIG_ATOMIC64, Richard Henderson, 2016/09/16