On Mon, Nov 16, 2020 at 03:08:36PM +0100, Tobias Burnus wrote:
> as discussed the other day (I think via IRC or in a patch review),
>   omp_list_clauses
> did grow quite a bit: it has 26 entries and I am about to add two
> more.
> 
> This variable is used as:
>  typedef struct gfc_omp_clauses
>  {
>    ...
>    gfc_omp_namelist *lists[OMP_LIST_NUM];
> 
> with sizeof(gfc_omp_namelist) = 5*sizeof(void*) + sizeof(locus);
> 
> This patch replaces it with a linked list.
> 
> 
> I am not really sure the new version is that readable and whether
> we move into the right direction or not.

> --- a/gcc/fortran/gfortran.h
> +++ b/gcc/fortran/gfortran.h
> @@ -1240,7 +1240,7 @@ enum gfc_omp_linear_op
>  /* For use in OpenMP clauses in case we need extra information
>     (aligned clause alignment, linear clause step, etc.).  */
>  
> -typedef struct gfc_omp_namelist
> +typedef struct gfc_omp_namelist_item
>  {
>    struct gfc_symbol *sym;
>    struct gfc_expr *expr;
> @@ -1254,17 +1254,16 @@ typedef struct gfc_omp_namelist
>        bool lastprivate_conditional;
>      } u;
>    struct gfc_omp_namelist_udr *udr;
> -  struct gfc_omp_namelist *next;
> +  struct gfc_omp_namelist_item *next;
>    locus where;
>  }
> -gfc_omp_namelist;
> +gfc_omp_namelist_item;
> +#define gfc_get_omp_namelist_item() XCNEW (gfc_omp_namelist_item)
>  
> -#define gfc_get_omp_namelist() XCNEW (gfc_omp_namelist)
> -
> -enum
> +enum omp_list_clauses
>  {
> -  OMP_LIST_FIRST,
> -  OMP_LIST_PRIVATE = OMP_LIST_FIRST,
> +  OMP_LIST_UNSET,
> +  OMP_LIST_PRIVATE,
>    OMP_LIST_FIRSTPRIVATE,
>    OMP_LIST_LASTPRIVATE,
>    OMP_LIST_COPYPRIVATE,
> @@ -1289,8 +1288,7 @@ enum
>    OMP_LIST_IS_DEVICE_PTR,
>    OMP_LIST_USE_DEVICE_PTR,
>    OMP_LIST_USE_DEVICE_ADDR,
> -  OMP_LIST_NONTEMPORAL,
> -  OMP_LIST_NUM
> +  OMP_LIST_NONTEMPORAL
>  };
>  
>  /* Because a symbol can belong to multiple namelists, they must be
> @@ -1386,12 +1384,22 @@ enum gfc_omp_memorder
>    OMP_MEMORDER_RELAXED
>  };
>  
> +typedef struct gfc_omp_namelist
> +{
> +  enum omp_list_clauses clause;
> +  gfc_omp_namelist_item *item;
> +  struct gfc_omp_namelist *next;
> +}
> +gfc_omp_namelist;

I meant something slightly different, in particular not
this gfc_omp_namelist vs. gfc_omp_namelist_item (i.e. linked list of linked
lists), but just a linked list, i.e. just add
  ENUM_BITFIELD (enum omp_list_clauses) clause : 16;
  int flags : 16;
into gfc_omp_namelist where the flags could hold various flags for certain
clauses, e.g. for OMP_LIST_LASTPRIVATE it could hold the conditional
modifier, for OMP_LIST_REDUCTION the inscan and task modifiers, etc.
Or do you see any advantages in having the same clauses for different
symbols adjacent in the FE?

        Jakub

Reply via email to