From patchwork Fri Oct 20 23:19:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116557 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2228849qgn; Fri, 20 Oct 2017 16:34:02 -0700 (PDT) X-Received: by 10.55.53.9 with SMTP id c9mr1252073qka.177.1508542442862; Fri, 20 Oct 2017 16:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508542442; cv=none; d=google.com; s=arc-20160816; b=JkKpRocblvKsdr3t6UhqJaYwXsIok/JzfSwEgbGDMow9UthsMYYn4LARL/QIcD8fQz bxGeJs7XYyiSP377ML7n4XXMEbye+YQkmQCwYheQVn49yeSLwghdxA/VQaXTcQT3Qocr U6CZgIu7bZBU1FEJ32z+vgr57KLWdHmBm0kI0UmSyqtKXcdkblODfOHInL0RStcq8wBn b5dW7JKJLdbAWBC9B6td/dzcWk0OU/MjV50fBGdLmnCyaXW/TzfPI57CPCzXZWQcuAGv inhaWQ0k9qPf89f9RHh2wYp4BSRyxQ/Bg1FBaRcqk30M3goX2Y4tEIwDPmB5gMVBA4oj 9kIw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=OwI6l91+9YmXPZBWwlJ/hNt1Hejm2cjkFwXlzeCLPCI=; b=t9y/OXSmDQ6V13VxdcXTB6tODMfDVz8x0Lb4Oo1FvRLAfie5ySTEwaavUGGltwSY1h 0VXVotTG3c5GfDj+qPVdJzD2uajAVU+/DztnKili9/6mAMLHeaAXwmsbUalzCS+oAtGV LMD8ktLuyjcwEUP5qLWgQUuUutogYzjFgSwUGKkvGVgGj0E+rW1htAlWh/Ki7LlvO9SP iMqMZ04KAgcQtIEyDNlbxPpqlWRg4Z1m1j+BZ0x48RDHrU2v0ZQwdu04aol5mMtXJLME KlXKjj/uCbdSVhHRh37BXFN+Nab4ySYSpbKNIpUOpmjFu+/lL09Cz69LT4UiFSA2DY+9 b+Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=X1QI1dCt; 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 x3si220115qtf.71.2017.10.20.16.34.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 Oct 2017 16:34:02 -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=X1QI1dCt; 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]:56034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gng-0001Q4-JI for patch@linaro.org; Fri, 20 Oct 2017 19:34:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gaz-00062G-VQ for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5gay-0007fT-Cm for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:53 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:55376) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5gay-0007f2-5g for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:52 -0400 Received: by mail-pf0-x243.google.com with SMTP id 17so13066247pfn.12 for ; Fri, 20 Oct 2017 16:20:52 -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; bh=OwI6l91+9YmXPZBWwlJ/hNt1Hejm2cjkFwXlzeCLPCI=; b=X1QI1dCtR6EFo4e/sRiuPxCAFXCXTkRFerb3p48QEnKWgUx/ttf9Len1dVg/bh7Ezo D68Fnmih2c2PAOU0BSMi/CXnQMTHXUrWelp3yYiaDWbQMRR/w6igw992DwdTStSv82HC d/aLSjeLBfR4Asqx6XmE8GRIKTHGldc8PUsCU= 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; bh=OwI6l91+9YmXPZBWwlJ/hNt1Hejm2cjkFwXlzeCLPCI=; b=gUNrox1qyMJ6FffF4P0ZnDzj72CjlZdEIz9nCcWmJ0uVP+GUWQbZZlKfvmEFOd+eOe 0ubKZICcfrMVn6Jt0Wv6CMS3oRoCKakYQwcO8MKciiNmY+q1nIIWyA+pVFkYV4LpiXUa x4b7o2D74KPStkIOwOFFw/EtaoVi8UNT9NzrbTpEl5oozxi4FraakjOEmc5OtLV0S8Zb sld8nRiRqK+0gbjqoC27JFElYjEAYODXbPs4UGOfYeCMg5I5WdZIXrnd1c/Nrk26y2Qp dvQLg9etMsiHpKf2OKZSTmxVhmoI3xooPGlSjg2y3sYtOLrwaI+JhszN9gz/Zvl+22ZK L/lg== X-Gm-Message-State: AMCzsaUjgpNw8ZC0vA22B8wP65StdBJRIT9F7TfOJXhQQR62x2KgcDWr mMGC9kNtpdWMkEOvhEp0kRv59Q8/12M= X-Google-Smtp-Source: ABhQp+RMiRFLTfKCXOok5nMlPlkgdWWKD3cHmkDkszxOOHAOB0lOtoazR8NXb8q06OiHdXWs5PzJng== X-Received: by 10.159.216.140 with SMTP id s12mr5416363plp.318.1508541650931; Fri, 20 Oct 2017 16:20:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-165-104.tukw.qwest.net. [97.113.165.104]) by smtp.gmail.com with ESMTPSA id a17sm3532594pfk.173.2017.10.20.16.20.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 16:20:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 20 Oct 2017 16:19:48 -0700 Message-Id: <20171020232023.15010-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171020232023.15010-1-richard.henderson@linaro.org> References: <20171020232023.15010-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v7 17/52] tcg: Introduce temp_tcgv_{i32, i64, ptr} 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: pbonzini@redhat.com, cota@braap.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- tcg/tcg.h | 26 +++++++++++++++++----- tcg/tcg.c | 74 +++++++++++++++++++++++++++------------------------------------ 2 files changed, 53 insertions(+), 47 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota Reviewed-by: Philippe Mathieu-Daudé diff --git a/tcg/tcg.h b/tcg/tcg.h index fb8ce01664..9432962d7b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -786,6 +786,21 @@ static inline TCGTemp *tcgv_ptr_temp(TCGv_ptr t) return arg_temp(tcgv_ptr_arg(t)); } +static inline TCGv_i32 temp_tcgv_i32(TCGTemp *t) +{ + return (TCGv_i32)temp_idx(t); +} + +static inline TCGv_i64 temp_tcgv_i64(TCGTemp *t) +{ + return (TCGv_i64)temp_idx(t); +} + +static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) +{ + return (TCGv_ptr)temp_idx(t); +} + static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { tcg_ctx.gen_op_buf[op_idx].args[arg] = v; @@ -837,7 +852,8 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb); void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size); -int tcg_global_mem_new_internal(TCGType, TCGv_ptr, intptr_t, const char *); +TCGTemp *tcg_global_mem_new_internal(TCGType, TCGv_ptr, + intptr_t, const char *); TCGv_i32 tcg_global_reg_new_i32(TCGReg reg, const char *name); TCGv_i64 tcg_global_reg_new_i64(TCGReg reg, const char *name); @@ -851,8 +867,8 @@ void tcg_temp_free_i64(TCGv_i64 arg); static inline TCGv_i32 tcg_global_mem_new_i32(TCGv_ptr reg, intptr_t offset, const char *name) { - int idx = tcg_global_mem_new_internal(TCG_TYPE_I32, reg, offset, name); - return MAKE_TCGV_I32(idx); + TCGTemp *t = tcg_global_mem_new_internal(TCG_TYPE_I32, reg, offset, name); + return temp_tcgv_i32(t); } static inline TCGv_i32 tcg_temp_new_i32(void) @@ -868,8 +884,8 @@ static inline TCGv_i32 tcg_temp_local_new_i32(void) static inline TCGv_i64 tcg_global_mem_new_i64(TCGv_ptr reg, intptr_t offset, const char *name) { - int idx = tcg_global_mem_new_internal(TCG_TYPE_I64, reg, offset, name); - return MAKE_TCGV_I64(idx); + TCGTemp *t = tcg_global_mem_new_internal(TCG_TYPE_I64, reg, offset, name); + return temp_tcgv_i64(t); } static inline TCGv_i64 tcg_temp_new_i64(void) diff --git a/tcg/tcg.c b/tcg/tcg.c index cb985aabdc..0a9bfa4236 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -492,8 +492,8 @@ static inline TCGTemp *tcg_global_alloc(TCGContext *s) return ts; } -static int tcg_global_reg_new_internal(TCGContext *s, TCGType type, - TCGReg reg, const char *name) +static TCGTemp *tcg_global_reg_new_internal(TCGContext *s, TCGType type, + TCGReg reg, const char *name) { TCGTemp *ts; @@ -509,44 +509,43 @@ static int tcg_global_reg_new_internal(TCGContext *s, TCGType type, ts->name = name; tcg_regset_set_reg(s->reserved_regs, reg); - return temp_idx(ts); + return ts; } void tcg_set_frame(TCGContext *s, TCGReg reg, intptr_t start, intptr_t size) { - int idx; s->frame_start = start; s->frame_end = start + size; - idx = tcg_global_reg_new_internal(s, TCG_TYPE_PTR, reg, "_frame"); - s->frame_temp = &s->temps[idx]; + s->frame_temp + = tcg_global_reg_new_internal(s, TCG_TYPE_PTR, reg, "_frame"); } TCGv_i32 tcg_global_reg_new_i32(TCGReg reg, const char *name) { TCGContext *s = &tcg_ctx; - int idx; + TCGTemp *t; if (tcg_regset_test_reg(s->reserved_regs, reg)) { tcg_abort(); } - idx = tcg_global_reg_new_internal(s, TCG_TYPE_I32, reg, name); - return MAKE_TCGV_I32(idx); + t = tcg_global_reg_new_internal(s, TCG_TYPE_I32, reg, name); + return temp_tcgv_i32(t); } TCGv_i64 tcg_global_reg_new_i64(TCGReg reg, const char *name) { TCGContext *s = &tcg_ctx; - int idx; + TCGTemp *t; if (tcg_regset_test_reg(s->reserved_regs, reg)) { tcg_abort(); } - idx = tcg_global_reg_new_internal(s, TCG_TYPE_I64, reg, name); - return MAKE_TCGV_I64(idx); + t = tcg_global_reg_new_internal(s, TCG_TYPE_I64, reg, name); + return temp_tcgv_i64(t); } -int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, - intptr_t offset, const char *name) +TCGTemp *tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, + intptr_t offset, const char *name) { TCGContext *s = &tcg_ctx; TCGTemp *base_ts = &s->temps[GET_TCGV_PTR(base)]; @@ -598,10 +597,10 @@ int tcg_global_mem_new_internal(TCGType type, TCGv_ptr base, ts->mem_offset = offset; ts->name = name; } - return temp_idx(ts); + return ts; } -static int tcg_temp_new_internal(TCGType type, int temp_local) +static TCGTemp *tcg_temp_new_internal(TCGType type, int temp_local) { TCGContext *s = &tcg_ctx; TCGTemp *ts; @@ -638,36 +637,30 @@ static int tcg_temp_new_internal(TCGType type, int temp_local) ts->temp_allocated = 1; ts->temp_local = temp_local; } - idx = temp_idx(ts); } #if defined(CONFIG_DEBUG_TCG) s->temps_in_use++; #endif - return idx; + return ts; } TCGv_i32 tcg_temp_new_internal_i32(int temp_local) { - int idx; - - idx = tcg_temp_new_internal(TCG_TYPE_I32, temp_local); - return MAKE_TCGV_I32(idx); + TCGTemp *t = tcg_temp_new_internal(TCG_TYPE_I32, temp_local); + return temp_tcgv_i32(t); } TCGv_i64 tcg_temp_new_internal_i64(int temp_local) { - int idx; - - idx = tcg_temp_new_internal(TCG_TYPE_I64, temp_local); - return MAKE_TCGV_I64(idx); + TCGTemp *t = tcg_temp_new_internal(TCG_TYPE_I64, temp_local); + return temp_tcgv_i64(t); } -static void tcg_temp_free_internal(int idx) +static void tcg_temp_free_internal(TCGTemp *ts) { TCGContext *s = &tcg_ctx; - TCGTemp *ts; - int k; + int k, idx; #if defined(CONFIG_DEBUG_TCG) s->temps_in_use--; @@ -676,23 +669,23 @@ static void tcg_temp_free_internal(int idx) } #endif - tcg_debug_assert(idx >= s->nb_globals && idx < s->nb_temps); - ts = &s->temps[idx]; + tcg_debug_assert(ts->temp_global == 0); tcg_debug_assert(ts->temp_allocated != 0); ts->temp_allocated = 0; + idx = temp_idx(ts); k = ts->base_type + (ts->temp_local ? TCG_TYPE_COUNT : 0); set_bit(idx, s->free_temps[k].l); } void tcg_temp_free_i32(TCGv_i32 arg) { - tcg_temp_free_internal(GET_TCGV_I32(arg)); + tcg_temp_free_internal(tcgv_i32_temp(arg)); } void tcg_temp_free_i64(TCGv_i64 arg) { - tcg_temp_free_internal(GET_TCGV_I64(arg)); + tcg_temp_free_internal(tcgv_i64_temp(arg)); } TCGv_i32 tcg_const_i32(int32_t val) @@ -1001,7 +994,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) for (i = real_args = 0; i < nargs; ++i) { int is_64bit = sizemask & (1 << (i+1)*2); if (is_64bit) { - TCGv_i64 orig = MAKE_TCGV_I64(temp_idx(args[i])); + TCGv_i64 orig = temp_tcgv_i64(args[i]); TCGv_i32 h = tcg_temp_new_i32(); TCGv_i32 l = tcg_temp_new_i32(); tcg_gen_extr_i64_i32(l, h, orig); @@ -1021,7 +1014,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) int is_signed = sizemask & (2 << (i+1)*2); if (!is_64bit) { TCGv_i64 temp = tcg_temp_new_i64(); - TCGv_i64 orig = MAKE_TCGV_I64(temp_idx(args[i])); + TCGv_i64 orig = temp_tcgv_i64(args[i]); if (is_signed) { tcg_gen_ext32s_i64(temp, orig); } else { @@ -1130,10 +1123,8 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) for (i = real_args = 0; i < orig_nargs; ++i) { int is_64bit = orig_sizemask & (1 << (i+1)*2); if (is_64bit) { - TCGv_i32 h = MAKE_TCGV_I32(temp_idx(args[real_args++])); - TCGv_i32 l = MAKE_TCGV_I32(temp_idx(args[real_args++])); - tcg_temp_free_i32(h); - tcg_temp_free_i32(l); + tcg_temp_free_internal(args[real_args++]); + tcg_temp_free_internal(args[real_args++]); } else { real_args++; } @@ -1142,7 +1133,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) /* The 32-bit ABI returned two 32-bit pieces. Re-assemble them. Note that describing these as TCGv_i64 eliminates an unnecessary zero-extension that tcg_gen_concat_i32_i64 would create. */ - tcg_gen_concat32_i64(MAKE_TCGV_I64(temp_idx(ret)), retl, reth); + tcg_gen_concat32_i64(temp_tcgv_i64(ret), retl, reth); tcg_temp_free_i64(retl); tcg_temp_free_i64(reth); } @@ -1150,8 +1141,7 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args) for (i = 0; i < nargs; ++i) { int is_64bit = sizemask & (1 << (i+1)*2); if (!is_64bit) { - TCGv_i64 temp = MAKE_TCGV_I64(temp_idx(args[i])); - tcg_temp_free_i64(temp); + tcg_temp_free_internal(args[i]); } } #endif /* TCG_TARGET_EXTEND_ARGS */