Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KM4ks-0000wx-4T for qemu-devel@nongnu.org; Thu, 24 Jul 2008 13:37:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KM4ko-0000uG-Ip for qemu-devel@nongnu.org; Thu, 24 Jul 2008 13:37:29 -0400 Received: from [199.232.76.173] (port=59504 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KM4ko-0000u1-8T for qemu-devel@nongnu.org; Thu, 24 Jul 2008 13:37:26 -0400 Received: from savannah.gnu.org ([199.232.41.3]:41396 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KM4kn-0007So-GE for qemu-devel@nongnu.org; Thu, 24 Jul 2008 13:37:26 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KM4kZ-0000OA-2u for qemu-devel@nongnu.org; Thu, 24 Jul 2008 17:37:11 +0000 Received: from malc by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KM4kY-0000O6-IY for qemu-devel@nongnu.org; Thu, 24 Jul 2008 17:37:10 +0000 MIME-Version: 1.0 Errors-To: malc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: malc Message-Id: Date: Thu, 24 Jul 2008 17:37:10 +0000 Subject: [Qemu-devel] [4939] Emit and use adhoc function descriptor for code_gen_prologue on PPC64 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: 4939 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4939 Author: malc Date: 2008-07-24 17:37:09 +0000 (Thu, 24 Jul 2008) Log Message: ----------- Emit and use adhoc function descriptor for code_gen_prologue on PPC64 Thus avoiding fragile inline assembly hackery to call into generated code. Modified Paths: -------------- trunk/tcg/ppc64/tcg-target.c trunk/tcg/tcg.h Modified: trunk/tcg/ppc64/tcg-target.c =================================================================== --- trunk/tcg/ppc64/tcg-target.c 2008-07-24 11:28:51 UTC (rev 4938) +++ trunk/tcg/ppc64/tcg-target.c 2008-07-24 17:37:09 UTC (rev 4939) @@ -773,6 +773,7 @@ void tcg_target_qemu_prologue (TCGContext *s) { int i, frame_size; + uint64_t addr; frame_size = 0 + 8 /* back chain */ @@ -786,6 +787,12 @@ ; frame_size = (frame_size + 15) & ~15; + /* First emit adhoc function descriptor */ + addr = (uint64_t) s->code_ptr + 24; + tcg_out32 (s, addr >> 32); tcg_out32 (s, addr); /* entry point */ + s->code_ptr += 16; /* skip TOC and environment pointer */ + + /* Prologue */ tcg_out32 (s, MFSPR | RT (0) | LR); tcg_out32 (s, STDU | RS (1) | RA (1) | (-frame_size & 0xffff)); for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) @@ -796,10 +803,11 @@ ) ); tcg_out32 (s, STD | RS (0) | RA (1) | (frame_size + 20)); - tcg_out32 (s, STD | RS (2) | RA (1) | (frame_size + 40)); tcg_out32 (s, MTSPR | RS (3) | CTR); tcg_out32 (s, BCCTR | BO_ALWAYS); + + /* Epilogue */ tb_ret_addr = s->code_ptr; for (i = 0; i < ARRAY_SIZE (tcg_target_callee_save_regs); ++i) @@ -810,7 +818,6 @@ ) ); tcg_out32 (s, LD | RT (0) | RA (1) | (frame_size + 20)); - tcg_out32 (s, LD | RT (2) | RA (1) | (frame_size + 40)); tcg_out32 (s, MTSPR | RS (0) | LR); tcg_out32 (s, ADDI | RT (1) | RA (1) | frame_size); tcg_out32 (s, BCLR | BO_ALWAYS); Modified: trunk/tcg/tcg.h =================================================================== --- trunk/tcg/tcg.h 2008-07-24 11:28:51 UTC (rev 4938) +++ trunk/tcg/tcg.h 2008-07-24 17:37:09 UTC (rev 4939) @@ -413,24 +413,9 @@ uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2); extern uint8_t code_gen_prologue[]; -#ifdef __powerpc__ -#ifdef __powerpc64__ -#define tcg_qemu_tb_exec(tb_ptr) \ - ({ unsigned long p; \ - asm volatile ( \ - "mtctr %1\n\t" \ - "mr 3,%2\n\t" \ - "bctrl\n\t" \ - "mr %0,3\n\t" \ - : "=r" (p) \ - : "r" (code_gen_prologue), "r" (tb_ptr) \ - : "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"); \ - p; \ - }) -#else +#if defined(__powerpc__) && !defined(__powerpc64__) #define tcg_qemu_tb_exec(tb_ptr) \ ((long REGPARM __attribute__ ((longcall)) (*)(void *))code_gen_prologue)(tb_ptr) -#endif #else #define tcg_qemu_tb_exec(tb_ptr) ((long REGPARM (*)(void *))code_gen_prologue)(tb_ptr) #endif