From patchwork Fri Oct 20 23:19:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116554 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2228509qgn; Fri, 20 Oct 2017 16:33:31 -0700 (PDT) X-Received: by 10.237.55.200 with SMTP id j66mr1805521qtb.210.1508542411494; Fri, 20 Oct 2017 16:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508542411; cv=none; d=google.com; s=arc-20160816; b=bz0QLU4mArXGp6nEfy+b8rWO7GdkWM/pEgIM0R+OLvioLtx6aWUW2vRw+Nh0jLg1vF dUVgdJx4OaNd6jGqpFaQYtyQ6eMDjy9fn4HWwluaRZg8ONP8SeQkvHaf33sivdLQKjpd pyLPlHWWS9MMPx1L1rCnaEJ9V7OeST4AUjt6nRV/DKGJfno2KbrHKeB32uXHWyhypYJd aSgH1rtFjP9iNwh8AfQSfC9ub0cJ3vIGa3l3W8H+3HmzKe7FLxpHaU9EEsfuyEFU+rXA mms/L5vGwz/oqXItP5xZXkMGtwD7vnQ39r8/74e1uaTHQ6dRRlX93n5CdfoGm9BwTv3w fosA== 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=I4aIomlIdr8KvbQyDGfppozQNujRHTdczaZ775FqqFE=; b=zWgVMDL2AJM98oCRZm+YfP+MJFIbg12MWZn2+qSz6ZUHIROVapBJQkV+r9LIQq35ts ijMhoWhOc4mVPEdiqShlInQza07yWYDkcGp/hKp0fkWzgaBYE4IrGTFR3n5JELAcAXFF 7u2xF0m3Zwx7tZmMloLiJVs/URLYAw2kJIvf5t5IGa5Dcgu414hGqe6ej1j8ILM1EWgq H62hO81aq5Vp2CxI2vWhge1WpLKS0AF+KX9daf4buHYY4JdvTdwkN3QG7HZqNFu7NzaL WPeDDwgPdINr1k3qHucDvqkH8S1cWhui915jf+OTT16OJz0WkgM2c0oNRZW78b5ykvEn Jb0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B8qEMhbZ; 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 j192si1706258qke.33.2017.10.20.16.33.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 Oct 2017 16:33:31 -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=B8qEMhbZ; 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]:56031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gnB-0000ll-6p for patch@linaro.org; Fri, 20 Oct 2017 19:33:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gb1-00063v-HV for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5gaz-0007gA-Vg for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:55 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:43668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5gaz-0007fp-OL for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:53 -0400 Received: by mail-pf0-x242.google.com with SMTP id a8so13073591pfc.0 for ; Fri, 20 Oct 2017 16:20:53 -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=I4aIomlIdr8KvbQyDGfppozQNujRHTdczaZ775FqqFE=; b=B8qEMhbZ1iWIGMvmqWZidHgfUaNtDcghqHUVFYvg5Vv/MsPQJOf4GbXvl/m+o6HxCX JpSze0yv95zJ+hwJ+DjSTV/27fe+DHM4XmB25QfTxyWBFwlOfFn1B2LcG3E4lFYZU/c8 +y7Did08C5u77VsNyTGFGFUfqSvNZ0Z7aPJcM= 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=I4aIomlIdr8KvbQyDGfppozQNujRHTdczaZ775FqqFE=; b=OBjBApVO5+BnUZZ6PgFv71Tjts1Wki85epfj5D4oiVadG8z5EG66C7F/fd5AqCFDcH f+D83BRKvJCbMX2qXX+6eM6S/cP7nMmyKKYtZX2SiazqPkpprVa63ccAunps4Isd0yBd OeTLb9yMqFNt8tdrOPDAhbNi7qYHHbJ478BXzn5N0yQ97xBmqXPoKS6H3V6ySgeKIrtf 1TA6MeVE2/SPpG7oy7NkVKw9/x6sjjv13aq/OJhC5ncELTCs94aTj/jlFB5sGACL8qM2 sWIRjPsbKzQdYhRq5HNNZ7GQOKX66wJJ55ZIR+Ox9Tj7k5NfWuRORr3QDzDefhikpqVw 9oaQ== X-Gm-Message-State: AMCzsaV5T5dqNeblhV04o7L9XmBu0EjHP+EVWndUYIZD+Nmp+ZRAQ+Ce tUrI0iN7dXN7XWIPQJAORIaVVJltV7E= X-Google-Smtp-Source: ABhQp+Tab2auDJhgfkt/gnJvg9chbXFTBkJCzUe6Pp0R2KTDgnyyFN31RJ0Hvslc0Pq7zatP2Zt3ZA== X-Received: by 10.84.242.76 with SMTP id c12mr5193397pll.51.1508541652455; Fri, 20 Oct 2017 16:20:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 16:20:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 20 Oct 2017 16:19:49 -0700 Message-Id: <20171020232023.15010-19-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::242 Subject: [Qemu-devel] [PATCH v7 18/52] tcg: Remove GET_TCGV_* and MAKE_TCGV_* 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" The GET and MAKE functions weren't really specific enough. We now have a full compliment of functions that convert exactly between temporaries, arguments, tcgv pointers, and indices. The target/sparc change is also a bug fix, which would have affected a host that defines TCG_TARGET_HAS_extr[lh]_i64_i32, i.e. MIPS64. Signed-off-by: Richard Henderson --- include/exec/helper-head.h | 4 --- tcg/tcg.h | 78 ++++++++++++++++------------------------------ target/sparc/translate.c | 15 +++------ tcg/tcg-op.c | 4 +-- tcg/tcg.c | 2 +- 5 files changed, 34 insertions(+), 69 deletions(-) -- 2.13.6 Reviewed-by: Emilio G. Cota diff --git a/include/exec/helper-head.h b/include/exec/helper-head.h index 13286018fd..639eefdbc0 100644 --- a/include/exec/helper-head.h +++ b/include/exec/helper-head.h @@ -20,10 +20,6 @@ #define HELPER(name) glue(helper_, name) -#define GET_TCGV_i32 GET_TCGV_I32 -#define GET_TCGV_i64 GET_TCGV_I64 -#define GET_TCGV_ptr GET_TCGV_PTR - /* Some types that make sense in C, but not for TCG. */ #define dh_alias_i32 i32 #define dh_alias_s32 i32 diff --git a/tcg/tcg.h b/tcg/tcg.h index 9432962d7b..b7fac0db8a 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -414,10 +414,7 @@ typedef tcg_target_ulong TCGArg; integers, but keeping them in pointer types like this means that the compiler will complain if you accidentally pass a TCGv_i32 to a function which takes a TCGv_i64, and so on. Only the internals of - TCG need to care about the actual contents of the types, and they always - box and unbox via the MAKE_TCGV_* and GET_TCGV_* functions. - Converting to and from intptr_t rather than int reduces the number - of sign-extension instructions that get implied on 64-bit hosts. */ + TCG need to care about the actual contents of the types. */ typedef struct TCGv_i32_d *TCGv_i32; typedef struct TCGv_i64_d *TCGv_i64; @@ -431,53 +428,18 @@ typedef TCGv_ptr TCGv_env; #error Unhandled TARGET_LONG_BITS value #endif -static inline TCGv_i32 QEMU_ARTIFICIAL MAKE_TCGV_I32(intptr_t i) -{ - return (TCGv_i32)i; -} - -static inline TCGv_i64 QEMU_ARTIFICIAL MAKE_TCGV_I64(intptr_t i) -{ - return (TCGv_i64)i; -} - -static inline TCGv_ptr QEMU_ARTIFICIAL MAKE_TCGV_PTR(intptr_t i) -{ - return (TCGv_ptr)i; -} - -static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_I32(TCGv_i32 t) -{ - return (intptr_t)t; -} - -static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_I64(TCGv_i64 t) -{ - return (intptr_t)t; -} - -static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) -{ - return (intptr_t)t; -} - -#if TCG_TARGET_REG_BITS == 32 -#define TCGV_LOW(t) MAKE_TCGV_I32(GET_TCGV_I64(t)) -#define TCGV_HIGH(t) MAKE_TCGV_I32(GET_TCGV_I64(t) + 1) -#endif - -#define TCGV_EQUAL_I32(a, b) (GET_TCGV_I32(a) == GET_TCGV_I32(b)) -#define TCGV_EQUAL_I64(a, b) (GET_TCGV_I64(a) == GET_TCGV_I64(b)) -#define TCGV_EQUAL_PTR(a, b) (GET_TCGV_PTR(a) == GET_TCGV_PTR(b)) +#define TCGV_EQUAL_I32(a, b) ((a) == (b)) +#define TCGV_EQUAL_I64(a, b) ((a) == (b)) +#define TCGV_EQUAL_PTR(a, b) ((a) == (b)) /* Dummy definition to avoid compiler warnings. */ -#define TCGV_UNUSED_I32(x) x = MAKE_TCGV_I32(-1) -#define TCGV_UNUSED_I64(x) x = MAKE_TCGV_I64(-1) -#define TCGV_UNUSED_PTR(x) x = MAKE_TCGV_PTR(-1) +#define TCGV_UNUSED_I32(x) (x = (TCGv_i32)-1) +#define TCGV_UNUSED_I64(x) (x = (TCGv_i64)-1) +#define TCGV_UNUSED_PTR(x) (x = (TCGv_ptr)-1) -#define TCGV_IS_UNUSED_I32(x) (GET_TCGV_I32(x) == -1) -#define TCGV_IS_UNUSED_I64(x) (GET_TCGV_I64(x) == -1) -#define TCGV_IS_UNUSED_PTR(x) (GET_TCGV_PTR(x) == -1) +#define TCGV_IS_UNUSED_I32(x) ((x) == (TCGv_i32)-1) +#define TCGV_IS_UNUSED_I64(x) ((x) == (TCGv_i64)-1) +#define TCGV_IS_UNUSED_PTR(x) ((x) == (TCGv_ptr)-1) /* call flags */ /* Helper does not read globals (either directly or through an exception). It @@ -801,6 +763,18 @@ static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) return (TCGv_ptr)temp_idx(t); } +#if TCG_TARGET_REG_BITS == 32 +static inline TCGv_i32 TCGV_LOW(TCGv_i64 t) +{ + return temp_tcgv_i32(tcgv_i64_temp(t)); +} + +static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t) +{ + return temp_tcgv_i32(tcgv_i64_temp(t) + 1); +} +#endif + static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v) { tcg_ctx.gen_op_buf[op_idx].args[arg] = v; @@ -972,8 +946,8 @@ do {\ } while (0) #if UINTPTR_MAX == UINT32_MAX -#define TCGV_NAT_TO_PTR(n) MAKE_TCGV_PTR(GET_TCGV_I32(n)) -#define TCGV_PTR_TO_NAT(n) MAKE_TCGV_I32(GET_TCGV_PTR(n)) +static inline TCGv_ptr TCGV_NAT_TO_PTR(TCGv_i32 n) { return (TCGv_ptr)n; } +static inline TCGv_i32 TCGV_PTR_TO_NAT(TCGv_ptr n) { return (TCGv_i32)n; } #define tcg_const_ptr(V) TCGV_NAT_TO_PTR(tcg_const_i32((intptr_t)(V))) #define tcg_global_reg_new_ptr(R, N) \ @@ -983,8 +957,8 @@ do {\ #define tcg_temp_new_ptr() TCGV_NAT_TO_PTR(tcg_temp_new_i32()) #define tcg_temp_free_ptr(T) tcg_temp_free_i32(TCGV_PTR_TO_NAT(T)) #else -#define TCGV_NAT_TO_PTR(n) MAKE_TCGV_PTR(GET_TCGV_I64(n)) -#define TCGV_PTR_TO_NAT(n) MAKE_TCGV_I64(GET_TCGV_PTR(n)) +static inline TCGv_ptr TCGV_NAT_TO_PTR(TCGv_i64 n) { return (TCGv_ptr)n; } +static inline TCGv_i64 TCGV_PTR_TO_NAT(TCGv_ptr n) { return (TCGv_i64)n; } #define tcg_const_ptr(V) TCGV_NAT_TO_PTR(tcg_const_i64((intptr_t)(V))) #define tcg_global_reg_new_ptr(R, N) \ diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 6290705b11..83a7d8e3ee 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -171,18 +171,13 @@ static TCGv_i32 gen_load_fpr_F(DisasContext *dc, unsigned int src) return TCGV_HIGH(cpu_fpr[src / 2]); } #else + TCGv_i32 ret = get_temp_i32(dc); if (src & 1) { - return MAKE_TCGV_I32(GET_TCGV_I64(cpu_fpr[src / 2])); + tcg_gen_extrl_i64_i32(ret, cpu_fpr[src / 2]); } else { - TCGv_i32 ret = get_temp_i32(dc); - TCGv_i64 t = tcg_temp_new_i64(); - - tcg_gen_shri_i64(t, cpu_fpr[src / 2], 32); - tcg_gen_extrl_i64_i32(ret, t); - tcg_temp_free_i64(t); - - return ret; + tcg_gen_extrh_i64_i32(ret, cpu_fpr[src / 2]); } + return ret; #endif } @@ -195,7 +190,7 @@ static void gen_store_fpr_F(DisasContext *dc, unsigned int dst, TCGv_i32 v) tcg_gen_mov_i32(TCGV_HIGH(cpu_fpr[dst / 2]), v); } #else - TCGv_i64 t = MAKE_TCGV_I64(GET_TCGV_I32(v)); + TCGv_i64 t = (TCGv_i64)v; tcg_gen_deposit_i64(cpu_fpr[dst / 2], cpu_fpr[dst / 2], t, (dst & 1 ? 0 : 32), 32); #endif diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index be4b623e82..9561510d9c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2460,7 +2460,7 @@ void tcg_gen_extrl_i64_i32(TCGv_i32 ret, TCGv_i64 arg) tcg_gen_op2(INDEX_op_extrl_i64_i32, tcgv_i32_arg(ret), tcgv_i64_arg(arg)); } else { - tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(arg))); + tcg_gen_mov_i32(ret, (TCGv_i32)arg); } } @@ -2474,7 +2474,7 @@ void tcg_gen_extrh_i64_i32(TCGv_i32 ret, TCGv_i64 arg) } else { TCGv_i64 t = tcg_temp_new_i64(); tcg_gen_shri_i64(t, arg, 32); - tcg_gen_mov_i32(ret, MAKE_TCGV_I32(GET_TCGV_I64(t))); + tcg_gen_mov_i32(ret, (TCGv_i32)t); tcg_temp_free_i64(t); } } diff --git a/tcg/tcg.c b/tcg/tcg.c index 0a9bfa4236..3a73912827 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -548,7 +548,7 @@ 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)]; + TCGTemp *base_ts = tcgv_ptr_temp(base); TCGTemp *ts = tcg_global_alloc(s); int indirect_reg = 0, bigendian = 0; #ifdef HOST_WORDS_BIGENDIAN