Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L6Qv1-0006st-TQ for qemu-devel@nongnu.org; Sat, 29 Nov 2008 09:35:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L6Qv0-0006sh-Dm for qemu-devel@nongnu.org; Sat, 29 Nov 2008 09:35:34 -0500 Received: from [199.232.76.173] (port=58259 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L6Qv0-0006se-8a for qemu-devel@nongnu.org; Sat, 29 Nov 2008 09:35:34 -0500 Received: from fmmailgate02.web.de ([217.72.192.227]:40562) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L6Quz-0006u5-E7 for qemu-devel@nongnu.org; Sat, 29 Nov 2008 09:35:34 -0500 Message-Id: <6044C5AC-C1B7-42AF-80F0-2254392A9F37@web.de> From: =?ISO-8859-1?Q?Andreas_F=E4rber?= Content-Type: multipart/mixed; boundary=Apple-Mail-18-554018718 Mime-Version: 1.0 (Apple Message framework v929.2) Date: Sat, 29 Nov 2008 15:35:21 +0100 Sender: andreas.faerber@web.de Subject: [Qemu-devel] [PATCH] ppc: Convert op_440_dlmzb to TCG 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 Cc: =?ISO-8859-1?Q?Aur=E9lien_Jarno?= --Apple-Mail-18-554018718 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Replace {op,do}_440_dlmzb and op_440_dlmzb_update_Rc with inline TCG instructions. The two loops of do_440_dlmzb are unrolled. Signed-off-by: Andreas Faerber --- Compile-tested on Linux/amd64. diff --git a/target-ppc/op.c b/target-ppc/op.c index 5d2cfa1..a26b1da 100644 --- a/target-ppc/op.c +++ b/target-ppc/op.c @@ -839,25 +839,6 @@ void OPPROTO op_4xx_tlbwe_hi (void) } #endif -/* SPR micro-ops */ -/* 440 specific */ -void OPPROTO op_440_dlmzb (void) -{ - do_440_dlmzb(); - RETURN(); -} - -void OPPROTO op_440_dlmzb_update_Rc (void) -{ - if (T0 == 8) - T0 = 0x2; - else if (T0 < 4) - T0 = 0x4; - else - T0 = 0x8; - RETURN(); -} - #if !defined(CONFIG_USER_ONLY) void OPPROTO op_store_pir (void) { diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index 6addc74..a055ee6 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -1754,27 +1754,6 @@ void do_store_403_pb (int num) } #endif -/* 440 specific */ -void do_440_dlmzb (void) -{ - target_ulong mask; - int i; - - i = 1; - for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { - if ((T0 & mask) == 0) - goto done; - i++; - } - for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { - if ((T1 & mask) == 0) - break; - i++; - } - done: - T0 = i; -} - / *****************************************************************************/ /* SPE extension helpers */ /* Use a table to make this quicker */ diff --git a/target-ppc/op_helper.h b/target-ppc/op_helper.h index 1c046d8..aaaba5c 100644 --- a/target-ppc/op_helper.h +++ b/target-ppc/op_helper.h @@ -112,9 +112,6 @@ void do_4xx_tlbwe_lo (void); void do_4xx_tlbwe_hi (void); #endif -/* PowerPC 440 specific helpers */ -void do_440_dlmzb (void); - /* PowerPC 403 specific helpers */ #if !defined(CONFIG_USER_ONLY) void do_load_403_pb (int num); diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 95cb482..59533ac 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -5872,12 +5872,49 @@ GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC) { tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]); tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); - gen_op_440_dlmzb(); + TCGv t0 = tcg_temp_new(); + int endLabel = gen_new_label(); + int i = 1; + target_ulong mask; + for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { + tcg_gen_andi_tl(t0, cpu_T[0], mask); + int nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, nextLabel); + tcg_gen_movi_tl(cpu_T[0], i++); + tcg_gen_br(endLabel); + gen_set_label(nextLabel); + } + for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { + tcg_gen_andi_tl(t0, cpu_T[1], mask); + int nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, nextLabel); + tcg_gen_movi_tl(cpu_T[0], i++); + tcg_gen_br(endLabel); + gen_set_label(nextLabel); + } + tcg_gen_movi_tl(cpu_T[0], i); + gen_set_label(endLabel); + tcg_temp_free(t0); tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); tcg_gen_andi_tl(cpu_xer, cpu_xer, ~0x7F); tcg_gen_or_tl(cpu_xer, cpu_xer, cpu_T[0]); if (Rc(ctx->opcode)) { - gen_op_440_dlmzb_update_Rc(); + endLabel = gen_new_label(); + int nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, cpu_T[0], 8, nextLabel); + tcg_gen_movi_tl(cpu_T[0], 0x2); + tcg_gen_br(endLabel); + + gen_set_label(nextLabel); + nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_GE, cpu_T[0], 4, nextLabel); + tcg_gen_movi_tl(cpu_T[0], 0x4); + tcg_gen_br(endLabel); + + gen_set_label(nextLabel); + tcg_gen_movi_tl(cpu_T[0], 0x8); + + gen_set_label(endLabel); tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_T[0]); tcg_gen_andi_i32(cpu_crf[0], cpu_crf[0], 0xf); } --Apple-Mail-18-554018718 Content-Disposition: attachment; filename=op_440_dlmzb.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="op_440_dlmzb.diff" Content-Transfer-Encoding: 7bit diff --git a/target-ppc/op.c b/target-ppc/op.c index 5d2cfa1..a26b1da 100644 --- a/target-ppc/op.c +++ b/target-ppc/op.c @@ -839,25 +839,6 @@ void OPPROTO op_4xx_tlbwe_hi (void) } #endif -/* SPR micro-ops */ -/* 440 specific */ -void OPPROTO op_440_dlmzb (void) -{ - do_440_dlmzb(); - RETURN(); -} - -void OPPROTO op_440_dlmzb_update_Rc (void) -{ - if (T0 == 8) - T0 = 0x2; - else if (T0 < 4) - T0 = 0x4; - else - T0 = 0x8; - RETURN(); -} - #if !defined(CONFIG_USER_ONLY) void OPPROTO op_store_pir (void) { diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c index 6addc74..a055ee6 100644 --- a/target-ppc/op_helper.c +++ b/target-ppc/op_helper.c @@ -1754,27 +1754,6 @@ void do_store_403_pb (int num) } #endif -/* 440 specific */ -void do_440_dlmzb (void) -{ - target_ulong mask; - int i; - - i = 1; - for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { - if ((T0 & mask) == 0) - goto done; - i++; - } - for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { - if ((T1 & mask) == 0) - break; - i++; - } - done: - T0 = i; -} - /*****************************************************************************/ /* SPE extension helpers */ /* Use a table to make this quicker */ diff --git a/target-ppc/op_helper.h b/target-ppc/op_helper.h index 1c046d8..aaaba5c 100644 --- a/target-ppc/op_helper.h +++ b/target-ppc/op_helper.h @@ -112,9 +112,6 @@ void do_4xx_tlbwe_lo (void); void do_4xx_tlbwe_hi (void); #endif -/* PowerPC 440 specific helpers */ -void do_440_dlmzb (void); - /* PowerPC 403 specific helpers */ #if !defined(CONFIG_USER_ONLY) void do_load_403_pb (int num); diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 95cb482..59533ac 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -5872,12 +5872,49 @@ GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC) { tcg_gen_mov_tl(cpu_T[0], cpu_gpr[rS(ctx->opcode)]); tcg_gen_mov_tl(cpu_T[1], cpu_gpr[rB(ctx->opcode)]); - gen_op_440_dlmzb(); + TCGv t0 = tcg_temp_new(); + int endLabel = gen_new_label(); + int i = 1; + target_ulong mask; + for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { + tcg_gen_andi_tl(t0, cpu_T[0], mask); + int nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, nextLabel); + tcg_gen_movi_tl(cpu_T[0], i++); + tcg_gen_br(endLabel); + gen_set_label(nextLabel); + } + for (mask = 0xFF000000; mask != 0; mask = mask >> 8) { + tcg_gen_andi_tl(t0, cpu_T[1], mask); + int nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, nextLabel); + tcg_gen_movi_tl(cpu_T[0], i++); + tcg_gen_br(endLabel); + gen_set_label(nextLabel); + } + tcg_gen_movi_tl(cpu_T[0], i); + gen_set_label(endLabel); + tcg_temp_free(t0); tcg_gen_mov_tl(cpu_gpr[rA(ctx->opcode)], cpu_T[0]); tcg_gen_andi_tl(cpu_xer, cpu_xer, ~0x7F); tcg_gen_or_tl(cpu_xer, cpu_xer, cpu_T[0]); if (Rc(ctx->opcode)) { - gen_op_440_dlmzb_update_Rc(); + endLabel = gen_new_label(); + int nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_NE, cpu_T[0], 8, nextLabel); + tcg_gen_movi_tl(cpu_T[0], 0x2); + tcg_gen_br(endLabel); + + gen_set_label(nextLabel); + nextLabel = gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_GE, cpu_T[0], 4, nextLabel); + tcg_gen_movi_tl(cpu_T[0], 0x4); + tcg_gen_br(endLabel); + + gen_set_label(nextLabel); + tcg_gen_movi_tl(cpu_T[0], 0x8); + + gen_set_label(endLabel); tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_T[0]); tcg_gen_andi_i32(cpu_crf[0], cpu_crf[0], 0xf); } --Apple-Mail-18-554018718 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-18-554018718--