linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Ramsay Jones <ramsay@ramsayjones.plus.com>
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 03/12] builtin: make eval_sync_compare_and_swap() more generic
Date: Mon, 19 Oct 2020 06:59:42 +0200	[thread overview]
Message-ID: <20201019045942.jvjbfa25sn2hfnxb@ltop.local> (raw)
In-Reply-To: <728b9b1a-600a-ee81-a2cb-16c684124d0e@ramsayjones.plus.com>

On Sun, Oct 18, 2020 at 10:31:55PM +0100, Ramsay Jones wrote:
> On 17/10/2020 23:56, Luc Van Oostenryck wrote:
> > Most __sync_* or __atomic_* builtin functions have one or
> > more arguments having its real type determined by the first
> > argument: either the same type (a pointer to an integral type)
> > or the type of the object it points to.
> > 
> > Currently, only __sync_{bool,val}_compare_and_swap() are handled
> > but lots of very similar variants would be needed for the others.
> > So, make it a generic function, able to handle all these builtins.
> > 
> > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> > ---
> >  builtin.c | 47 +++++++++++++++++++++++++++++++----------------
> >  1 file changed, 31 insertions(+), 16 deletions(-)
> > 
> > diff --git a/builtin.c b/builtin.c
> > index 0d4cb12cca22..880dd54f647e 100644
> > --- a/builtin.c
> > +++ b/builtin.c
> > @@ -31,6 +31,14 @@
> >  #include "compat/bswap.h"
> >  #include <stdarg.h>
> >  
> > +#define dyntype incomplete_ctype
> > +static bool is_dynamic_type(struct symbol *t)
> > +{
> > +	if (t->type == SYM_NODE)
> > +		t = t->ctype.base_type;
> > +	return t == &dyntype;
> > +}
> > +
> >  static int evaluate_to_int_const_expr(struct expression *expr)
> >  {
> >  	expr->ctype = &int_ctype;
> > @@ -362,29 +370,32 @@ static struct symbol_op overflow_p_op = {
> >  };
> >  
> >  
> > -static int eval_sync_compare_and_swap(struct expression *expr)
> > +static int eval_atomic_common(struct expression *expr)
> >  {
> > +	struct symbol *fntype = expr->fn->ctype->ctype.base_type;
> >  	struct symbol_list *types = NULL;
> >  	struct symbol *ctype = NULL;
> > +	struct symbol *t;
> >  	struct expression *arg;
> >  	int n = 0;
> >  
> > -	/* the first arg is a pointer type; we'd already verified that */
> > +	// The number of arguments have already be verified.
> > +	// The first arg must be a pointer type to an integral type.
> 
> s/pointer type to/pointer to/
> (it just sounds odd, otherwise)
> or maybe ... must be a 'pointer to an integral' type. ?

Well, yes, it's a bit hard to express clearly. The real infos are:
* it must be a 'struct symbol *', the are used for any type, pointer or not
* the type represented by this 'struct symbol *' must indeed be a pointer :
  (first_args->type == SYM_PTR) to an integral type:
  (first_args->ctype.base_type = &int_ctype).
So yes, "must be a 'pointer to an integral' type. " seems to do the job.

Thanks
-- Luc

  reply	other threads:[~2020-10-19  4:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-17 22:56 [PATCH 00/12] fix and complete the evaluation of atomic builtins Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 01/12] builtin: add generic .args method Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 02/12] builtin: add builtin type for volatile void * Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 03/12] builtin: make eval_sync_compare_and_swap() more generic Luc Van Oostenryck
2020-10-18 21:31   ` Ramsay Jones
2020-10-19  4:59     ` Luc Van Oostenryck [this message]
2020-10-17 22:56 ` [PATCH 04/12] builtin: evaluate __sync_*_fetch*() Luc Van Oostenryck
2020-10-18 23:59   ` Ramsay Jones
2020-10-19  4:44     ` Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 05/12] builtin: fix evaluation of __sync_lock_release Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 06/12] builtin: __sync_synchronize() too is variadic Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 07/12] builtin: add predefines for __ATOMIC_RELAXED & friends Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 08/12] builtin: add support for __atomic_add_fetch(), Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 09/12] builtin: add support for others generic atomic builtins Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 10/12] builtin: add builtin type: [volatile] pointer to bool Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 11/12] builtin: add support for __atomic_clear() Luc Van Oostenryck
2020-10-17 22:56 ` [PATCH 12/12] builtin: add support for remaining atomic builtins 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=20201019045942.jvjbfa25sn2hfnxb@ltop.local \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=ramsay@ramsayjones.plus.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).