From patchwork Fri Oct 20 23:19:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 116562 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2231226qgn; Fri, 20 Oct 2017 16:37:53 -0700 (PDT) X-Received: by 10.200.27.89 with SMTP id p25mr10125170qtk.147.1508542673838; Fri, 20 Oct 2017 16:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508542673; cv=none; d=google.com; s=arc-20160816; b=Cni03emgJbmrdbFKFdTD8tr3rB0xdAiUrcKKmuXVAodhnnMkfFXjGhvJi6LR6rI+FW 97h4vZq2LrwtvGXTd05ZLrQaZJMhC1n+3eZtcaYkleAAEAsFAPfGCFukT5YvKWUjy57G 1xcKHztzhl3Y7FK3BXa/2o9OWILlaMM4fv3A7/6Qd0wkUUn/jLRfy7SwvcCLf64H4iPP R8q5VACmInhXnZu19o9pnf+e7HktaX5Cub6/Tzi74vnh4mWPf2Z2AH9fp8R3PpP9Ikkq zzbvFYn1gNGJuN24Egz/5K40tWJ4EymsO2m38AgBOnSHMV3I89E3r6BKLNYdlNSaJdOM g5/w== 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=hRtoD4SvWpc0HyZ9lLteizd04lbxfZCLDInTSdGuJNU=; b=VhUt+i2jBFSxw4mm6Xqnc/no3Wum7+i3I/FKFj4jj3F8H0yfLyiCkW2Is2ZgTvyLQ2 UYYmma63JGz5PwGI47o1T0ducX4Zeo8o8RVOEwVY3WGaA0imdoJYvGHdBdNce+HTz3fS VTTseRfSkaSZdY1vVtBJlKEBQKES1q19TlfG6iYrv4bum0usNvAnXk0lTaEiJG0R3/Nf x/qNsLF6RpKekTHxuZAKZvjE11SmeS1U6Y6sOdPwWr5qhKwW0gnE8mDoOOBFOG3JHlEg 0mK9Y1Y7A4R6ifE0rlZV8k7zR6srXQ5nN9VC76hG5V+P8D7D6gfDlY9/MabThND4RwxH v2+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=AOBiV77s; 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 m125si1659939qkd.112.2017.10.20.16.37.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 Oct 2017 16:37:53 -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=AOBiV77s; 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]:56050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5grP-0005CM-OK for patch@linaro.org; Fri, 20 Oct 2017 19:37:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5gb7-00066R-Cz for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:21:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5gb4-0007iA-50 for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:21:01 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:50160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5gb3-0007hx-V3 for qemu-devel@nongnu.org; Fri, 20 Oct 2017 19:20:58 -0400 Received: by mail-pf0-x242.google.com with SMTP id i5so13070066pfe.6 for ; Fri, 20 Oct 2017 16:20:57 -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=hRtoD4SvWpc0HyZ9lLteizd04lbxfZCLDInTSdGuJNU=; b=AOBiV77sn8n9LbOvpk6tlWKKVpvh9OVsCJT6IwS2UTCY1OWzQ3UdO2dZYAJHqpoNby OmxPleL5zxrN/dR7BMqjrmd+d2mCNEZVtGqsJlNpCpCInFmR4tkBLYDEUNhYWJAVgj2p uS43CnFybOKvg0cbgYQ+CtbueX06bxUi/pBlM= 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=hRtoD4SvWpc0HyZ9lLteizd04lbxfZCLDInTSdGuJNU=; b=hKTuj+kPXlExbPpyewPrRPsXwWcABD93YymJ3pBAceNtuvGl3eCEvlgR6G5Hycr2Sf TdW68PnMFLWemR17pw3q4Uz/y299oKX2x+TmEH/RMuD02shlddPN0OI9vLJVEiJGs9n5 gdWk69O1FlwsGUfEhuHf1nbI8lrzI7WkVfXhdozAIK3hmlSM0KH2vjUgLO2ilJKhmgJb 3gOWFBE0PONcWp+AK0+VykIzyoYMRUKtXvx+OZvTXQ3vI3KPsOIHrwLKUhRH2IiBABUz UjfKB3x9jlL575LnVEj7apIEiD4FSj3yj7j/DwrIKxxHnteFEG0RWf1MNK3SNpNeWHNZ OyVQ== X-Gm-Message-State: AMCzsaVqqj/+DC8cQsrWA9uiYt0eq4Twx+Y5nM11YmG+5KXXNkxRmZeh 02MZ5clfg6RmpG4cNbkjWsLqnOhN2BY= X-Google-Smtp-Source: ABhQp+SQvtLzg8AWZtHow3S4s3gb7/iJlPnJyodG944RkLv9sW7JNjM9fOwml29xpPrgkzuHYo3IdQ== X-Received: by 10.99.45.198 with SMTP id t189mr5773234pgt.286.1508541656747; Fri, 20 Oct 2017 16:20:56 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2017 16:20:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 20 Oct 2017 16:19:52 -0700 Message-Id: <20171020232023.15010-22-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 21/52] 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: pbonzini@redhat.com, cota@braap.org, f4bug@amsat.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Richard Henderson --- tcg/tcg.h | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 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 8f692bc6cf..7fe0fb9e07 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -429,13 +429,13 @@ typedef TCGv_ptr TCGv_env; #endif /* Dummy definition to avoid compiler warnings. */ -#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_UNUSED_I32(x) (x = (TCGv_i32)NULL) +#define TCGV_UNUSED_I64(x) (x = (TCGv_i64)NULL) +#define TCGV_UNUSED_PTR(x) (x = (TCGv_ptr)NULL) -#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) +#define TCGV_IS_UNUSED_I32(x) ((x) == (TCGv_i32)NULL) +#define TCGV_IS_UNUSED_I64(x) ((x) == (TCGv_i64)NULL) +#define TCGV_IS_UNUSED_PTR(x) ((x) == (TCGv_ptr)NULL) /* call flags */ /* Helper does not read globals (either directly or through an exception). It @@ -454,7 +454,7 @@ typedef TCGv_ptr TCGv_env; #define TCG_CALL_NO_WG_SE (TCG_CALL_NO_WG | TCG_CALL_NO_SE) /* used to align parameters */ -#define TCG_CALL_DUMMY_ARG ((TCGArg)(-1)) +#define TCG_CALL_DUMMY_ARG ((TCGArg)0) /* Conditions. Note that these are laid out for easy manipulation by the functions below: @@ -701,17 +701,20 @@ static inline size_t temp_idx(TCGTemp *ts) static inline TCGArg temp_arg(TCGTemp *ts) { - return temp_idx(ts); + ptrdiff_t a = (void *)ts - (void *)&tcg_ctx; + tcg_debug_assert(a >= offsetof(TCGContext, temps) + && a < offsetof(TCGContext, temps[tcg_ctx.nb_temps])); + return a; } static inline TCGTemp *arg_temp(TCGArg a) { - return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a]; -} - -static inline size_t arg_index(TCGArg a) -{ - return a; + if (a == TCG_CALL_DUMMY_ARG) { + return NULL; + } + tcg_debug_assert(a >= offsetof(TCGContext, temps) + && a < offsetof(TCGContext, temps[tcg_ctx.nb_temps])); + return (void *)&tcg_ctx + a; } static inline TCGArg tcgv_i32_arg(TCGv_i32 t) @@ -746,17 +749,17 @@ static inline TCGTemp *tcgv_ptr_temp(TCGv_ptr t) static inline TCGv_i32 temp_tcgv_i32(TCGTemp *t) { - return (TCGv_i32)temp_idx(t); + return (TCGv_i32)temp_arg(t); } static inline TCGv_i64 temp_tcgv_i64(TCGTemp *t) { - return (TCGv_i64)temp_idx(t); + return (TCGv_i64)temp_arg(t); } static inline TCGv_ptr temp_tcgv_ptr(TCGTemp *t) { - return (TCGv_ptr)temp_idx(t); + return (TCGv_ptr)temp_arg(t); } #if TCG_TARGET_REG_BITS == 32