From patchwork Mon Mar 27 21:24:02 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: 9647539 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 CDCB3601D7 for ; Mon, 27 Mar 2017 21:27:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF8DF20007 for ; Mon, 27 Mar 2017 21:27:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4799205FD; Mon, 27 Mar 2017 21:27:12 +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 40B4E1FF28 for ; Mon, 27 Mar 2017 21:27:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752476AbdC0V1M (ORCPT ); Mon, 27 Mar 2017 17:27:12 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33966 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752452AbdC0V1I (ORCPT ); Mon, 27 Mar 2017 17:27:08 -0400 Received: by mail-wr0-f195.google.com with SMTP id w43so14205292wrb.1 for ; Mon, 27 Mar 2017 14:27:07 -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=iVu9UhbW7RJw8V3iZqAJYovHjTOhB4Bg35snLbeweK0=; b=QLxH4cosPpHtI4zXYRqx/k72JBEFNeSo5P0uCCl9nDJpDM3lTP99pEkv5bDbaB6sqK z7ecPs4IvPPBJK60eSixyN3qWlv1j4e6RLr8cxyN7g8So1b8Jv6h3DpwGI+wzkJP8osm lJBiTDe0c2tKmK09OrSak5dkvq4kex/3QcHueSS1TH2yluhCPd4ctLmDKTUHPHrUub+1 Z7Qvkb7owYhF/us1X4M2bD0g1t+cz86ETpJZ8HSnvPDlX3q3fsyR/eodL1izHNb6QHZO xta2Ql2DwGwYvWASne/DcR+AOXwhUsaCAMde2VohM+4BtGzZtvE8njMksWBr/4TzSw/e W+bQ== 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=iVu9UhbW7RJw8V3iZqAJYovHjTOhB4Bg35snLbeweK0=; b=hj+r3stgeGAgx3ZyyVqj+sTqLPMH0nDn02eos72El/Le9Vg5WC8+zxJQKTI7UIN6ha 2C9PTabjzPZcRx2aXG/OhShFCeRHuaeUmTvOBE3inBmPbImy995jzeUemw62vmjTF7IC TLx53b86HP6BWhi/ipmgtZJUgFrA/JyLqDITJLCytlrBfKaDyOhPR4iIiQduchRUVSPF 79yY+3mCYdAplDsSGuWiKDpKDUslq9owiQP3DjeOez7/wDWY/8D01tpOPby+iWUNNcMB 7lfkHvKkzFSxKpYNk192W1dhuT6YmHfGrH3Bu5QqLPQC7uY4oSJEOcddOfePJmTvt6Cm Wo5Q== X-Gm-Message-State: AFeK/H2uoF/Ozsd2uw+Y7ruu443n8HSQchi0s207MmceOPLrDZpAj9xOD/4XuhS8GsAtMw== X-Received: by 10.223.150.88 with SMTP id c24mr10936014wra.202.1490650021693; Mon, 27 Mar 2017 14:27:01 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:802:b00:496:ae63:aebb:a034]) by smtp.gmail.com with ESMTPSA id k203sm973767wmk.4.2017.03.27.14.27.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 14:27:01 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH v6 38/52] llvm: introduce get_ioperand() Date: Mon, 27 Mar 2017 23:24:02 +0200 Message-Id: <20170327212416.18536-39-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170327212416.18536-1-luc.vanoostenryck@gmail.com> References: <20170327212416.18536-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 Signed-off-by: Luc Van Oostenryck --- sparse-llvm.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/sparse-llvm.c b/sparse-llvm.c index 58fe8e213..0c92eab23 100644 --- a/sparse-llvm.c +++ b/sparse-llvm.c @@ -456,6 +456,27 @@ static LLVMValueRef adjust_type(struct function *fn, struct symbol *ctype, LLVMV return val; } +/* + * Get the LLVMValue corresponding to the pseudo + * and force the type corresponding to ctype. + */ +static LLVMValueRef get_operand(struct function *fn, struct symbol *ctype, pseudo_t pseudo) +{ + LLVMValueRef target = pseudo_to_value(fn, ctype, pseudo); + return adjust_type(fn, ctype, target); +} + +/* + * Get the LLVMValue corresponding to the pseudo + * and force the type corresponding to ctype but + * map all pointers to intptr_t. + */ +static LLVMValueRef get_ioperand(struct function *fn, struct symbol *ctype, pseudo_t pseudo) +{ + LLVMValueRef target = pseudo_to_value(fn, ctype, pseudo); + return value_to_ivalue(fn, ctype, target); +} + static LLVMValueRef calc_gep(LLVMBuilderRef builder, LLVMValueRef base, LLVMValueRef off) { LLVMTypeRef type = LLVMTypeOf(base); @@ -515,11 +536,8 @@ static void output_op_binary(struct function *fn, struct instruction *insn) LLVMValueRef lhs, rhs, target; char target_name[64]; - lhs = pseudo_to_value(fn, insn->type, insn->src1); - lhs = value_to_ivalue(fn, insn->type, lhs); - - rhs = pseudo_to_value(fn, insn->type, insn->src2); - rhs = value_to_ivalue(fn, insn->type, rhs); + lhs = get_ioperand(fn, insn->type, insn->src1); + rhs = get_ioperand(fn, insn->type, insn->src2); pseudo_name(insn->target, target_name);