From patchwork Mon Aug 17 19:38:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 508281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 08FD31401F6 for ; Tue, 18 Aug 2015 21:58:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=p7CA0mCa; dkim-atps=neutral Received: from localhost ([::1]:55811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRQIO-0007cx-6e for incoming@patchwork.ozlabs.org; Mon, 17 Aug 2015 15:42:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRQFq-0005y3-DB for qemu-devel@nongnu.org; Mon, 17 Aug 2015 15:39:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZRQFp-0008I9-B2 for qemu-devel@nongnu.org; Mon, 17 Aug 2015 15:39:34 -0400 Received: from mail-qk0-x234.google.com ([2607:f8b0:400d:c09::234]:34898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZRQFp-0008I4-6z for qemu-devel@nongnu.org; Mon, 17 Aug 2015 15:39:33 -0400 Received: by qkbm65 with SMTP id m65so50400875qkb.2 for ; Mon, 17 Aug 2015 12:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Jj83JMd6/WrHV9FDq1JHDnXeTqbcS46paqNy2+TWX0=; b=p7CA0mCaF96yoXPFoWLSGs7OH1nsQOa0Zb3L4yEx9f3Wol1W9owY1ySqUDAFBEsuG9 8t6zT+hg7XYua4MGFaiPMbPy0aH4BuIGX/0QTSV8oNS9jUvRUB0Zg8vxzBavUtTB9dtH SVhLn+dCWCWROvtmcofxsx+Hua1BXkJunrI3yWAP8UHKv1oEpXSxp02TxcTQcgJKzRF8 11NL7n6hyZntKrXskzAtRvUO2nRqYNtpRi97h8S7Bej+4rCL3Ya+iIjel6rnKDEZY8dl 0NKIIzJLj07F0sQDZR7co1y8HZ1M3X913ri7vKP2dg8uOhXQoG9a/P5cc6gK6L3F3bAG aYkw== X-Received: by 10.55.22.132 with SMTP id 4mr3559671qkw.20.1439840372840; Mon, 17 Aug 2015 12:39:32 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by smtp.gmail.com with ESMTPSA id z101sm8772880qge.31.2015.08.17.12.39.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2015 12:39:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 17 Aug 2015 12:38:27 -0700 Message-Id: <1439840320-20897-5-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1439840320-20897-1-git-send-email-rth@twiddle.net> References: <1439840320-20897-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::234 Cc: peter.maydell@linaro.org, Aurelien Jarno Subject: [Qemu-devel] [PATCH 04/17] tcg/optimize: track const/copy status separately X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Aurelien Jarno Instead of using an enum which could be either a copy or a const, track them separately. This will be used in the next patch. Constants are tracked through a bool. Copies are tracked by initializing temp's next_copy and prev_copy to itself, allowing to simplify the code a bit. Cc: Richard Henderson Signed-off-by: Aurelien Jarno --- tcg/optimize.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/tcg/optimize.c b/tcg/optimize.c index 719fee2..e69ab05 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -35,14 +35,8 @@ glue(glue(case INDEX_op_, x), _i32): \ glue(glue(case INDEX_op_, x), _i64) -typedef enum { - TCG_TEMP_UNDEF = 0, - TCG_TEMP_CONST, - TCG_TEMP_COPY, -} tcg_temp_state; - struct tcg_temp_info { - tcg_temp_state state; + bool is_const; uint16_t prev_copy; uint16_t next_copy; tcg_target_ulong val; @@ -54,27 +48,22 @@ static TCGTempSet temps_used; static inline bool temp_is_const(TCGArg arg) { - return temps[arg].state == TCG_TEMP_CONST; + return temps[arg].is_const; } static inline bool temp_is_copy(TCGArg arg) { - return temps[arg].state == TCG_TEMP_COPY; + return temps[arg].next_copy != arg; } -/* Reset TEMP's state to TCG_TEMP_UNDEF. If TEMP only had one copy, remove - the copy flag from the left temp. */ +/* Reset TEMP's state, possibly removing the temp for the list of copies. */ static void reset_temp(TCGArg temp) { - if (temp_is_copy(temp)) { - if (temps[temp].prev_copy == temps[temp].next_copy) { - temps[temps[temp].next_copy].state = TCG_TEMP_UNDEF; - } else { - temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy; - temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy; - } - } - temps[temp].state = TCG_TEMP_UNDEF; + temps[temps[temp].next_copy].prev_copy = temps[temp].prev_copy; + temps[temps[temp].prev_copy].next_copy = temps[temp].next_copy; + temps[temp].next_copy = temp; + temps[temp].prev_copy = temp; + temps[temp].is_const = false; temps[temp].mask = -1; } @@ -88,7 +77,9 @@ static void reset_all_temps(int nb_temps) static void init_temp_info(TCGArg temp) { if (!test_bit(temp, temps_used.l)) { - temps[temp].state = TCG_TEMP_UNDEF; + temps[temp].next_copy = temp; + temps[temp].prev_copy = temp; + temps[temp].is_const = false; temps[temp].mask = -1; set_bit(temp, temps_used.l); } @@ -218,7 +209,7 @@ static void tcg_opt_gen_movi(TCGContext *s, TCGOp *op, TCGArg *args, op->opc = new_op; reset_temp(dst); - temps[dst].state = TCG_TEMP_CONST; + temps[dst].is_const = true; temps[dst].val = val; mask = val; if (TCG_TARGET_REG_BITS > 32 && new_op == INDEX_op_movi_i32) { @@ -260,16 +251,11 @@ static void tcg_opt_gen_mov(TCGContext *s, TCGOp *op, TCGArg *args, assert(!temp_is_const(src)); if (s->temps[src].type == s->temps[dst].type) { - if (!temp_is_copy(src)) { - temps[src].state = TCG_TEMP_COPY; - temps[src].next_copy = src; - temps[src].prev_copy = src; - } - temps[dst].state = TCG_TEMP_COPY; temps[dst].next_copy = temps[src].next_copy; temps[dst].prev_copy = src; temps[temps[dst].next_copy].prev_copy = dst; temps[src].next_copy = dst; + temps[dst].is_const = false; } args[0] = dst;