From patchwork Wed Aug 16 15:34:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9903987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5DB7A60231 for ; Wed, 16 Aug 2017 15:35:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FF4B22B27 for ; Wed, 16 Aug 2017 15:35:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44998286AC; Wed, 16 Aug 2017 15:35:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1F2922B27 for ; Wed, 16 Aug 2017 15:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751569AbdHPPfe (ORCPT ); Wed, 16 Aug 2017 11:35:34 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:32856 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751642AbdHPPfe (ORCPT ); Wed, 16 Aug 2017 11:35:34 -0400 Received: by mail-wr0-f196.google.com with SMTP id n88so3697638wrb.0 for ; Wed, 16 Aug 2017 08:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EeF1HcAGAOn0nMZA1eJRMklILQuTSmILs+CWnRfHGHw=; b=G+9pnkVXDp33tG+6//l+DcN1wEv05zjnmK8vsgKz5Zp5+RVC2OXP3GXuknTK2I13wV TEgymO+kVurM80ZRl5JTAnP5c/bQFzfFwiOxNytWIPl2sle7FlUzMk/u65AP0sq4V5Fz hnF2gW7d+Z/xgXQWIFd8ljxyoycvaeUI9cpiUps9ZI8VdU6c7bZHw261h0w/i+I49lBb GUk3h5tOM8+wYd3w0bJpAX2xO+9szWAyLpxtfeo/Okp5PVn7ie6x8tp5J+IEZy3yGvK3 xQFYpZYQWPn0fcA1OXoxel9zftzmJBcAi9HqD7y41agCBEaDDDyXEvaL7nYGM9kVq8W+ 2+cg== 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=EeF1HcAGAOn0nMZA1eJRMklILQuTSmILs+CWnRfHGHw=; b=IRC5KmUF+MBx4qSH5dPu4J9DihxpHNSxUa59jwgXdOvJA+QUKEN/Aw49INb7n4POlB OvT2syBgJTrwmHk6GCve3qSIjipUIkTN0gqtoZVlvWq6w5lUsafmJxEspIegD37rKOX2 O6FXKMabIgZ4qwM/iVDQOvYJIegp6bbrVOFgXFHTFI31cTkCvVJaV9fjACLf61L2o69c yO8rWx/tiu8CcrT/Y0y3JJFLvMPxg95ScMt3lehhozUry7v7hsArwkmi+/etrfuxpyte 6A0ivai0eY6boPjLzcaKMzs4McM2g5V0DaICXeD/wt+tIGlWSgge9FiDZVTJ2nZ8g1Sm sKUA== X-Gm-Message-State: AHYfb5hk3qzVXU4s5M+MiLzrXxarbKCzm0nofdTNWpxNhoMS6twzq/6c uSS48wMyBNNiETi/0fk= X-Received: by 10.80.171.92 with SMTP id t28mr2308298edc.242.1502897732781; Wed, 16 Aug 2017 08:35:32 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4076:600:895a:bb88:13f:9772]) by smtp.gmail.com with ESMTPSA id y19sm690635edi.6.2017.08.16.08.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 08:35:32 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Linus Torvalds , Christopher Li , Luc Van Oostenryck Subject: [PATCH 14/29] extract alloc_phisrc() from alloc_phi() Date: Wed, 16 Aug 2017 17:34:40 +0200 Message-Id: <20170816153455.97693-15-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170816153455.97693-1-luc.vanoostenryck@gmail.com> References: <20170816153455.97693-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This give us: - a clearer name (than alloc_phi()) - more flexibility when we need the instruction and not the pseudo. Signed-off-by: Luc Van Oostenryck --- linearize.c | 26 ++++++++++++++++---------- linearize.h | 1 + 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/linearize.c b/linearize.c index 0af92a08e..1630810d4 100644 --- a/linearize.c +++ b/linearize.c @@ -830,26 +830,32 @@ pseudo_t undef_pseudo(void) return pseudo; } -pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type) +struct instruction *alloc_phisrc(pseudo_t pseudo, struct symbol *type) { - struct instruction *insn; - pseudo_t phi; + struct instruction *insn = alloc_typed_instruction(OP_PHISOURCE, type); + pseudo_t phi = __alloc_pseudo(0); static int nr = 0; - if (!source) - return VOID; - - insn = alloc_typed_instruction(OP_PHISOURCE, type); - phi = __alloc_pseudo(0); phi->type = PSEUDO_PHI; phi->nr = ++nr; phi->def = insn; use_pseudo(insn, pseudo, &insn->phi_src); - insn->bb = source; insn->target = phi; + return insn; +} + +pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type) +{ + struct instruction *insn; + + if (!source) + return VOID; + + insn = alloc_phisrc(pseudo, type); + insn->bb = source; add_instruction(&source->insns, insn); - return phi; + return insn->target; } pseudo_t insert_phi_node(struct basic_block *bb, struct symbol *type) diff --git a/linearize.h b/linearize.h index a67f5b3e7..a550035d3 100644 --- a/linearize.h +++ b/linearize.h @@ -332,6 +332,7 @@ struct entrypoint { extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false); extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target); +struct instruction *alloc_phisrc(pseudo_t pseudo, struct symbol *type); pseudo_t insert_phi_node(struct basic_block *bb, struct symbol *type); pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type); pseudo_t alloc_pseudo(struct instruction *def);