aboutsummaryrefslogtreecommitdiff
path: root/include/qemu
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2023-05-02 21:18:45 +0100
committerRichard Henderson <richard.henderson@linaro.org>2023-05-02 21:18:45 +0100
commit4ebc33f3f3b656ebf62112daca6aa0f8019b4891 (patch)
treed1aa3082a2b2e1fbcdac6446643974e8a2ec0e1e /include/qemu
parentc586691e676214eb7edf6a468e84e7ce3b314d43 (diff)
parent129f1f9ee7df77d367d961b3c25353612d33cd83 (diff)
downloadqemu-4ebc33f3f3b656ebf62112daca6aa0f8019b4891.zip
qemu-4ebc33f3f3b656ebf62112daca6aa0f8019b4891.tar.gz
qemu-4ebc33f3f3b656ebf62112daca6aa0f8019b4891.tar.bz2
Merge tag 'pull-tcg-20230502-2' of https://gitlab.com/rth7680/qemu into staging
Misc tcg-related patch queue. # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmRRb30dHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+obAgAmL4F1gdkbUUPKnkv # poYwutCX+c3kog22TF29BlKgC8vJa6UbRLMphz5q7v3wbCKQJMeNV/sKa+mhnHBK # CB3wP8xXVAahWFARmWTIZEqlB3HQ/RIzhc5saKkiSzcGIrtXUj6fdfrz7mae+w/g # kDGCbK8hGyuE580j9QAIPbpfqPoNhIPziECFA1AsNf5Krpxc1nDqIfZEuUzTLtLO # 1WoSaUVbiGDQrTe2OVKF2mtrGbr2vWI1vnHJl67Lom6rG0LzOjb3W/8IN+n0+46E # 7pMlUCDT1zeTxevRxBvDmwgCYA/QjFosd4enUuhVReTxTNhUc69+QyuOAhHO/IEq # T0V3eA== # =qZDQ # -----END PGP SIGNATURE----- # gpg: Signature made Tue 02 May 2023 09:15:57 PM BST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-tcg-20230502-2' of https://gitlab.com/rth7680/qemu: tcg: Introduce tcg_out_movext2 tcg/mips: Conditionalize tcg_out_exts_i32_i64 tcg/loongarch64: Conditionalize tcg_out_exts_i32_i64 accel/tcg: Add cpu_ld*_code_mmu migration/xbzrle: Use __attribute__((target)) for avx512 qemu/int128: Re-shuffle Int128Alias members tcg: Add tcg_gen_gvec_rotrs tcg: Add tcg_gen_gvec_andcs qemu/host-utils.h: Add clz and ctz functions for lower-bit integers qemu/bitops.h: Limit rotate amounts accel/tcg: Uncache the host address for instruction fetch when tlb size < 1 softmmu: Tidy dirtylimit_dirty_ring_full_time Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/bitops.h16
-rw-r--r--include/qemu/host-utils.h54
-rw-r--r--include/qemu/int128.h4
3 files changed, 64 insertions, 10 deletions
diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h
index 03213ce..cb3526d 100644
--- a/include/qemu/bitops.h
+++ b/include/qemu/bitops.h
@@ -218,7 +218,7 @@ static inline unsigned long find_first_zero_bit(const unsigned long *addr,
*/
static inline uint8_t rol8(uint8_t word, unsigned int shift)
{
- return (word << shift) | (word >> ((8 - shift) & 7));
+ return (word << (shift & 7)) | (word >> (-shift & 7));
}
/**
@@ -228,7 +228,7 @@ static inline uint8_t rol8(uint8_t word, unsigned int shift)
*/
static inline uint8_t ror8(uint8_t word, unsigned int shift)
{
- return (word >> shift) | (word << ((8 - shift) & 7));
+ return (word >> (shift & 7)) | (word << (-shift & 7));
}
/**
@@ -238,7 +238,7 @@ static inline uint8_t ror8(uint8_t word, unsigned int shift)
*/
static inline uint16_t rol16(uint16_t word, unsigned int shift)
{
- return (word << shift) | (word >> ((16 - shift) & 15));
+ return (word << (shift & 15)) | (word >> (-shift & 15));
}
/**
@@ -248,7 +248,7 @@ static inline uint16_t rol16(uint16_t word, unsigned int shift)
*/
static inline uint16_t ror16(uint16_t word, unsigned int shift)
{
- return (word >> shift) | (word << ((16 - shift) & 15));
+ return (word >> (shift & 15)) | (word << (-shift & 15));
}
/**
@@ -258,7 +258,7 @@ static inline uint16_t ror16(uint16_t word, unsigned int shift)
*/
static inline uint32_t rol32(uint32_t word, unsigned int shift)
{
- return (word << shift) | (word >> ((32 - shift) & 31));
+ return (word << (shift & 31)) | (word >> (-shift & 31));
}
/**
@@ -268,7 +268,7 @@ static inline uint32_t rol32(uint32_t word, unsigned int shift)
*/
static inline uint32_t ror32(uint32_t word, unsigned int shift)
{
- return (word >> shift) | (word << ((32 - shift) & 31));
+ return (word >> (shift & 31)) | (word << (-shift & 31));
}
/**
@@ -278,7 +278,7 @@ static inline uint32_t ror32(uint32_t word, unsigned int shift)
*/
static inline uint64_t rol64(uint64_t word, unsigned int shift)
{
- return (word << shift) | (word >> ((64 - shift) & 63));
+ return (word << (shift & 63)) | (word >> (-shift & 63));
}
/**
@@ -288,7 +288,7 @@ static inline uint64_t rol64(uint64_t word, unsigned int shift)
*/
static inline uint64_t ror64(uint64_t word, unsigned int shift)
{
- return (word >> shift) | (word << ((64 - shift) & 63));
+ return (word >> (shift & 63)) | (word << (-shift & 63));
}
/**
diff --git a/include/qemu/host-utils.h b/include/qemu/host-utils.h
index 3ce62bf..d3b4dce 100644
--- a/include/qemu/host-utils.h
+++ b/include/qemu/host-utils.h
@@ -108,6 +108,36 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
#endif
/**
+ * clz8 - count leading zeros in a 8-bit value.
+ * @val: The value to search
+ *
+ * Returns 8 if the value is zero. Note that the GCC builtin is
+ * undefined if the value is zero.
+ *
+ * Note that the GCC builtin will upcast its argument to an `unsigned int`
+ * so this function subtracts off the number of prepended zeroes.
+ */
+static inline int clz8(uint8_t val)
+{
+ return val ? __builtin_clz(val) - 24 : 8;
+}
+
+/**
+ * clz16 - count leading zeros in a 16-bit value.
+ * @val: The value to search
+ *
+ * Returns 16 if the value is zero. Note that the GCC builtin is
+ * undefined if the value is zero.
+ *
+ * Note that the GCC builtin will upcast its argument to an `unsigned int`
+ * so this function subtracts off the number of prepended zeroes.
+ */
+static inline int clz16(uint16_t val)
+{
+ return val ? __builtin_clz(val) - 16 : 16;
+}
+
+/**
* clz32 - count leading zeros in a 32-bit value.
* @val: The value to search
*
@@ -154,6 +184,30 @@ static inline int clo64(uint64_t val)
}
/**
+ * ctz8 - count trailing zeros in a 8-bit value.
+ * @val: The value to search
+ *
+ * Returns 8 if the value is zero. Note that the GCC builtin is
+ * undefined if the value is zero.
+ */
+static inline int ctz8(uint8_t val)
+{
+ return val ? __builtin_ctz(val) : 8;
+}
+
+/**
+ * ctz16 - count trailing zeros in a 16-bit value.
+ * @val: The value to search
+ *
+ * Returns 16 if the value is zero. Note that the GCC builtin is
+ * undefined if the value is zero.
+ */
+static inline int ctz16(uint16_t val)
+{
+ return val ? __builtin_ctz(val) : 16;
+}
+
+/**
* ctz32 - count trailing zeros in a 32-bit value.
* @val: The value to search
*
diff --git a/include/qemu/int128.h b/include/qemu/int128.h
index f62a46b..9e46cfae 100644
--- a/include/qemu/int128.h
+++ b/include/qemu/int128.h
@@ -483,9 +483,9 @@ static inline void bswap128s(Int128 *s)
*/
#ifdef CONFIG_INT128
typedef union {
- Int128 s;
- __int128_t i;
__uint128_t u;
+ __int128_t i;
+ Int128 s;
} Int128Alias __attribute__((transparent_union));
#else
typedef Int128 Int128Alias;