From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpI9L-0001fH-PD for qemu-devel@nongnu.org; Fri, 14 Nov 2014 09:47:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XpI9F-0008L2-Py for qemu-devel@nongnu.org; Fri, 14 Nov 2014 09:46:59 -0500 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:36200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XpI9F-0008Kw-II for qemu-devel@nongnu.org; Fri, 14 Nov 2014 09:46:53 -0500 Received: by mail-wi0-f179.google.com with SMTP id ex7so2934736wid.0 for ; Fri, 14 Nov 2014 06:46:52 -0800 (PST) Sender: Richard Henderson Message-ID: <546615D4.6010504@twiddle.net> Date: Fri, 14 Nov 2014 15:46:44 +0100 From: Richard Henderson MIME-Version: 1.0 References: <1415723092-4088-1-git-send-email-rth@twiddle.net> <1415723092-4088-8-git-send-email-rth@twiddle.net> <54661ECC.2010901@mail.uni-paderborn.de> In-Reply-To: <54661ECC.2010901@mail.uni-paderborn.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2.3 7/8] tcg: Implement insert_op_before List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bastian Koppelmann , qemu-devel@nongnu.org Cc: aurelien@aurel32.net On 11/14/2014 04:25 PM, Bastian Koppelmann wrote: > > On 11/11/2014 04:24 PM, Richard Henderson wrote: >> Rather reserving space in the op stream for optimization, >> let the optimizer add ops as necessary. >> >> Signed-off-by: Richard Henderson >> --- >> tcg/optimize.c | 57 +++++++++++++++++++++++++++++++++++---------------------- >> tcg/tcg-op.c | 16 ---------------- >> 2 files changed, 35 insertions(+), 38 deletions(-) >> >> diff --git a/tcg/optimize.c b/tcg/optimize.c >> index 973fbb4..067917c 100644 >> --- a/tcg/optimize.c >> +++ b/tcg/optimize.c >> @@ -67,6 +67,37 @@ static void reset_temp(TCGArg temp) >> temps[temp].mask = -1; >> } >> +static TCGOp *insert_op_before(TCGContext *s, TCGOp *old_op, >> + TCGOpcode opc, int nargs) >> +{ >> + int oi = s->gen_next_op_idx; >> + int pi = s->gen_next_parm_idx; >> + int prev = old_op->prev; >> + int next = old_op - s->gen_op_buf; >> + TCGOp *new_op; >> + >> + tcg_debug_assert(oi < OPC_BUF_SIZE); >> + tcg_debug_assert(pi + nargs <= OPPARAM_BUF_SIZE); > I thinks it is better to assure these assertion always hold, e.g. > > if (oi < OPC_BUF_SIZE || pi + nargs <= OPPARAM_BUF_SIZE) { > return NULL; > } > ... > TCGOp *op2 = insert_op_before(s, op, INDEX_op_movi_i32, 2); > if (op2) { > *args2 = &s->gen_opparam_buf[op2->args]; > } > > Or how do we know they always hold? For the same reason we don't bother checking during initial generation of the opcodes. We simply assume there's enough space. Not a good answer but... > All references on tcg_gen_op0 are gone, so lets remove it. Fair enough. r~