From patchwork Mon Oct 16 17:25:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115931 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3935910qgn; Mon, 16 Oct 2017 10:29:21 -0700 (PDT) X-Received: by 10.200.38.225 with SMTP id 30mr16358757qtp.334.1508174961593; Mon, 16 Oct 2017 10:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508174961; cv=none; d=google.com; s=arc-20160816; b=LkklHexSsE9JFQZrFZh12XWpaTGboKLck0pywaOwJh+kPJNvTofM1zIqr6kKqVY4sb ObBdcqn2ZVU1SIsccapKyykOIP+IRwAylCXujJDItJmdllzVMa5J3yQaoWNFs1Czzp08 goGireuex8nY1LNw0tBQAjHsYnxxE8sEYUTvZKag9WjbSiXfSUdQP8FtFDpNJrNodGWG YCE0ZteMVs4BbOvQQtKioCQB7jttYLHB8hzM+81og6Y+DEFB6u4cuo2fzuq8eSESkejm +dHH7ukEmq0X13c1xaYohFUeCluqF59j/Ax0qavbgijEUGtjd5vZxgCiUm0Wwy8P/oPz SNUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=mupzlOYUAuyNywOnggVbrrdzIC7T3+eQFkWsnwKDReo=; b=Q0QYYeGXpzaTWThNHjSiMr2Q2bmgAmOugEyy9Cy9tUW4ErLYDKIt/6tFuU7t5NS8g0 x2xewgcjhcWLxtYs/PY+DphIibo3LHxit+B8YaDnzyLwduFyKZl+hBYeDg9wJhcWt1J4 wdRicPZPFjfL9YWu+m3T6N/X/nC0ze6aDAAC7jxt+x96Af7Pbg2njzXs8oJZMst5Z7mi YnaDgdbe8ulRJZU1fzK4rkSnOBs9KBSIznhdGGElwCfyL9FDCJko/GthRCbf2ZUESsKf Q1KwqaI8V6EUuLhN9ZsY3AnRnmcDAVY5pfWf1XscHq59jSYj7/jrTYTnoBQPRjGcCe38 GLDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fykog55G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id h19si1414288qtk.307.2017.10.16.10.29.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fykog55G; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49CZ-0004Q5-Bo for patch@linaro.org; Mon, 16 Oct 2017 13:29:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e499h-0001ss-KN for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499g-0003Gl-46 for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:21 -0400 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:45355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499f-0003GA-Rk for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:20 -0400 Received: by mail-pf0-x22f.google.com with SMTP id d28so16306527pfe.2 for ; Mon, 16 Oct 2017 10:26:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mupzlOYUAuyNywOnggVbrrdzIC7T3+eQFkWsnwKDReo=; b=fykog55GnhboxY86I2Djd7qEQCM+I3+yIMD6ahDlWHuID0zEP1fBZmgZAH8Qe8P1qr p0OEfJIPCKRsgUZ5X5AI0rj6DtoUNUU3zisiMm6co/yB6ZZTKXIJNUpsCvrifFLRzHbV 7iZFQYzN7Fm09Uk64b0OnZzMO+7D/CICA/kGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mupzlOYUAuyNywOnggVbrrdzIC7T3+eQFkWsnwKDReo=; b=AqbiQYV4ziGJW3cxEmlEBTm8t1XJ0YtlFRnF6IOx76A58C/ori2A35EYEvg63OSRN1 TnGDJQ8EWxkhW9yHY82Yw9KGqLCf+6M37Dp0NQa0VtRG4mRJ0FtpB0wW/0yabk57DSBz oODcPNlu4G7e0r7bhcioXdRZ+JRyBju9Ybbd5oDBqF1+oAUh4YYwebWJJofFmKNcbabR G5BbH/rMmeHnsPQ52gpKEAKreEklL4829o/2xp/iHas5Rd/VhKQp1NfneevHwUMHs3Dd D8MyncM2XifJIJX0hzdjY2WlB2hAteknklvtG91vZUTdAWvMbkYgcTqhJ6gFWiouM5Fb 3Tbg== X-Gm-Message-State: AMCzsaUbQGMkWcw0gXyk874ih+qH9mEriLQeXuPXS7+n8rrc5ZvhJtSA fMN34SPxWcYGeXjH2PXav95qN4gY4DY= X-Google-Smtp-Source: AOwi7QAOMAxG3MRSzlAmWD+gqflHr+touUIKHNhDtT1OcwgVdXKIRrnmNzodxLYqSb/k8uIE+vtL1g== X-Received: by 10.159.208.5 with SMTP id a5mr9744896plp.436.1508174778543; Mon, 16 Oct 2017 10:26:18 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-104-76.tukw.qwest.net. [97.126.104.76]) by smtp.gmail.com with ESMTPSA id i187sm5594249pfc.96.2017.10.16.10.26.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:23 -0700 Message-Id: <20171016172609.23422-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171016172609.23422-1-richard.henderson@linaro.org> References: <20171016172609.23422-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22f Subject: [Qemu-devel] [PATCH v6 04/50] tcg: Propagate TCGOp down to allocators 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: cota@braap.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/tcg.c | 78 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/tcg/tcg.c b/tcg/tcg.c index 4f56077f64..147b8904d8 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2334,25 +2334,24 @@ static void tcg_reg_alloc_do_movi(TCGContext *s, TCGTemp *ots, } } -static void tcg_reg_alloc_movi(TCGContext *s, const TCGArg *args, - TCGLifeData arg_life) +static void tcg_reg_alloc_movi(TCGContext *s, const TCGOp *op) { - TCGTemp *ots = &s->temps[args[0]]; - tcg_target_ulong val = args[1]; + TCGTemp *ots = &s->temps[op->args[0]]; + tcg_target_ulong val = op->args[1]; - tcg_reg_alloc_do_movi(s, ots, val, arg_life); + tcg_reg_alloc_do_movi(s, ots, val, op->life); } -static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, - const TCGArg *args, TCGLifeData arg_life) +static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op) { + const TCGLifeData arg_life = op->life; TCGRegSet allocated_regs; TCGTemp *ts, *ots; TCGType otype, itype; allocated_regs = s->reserved_regs; - ots = &s->temps[args[0]]; - ts = &s->temps[args[1]]; + ots = &s->temps[op->args[0]]; + ts = &s->temps[op->args[1]]; /* Note that otype != itype for no-op truncation. */ otype = ots->type; @@ -2382,7 +2381,7 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, liveness analysis disabled). */ tcg_debug_assert(NEED_SYNC_ARG(0)); if (!ots->mem_allocated) { - temp_allocate_frame(s, args[0]); + temp_allocate_frame(s, op->args[0]); } tcg_out_st(s, otype, ts->reg, ots->mem_base->reg, ots->mem_offset); if (IS_DEAD_ARG(1)) { @@ -2416,10 +2415,10 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOpDef *def, } } -static void tcg_reg_alloc_op(TCGContext *s, - const TCGOpDef *def, TCGOpcode opc, - const TCGArg *args, TCGLifeData arg_life) +static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op) { + const TCGLifeData arg_life = op->life; + const TCGOpDef * const def = &tcg_op_defs[op->opc]; TCGRegSet i_allocated_regs; TCGRegSet o_allocated_regs; int i, k, nb_iargs, nb_oargs; @@ -2430,21 +2429,24 @@ static void tcg_reg_alloc_op(TCGContext *s, TCGArg new_args[TCG_MAX_OP_ARGS]; int const_args[TCG_MAX_OP_ARGS]; + /* Sanity check that we've not introduced any unhandled opcodes. */ + tcg_debug_assert(!(def->flags & TCG_OPF_NOT_PRESENT)); + nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; /* copy constants */ memcpy(new_args + nb_oargs + nb_iargs, - args + nb_oargs + nb_iargs, + op->args + nb_oargs + nb_iargs, sizeof(TCGArg) * def->nb_cargs); i_allocated_regs = s->reserved_regs; o_allocated_regs = s->reserved_regs; /* satisfy input constraints */ - for(k = 0; k < nb_iargs; k++) { + for (k = 0; k < nb_iargs; k++) { i = def->sorted_args[nb_oargs + k]; - arg = args[i]; + arg = op->args[i]; arg_ct = &def->args_ct[i]; ts = &s->temps[arg]; @@ -2462,7 +2464,7 @@ static void tcg_reg_alloc_op(TCGContext *s, if (ts->fixed_reg) { /* if fixed register, we must allocate a new register if the alias is not the same register */ - if (arg != args[arg_ct->alias_index]) + if (arg != op->args[arg_ct->alias_index]) goto allocate_in_reg; } else { /* if the input is aliased to an output and if it is @@ -2503,7 +2505,7 @@ static void tcg_reg_alloc_op(TCGContext *s, /* mark dead temporaries and free the associated registers */ for (i = nb_oargs; i < nb_oargs + nb_iargs; i++) { if (IS_DEAD_ARG(i)) { - temp_dead(s, &s->temps[args[i]]); + temp_dead(s, &s->temps[op->args[i]]); } } @@ -2527,7 +2529,7 @@ static void tcg_reg_alloc_op(TCGContext *s, /* satisfy the output constraints */ for(k = 0; k < nb_oargs; k++) { i = def->sorted_args[k]; - arg = args[i]; + arg = op->args[i]; arg_ct = &def->args_ct[i]; ts = &s->temps[arg]; if ((arg_ct->ct & TCG_CT_ALIAS) @@ -2566,11 +2568,11 @@ static void tcg_reg_alloc_op(TCGContext *s, } /* emit instruction */ - tcg_out_op(s, opc, new_args, const_args); + tcg_out_op(s, op->opc, new_args, const_args); /* move the outputs in the correct register if needed */ for(i = 0; i < nb_oargs; i++) { - ts = &s->temps[args[i]]; + ts = &s->temps[op->args[i]]; reg = new_args[i]; if (ts->fixed_reg && ts->reg != reg) { tcg_out_mov(s, ts->type, ts->reg, reg); @@ -2589,9 +2591,11 @@ static void tcg_reg_alloc_op(TCGContext *s, #define STACK_DIR(x) (x) #endif -static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, - const TCGArg * const args, TCGLifeData arg_life) +static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) { + const int nb_oargs = op->callo; + const int nb_iargs = op->calli; + const TCGLifeData arg_life = op->life; int flags, nb_regs, i; TCGReg reg; TCGArg arg; @@ -2602,8 +2606,8 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, int allocate_args; TCGRegSet allocated_regs; - func_addr = (tcg_insn_unit *)(intptr_t)args[nb_oargs + nb_iargs]; - flags = args[nb_oargs + nb_iargs + 1]; + func_addr = (tcg_insn_unit *)(intptr_t)op->args[nb_oargs + nb_iargs]; + flags = op->args[nb_oargs + nb_iargs + 1]; nb_regs = ARRAY_SIZE(tcg_target_call_iarg_regs); if (nb_regs > nb_iargs) { @@ -2622,8 +2626,8 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, } stack_offset = TCG_TARGET_CALL_STACK_OFFSET; - for(i = nb_regs; i < nb_iargs; i++) { - arg = args[nb_oargs + i]; + for (i = nb_regs; i < nb_iargs; i++) { + arg = op->args[nb_oargs + i]; #ifdef TCG_TARGET_STACK_GROWSUP stack_offset -= sizeof(tcg_target_long); #endif @@ -2640,8 +2644,8 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, /* assign input registers */ allocated_regs = s->reserved_regs; - for(i = 0; i < nb_regs; i++) { - arg = args[nb_oargs + i]; + for (i = 0; i < nb_regs; i++) { + arg = op->args[nb_oargs + i]; if (arg != TCG_CALL_DUMMY_ARG) { ts = &s->temps[arg]; reg = tcg_target_call_iarg_regs[i]; @@ -2663,9 +2667,9 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, } /* mark dead temporaries and free the associated registers */ - for(i = nb_oargs; i < nb_iargs + nb_oargs; i++) { + for (i = nb_oargs; i < nb_iargs + nb_oargs; i++) { if (IS_DEAD_ARG(i)) { - temp_dead(s, &s->temps[args[i]]); + temp_dead(s, &s->temps[op->args[i]]); } } @@ -2690,7 +2694,7 @@ static void tcg_reg_alloc_call(TCGContext *s, int nb_oargs, int nb_iargs, /* assign output registers and emit moves if needed */ for(i = 0; i < nb_oargs; i++) { - arg = args[i]; + arg = op->args[i]; ts = &s->temps[arg]; reg = tcg_target_call_oarg_regs[i]; tcg_debug_assert(s->reg_to_temp[reg] == NULL); @@ -2838,8 +2842,6 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) for (oi = s->gen_op_buf[0].next; oi != 0; oi = oi_next) { TCGOp * const op = &s->gen_op_buf[oi]; TCGOpcode opc = op->opc; - const TCGOpDef *def = &tcg_op_defs[opc]; - TCGLifeData arg_life = op->life; oi_next = op->next; #ifdef CONFIG_PROFILER @@ -2849,11 +2851,11 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) switch (opc) { case INDEX_op_mov_i32: case INDEX_op_mov_i64: - tcg_reg_alloc_mov(s, def, op->args, arg_life); + tcg_reg_alloc_mov(s, op); break; case INDEX_op_movi_i32: case INDEX_op_movi_i64: - tcg_reg_alloc_movi(s, op->args, arg_life); + tcg_reg_alloc_movi(s, op); break; case INDEX_op_insn_start: if (num_insns >= 0) { @@ -2878,7 +2880,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) tcg_out_label(s, arg_label(op->args[0]), s->code_ptr); break; case INDEX_op_call: - tcg_reg_alloc_call(s, op->callo, op->calli, op->args, arg_life); + tcg_reg_alloc_call(s, op); break; default: /* Sanity check that we've not introduced any unhandled opcodes. */ @@ -2886,7 +2888,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) /* Note: in order to speed up the code, it would be much faster to have specialized register allocator functions for some common argument patterns */ - tcg_reg_alloc_op(s, def, opc, op->args, arg_life); + tcg_reg_alloc_op(s, op); break; } #ifdef CONFIG_DEBUG_TCG