From: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>
To: linux-sparse@vger.kernel.org
Cc: "Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
"Pekka Enberg" <penberg@kernel.org>,
"Christopher Li" <sparse@chrisli.org>,
"Jeff Garzik" <jgarzik@redhat.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Xi Wang" <xi.wang@gmail.com>
Subject: [PATCH 2/4] sparse, llvm: de-duplicate load/store address calculation code
Date: Sat, 18 May 2013 19:52:05 +0200 [thread overview]
Message-ID: <1368899527-2350-2-git-send-email-j.neuschaefer@gmx.net> (raw)
In-Reply-To: <1368899527-2350-1-git-send-email-j.neuschaefer@gmx.net>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
sparse-llvm.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/sparse-llvm.c b/sparse-llvm.c
index 837a96f..8573eda 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -598,10 +598,10 @@ static void output_op_ret(struct function *fn, struct instruction *insn)
LLVMBuildRetVoid(fn->builder);
}
-static void output_op_load(struct function *fn, struct instruction *insn)
+static LLVMValueRef calc_memop_addr(struct function *fn, struct instruction *insn)
{
LLVMTypeRef int_type;
- LLVMValueRef src_p, src_i, ofs_i, addr_i, addr, target;
+ LLVMValueRef src_p, src_i, ofs_i, addr_i, addr;
/* int type large enough to hold a pointer */
int_type = LLVMIntType(bits_in_pointer);
@@ -617,6 +617,16 @@ static void output_op_load(struct function *fn, struct instruction *insn)
addr = LLVMBuildIntToPtr(fn->builder, addr_i,
LLVMTypeOf(src_p), "addr");
+ return addr;
+}
+
+
+static void output_op_load(struct function *fn, struct instruction *insn)
+{
+ LLVMValueRef addr, target;
+
+ addr = calc_memop_addr(fn, insn);
+
/* perform load */
target = LLVMBuildLoad(fn->builder, addr, "load_target");
@@ -625,22 +635,9 @@ static void output_op_load(struct function *fn, struct instruction *insn)
static void output_op_store(struct function *fn, struct instruction *insn)
{
- LLVMTypeRef int_type;
- LLVMValueRef src_p, src_i, ofs_i, addr_i, addr, target, target_in;
-
- /* int type large enough to hold a pointer */
- int_type = LLVMIntType(bits_in_pointer);
-
- /* convert to integer, add src + offset */
- src_p = pseudo_to_value(fn, insn, insn->src);
- src_i = LLVMBuildPtrToInt(fn->builder, src_p, int_type, "src_i");
+ LLVMValueRef addr, target, target_in;
- ofs_i = LLVMConstInt(int_type, insn->offset, 0);
- addr_i = LLVMBuildAdd(fn->builder, src_i, ofs_i, "addr_i");
next prev parent reply other threads:[~2013-05-18 17:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-18 17:52 [PATCH 1/4] sparse, llvm: Fix resulting type of store address calculations Jonathan Neuschäfer
2013-05-18 17:52 ` Jonathan Neuschäfer [this message]
2013-05-18 17:52 ` [PATCH 3/4] sparse, llvm: base load/store address type on insn_symbol_type() Jonathan Neuschäfer
2013-05-18 22:45 ` Xi Wang
2013-05-19 0:17 ` Jonathan Neuschäfer
2013-05-18 17:52 ` [PATCH 4/4] sparse, llvm: add a struct access test case Jonathan Neuschäfer
2013-05-19 8:01 ` [PATCH 1/4] sparse, llvm: Fix resulting type of store address calculations Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1368899527-2350-2-git-send-email-j.neuschaefer@gmx.net \
--to=j.neuschaefer@gmx.net \
--cc=jgarzik@redhat.com \
--cc=linux-sparse@vger.kernel.org \
--cc=penberg@kernel.org \
--cc=sparse@chrisli.org \
--cc=torvalds@linux-foundation.org \
--cc=xi.wang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).