From patchwork Wed Nov 23 13:01:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 698258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tP38J3DXfz9sCZ for ; Thu, 24 Nov 2016 00:29:04 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="yICkXtH9"; dkim-atps=neutral Received: from localhost ([::1]:33780 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Xbi-0003kQ-Am for incoming@patchwork.ozlabs.org; Wed, 23 Nov 2016 08:29:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9XD0-0007eH-EK for qemu-devel@nongnu.org; Wed, 23 Nov 2016 08:03:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9XCq-0004cT-8Q for qemu-devel@nongnu.org; Wed, 23 Nov 2016 08:03:26 -0500 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:34766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c9XCq-0004cL-20 for qemu-devel@nongnu.org; Wed, 23 Nov 2016 08:03:20 -0500 Received: by mail-oi0-x241.google.com with SMTP id m75so920212oig.1 for ; Wed, 23 Nov 2016 05:03:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=X9wp3BPHpx6FGgF8Jf71umA3LRITuHfNj/f5zTjINi4=; b=yICkXtH9Fjng8hiurnmxPhyg0DZJvuZ9rykePIZj7pv/ouo9qeVb7ZQFJGmUOHhJTn eUekMHpG0Dr3AnHUZcdogA7M3nlcYeQq6G1LvjTowZtBEYoWWuCF9C/mBUHv3QKxnlee keeDIgcIJMd25kJIF8+lQpwQL7pihnVFiFTOJ/tzfgy6i4/4bqa5Bp+JvPVKiQzgnv2y XxnlfOqXVPdwesxBDcPESiEU6SiGyetDWfwpbRwHywQr0LleQUhO+sSZa+BR1W8ZDlIA fayFQFbMKhwyy2658H3eTDNC5YkyuDlJ/Pj6FhxycyAe6VQbK92sD3hKx/0bj/6vOkjf a7YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=X9wp3BPHpx6FGgF8Jf71umA3LRITuHfNj/f5zTjINi4=; b=LwAStU7wgWC8/AeXhFFV8cEz0v6Go8L2tthHbzALtOBhEIC93YPmDHCXUl+sc2Kvra 2cQDoamt1b8o/Vlisrow/5P5fQrZpu2cFHtPI5dh1gJhHJPbyh1k0iOc81JjQpiRzcxb cwM4HAxQSIjMM1jsTzQd/VkLl9TLHFu9KTn3VLS4f0NdS5EpvrRHYSEYyqgNyvha0sI7 5N6ZIha84QwFl/b+WiLXcC53hht6fut2vhuyir5Cyg/U8xC9/FoJYMIG2TvEEmoljnsA qZWk4HO/x16DR1WJNx+PU4XL0NJ5PBhNG8GaARjsMr9X1jNUTcluqBEsYjrXFMhb3dD+ Cglg== X-Gm-Message-State: AKaTC006Wz2bgGCYQuhpmIidD+aqdnoWmXaqt39VTptLkzBS/QhXRI1QkYS36t00hrj67w== X-Received: by 10.157.56.36 with SMTP id i33mr1747577otc.253.1479906199398; Wed, 23 Nov 2016 05:03:19 -0800 (PST) Received: from bigtime.twiddle.net.twiddle.net ([172.56.6.66]) by smtp.gmail.com with ESMTPSA id t184sm10260000oie.21.2016.11.23.05.03.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Nov 2016 05:03:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 23 Nov 2016 14:01:17 +0100 Message-Id: <1479906121-12211-21-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479906121-12211-1-git-send-email-rth@twiddle.net> References: <1479906121-12211-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH v4 20/64] tcg: Add markup for output requires new register X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alex.bennee@linaro.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is the same concept as, and same markup as, the early clobber markup in gcc. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- tcg/tcg.c | 34 ++++++++++++++++++++++------------ tcg/tcg.h | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index aabf94f..27913f0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1263,6 +1263,10 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs) if (*ct_str == '\0') break; switch(*ct_str) { + case '&': + def->args_ct[i].ct |= TCG_CT_NEWREG; + ct_str++; + break; case 'i': def->args_ct[i].ct |= TCG_CT_CONST; ct_str++; @@ -2208,7 +2212,8 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOpDef *def, TCGOpcode opc, const TCGArg *args, TCGLifeData arg_life) { - TCGRegSet allocated_regs; + TCGRegSet i_allocated_regs; + TCGRegSet o_allocated_regs; int i, k, nb_iargs, nb_oargs; TCGReg reg; TCGArg arg; @@ -2225,8 +2230,10 @@ static void tcg_reg_alloc_op(TCGContext *s, args + nb_oargs + nb_iargs, sizeof(TCGArg) * def->nb_cargs); + tcg_regset_set(i_allocated_regs, s->reserved_regs); + tcg_regset_set(o_allocated_regs, s->reserved_regs); + /* satisfy input constraints */ - tcg_regset_set(allocated_regs, s->reserved_regs); for(k = 0; k < nb_iargs; k++) { i = def->sorted_args[nb_oargs + k]; arg = args[i]; @@ -2241,7 +2248,7 @@ static void tcg_reg_alloc_op(TCGContext *s, goto iarg_end; } - temp_load(s, ts, arg_ct->u.regs, allocated_regs); + temp_load(s, ts, arg_ct->u.regs, i_allocated_regs); if (arg_ct->ct & TCG_CT_IALIAS) { if (ts->fixed_reg) { @@ -2275,13 +2282,13 @@ static void tcg_reg_alloc_op(TCGContext *s, allocate_in_reg: /* allocate a new register matching the constraint and move the temporary register into it */ - reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs, + reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, ts->indirect_base); tcg_out_mov(s, ts->type, reg, ts->reg); } new_args[i] = reg; const_args[i] = 0; - tcg_regset_set_reg(allocated_regs, reg); + tcg_regset_set_reg(i_allocated_regs, reg); iarg_end: ; } @@ -2293,24 +2300,23 @@ static void tcg_reg_alloc_op(TCGContext *s, } if (def->flags & TCG_OPF_BB_END) { - tcg_reg_alloc_bb_end(s, allocated_regs); + tcg_reg_alloc_bb_end(s, i_allocated_regs); } else { if (def->flags & TCG_OPF_CALL_CLOBBER) { /* XXX: permit generic clobber register list ? */ for (i = 0; i < TCG_TARGET_NB_REGS; i++) { if (tcg_regset_test_reg(tcg_target_call_clobber_regs, i)) { - tcg_reg_free(s, i, allocated_regs); + tcg_reg_free(s, i, i_allocated_regs); } } } if (def->flags & TCG_OPF_SIDE_EFFECTS) { /* sync globals if the op has side effects and might trigger an exception. */ - sync_globals(s, allocated_regs); + sync_globals(s, i_allocated_regs); } /* satisfy the output constraints */ - tcg_regset_set(allocated_regs, s->reserved_regs); for(k = 0; k < nb_oargs; k++) { i = def->sorted_args[k]; arg = args[i]; @@ -2318,6 +2324,10 @@ static void tcg_reg_alloc_op(TCGContext *s, ts = &s->temps[arg]; if (arg_ct->ct & TCG_CT_ALIAS) { reg = new_args[arg_ct->alias_index]; + } else if (arg_ct->ct & TCG_CT_NEWREG) { + reg = tcg_reg_alloc(s, arg_ct->u.regs, + i_allocated_regs | o_allocated_regs, + ts->indirect_base); } else { /* if fixed register, we try to use it */ reg = ts->reg; @@ -2325,10 +2335,10 @@ static void tcg_reg_alloc_op(TCGContext *s, tcg_regset_test_reg(arg_ct->u.regs, reg)) { goto oarg_end; } - reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs, + reg = tcg_reg_alloc(s, arg_ct->u.regs, o_allocated_regs, ts->indirect_base); } - tcg_regset_set_reg(allocated_regs, reg); + tcg_regset_set_reg(o_allocated_regs, reg); /* if a fixed register is used, then a move will be done afterwards */ if (!ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) { @@ -2357,7 +2367,7 @@ static void tcg_reg_alloc_op(TCGContext *s, tcg_out_mov(s, ts->type, ts->reg, reg); } if (NEED_SYNC_ARG(i)) { - temp_sync(s, ts, allocated_regs, IS_DEAD_ARG(i)); + temp_sync(s, ts, o_allocated_regs, IS_DEAD_ARG(i)); } else if (IS_DEAD_ARG(i)) { temp_dead(s, ts); } diff --git a/tcg/tcg.h b/tcg/tcg.h index 5fd3733..ebfcefd 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -851,6 +851,7 @@ void tcg_dump_op_count(FILE *f, fprintf_function cpu_fprintf); #define TCG_CT_ALIAS 0x80 #define TCG_CT_IALIAS 0x40 +#define TCG_CT_NEWREG 0x20 /* output requires a new register */ #define TCG_CT_REG 0x01 #define TCG_CT_CONST 0x02 /* any constant of register size */