All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH v5 05/14] add is_signed_type()
Date: Sat, 25 Mar 2017 00:14:12 +0100	[thread overview]
Message-ID: <20170324231421.14869-6-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170324231421.14869-1-luc.vanoostenryck@gmail.com>

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 compile-i386.c | 14 ++------------
 show-parse.c   | 11 +----------
 symbol.h       |  9 +++++++++
 3 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/compile-i386.c b/compile-i386.c
index 44b72ec39..a7db0843d 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -192,7 +192,6 @@ static const char *current_section;
 static void emit_comment(const char * fmt, ...) FORMAT_ATTR(1);
 static void emit_move(struct storage *src, struct storage *dest,
 		      struct symbol *ctype, const char *comment);
-static int type_is_signed(struct symbol *sym);
 static struct storage *x86_address_gen(struct expression *expr);
 static struct storage *x86_symbol_expr(struct symbol *sym);
 static void x86_symbol(struct symbol *sym);
@@ -1165,7 +1164,7 @@ static void emit_move(struct storage *src, struct storage *dest,
 
 	if (ctype) {
 		bits = ctype->bit_size;
-		is_signed = type_is_signed(ctype);
+		is_signed = is_signed_type(ctype);
 	} else {
 		bits = 32;
 		is_signed = 0;
@@ -1357,7 +1356,7 @@ static struct storage *emit_binop(struct expression *expr)
 	if ((expr->op == '/') || (expr->op == '%'))
 		return emit_divide(expr, left, right);
 
-	is_signed = type_is_signed(expr->ctype);
+	is_signed = is_signed_type(expr->ctype);
 
 	switch (expr->op) {
 	case '+':
@@ -2266,15 +2265,6 @@ static void x86_symbol_init(struct symbol *sym)
 	priv->addr = new;
 }
 
-static int type_is_signed(struct symbol *sym)
-{
-	if (sym->type == SYM_NODE)
-		sym = sym->ctype.base_type;
-	if (sym->type == SYM_PTR)
-		return 0;
-	return !(sym->ctype.modifiers & MOD_UNSIGNED);
-}
-
 static struct storage *x86_label_expr(struct expression *expr)
 {
 	struct storage *new = stack_alloc(4);
diff --git a/show-parse.c b/show-parse.c
index d365d737f..b6ab7b3db 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -949,15 +949,6 @@ static int show_symbol_init(struct symbol *sym)
 	return 0;
 }
 
-static int type_is_signed(struct symbol *sym)
-{
-	if (sym->type == SYM_NODE)
-		sym = sym->ctype.base_type;
-	if (sym->type == SYM_PTR)
-		return 0;
-	return !(sym->ctype.modifiers & MOD_UNSIGNED);
-}
-
 static int show_cast_expr(struct expression *expr)
 {
 	struct symbol *old_type, *new_type;
@@ -973,7 +964,7 @@ static int show_cast_expr(struct expression *expr)
 	if (oldbits >= newbits)
 		return op;
 	new = new_pseudo();
-	is_signed = type_is_signed(old_type);
+	is_signed = is_signed_type(old_type);
 	if (is_signed) {
 		printf("\tsext%d.%d\tv%d,v%d\n", oldbits, newbits, new, op);
 	} else {
diff --git a/symbol.h b/symbol.h
index 36f8345b5..0621d36d7 100644
--- a/symbol.h
+++ b/symbol.h
@@ -335,6 +335,15 @@ static inline int is_enum_type(const struct symbol *type)
 	return (type->type == SYM_ENUM);
 }
 
+static inline int is_signed_type(struct symbol *sym)
+{
+	if (sym->type == SYM_NODE)
+		sym = sym->ctype.base_type;
+	if (sym->type == SYM_PTR)
+		return 0;
+	return !(sym->ctype.modifiers & MOD_UNSIGNED);
+}
+
 static inline int is_type_type(struct symbol *type)
 {
 	return (type->ctype.modifiers & MOD_TYPE) != 0;
-- 
2.12.0


  parent reply	other threads:[~2017-03-24 23:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 23:14 [PATCH 00/14] prepare LLVM fixes Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 01/14] don't output value of anonymous symbol's pointer Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 02/14] canonicalize binops before simplification Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 03/14] canonicalize compare instructions Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 04/14] rewrite compare_opcode() like swap_compare_opcode() Luc Van Oostenryck
2017-03-24 23:24   ` Linus Torvalds
2017-03-24 23:54     ` Luc Van Oostenryck
2017-03-25 23:35       ` Christopher Li
2017-03-26  0:22         ` Luc Van Oostenryck
2017-03-27 16:29         ` Luc Van Oostenryck
2017-03-24 23:14 ` Luc Van Oostenryck [this message]
2017-03-24 23:14 ` [PATCH v5 06/14] fix usage of inlined calls Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 07/14] inlined calls should not block BB packing Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 08/14] give function's arguments a type via OP_PUSH Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 09/14] insure that all OP_PUSHs are just before their OP_CALL Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 10/14] give a type to OP_PHISOURCEs Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 11/14] give a type to OP_SELs, always Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 12/14] give a type to OP_SWITCHs Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 13/14] add doc about sparse's instructions/IR Luc Van Oostenryck
2017-03-24 23:14 ` [PATCH v5 14/14] add support for wider type in switch-case Luc Van Oostenryck

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=20170324231421.14869-6-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.