From patchwork Wed Aug 23 20:15:19 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: 9918265 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 DAD52602CB for ; Wed, 23 Aug 2017 20:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDB4828A2D for ; Wed, 23 Aug 2017 20:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C277C28A2C; Wed, 23 Aug 2017 20:16:27 +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 6355F28A2C for ; Wed, 23 Aug 2017 20:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932676AbdHWUQ1 (ORCPT ); Wed, 23 Aug 2017 16:16:27 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37090 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932443AbdHWUQ0 (ORCPT ); Wed, 23 Aug 2017 16:16:26 -0400 Received: by mail-wm0-f65.google.com with SMTP id v186so630590wmf.4 for ; Wed, 23 Aug 2017 13:16:26 -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=Fh6G/FOVylHYwRCpBrupBeJtHVGr6QiZY2Jtr3/bq8s=; b=qTGqo814ARKV1nlVULePJ2GJZhpn0wxkrKKLt/3kqEmTV7z3tqXhgMzs5x6qsxjymx S0sS44AZEWi4VxAI8kXa9TcDXodNWBxkJHVQIMa0mqmTVWw+fCLfN7+CMgtNZ9vqc/p4 3jPFHug5HjTRggLJ3H0kzBFkH+gulfgCDrA/lbD+DsrbsBML/GdhcqoT0NvgJl/C7Ve0 wUon2hxPtokldNWc1BvNdJnn2ZJp/RttUR3IpnnLZWbrrhPml07ghAZaVC25xrDTf9Cg yxZa0yKhXOe5vIhOjhqNEDVYxhakyw/j/exzFABz6aMexJHHvf5TvZzmRWjEl0MHFegY 3p0w== 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=Fh6G/FOVylHYwRCpBrupBeJtHVGr6QiZY2Jtr3/bq8s=; b=GiPTrYueE8K4FCfqKFqt8BiQRPluJdsmuINAqB0MVasI/Vz4Nkba7ryclBqGEh0tOk ggt8IBWr0iVCCeegtNxO8iDvmmcmet9MGVLSDxBJ8igCYGB3Mz47pagROg0QIBczbWIU JTUPLO1BTVqxj1VR34cMjLnOivopQ6SjuTWy+gvfeDhoC3GCeQ6qT2rTBW271MM19KjC GDC6yDHehC3mAj1WVQJCB+zIA09NkwyH7WbAf0qfRCc8+U6MdCkxQGVxmY9NekcRczYj nUbgGQm04x1LoabprusJbx2+oLiznc7A+8u+Uv4Sg0CLVII3zmnuUfqrTFb/GG0/F9jy KSPA== X-Gm-Message-State: AHYfb5j69C8A0+mnZONgovDNskpe92zxKC+jubyPA1xWE4OTaeD/0voA 4mmKkHng4t63cr1AJkE= X-Received: by 10.80.164.6 with SMTP id u6mr702907edb.250.1503519385183; Wed, 23 Aug 2017 13:16:25 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:4076:600:9020:103b:7912:3a40]) by smtp.gmail.com with ESMTPSA id e29sm1183374edd.88.2017.08.23.13.16.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 13:16:24 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [RFC PATCH 13/48] extract alloc_phisrc() from alloc_phi() Date: Wed, 23 Aug 2017 22:15:19 +0200 Message-Id: <20170823201554.90551-14-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.14.0 In-Reply-To: <20170823201554.90551-1-luc.vanoostenryck@gmail.com> References: <20170823201554.90551-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 4f4102af7..6cf97a42e 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);