From: Matthew Wilcox <matthew@wil.cx>
To: linux-sparse@vger.kernel.org
Subject: [PATCH] Add __builtin_popcountl
Date: Thu, 26 Oct 2006 11:47:30 -0600 [thread overview]
Message-ID: <20061026174730.GE5591@parisc-linux.org> (raw)
IA-64 uses __builtin_popcountl() which wasn't a function sparse knew
about. This patch adds it. I've never looked at sparse before, so this
is a hack-and-run job. Please feel free to rewrite it if it doesn't suit.
Signed-off-by: Matthew Wilcox <matthew@wil.cx>
diff --git a/symbol.c b/symbol.c
index 6c91112..388e19d 100644
--- a/symbol.c
+++ b/symbol.c
@@ -592,6 +592,29 @@ static int evaluate_choose(struct expres
return 1;
}
+static int arguments_popcountl(struct expression *expr)
+{
+ struct expression_list *arglist = expr->args;
+ struct expression *arg;
+ int i = 0;
+
+ FOR_EACH_PTR (arglist, arg) {
+ if (!evaluate_expression(arg))
+ return 0;
+ i++;
+ } END_FOR_EACH_PTR(arg);
+ if (i < 1) {
+ sparse_error(expr->pos,
+ "not enough arguments for __builtin_popcountl");
+ return 0;
+ } if (i > 1) {
+ sparse_error(expr->pos,
+ "too many arguments for __builtin_popcountl");
+ return 0;
+ }
+ return 1;
+}
+
static int expand_expect(struct expression *expr, int cost)
{
struct expression *arg = first_ptr_list((struct ptr_list *) expr->args);
@@ -744,6 +767,11 @@ static struct symbol_op choose_op = {
.args = arguments_choose,
};
+static struct symbol_op popcountl_op = {
+ .evaluate = evaluate_to_integer,
+ .args = arguments_popcountl,
+};
+
/*
* Builtin functions
*/
@@ -754,6 +782,7 @@ static struct sym_init eval_init_table[]
{ "__builtin_warning", &builtin_fn_type, MOD_TOPLEVEL, &warning_op },
{ "__builtin_expect", &builtin_fn_type, MOD_TOPLEVEL, &expect_op },
{ "__builtin_choose_expr", &builtin_fn_type, MOD_TOPLEVEL, &choose_op },
+ { "__builtin_popcountl", &builtin_fn_type, MOD_TOPLEVEL, &popcountl_op },
{ NULL, NULL, 0 }
};
next reply other threads:[~2006-10-26 17:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-26 17:47 Matthew Wilcox [this message]
2006-10-26 18:43 ` [PATCH] Add __builtin_popcountl Al Viro
2006-10-26 18:56 ` Linus Torvalds
2006-10-26 19:19 ` Al Viro
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=20061026174730.GE5591@parisc-linux.org \
--to=matthew@wil.cx \
--cc=linux-sparse@vger.kernel.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 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).