From patchwork Tue Apr 27 21:23:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Brady X-Patchwork-Id: 51108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 802DBB7D41 for ; Wed, 28 Apr 2010 07:26:46 +1000 (EST) Received: from localhost ([127.0.0.1]:45134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6sHX-0006R0-CE for incoming@patchwork.ozlabs.org; Tue, 27 Apr 2010 17:25:27 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6sG6-0006PY-7A for qemu-devel@nongnu.org; Tue, 27 Apr 2010 17:23:58 -0400 Received: from [140.186.70.92] (port=60077 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6sG4-0006OP-U9 for qemu-devel@nongnu.org; Tue, 27 Apr 2010 17:23:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6sG3-0003Y6-92 for qemu-devel@nongnu.org; Tue, 27 Apr 2010 17:23:56 -0400 Received: from c.painless.aaisp.net.uk ([81.187.30.53]:39293) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6sG3-0003W9-4e for qemu-devel@nongnu.org; Tue, 27 Apr 2010 17:23:55 -0400 Received: from zubnet.me.uk ([81.187.243.246] helo=circe) by c.painless.aaisp.net.uk with esmtp (Exim 4.69) (envelope-from ) id 1O6sFs-0003mF-6k for qemu-devel@nongnu.org; Tue, 27 Apr 2010 22:23:44 +0100 Received: by circe (Postfix, from userid 1000) id 0DE5A321D3D; Tue, 27 Apr 2010 22:23:36 +0100 (BST) Date: Tue, 27 Apr 2010 22:23:35 +0100 From: Stuart Brady To: qemu-devel@nongnu.org Message-ID: <20100427212335.GA6194@zubnet.me.uk> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH] Clean up definition of MAX_OPC_PARAM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org MAX_OPC_PARAM is intended to refer to the maximum number of entries used in gen_opparam_buf[] for any single helper call. It is currently defined as 10, but for 32-bit archs, the correct value (with a maximum for four helper arguments) is 14, and for 64-bit archs, only 9 entries are needed. tcg_gen_callN() fills four entries with the function address, flags, number of args, etc. and on 32-bit archs uses a further two entries per argument (with a maximum of four helper arguments), plus two more for the return value. On 64-bit archs, only half as many entries are used for the args and the return value. In reality, TBs tend not to consist purely of helper calls exceeding the stated 10 gen_opparam_buf[] entries, so this would never actually be a problem on 32-bit archs, but the definition is still rather confusing. Signed-off-by: Stuart Brady diff --git a/exec-all.h b/exec-all.h index 4bae1e2..1016de2 100644 --- a/exec-all.h +++ b/exec-all.h @@ -44,8 +44,20 @@ typedef struct TranslationBlock TranslationBlock; /* XXX: make safe guess about sizes */ #define MAX_OP_PER_INSTR 96 -/* A Call op needs up to 6 + 2N parameters (N = number of arguments). */ -#define MAX_OPC_PARAM 10 + +#if HOST_LONG_BITS == 32 +#define MAX_OPC_PARAM_PER_ARG 2 +#else +#define MAX_OPC_PARAM_PER_ARG 1 +#endif +#define MAX_OPC_PARAM_IARGS 4 +#define MAX_OPC_PARAM_OARGS 1 +#define MAX_OPC_PARAM_ARGS (MAX_OPC_PARAM_IARGS + MAX_OPC_PARAM_OARGS) + +/* A Call op needs up to 4 + 2N parameters on 32-bit archs, + * and up to 4 + N parameters on 64-bit archs + * (N = number of input arguments + output arguments). */ +#define MAX_OPC_PARAM (4 + (MAX_OPC_PARAM_PER_ARG * MAX_OPC_PARAM_ARGS)) #define OPC_BUF_SIZE 640 #define OPC_MAX_SIZE (OPC_BUF_SIZE - MAX_OP_PER_INSTR)