From patchwork Mon Oct 16 17:25:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 115942 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3943203qgn; Mon, 16 Oct 2017 10:37:06 -0700 (PDT) X-Received: by 10.55.6.22 with SMTP id 22mr13968920qkg.340.1508175426897; Mon, 16 Oct 2017 10:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508175426; cv=none; d=google.com; s=arc-20160816; b=KH1gcXpoDiLoN4vM3al3G5SgCPPPyhDj7BaPq1alWdGqLZOYgGeCvwjtOHR2AT5Tu/ TdlG1f/8L0yh1fW4lTDmzt5iDWurxhyXeg5+YEYZFN2XOyoq+wj63aEKVAKNwKYF5kxR OjEf2JfQoGFok/3A2+pOAqSLy5hY1WY4l6IMq0/dbJtZGsTqC20ZWLj/Sm3blQ7eYcIT AVFJ9U/kjWjIMAvYwfZHu+zZt6zWwc8QtlVF1H3PyGVpsYYQjxCQJx4QbY+J9fYKWUVU ZGg1SmBsgZ8e1ym29BGMu+tMEd9VrgcC0sgU4wdnb4+U6bxqaTGFKyM5/84NEKm/5Rin LQtA== 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=W/uVhJTBBm1QQTcQZ5J5hpaa/mYKhmO+eNQ749BoQnc=; b=EtTOWKDmkpqLU3rw12b8o2M3W9LTbIEXLuwYgg4nIkiWdQjPmXDsHRd5xFx/wWOBXo gSrBWBlhIl6IJTGdT18UWLoeEIfcRXrzkV9U3ZY4NqiXEhgdpwmDotvF/VW5H+6kCM39 VxGihlLBScWvBDl1xtdCgOSNgWVqMYz1TlTV4v0BMW0M3c9tB3QS9p/Oqq/jxW31D6wp Y1DX6G00xbgF91O1v77IVxrl07dz1n4xlEwxlpDMRg7lWSSd5HooOZiVNxmly4FyKh6h 4NtyAf3c2SYFaOgzaUxuzTjs9+mE39LZKf+5NBZ/CRPigh70QYhRvXd9+PSIlJ08JPKH AXzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=gFW2XShd; 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 45si405903qtx.60.2017.10.16.10.37.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 Oct 2017 10:37:06 -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=gFW2XShd; 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]:34338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49K4-0002Na-Q9 for patch@linaro.org; Mon, 16 Oct 2017 13:37:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e49A1-0002DC-0t for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e499z-0003X8-UB for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:41 -0400 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:50192) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e499z-0003Wg-PQ for qemu-devel@nongnu.org; Mon, 16 Oct 2017 13:26:39 -0400 Received: by mail-pf0-x234.google.com with SMTP id b6so7884690pfh.7 for ; Mon, 16 Oct 2017 10:26:39 -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=W/uVhJTBBm1QQTcQZ5J5hpaa/mYKhmO+eNQ749BoQnc=; b=gFW2XShd8C6UDw3abz56YyC3V96r5EK01BVi4ld5vfTaAF1RJI+zQxPVyGl2yW0V72 YNCYe0iJxR8nKQ11MJtI2wHP+XKYFgZ8ggn7koheX7yQTrsF57YKkeRJHeJFancBHyCH +tOGq5iYxlFqVo8OhnKUFDLV88AcukPXaNjg8= 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=W/uVhJTBBm1QQTcQZ5J5hpaa/mYKhmO+eNQ749BoQnc=; b=mB9zxhsmIzCfhnmvyXUxKyiomZQDpR4h5TXPhbuNBcis0DZnWHgocpAqerSs0vQU5e QLlUiRqHYLG18s3vhxhipQoKcVvVw1CwXDvfkcNo8PMSRX1NHvKUfDAgDcbmjO07Q0Gv v8Vxsj1FJT8My3YwHEA77BZ7yaG/2tYChIgWP+mb5mv+6fo+j30Fqj5DXJGpgyW4NAJU Kafj6HIO80iSJP8Bd0qtfEKbGmrpAsxjgd4bDD/tgJXIu1vIWMPKsHNxL3TcMqqF+z/b pphoRtYD9Q+XuKYdgZf6/nozjwWaMe3HOQwcxkwYNc93RguvZ8JnCkjaG/CG0+dgm4q9 g/cQ== X-Gm-Message-State: AMCzsaV+2WHY+Y9nYrramsVZ8y0BU5pjCbKC50kV9yyVN6ymU72yK6YU iTwWaB8wbxd5cshqghJxOsJ+VfvVbgQ= X-Google-Smtp-Source: AOwi7QAde+ThUnfKOzgm4ez6HN4ak7CwTBr/Jy2Vl6H7dZ4OIWZC51y8Skc/R3ICsFz97NN4ptxfDw== X-Received: by 10.159.208.2 with SMTP id a2mr9709858plp.370.1508174798617; Mon, 16 Oct 2017 10:26:38 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Oct 2017 10:26:37 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 10:25:37 -0700 Message-Id: <20171016172609.23422-19-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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::234 Subject: [Qemu-devel] [PATCH v6 18/50] tcg: Reserve temporary index 0 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Since we cast indicies to pointers, reserving 0 allows us to use NULL for unused/dummy instead of (T *)-1. Signed-off-by: Richard Henderson --- tcg/tcg.h | 16 ++++++++-------- tcg/tcg.c | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) -- 2.13.6 diff --git a/tcg/tcg.h b/tcg/tcg.h index b8ede7fe5c..ccf1bcdaf6 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -471,13 +471,13 @@ static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) #define TCGV_EQUAL_PTR(a, b) (GET_TCGV_PTR(a) == GET_TCGV_PTR(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) = NULL) +#define TCGV_UNUSED_I64(x) ((x) = NULL) +#define TCGV_UNUSED_PTR(x) ((x) = NULL) -#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) (GET_TCGV_I32(x) == 0) +#define TCGV_IS_UNUSED_I64(x) (GET_TCGV_I64(x) == 0) +#define TCGV_IS_UNUSED_PTR(x) (GET_TCGV_PTR(x) == 0) /* call flags */ /* Helper does not read globals (either directly or through an exception). It @@ -496,7 +496,7 @@ static inline intptr_t QEMU_ARTIFICIAL GET_TCGV_PTR(TCGv_ptr t) #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: @@ -737,7 +737,7 @@ extern bool parallel_cpus; static inline size_t temp_idx(TCGTemp *ts) { ptrdiff_t n = ts - tcg_ctx.temps; - tcg_debug_assert(n >= 0 && n < tcg_ctx.nb_temps); + tcg_debug_assert(n > 0 && n < tcg_ctx.nb_temps); return n; } diff --git a/tcg/tcg.c b/tcg/tcg.c index 129aecca60..7cf39f7067 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -333,7 +333,10 @@ void tcg_context_init(TCGContext *s) int *sorted_args; memset(s, 0, sizeof(*s)); - s->nb_globals = 0; + /* Reserve temp index 0 so that, with the funny casting that we do, + the first one doesn't look like NULL. */ + s->nb_globals = 1; + s->nb_temps = 1; /* Count total number of arguments and allocate the corresponding space */