From: Christopher Li <sparse@chrisli.org>
To: Jiri Slaby <jslaby@suse.cz>
Cc: Linux-Sparse <linux-sparse@vger.kernel.org>
Subject: Re: [PATCH 1/1] parser: add support for asm goto
Date: Thu, 10 Jun 2010 12:18:07 -0700 [thread overview]
Message-ID: <AANLkTikFMmCaTyACFgGGU84XxPUtpbfz0b3U67ZHj-jJ@mail.gmail.com> (raw)
In-Reply-To: <1276158810-21313-1-git-send-email-jslaby@suse.cz>
Hi Jirl,
Thank you for the patch. Over all looks good.
Can you add a validations test case for me? It would be great to see
sparse fail on the test case then your patch makes it work.
Some minor nitpick follows. If you are busy, just give me the test case,
I can do the rest of the change for you,
On Thu, Jun 10, 2010 at 1:33 AM, Jiri Slaby <jslaby@suse.cz> wrote:
> As of gcc 4.5, asm goto("jmp %l[label]" : OUT : IN : CLOB : LABELS) is
> supported. Add this support to the parser so that it won't choke on
> the newest Linux kernel when compiling with gcc 4.5.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
> ---
> evaluate.c | 8 ++++++++
> parse.c | 23 +++++++++++++++++++++++
> parse.h | 1 +
> 3 files changed, 32 insertions(+), 0 deletions(-)
>
> diff --git a/evaluate.c b/evaluate.c
> index 28bfd7c..5bb26df 100644
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -3149,6 +3149,7 @@ static void verify_input_constraint(struct expression *expr, const char *constra
> static void evaluate_asm_statement(struct statement *stmt)
> {
> struct expression *expr;
> + struct symbol *sym;
> int state;
>
> expr = stmt->asm_string;
> @@ -3225,6 +3226,13 @@ static void evaluate_asm_statement(struct statement *stmt)
> continue;
> expression_error(expr, "asm clobber is not a string");
> } END_FOR_EACH_PTR(expr);
> +
> + FOR_EACH_PTR(stmt->asm_labels, sym) {
> + if (!sym || sym->type != SYM_LABEL) {
> + sparse_error(stmt->pos, "bad asm label");
> + return;
> + }
> + } END_FOR_EACH_PTR(sym);
> }
>
> static void evaluate_case_statement(struct statement *stmt)
> diff --git a/parse.c b/parse.c
> index f81b19f..e292570 100644
> --- a/parse.c
> +++ b/parse.c
> @@ -1889,12 +1889,33 @@ static struct token *parse_asm_clobbers(struct token *token, struct statement *s
> return token;
> }
>
> +static struct token *parse_asm_labels(struct token *token, struct statement *stmt,
> + struct symbol_list **labels)
> +{
> + struct symbol *label;
What is the stmt argument doing here?
> +
> + do {
> + token = token->next; /* skip ':' and ',' */
I think it would be better to enter parse_asm_labels with ':' already
skipped. You can modify the caller do:
parse_asm_lablels(token->next).
It is tempting to make the function name as parse_label_list() because
without ':', there is nothing specific about asm any more. It is your
call.
The while loop can write as follows, with fewer break outs
and read better for me.
while (token_type(token) == TOKEN_IDENT) {
struct symbol *label = label_symbol(token);
add_symbol(lables, label);
token = token->next;
if (!match_op(token, ',')
break;
token = token->next;
}
> + if (token_type(token) != TOKEN_IDENT)
> + return token;
> + label = label_symbol(token);
> + add_symbol(labels, label);
> + token = token->next;
> + } while (match_op(token, ','));
> + return token;
> +}
> +
> static struct token *parse_asm_statement(struct token *token, struct statement *stmt)
> {
> + int is_goto = 0;
> +
> token = token->next;
> stmt->type = STMT_ASM;
> if (match_idents(token, &__volatile___ident, &__volatile_ident, &volatile_ident, NULL)) {
> token = token->next;
> + } else if (match_idents(token, &goto_ident, NULL)) {
match_idents is over kill here. You just need to do:
else if (token->ident == &goto_ident) {
> + is_goto = 1;
> + token = token->next;
> }
> token = expect(token, '(', "after asm");
> token = parse_expression(token, &stmt->asm_string);
> @@ -1904,6 +1925,8 @@ static struct token *parse_asm_statement(struct token *token, struct statement *
> token = parse_asm_operands(token, stmt, &stmt->asm_inputs);
> if (match_op(token, ':'))
> token = parse_asm_clobbers(token, stmt, &stmt->asm_clobbers);
> + if (is_goto && match_op(token, ':'))
> + token = parse_asm_labels(token, stmt, &stmt->asm_labels);
parse_asm_labels(token->next ....) to match previous change.
Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next parent reply other threads:[~2010-06-10 19:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1276158810-21313-1-git-send-email-jslaby@suse.cz>
2010-06-10 19:18 ` Christopher Li [this message]
2010-06-11 15:05 ` [PATCH 1/1] parser: add support for asm goto Jiri Slaby
2010-06-11 20:21 ` Christopher Li
2010-06-18 0:35 ` Christopher Li
2010-06-18 8:21 ` Jiri Slaby
2010-06-18 8:23 ` Jiri Slaby
2010-06-18 8:29 ` Jiri Slaby
2010-06-18 9:40 ` Christopher Li
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=AANLkTikFMmCaTyACFgGGU84XxPUtpbfz0b3U67ZHj-jJ@mail.gmail.com \
--to=sparse@chrisli.org \
--cc=jslaby@suse.cz \
--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).