TCI/TCG patches
The following changes since commit f828a4c8faa118e0ebab3e353ac6840f3b2a0318:
Merge remote-tracking branch 'stefanha/tracing' into staging (2013-09-23 11:53:22 -0500)
are available in the git repository at:
git://qemu.weilnetz.de/qemu.git tci
for you to fetch changes up to 3df2b8fde949be86d8a78923c992fdd698d4ea4c:
misc: Use new rotate functions (2013-09-25 21:23:05 +0200)
----------------------------------------------------------------
Stefan Weil (3):
tci: Add implementation of rotl_i64, rotr_i64
bitops: Add rotate functions (rol8, ror8, ...)
misc: Use new rotate functions
include/qemu/bitops.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ target-arm/iwmmxt_helper.c | 2 +- tcg/optimize.c | 12 ++++-------- tcg/tci/tcg-target.c | 1 - tci.c | 14 +++++++++++--- 5 files changed, 96 insertions(+), 13 deletions(-)
[PULL 1/3] tci: Add implementation of rotl_i64, rotr_i64 [PULL 2/3] bitops: Add rotate functions (rol8, ror8, ...) [PULL 3/3] misc: Use new rotate functions
[Qemu-devel] [PULL 2/3] bitops: Add rotate functions (rol8, ror8, ...)
These functions were copies from include/linux/bitopts.h.
--- include/qemu/bitops.h | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+)
include/qemu/bitops.h +80 -0
@@ -184,6 +184,86 @@ static inline unsigned long hweight_long(unsigned long w) }/** +* rol8 - rotate an 8-bit value left +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint8_t rol8 (uint8_t word,unsigned int shift) +{ +return (word << shift) | (word >> (8 - shift)); +} + +/** +* ror8 - rotate an 8-bit value right +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint8_t ror8 (uint8_t word,unsigned int shift) +{ +return (word >> shift) | (word << (8 - shift)); +} + +/** +* rol16 - rotate a 16-bit value left +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint16_t rol16 (uint16_t word,unsigned int shift) +{ +return (word << shift) | (word >> (16 - shift)); +} + +/** +* ror16 - rotate a 16-bit value right +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint16_t ror16 (uint16_t word,unsigned int shift) +{ +return (word >> shift) | (word << (16 - shift)); +} + +/** +* rol32 - rotate a 32-bit value left +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint32_t rol32 (uint32_t word,unsigned int shift) +{ +return (word << shift) | (word >> (32 - shift)); +} + +/** +* ror32 - rotate a 32-bit value right +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint32_t ror32 (uint32_t word,unsigned int shift) +{ +return (word >> shift) | (word << (32 - shift)); +} + +/** +* rol64 - rotate a 64-bit value left +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint64_t rol64 (uint64_t word,unsigned int shift) +{ +return (word << shift) | (word >> (64 - shift)); +} + +/** +* ror64 - rotate a 64-bit value right +* @word: value to rotate +* @shift: bits to roll +*/ +static inline uint64_t ror64 (uint64_t word,unsigned int shift) +{ +return (word >> shift) | (word << (64 - shift)); +} + +/** * extract32: * @value: the value to extract the bit field from * @start: the lowest bit in the bit field (numbered from 0)
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 3/3] misc: Use new rotate functions
In reply to Stefan WeilReviewed by: Richard Henderson <[email protected]>
--- target-arm/iwmmxt_helper.c | 2 +- tcg/optimize.c | 12 ++++-------- tci.c | 8 ++++---- 3 files changed, 9 insertions(+), 13 deletions(-)
target-arm/iwmmxt_helper.c +1 -1
@@ -577,7 +577,7 @@ uint64_t HELPER(iwmmxt_rorl)(CPUARMState *env, uint64_t x, uint32_t n)uint64_t HELPER (iwmmxt_rorq )(CPUARMState *env,uint64_t x,uint32_t n) { - x = (x >> n) | (x << (64 - n)); + x =ror64 (x, n); env->iwmmxt.cregs[ARM_IWMMXT_wCASF] =NZBIT64 (x);return x; }
tcg/optimize.c +4 -8
@@ -238,20 +238,16 @@ static TCGArg do_constant_folding_2(TCGOpcode op, TCGArg x, TCGArg y)return (int64_t )x >> (int64_t )y;case INDEX_op_rotr_i32: - x = ((uint32_t )x << (32 - y)) | ((uint32_t )x >> y); -return x; +return ror32 (x, y);case INDEX_op_rotr_i64: - x = ((uint64_t )x << (64 - y)) | ((uint64_t )x >> y); -return x; +return ror64 (x, y);case INDEX_op_rotl_i32: - x = ((uint32_t )x << y) | ((uint32_t )x >> (32 - y)); -return x; +return rol32 (x, y);case INDEX_op_rotl_i64: - x = ((uint64_t )x << y) | ((uint64_t )x >> (64 - y)); -return x; +return rol64 (x, y); CASE_OP_32_64(not):return ~x;
tci.c +4 -4
@@ -688,13 +688,13 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr) t0 = *tb_ptr++; t1 =tci_read_ri32 (&tb_ptr); t2 =tci_read_ri32 (&tb_ptr); -tci_write_reg32 (t0, (t1 << t2) | (t1 >> (32 - t2))); +tci_write_reg32 (t0,rol32 (t1, t2));break ;case INDEX_op_rotr_i32: t0 = *tb_ptr++; t1 =tci_read_ri32 (&tb_ptr); t2 =tci_read_ri32 (&tb_ptr); -tci_write_reg32 (t0, (t1 >> t2) | (t1 << (32 - t2))); +tci_write_reg32 (t0,ror32 (t1, t2));break ;#endif #if TCG_TARGET_HAS_deposit_i32
@@ -955,13 +955,13 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr) t0 = *tb_ptr++; t1 =tci_read_ri64 (&tb_ptr); t2 =tci_read_ri64 (&tb_ptr); -tci_write_reg64 (t0, (t1 << t2) | (t1 >> (64 - t2))); +tci_write_reg64 (t0,rol64 (t1, t2));break ;case INDEX_op_rotr_i64: t0 = *tb_ptr++; t1 =tci_read_ri64 (&tb_ptr); t2 =tci_read_ri64 (&tb_ptr); -tci_write_reg64 (t0, (t1 >> t2) | (t1 << (64 - t2))); +tci_write_reg64 (t0,ror64 (t1, t2));break ;#endif #if TCG_TARGET_HAS_deposit_i64
Signature · 1 line
1.7.10.4
[Qemu-devel] [PULL 1/3] tci: Add implementation of rotl_i64, rotr_i64
In reply to Stefan WeilIt is used by qemu-ppc64 when running Debian's busybox-static.
--- tcg/tci/tcg-target.c | 1 - tci.c | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
tcg/tci/tcg-target.c +0 -1
@@ -670,7 +670,6 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,case INDEX_op_shl_i64:case INDEX_op_shr_i64:case INDEX_op_sar_i64: -/* TODO: Implementation of rotl_i64, rotr_i64 missing in tci.c. */ case INDEX_op_rotl_i64:/* Optional (TCG_TARGET_HAS_rot_i64). */ case INDEX_op_rotr_i64:/* Optional (TCG_TARGET_HAS_rot_i64). */ tcg_out_r (s, args[0 ]);
tci.c +9 -1
@@ -952,8 +952,16 @@ uintptr_t tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)break ;#if TCG_TARGET_HAS_rot_i64case INDEX_op_rotl_i64: + t0 = *tb_ptr++; + t1 =tci_read_ri64 (&tb_ptr); + t2 =tci_read_ri64 (&tb_ptr); +tci_write_reg64 (t0, (t1 << t2) | (t1 >> (64 - t2))); +break ;case INDEX_op_rotr_i64: -TODO (); + t0 = *tb_ptr++; + t1 =tci_read_ri64 (&tb_ptr); + t2 =tci_read_ri64 (&tb_ptr); +tci_write_reg64 (t0, (t1 >> t2) | (t1 << (64 - t2)));break ;#endif #if TCG_TARGET_HAS_deposit_i64
Signature · 1 line
1.7.10.4