From patchwork Wed Nov 22 11:14:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746015 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239630wru; Wed, 22 Nov 2023 03:15:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IELnnlwOMHHRQ8gFfeEtfDwR6AaQ375Iajg5/Jq22dIevCacF104beFRUCBBDYn4oioLoER X-Received: by 2002:a25:2315:0:b0:da0:6cf3:c629 with SMTP id j21-20020a252315000000b00da06cf3c629mr1409654ybj.41.1700651736655; Wed, 22 Nov 2023 03:15:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651736; cv=pass; d=google.com; s=arc-20160816; b=Dk18/odpjeA7VsSKAXjL/iLGoqZT9gYjWVW5CJfRBjE7UXLJJVtRpQr1wcZEWrW/x1 /zLKFHRNb56cAVUPDolUya7IZ4PW6oyTEsARmJN2gxMLDXvFKns92PTObDeeKFooYlZ9 KFxEh4fHIua8TcAGqgItcZXi7hHWJcpVG6Abyxt15va1UFIG7QGWWnEBSRQfKK2ync69 Bc0Z/g/e5HF37S6Lzf1TS2Wm5LKc/GOPWkNMCOycC6EgfA50bc8bw9r6DRMM8s01IKJg cFqeSBSqb7uiOk5eNDUQfdxwm5fx3Ipymlo9jmz/W4NvHSqPO/C8X1zFNiQROKM/wAS6 17+w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=0dpmp0+82ieuy/6u/rtD3q28q5gN8tXahIG7ZMVwLB4=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=AR505dGrgefjrIYgBWTafszPBqd+DbGCNTHYQvM38O3MiyurFevJQJx93a7JtVgAFh FZtWDhboRdlNOIQ3lWuJ7XI6zuxOD3lCqJAj5j6P6gGvnTMNHvItwKlCXWfWAi62a8Dh hJL1MrTjjUDwQHtmwo0+cdXeULzSp1nDt2WacQHusFcpkCu9+z7U9nielFgt6c6ceWt7 VMjuHAc0idxFC5y9VqtbNxTclTJMXGXD+PnBekUVpThDhaXi1yPkLNqM3ZJ6eQNFI5Sb Lh+PvDLBkvxK7CK3YeVU/iIo00hzM+ROwxOTPTEhDxzWK/0Oya12RLm8rNDy1CXI5VSA y+lg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dBNWPiMt; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e15-20020ad4418f000000b00679182534adsi8048278qvp.24.2023.11.22.03.15.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:15:36 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dBNWPiMt; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DAEB3857000 for ; Wed, 22 Nov 2023 11:15:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 2E59C3858C29 for ; Wed, 22 Nov 2023 11:14:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E59C3858C29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2E59C3858C29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651697; cv=none; b=IvaeGrXuBccXnFNP+I9/CXrjjw8E+T9lCUK6E6Rt5wEZTI83fLg7sPjSn50Kpjs2HB92p8wgoLOz24Tq7Pbr+iSH/4gYs9TBmJreuZ5sSKzN3sW6iH/ZctslQJ7KhBQOrwxnupumrYeDQYvEV5ufnsXyPNhKvGPwe0qthu4bCYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651697; c=relaxed/simple; bh=tJ8/NYU8qbcCJmVtHwz5nuWPB3jDMdZiJiwQGuB+NeA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tJGc+Y9OUQaltuKXEI2mVviQy1XuM0MYDKUvM92BhVpn6L52QJpYsTYLnF3zQhtvrgNHmR2ImMC5YgJTTo56g1+GVwgEde0hxAe94FEjCzj8pYLpBwNKVbAzNpBn4wECLRiNBzvKTDWM1DRvVaveuggY929SC5Bv9LJRI+vFh90= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507f63fcbf6so1637718e87.1 for ; Wed, 22 Nov 2023 03:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651692; x=1701256492; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0dpmp0+82ieuy/6u/rtD3q28q5gN8tXahIG7ZMVwLB4=; b=dBNWPiMtS9saiCjEIF0aQcLPrK2jKJJwGpgjll1WjFqNdo8YB1IUP/J5/FajVuAsNQ iW1OhoX8rOA1OS+UdaXks28nEG6NQWHamTYTZq1xHTVzJ6RW/8dSo3RCbeuutcHCYlV9 v1mOQbEQQXbgItj9ea/np/plw4rPXh57YSVKIPcm4SrQjdYzKLad9mH0xUwaSNnAmHm+ UGbjz86JEMErrO+vQ+4a+6zUZYwvKCHYww44USsrXUn5Eui5OHhus/gd/h3z/H0HoiHt dX4eBPKeIcaeyxtWhfwMrD2vEUk9DH6DZqRYODq281gNroGEWw9PDBf9z3SgEAnHXJKO Ijkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651692; x=1701256492; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0dpmp0+82ieuy/6u/rtD3q28q5gN8tXahIG7ZMVwLB4=; b=Q7vDKi5Lfcb3U/gXFLVdU572iV4P5RcX7QUeVe+p2lVSfzc8CtUcxy3R53TdPCApkc CEBdSPgNLmsdByaJdZVzx4/Nn+fE5hLx1nLy+Sm7rA94i4MfyyPv+R5xZ6beIJfGaDL6 pOu1fAdstrWHxVdHWUpE91S723vkW2DyVMThl26OAdkw0kqklK3SmFTwZvYCfrbt9zTu POP02DohvaS54RitfGGhzGCJ12Ax7sGJeER8sNt2I/SRzINZZOZ0kT5X0A98KInAIsL7 twxN8MWMAQ7bYFdwLQbd8FswXgBCvUdohaKn0srEe3GbUvyl2t3A8brlWM1rAzvieVxq uGqA== X-Gm-Message-State: AOJu0YyC2WNJJ261g0plgderVsvDx2fQ6/43nV8E3ZBkzuke2ZwKIsv5 0qk6fF3Cfikpb0ahlhYv8+HhJv2Pjq6ggqVCd7iJ0jU= X-Received: by 2002:a05:6512:3daa:b0:509:b45:8879 with SMTP id k42-20020a0565123daa00b005090b458879mr1426297lfv.3.1700651691518; Wed, 22 Nov 2023 03:14:51 -0800 (PST) Received: from localhost.localdomain (static.225.72.216.95.clients.your-server.de. [95.216.72.225]) by smtp.gmail.com with ESMTPSA id t13-20020a195f0d000000b0050919538b00sm1848553lfb.79.2023.11.22.03.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:50 -0800 (PST) From: Maxim Kuvyrkov To: gcc-patches@gcc.gnu.org Cc: Maxim Kuvyrkov , Bernd Schmidt , Vladimir Makarov , Jeff Law , Alexander Monakov , Richard Guenther Subject: [PATCH v3 2/8] Unify implementations of print_hard_reg_set() Date: Wed, 22 Nov 2023 11:14:09 +0000 Message-Id: <20231122111415.815147-3-maxim.kuvyrkov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> References: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patch=linaro.org@gcc.gnu.org We currently have 3 implementations of print_hard_reg_set() (all with the same name!) in ira-color.cc, ira-conflicts.cc, and sel-sched-dump.cc. This patch generalizes implementation in ira-color.cc, and uses it in all other places. The declaration is added to hard-reg-set.h. The motivation for this patch is the [upcoming] need for print_hard_reg_set() in sched-deps.cc. gcc/ChangeLog: * hard-reg-set.h (print_hard_reg_set): Declare. * ira-color.cc (print_hard_reg_set): Generalize a bit. (debug_hard_reg_set, print_hard_regs_subforest,) (setup_allocno_available_regs_num): Update. * ira-conflicts.cc (print_hard_reg_set): Remove. (print_allocno_conflicts): Use global print_hard_reg_set(). * sel-sched-dump.cc (print_hard_reg_set): Remove. (dump_hard_reg_set): Use global print_hard_reg_set(). * sel-sched-dump.h (dump_hard_reg_set): Mark as DEBUG_FUNCTION. --- gcc/hard-reg-set.h | 3 +++ gcc/ira-color.cc | 17 ++++++++++------- gcc/ira-conflicts.cc | 39 ++++----------------------------------- gcc/sel-sched-dump.cc | 21 ++++----------------- gcc/sel-sched-dump.h | 2 +- 5 files changed, 22 insertions(+), 60 deletions(-) diff --git a/gcc/hard-reg-set.h b/gcc/hard-reg-set.h index b0bb9bce074..81bca6df0e5 100644 --- a/gcc/hard-reg-set.h +++ b/gcc/hard-reg-set.h @@ -524,4 +524,7 @@ call_used_or_fixed_reg_p (unsigned int regno) } #endif +/* ira-color.cc */ +extern void print_hard_reg_set (FILE *, HARD_REG_SET, const char *, bool); + #endif /* ! GCC_HARD_REG_SET_H */ diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc index f2e8ea34152..43564b44933 100644 --- a/gcc/ira-color.cc +++ b/gcc/ira-color.cc @@ -482,11 +482,14 @@ first_common_ancestor_node (allocno_hard_regs_node_t first, } /* Print hard reg set SET to F. */ -static void -print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p) +void +print_hard_reg_set (FILE *f, HARD_REG_SET set, + const char *title, bool new_line_p) { int i, start, end; + if (title) + fprintf (f, "%s", title); for (start = end = -1, i = 0; i < FIRST_PSEUDO_REGISTER; i++) { bool reg_included = TEST_HARD_REG_BIT (set, i); @@ -516,7 +519,7 @@ print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p) DEBUG_FUNCTION void debug_hard_reg_set (HARD_REG_SET set) { - print_hard_reg_set (stderr, set, true); + print_hard_reg_set (stderr, set, NULL, true); } /* Print allocno hard register subforest given by ROOTS and its LEVEL @@ -534,7 +537,7 @@ print_hard_regs_subforest (FILE *f, allocno_hard_regs_node_t roots, for (i = 0; i < level * 2; i++) fprintf (f, " "); fprintf (f, "%d:(", node->preorder_num); - print_hard_reg_set (f, node->hard_regs->set, false); + print_hard_reg_set (f, node->hard_regs->set, NULL, false); fprintf (f, ")@%" PRId64"\n", node->hard_regs->cost); print_hard_regs_subforest (f, node->first, level + 1); } @@ -2982,12 +2985,12 @@ setup_allocno_available_regs_num (ira_allocno_t a) " Allocno a%dr%d of %s(%d) has %d avail. regs ", ALLOCNO_NUM (a), ALLOCNO_REGNO (a), reg_class_names[aclass], ira_class_hard_regs_num[aclass], n); - print_hard_reg_set (ira_dump_file, data->profitable_hard_regs, false); + print_hard_reg_set (ira_dump_file, data->profitable_hard_regs, NULL, false); fprintf (ira_dump_file, ", %snode: ", data->profitable_hard_regs == data->hard_regs_node->hard_regs->set ? "" : "^"); print_hard_reg_set (ira_dump_file, - data->hard_regs_node->hard_regs->set, false); + data->hard_regs_node->hard_regs->set, NULL, false); for (i = 0; i < nwords; i++) { ira_object_t obj = ALLOCNO_OBJECT (a, i); @@ -3000,7 +3003,7 @@ setup_allocno_available_regs_num (ira_allocno_t a) } fprintf (ira_dump_file, " (confl regs = "); print_hard_reg_set (ira_dump_file, OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), - false); + NULL, false); fprintf (ira_dump_file, ")"); } fprintf (ira_dump_file, "\n"); diff --git a/gcc/ira-conflicts.cc b/gcc/ira-conflicts.cc index a4d93c8d734..69806b1a15b 100644 --- a/gcc/ira-conflicts.cc +++ b/gcc/ira-conflicts.cc @@ -670,37 +670,6 @@ build_conflicts (void) -/* Print hard reg set SET with TITLE to FILE. */ -static void -print_hard_reg_set (FILE *file, const char *title, HARD_REG_SET set) -{ - int i, start, end; - - fputs (title, file); - for (start = end = -1, i = 0; i < FIRST_PSEUDO_REGISTER; i++) - { - bool reg_included = TEST_HARD_REG_BIT (set, i); - - if (reg_included) - { - if (start == -1) - start = i; - end = i; - } - if (start >= 0 && (!reg_included || i == FIRST_PSEUDO_REGISTER - 1)) - { - if (start == end) - fprintf (file, " %d", start); - else if (start == end + 1) - fprintf (file, " %d %d", start, end); - else - fprintf (file, " %d-%d", start, end); - start = -1; - } - } - putc ('\n', file); -} - static void print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a) { @@ -759,14 +728,14 @@ print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a) conflicting_hard_regs = (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) & ~ira_no_alloc_regs & reg_class_contents[ALLOCNO_CLASS (a)]); - print_hard_reg_set (file, "\n;; total conflict hard regs:", - conflicting_hard_regs); + print_hard_reg_set (file, conflicting_hard_regs, + "\n;; total conflict hard regs:", true); conflicting_hard_regs = (OBJECT_CONFLICT_HARD_REGS (obj) & ~ira_no_alloc_regs & reg_class_contents[ALLOCNO_CLASS (a)]); - print_hard_reg_set (file, ";; conflict hard regs:", - conflicting_hard_regs); + print_hard_reg_set (file, conflicting_hard_regs, + ";; conflict hard regs:", true); putc ('\n', file); } diff --git a/gcc/sel-sched-dump.cc b/gcc/sel-sched-dump.cc index 05de9840937..5b2439cf4e2 100644 --- a/gcc/sel-sched-dump.cc +++ b/gcc/sel-sched-dump.cc @@ -535,26 +535,13 @@ dump_insn_vector (rtx_vec_t succs) sel_print ("NULL "); } -/* Dumps a hard reg set SET to FILE using PREFIX. */ -static void -print_hard_reg_set (FILE *file, const char *prefix, HARD_REG_SET set) -{ - int i; - - fprintf (file, "%s{ ", prefix); - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - { - if (TEST_HARD_REG_BIT (set, i)) - fprintf (file, "%d ", i); - } - fprintf (file, "}\n"); -} - /* Dumps a hard reg set SET using PREFIX. */ -void +DEBUG_FUNCTION void dump_hard_reg_set (const char *prefix, HARD_REG_SET set) { - print_hard_reg_set (sched_dump, prefix, set); + fprintf (sched_dump, "%s{", prefix); + print_hard_reg_set (sched_dump, set, NULL, false); + fprintf (sched_dump, "}\n"); } /* Pretty print INSN. This is used as a hook. */ diff --git a/gcc/sel-sched-dump.h b/gcc/sel-sched-dump.h index 2a207cefda2..e5095b2e986 100644 --- a/gcc/sel-sched-dump.h +++ b/gcc/sel-sched-dump.h @@ -214,7 +214,7 @@ extern void dump_av_set (av_set_t); extern void dump_lv_set (regset); extern void dump_blist (blist_t); extern void dump_flist (flist_t); -extern void dump_hard_reg_set (const char *, HARD_REG_SET); +DEBUG_FUNCTION extern void dump_hard_reg_set (const char *, HARD_REG_SET); extern void sel_debug_cfg_1 (int); extern void sel_debug_cfg (void); extern void setup_dump_cfg_params (void);