Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lgll6-0004qo-3n for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:07:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lgll2-0004jQ-D2 for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:07:29 -0400 Received: from [199.232.76.173] (port=35982 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lgll1-0004j0-Qe for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:07:27 -0400 Received: from mx20.gnu.org ([199.232.41.8]:2553) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lgll0-0006nk-QW for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:07:27 -0400 Received: from savannah.gnu.org ([199.232.41.3] helo=sv.gnu.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LgkaR-0002Mj-Om for qemu-devel@nongnu.org; Mon, 09 Mar 2009 14:52:27 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1LgkYv-0000xQ-Ki for qemu-devel@nongnu.org; Mon, 09 Mar 2009 18:50:53 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1LgkYv-0000xM-C6 for qemu-devel@nongnu.org; Mon, 09 Mar 2009 18:50:53 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Mon, 09 Mar 2009 18:50:53 +0000 Subject: [Qemu-devel] [6795] Implement TCG rotation ops for x86-64 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 6795 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6795 Author: aurel32 Date: 2009-03-09 18:50:53 +0000 (Mon, 09 Mar 2009) Log Message: ----------- Implement TCG rotation ops for x86-64 Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/tcg/tcg-op.h trunk/tcg/tcg-opc.h trunk/tcg/x86_64/tcg-target.c trunk/tcg/x86_64/tcg-target.h Modified: trunk/tcg/tcg-op.h =================================================================== --- trunk/tcg/tcg-op.h 2009-03-09 18:50:43 UTC (rev 6794) +++ trunk/tcg/tcg-op.h 2009-03-09 18:50:53 UTC (rev 6795) @@ -1573,6 +1573,9 @@ static inline void tcg_gen_rotl_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) { +#ifdef TCG_TARGET_HAS_rot_i32 + tcg_gen_op3_i32(INDEX_op_rotl_i32, ret, arg1, arg2); +#else TCGv_i32 t0, t1; t0 = tcg_temp_new_i32(); @@ -1583,10 +1586,14 @@ tcg_gen_or_i32(ret, t0, t1); tcg_temp_free_i32(t0); tcg_temp_free_i32(t1); +#endif } static inline void tcg_gen_rotl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) { +#ifdef TCG_TARGET_HAS_rot_i64 + tcg_gen_op3_i64(INDEX_op_rotl_i64, ret, arg1, arg2); +#else TCGv_i64 t0, t1; t0 = tcg_temp_new_i64(); @@ -1597,6 +1604,7 @@ tcg_gen_or_i64(ret, t0, t1); tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); +#endif } static inline void tcg_gen_rotli_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) @@ -1605,6 +1613,11 @@ if (arg2 == 0) { tcg_gen_mov_i32(ret, arg1); } else { +#ifdef TCG_TARGET_HAS_rot_i32 + TCGv_i32 t0 = tcg_const_i32(arg2); + tcg_gen_rotl_i32(ret, arg1, t0); + tcg_temp_free_i32(t0); +#else TCGv_i32 t0, t1; t0 = tcg_temp_new_i32(); t1 = tcg_temp_new_i32(); @@ -1613,6 +1626,7 @@ tcg_gen_or_i32(ret, t0, t1); tcg_temp_free_i32(t0); tcg_temp_free_i32(t1); +#endif } } @@ -1622,6 +1636,11 @@ if (arg2 == 0) { tcg_gen_mov_i64(ret, arg1); } else { +#ifdef TCG_TARGET_HAS_rot_i64 + TCGv_i64 t0 = tcg_const_i64(arg2); + tcg_gen_rotl_i64(ret, arg1, t0); + tcg_temp_free_i64(t0); +#else TCGv_i64 t0, t1; t0 = tcg_temp_new_i64(); t1 = tcg_temp_new_i64(); @@ -1630,11 +1649,15 @@ tcg_gen_or_i64(ret, t0, t1); tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); +#endif } } static inline void tcg_gen_rotr_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2) { +#ifdef TCG_TARGET_HAS_rot_i32 + tcg_gen_op3_i32(INDEX_op_rotr_i32, ret, arg1, arg2); +#else TCGv_i32 t0, t1; t0 = tcg_temp_new_i32(); @@ -1645,10 +1668,14 @@ tcg_gen_or_i32(ret, t0, t1); tcg_temp_free_i32(t0); tcg_temp_free_i32(t1); +#endif } static inline void tcg_gen_rotr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2) { +#ifdef TCG_TARGET_HAS_rot_i64 + tcg_gen_op3_i64(INDEX_op_rotr_i64, ret, arg1, arg2); +#else TCGv_i64 t0, t1; t0 = tcg_temp_new_i64(); @@ -1659,6 +1686,7 @@ tcg_gen_or_i64(ret, t0, t1); tcg_temp_free_i64(t0); tcg_temp_free_i64(t1); +#endif } static inline void tcg_gen_rotri_i32(TCGv_i32 ret, TCGv_i32 arg1, int32_t arg2) Modified: trunk/tcg/tcg-opc.h =================================================================== --- trunk/tcg/tcg-opc.h 2009-03-09 18:50:43 UTC (rev 6794) +++ trunk/tcg/tcg-opc.h 2009-03-09 18:50:53 UTC (rev 6795) @@ -67,10 +67,12 @@ DEF2(and_i32, 1, 2, 0, 0) DEF2(or_i32, 1, 2, 0, 0) DEF2(xor_i32, 1, 2, 0, 0) -/* shifts */ +/* shifts/rotates */ DEF2(shl_i32, 1, 2, 0, 0) DEF2(shr_i32, 1, 2, 0, 0) DEF2(sar_i32, 1, 2, 0, 0) +DEF2(rotl_i32, 1, 2, 0, 0) +DEF2(rotr_i32, 1, 2, 0, 0) DEF2(brcond_i32, 0, 2, 2, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) #if TCG_TARGET_REG_BITS == 32 @@ -120,10 +122,12 @@ DEF2(and_i64, 1, 2, 0, 0) DEF2(or_i64, 1, 2, 0, 0) DEF2(xor_i64, 1, 2, 0, 0) -/* shifts */ +/* shifts/rotates */ DEF2(shl_i64, 1, 2, 0, 0) DEF2(shr_i64, 1, 2, 0, 0) DEF2(sar_i64, 1, 2, 0, 0) +DEF2(rotl_i64, 1, 2, 0, 0) +DEF2(rotr_i64, 1, 2, 0, 0) DEF2(brcond_i64, 0, 2, 2, TCG_OPF_BB_END | TCG_OPF_SIDE_EFFECTS) #ifdef TCG_TARGET_HAS_ext8s_i64 Modified: trunk/tcg/x86_64/tcg-target.c =================================================================== --- trunk/tcg/x86_64/tcg-target.c 2009-03-09 18:50:43 UTC (rev 6794) +++ trunk/tcg/x86_64/tcg-target.c 2009-03-09 18:50:53 UTC (rev 6795) @@ -194,6 +194,8 @@ #define ARITH_XOR 6 #define ARITH_CMP 7 +#define SHIFT_ROL 0 +#define SHIFT_ROR 1 #define SHIFT_SHL 4 #define SHIFT_SHR 5 #define SHIFT_SAR 7 @@ -1049,7 +1051,13 @@ case INDEX_op_sar_i32: c = SHIFT_SAR; goto gen_shift32; - + case INDEX_op_rotl_i32: + c = SHIFT_ROL; + goto gen_shift32; + case INDEX_op_rotr_i32: + c = SHIFT_ROR; + goto gen_shift32; + case INDEX_op_shl_i64: c = SHIFT_SHL; gen_shift64: @@ -1070,7 +1078,13 @@ case INDEX_op_sar_i64: c = SHIFT_SAR; goto gen_shift64; - + case INDEX_op_rotl_i64: + c = SHIFT_ROL; + goto gen_shift64; + case INDEX_op_rotr_i64: + c = SHIFT_ROR; + goto gen_shift64; + case INDEX_op_brcond_i32: tcg_out_brcond(s, args[2], args[0], args[1], const_args[1], args[3], 0); @@ -1230,6 +1244,8 @@ { INDEX_op_shl_i32, { "r", "0", "ci" } }, { INDEX_op_shr_i32, { "r", "0", "ci" } }, { INDEX_op_sar_i32, { "r", "0", "ci" } }, + { INDEX_op_rotl_i32, { "r", "0", "ci" } }, + { INDEX_op_rotr_i32, { "r", "0", "ci" } }, { INDEX_op_brcond_i32, { "r", "ri" } }, @@ -1259,6 +1275,8 @@ { INDEX_op_shl_i64, { "r", "0", "ci" } }, { INDEX_op_shr_i64, { "r", "0", "ci" } }, { INDEX_op_sar_i64, { "r", "0", "ci" } }, + { INDEX_op_rotl_i64, { "r", "0", "ci" } }, + { INDEX_op_rotr_i64, { "r", "0", "ci" } }, { INDEX_op_brcond_i64, { "r", "re" } }, Modified: trunk/tcg/x86_64/tcg-target.h =================================================================== --- trunk/tcg/x86_64/tcg-target.h 2009-03-09 18:50:43 UTC (rev 6794) +++ trunk/tcg/x86_64/tcg-target.h 2009-03-09 18:50:53 UTC (rev 6795) @@ -65,6 +65,8 @@ #define TCG_TARGET_HAS_ext8s_i64 #define TCG_TARGET_HAS_ext16s_i64 #define TCG_TARGET_HAS_ext32s_i64 +#define TCG_TARGET_HAS_rot_i32 +#define TCG_TARGET_HAS_rot_i64 /* Note: must be synced with dyngen-exec.h */ #define TCG_AREG0 TCG_REG_R14