From nobody Tue Feb 10 11:32:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508925133007441.0597228810735; Wed, 25 Oct 2017 02:52:13 -0700 (PDT) Received: from localhost ([::1]:47373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7IM3-0005LA-5P for importer@patchew.org; Wed, 25 Oct 2017 05:52:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7I6Z-0008KU-W6 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:36:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7I6Y-0008Fu-58 for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:36:07 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:47225) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7I6X-0008DO-Ta for qemu-devel@nongnu.org; Wed, 25 Oct 2017 05:36:06 -0400 Received: by mail-wm0-x244.google.com with SMTP id r196so622442wmf.2 for ; Wed, 25 Oct 2017 02:36:05 -0700 (PDT) Received: from cloudburst.twiddle.net ([62.168.35.107]) by smtp.gmail.com with ESMTPSA id v23sm2751025wmh.8.2017.10.25.02.36.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Oct 2017 02:36:03 -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=+ZKfmpIeCuGmQ/ukqNE48h4VaJZW/yPbDvg/tr7lBLk=; b=MnH4uiBOviH86ztQwOvIHPzvIGKNilGsI4fJiVSYC2JZ6Y/L+7Lwx2Ny7RGf58lT7B N1Ugt0Dpb657EN9Nfn/eMQAbdfcgcB9nzdTbXymzHgh4CrtVGpGOW6VOUzpgS7OW7EWK 1QXmyJrhkQID4FyfmjKuvS+zhtOk2dNcj8IwE= 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=+ZKfmpIeCuGmQ/ukqNE48h4VaJZW/yPbDvg/tr7lBLk=; b=knw4zt34b96V7dje/ylkHCblGK55YjFy7dIMgyP3mhl8R8PqicaHTC/O8jmnW7GNfL GH+M4QSrPtEz8wbF0KxipT/RVeHzfU4LuEueXX4XZGjxgJ9vmlnQcT6NC4MAlUm8yV6A iI1w8g1yEC3uBlvvTsIKDCH9nTRkeAE8QLWHHX7s0nS6LcQwNQL4fgZI+OqKwDfRCErm XyWho+kOw2MH0+3Qw1HPNIvDVvZDueSoEocFH0mi/reHzLGRbOThrEuZcrPmdGV7Awdw jftU4vJ9TZU7dPr4h6D3JB0QnDiLeVQij9ovtE5L+57oV1kVlh9n63ecGr9qgcS9OJoa 5V/g== X-Gm-Message-State: AMCzsaWmXhLpC2ydRavRM6l7NVP6cAoXVqmxJRuZoSJ03Dzd3ciUEJpW MYzu/hye6EMZoMH01nO0qwLsWZxRq1w= X-Google-Smtp-Source: ABhQp+RqIOjB6c4/uxsGHJD8jckVJ4Hsj6LW8B/fU1st4cRv4r7u77QIEAasx5nSx7Ez/pT43nfIYg== X-Received: by 10.28.213.143 with SMTP id m137mr1072754wmg.67.1508924164691; Wed, 25 Oct 2017 02:36:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 25 Oct 2017 11:35:05 +0200 Message-Id: <20171025093535.10175-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171025093535.10175-1-richard.henderson@linaro.org> References: <20171025093535.10175-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PULL 21/51] tcg: Use offsets not indices for 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Using the offset of a temporary, relative to TCGContext, rather than its index means that we don't use 0. That leaves offset 0 free for a NULL representation without having to leave index 0 unused. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tcg/tcg.h | 64 ++++++++++++++++++++++++++++++++---------------------------= ---- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/tcg/tcg.h b/tcg/tcg.h index 8f692bc6cf..c85786fb47 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -428,14 +428,14 @@ typedef TCGv_ptr TCGv_env; #error Unhandled TARGET_LONG_BITS value #endif =20 -/* Dummy definition to avoid compiler warnings. */ -#define TCGV_UNUSED_I32(x) (x =3D (TCGv_i32)-1) -#define TCGV_UNUSED_I64(x) (x =3D (TCGv_i64)-1) -#define TCGV_UNUSED_PTR(x) (x =3D (TCGv_ptr)-1) +/* See the comment before tcgv_i32_temp. */ +#define TCGV_UNUSED_I32(x) (x =3D (TCGv_i32)NULL) +#define TCGV_UNUSED_I64(x) (x =3D (TCGv_i64)NULL) +#define TCGV_UNUSED_PTR(x) (x =3D (TCGv_ptr)NULL) =20 -#define TCGV_IS_UNUSED_I32(x) ((x) =3D=3D (TCGv_i32)-1) -#define TCGV_IS_UNUSED_I64(x) ((x) =3D=3D (TCGv_i64)-1) -#define TCGV_IS_UNUSED_PTR(x) ((x) =3D=3D (TCGv_ptr)-1) +#define TCGV_IS_UNUSED_I32(x) ((x) =3D=3D (TCGv_i32)NULL) +#define TCGV_IS_UNUSED_I64(x) ((x) =3D=3D (TCGv_i64)NULL) +#define TCGV_IS_UNUSED_PTR(x) ((x) =3D=3D (TCGv_ptr)NULL) =20 /* call flags */ /* Helper does not read globals (either directly or through an exception).= It @@ -453,8 +453,8 @@ typedef TCGv_ptr TCGv_env; #define TCG_CALL_NO_RWG_SE (TCG_CALL_NO_RWG | TCG_CALL_NO_SE) #define TCG_CALL_NO_WG_SE (TCG_CALL_NO_WG | TCG_CALL_NO_SE) =20 -/* used to align parameters */ -#define TCG_CALL_DUMMY_ARG ((TCGArg)(-1)) +/* Used to align parameters. See the comment before tcgv_i32_temp. */ +#define TCG_CALL_DUMMY_ARG ((TCGArg)0) =20 /* Conditions. Note that these are laid out for easy manipulation by the functions below: @@ -701,62 +701,64 @@ static inline size_t temp_idx(TCGTemp *ts) =20 static inline TCGArg temp_arg(TCGTemp *ts) { - return temp_idx(ts); + return (uintptr_t)ts; } =20 static inline TCGTemp *arg_temp(TCGArg a) { - return a =3D=3D TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; + return (TCGTemp *)(uintptr_t)a; } =20 -static inline size_t arg_index(TCGArg a) +/* Using the offset of a temporary, relative to TCGContext, rather than + its index means that we don't use 0. That leaves offset 0 free for + a NULL representation without having to leave index 0 unused. */ +static inline TCGTemp *tcgv_i32_temp(TCGv_i32 v) { - return a; -} - -static inline TCGArg tcgv_i32_arg(TCGv_i32 t) -{ - return (intptr_t)t; + uintptr_t o =3D (uintptr_t)v; + TCGTemp *t =3D (void *)&tcg_ctx + o; + tcg_debug_assert(offsetof(TCGContext, temps[temp_idx(t)]) =3D=3D o); + return t; } =20 -static inline TCGArg tcgv_i64_arg(TCGv_i64 t) +static inline TCGTemp *tcgv_i64_temp(TCGv_i64 v) { - return (intptr_t)t; + return tcgv_i32_temp((TCGv_i32)v); } =20 -static inline TCGArg tcgv_ptr_arg(TCGv_ptr t) +static inline TCGTemp *tcgv_ptr_temp(TCGv_ptr v) { - return (intptr_t)t; + return tcgv_i32_temp((TCGv_i32)v); } =20 -static inline TCGTemp *tcgv_i32_temp(TCGv_i32 t) +static inline TCGArg tcgv_i32_arg(TCGv_i32 v) { - return arg_temp(tcgv_i32_arg(t)); + return temp_arg(tcgv_i32_temp(v)); } =20 -static inline TCGTemp *tcgv_i64_temp(TCGv_i64 t) +static inline TCGArg tcgv_i64_arg(TCGv_i64 v) { - return arg_temp(tcgv_i64_arg(t)); + return temp_arg(tcgv_i64_temp(v)); } =20 -static inline TCGTemp *tcgv_ptr_temp(TCGv_ptr t) +static inline TCGArg tcgv_ptr_arg(TCGv_ptr v) { - return arg_temp(tcgv_ptr_arg(t)); + return temp_arg(tcgv_ptr_temp(v)); } =20 static inline TCGv_i32 temp_tcgv_i32(TCGTemp *t) { - return (TCGv_i32)temp_idx(t); + (void)temp_idx(t); /* trigger embedded assert */ + return (TCGv_i32)((void *)t - (void *)&tcg_ctx); } =20 static inline TCGv_i64 temp_tcgv_i64(TCGTemp *t) { - return (TCGv_i64)temp_idx(t); + return (TCGv_i64)temp_tcgv_i32(t); } =20 static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) { - return (TCGv_ptr)temp_idx(t); + return (TCGv_ptr)temp_tcgv_i32(t); } =20 #if TCG_TARGET_REG_BITS =3D=3D 32 --=20 2.13.6