From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiTei-0007sd-N1 for qemu-devel@nongnu.org; Fri, 31 May 2013 14:02:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiTed-0003Mb-Mz for qemu-devel@nongnu.org; Fri, 31 May 2013 14:02:24 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:35353) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiTed-0003MD-Dt for qemu-devel@nongnu.org; Fri, 31 May 2013 14:02:19 -0400 Message-ID: <51A8E597.4040608@huawei.com> Date: Fri, 31 May 2013 20:01:59 +0200 From: Jani Kokkonen MIME-Version: 1.0 References: <51A8E339.5000500@huawei.com> In-Reply-To: <51A8E339.5000500@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/4] tcg/aarch64: implement byte swap operations List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Laurent Desnogues , Claudio Fontana , qemu-devel@nongnu.org, Richard Henderson From: Claudio Fontana implement the optional byte swap operations with the dedicated aarch64 instructions. These instructions are also needed for the tlb lookup. Signed-off-by: Claudio Fontana --- tcg/aarch64/tcg-target.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tcg/aarch64/tcg-target.h | 10 +++++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c index 1343d49..716c987 100644 --- a/tcg/aarch64/tcg-target.c +++ b/tcg/aarch64/tcg-target.c @@ -658,6 +658,27 @@ static inline void tcg_out_goto_label_cond(TCGContext *s, } } +static inline void tcg_out_rev(TCGContext *s, int ext, TCGReg rd, TCGReg rm) +{ + /* using REV 0x5ac00800 */ + unsigned int base = ext ? 0xdac00c00 : 0x5ac00800; + tcg_out32(s, base | rm << 5 | rd); +} + +static inline void tcg_out_rev16(TCGContext *s, int ext, TCGReg rd, TCGReg rm) +{ + /* using REV16 0x5ac00400 */ + unsigned int base = ext ? 0xdac00400 : 0x5ac00400; + tcg_out32(s, base | rm << 5 | rd); +} + +static inline void tcg_out_rev32(TCGContext *s, TCGReg rd, TCGReg rm) +{ + /* using REV32 0xdac00800 */ + unsigned int base = 0xdac00800; + tcg_out32(s, base | rm << 5 | rd); +} + #ifdef CONFIG_SOFTMMU #include "exec/softmmu_defs.h" @@ -1010,6 +1031,20 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, tcg_out_qemu_st(s, args, 3); break; + case INDEX_op_bswap64_i64: + ext = 1; /* fall through */ + case INDEX_op_bswap32_i32: + tcg_out_rev(s, ext, args[0], args[1]); + break; + case INDEX_op_bswap16_i64: + ext = 1; /* fall through */ + case INDEX_op_bswap16_i32: + tcg_out_rev16(s, ext, args[0], args[1]); + break; + case INDEX_op_bswap32_i64: + tcg_out_rev32(s, args[0], args[1]); + break; + default: tcg_abort(); /* opcode not implemented */ } @@ -1091,6 +1126,13 @@ static const TCGTargetOpDef aarch64_op_defs[] = { { INDEX_op_qemu_st16, { "l", "l" } }, { INDEX_op_qemu_st32, { "l", "l" } }, { INDEX_op_qemu_st64, { "l", "l" } }, + + { INDEX_op_bswap16_i32, { "r", "r" } }, + { INDEX_op_bswap32_i32, { "r", "r" } }, + { INDEX_op_bswap16_i64, { "r", "r" } }, + { INDEX_op_bswap32_i64, { "r", "r" } }, + { INDEX_op_bswap64_i64, { "r", "r" } }, + { -1 }, }; diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 075ab2a..247ef43 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -44,8 +44,8 @@ typedef enum { #define TCG_TARGET_HAS_ext16s_i32 0 #define TCG_TARGET_HAS_ext8u_i32 0 #define TCG_TARGET_HAS_ext16u_i32 0 -#define TCG_TARGET_HAS_bswap16_i32 0 -#define TCG_TARGET_HAS_bswap32_i32 0 +#define TCG_TARGET_HAS_bswap16_i32 1 +#define TCG_TARGET_HAS_bswap32_i32 1 #define TCG_TARGET_HAS_not_i32 0 #define TCG_TARGET_HAS_neg_i32 0 #define TCG_TARGET_HAS_rot_i32 1 @@ -68,9 +68,9 @@ typedef enum { #define TCG_TARGET_HAS_ext8u_i64 0 #define TCG_TARGET_HAS_ext16u_i64 0 #define TCG_TARGET_HAS_ext32u_i64 0 -#define TCG_TARGET_HAS_bswap16_i64 0 -#define TCG_TARGET_HAS_bswap32_i64 0 -#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_bswap16_i64 1 +#define TCG_TARGET_HAS_bswap32_i64 1 +#define TCG_TARGET_HAS_bswap64_i64 1 #define TCG_TARGET_HAS_not_i64 0 #define TCG_TARGET_HAS_neg_i64 0 #define TCG_TARGET_HAS_rot_i64 1 -- 1.8.1