Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KausV-00046H-Q8 for qemu-devel@nongnu.org; Wed, 03 Sep 2008 12:06:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KausU-00045a-5u for qemu-devel@nongnu.org; Wed, 03 Sep 2008 12:06:42 -0400 Received: from [199.232.76.173] (port=56672 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KausT-00045S-TU for qemu-devel@nongnu.org; Wed, 03 Sep 2008 12:06:42 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:49513) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KausT-00024y-5T for qemu-devel@nongnu.org; Wed, 03 Sep 2008 12:06:41 -0400 Message-Id: <76B499BF-91D0-4DED-959C-EC0E652BC50D@web.de> From: =?ISO-8859-1?Q?Andreas_F=E4rber?= In-Reply-To: <9997B5FA-0A81-45DB-A19C-C878D909D7F4@web.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Apple Message framework v926) Subject: Re: [Qemu-devel] [PATCH 5/x] ppc: Convert op_load_gpr_{T0, T1, T2} to TCG Date: Wed, 3 Sep 2008 18:04:00 +0200 References: <1F0A98C0-A1DE-4548-8A4D-9E15EDC72686@web.de> <5CA2F35D-6016-4FE5-8289-EB8758A2D3A4@web.de> <5FBA68BE-2F96-41D9-B032-BCA4A96557A7@web.de> <16A6085C-BD53-4AB5-8E39-0CA993CE12FF@web.de> <8E69B597-ADAC-4E4B-A675-45FEDDAF65BF@web.de> <20080902232051.GS4681@volta.aurel32.net> <20080903050757.GX4681@volta.aurel32.net> <20080903124139.GA9674@hall.aurel32.net> <9997B5FA-0A81-45DB-A19C-C878D909D7F4@web.de> Sender: andreas.faerber@web.de 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?= Am 03.09.2008 um 14:58 schrieb Andreas F=E4rber: > Am 03.09.2008 um 14:41 schrieb Aur=E9lien Jarno: > >> This optimization has been done with dyngen in mind, we surely don't >> want to keep it with TCG. >> >> I currently have plenty of time, but almost no network =20 >> (travelling), so >> I'll work on implementing a solution, and commit the result most =20 >> probably >> tomorrow morning. > > I already have a solution cooking for cpu_T64 and SPE, including =20 > improved TCGv setup. It'll be no problem for me to incorporate your =20= > and Thiemo's comments in my revised patch. Here's a draft of what I've come up with so far: - Based on your comments, make the GPRs always 32-bit for ppc and 64-=20 bit for ppc64. - Introduce cpu_T64[0..2], for ppc. (required a change in cpu.h for 64-=20= bit host) - Introduce cpu_gprh[0..31] in addition to cpu_gpr[0..31], for ppc only. - Use sprintf for cpu_gpr, cpu_gprh names. diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 834c08d..c7291ed 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -33,17 +33,7 @@ typedef uint64_t ppc_gpr_t; #else /* defined (TARGET_PPC64) */ /* PowerPC 32 definitions */ -#if (HOST_LONG_BITS >=3D 64) -/* When using 64 bits temporary registers, - * we can use 64 bits GPR with no extra cost - * It's even an optimization as this will prevent - * the compiler to do unuseful masking in the micro-ops. - */ -typedef uint64_t ppc_gpr_t; -#else /* (HOST_LONG_BITS >=3D 64) */ typedef uint32_t ppc_gpr_t; -#endif /* (HOST_LONG_BITS >=3D 64) */ - #define TARGET_LONG_BITS 32 #if defined(TARGET_PPCEMB) @@ -541,7 +531,7 @@ struct CPUPPCState { /* First are the most commonly used resources * during translated code execution */ -#if (HOST_LONG_BITS =3D=3D 32) +#if (TARGET_LONG_BITS > HOST_LONG_BITS) || !defined(TARGET_PPC64) /* temporary fixed-point registers * used to emulate 64 bits registers on 32 bits hosts */ diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 9068936..c8ecfe2 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -44,15 +44,37 @@ /=20 = **************************************************************************= ***/ /* Code translation =20 helpers */ -static TCGv cpu_env, cpu_T[3]; +/* global register indexes */ +static TCGv cpu_env; +static char cpu_reg_names[10*3 + 22*4 +#if !defined(TARGET_PPC64) + + 10*4 + 22*5 +#endif +]; +static TCGv cpu_gpr[32]; +#if !defined(TARGET_PPC64) +static TCGv cpu_gprh[32]; +#endif + +/* dyngen register indexes */ +static TCGv cpu_T[3]; +#if defined(TARGET_PPC64) +#define cpu_T64 cpu_T +#else +static TCGv cpu_T64[3]; +#endif #include "gen-icount.h" void ppc_translate_init(void) { + int i; + char* p; static int done_init =3D 0; + if (done_init) return; + cpu_env =3D tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env"); #if TARGET_LONG_BITS > HOST_LONG_BITS cpu_T[0] =3D tcg_global_mem_new(TCG_TYPE_TL, @@ -66,6 +88,31 @@ void ppc_translate_init(void) cpu_T[1] =3D tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG2, "T1"); cpu_T[2] =3D tcg_global_reg_new(TCG_TYPE_TL, TCG_AREG3, "T2"); #endif +#if !defined(TARGET_PPC64) + cpu_T64[0] =3D tcg_global_mem_new(TCG_TYPE_I64, + TCG_AREG0, offsetof(CPUState, t0), + "T0_64"); + cpu_T64[1] =3D tcg_global_mem_new(TCG_TYPE_I64, + TCG_AREG0, offsetof(CPUState, t1), + "T1_64"); + cpu_T64[2] =3D tcg_global_mem_new(TCG_TYPE_I64, + TCG_AREG0, offsetof(CPUState, t2), + "T2_64"); +#endif + + p =3D cpu_reg_names; + for (i =3D 0; i < 32; i++) { + sprintf(p, "r%d", i); + cpu_gpr[i] =3D tcg_global_mem_new(TCG_TYPE_TL, + TCG_AREG0, offsetof(CPUState, gpr[i]), p); + p +=3D (i < 10) ? 3 : 4; +#if !defined(TARGET_PPC64) + sprintf(p, "r%dH", i); + cpu_gprh[i] =3D tcg_global_mem_new(TCG_TYPE_I32, + TCG_AREG0, offsetof(CPUState, gprh[i]), p); + p +=3D (i < 10) ? 4 : 5; +#endif + } /* register helpers */ #undef DEF_HELPER > SPE will be rarely used anyway I guess, so I think it's relatively =20 > "safe" for me to remove the dyngen optimization and simplify =20 > ppc_gpr_t during this transition. What I meant was that the ppc_gpr_t change still lets ppc-softmmu and =20= ppc-linux-user compile, and to my understanding none of these use SPE =20= by default at runtime. I did not want to comment on whether they are fully implemented in =20 QEMU or widely used in external code somewhere. As long as SPE compiles and isn't irrevocably damaged, we're good I =20 think. We'll have to go through and remove the cpu_T stuff later and =20 can optimize SPE with, e.g., local i64 temporaries then. Andreas