[PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 16 03:37:02 PDT 2016


Anastasia added a comment.

In https://reviews.llvm.org/D23086#515590, @yaxunl wrote:

> In https://reviews.llvm.org/D23086#515506, @Anastasia wrote:
>
> >
>
>
>
>
> > Surely vendors can re-implement all OpenCL types with an implicit typedef. For example this would just work:
>
> > 
>
> >   typedef int queue_t;
>
> >   void bar(queue_t q);
>
> >    
>
> > 
>
> > I am afraid we will need to provide some implementation to ndrange_t in Clang itself, otherwise I don't see how it could work. Also it would be good to offer standard functionality without any extra includes just like it worked up to now for all other features.
>
>
> It will work if we have a way to identify whether a type is ndrange_t type. So far I have suggested to compare the canonical types. Basically when we see a declaration of typedef with name 'ndrange_t', we save its canonical type X to ASTContext. When we need to check if type Y is ndrange_t, we just need to check Y->getCanonicalType() == X.
>
> On the other hand, pre-define ndrange_t in Clang does not solve the problem of how to decide if a type is ndrange_t, since user can define typedefs for ndrange_t, e.g.
>
>   typedef ndrange_t my_ndrange_t;
>   
>
> In this case, we still need to check the canonical type.


Why not to just identify the type by the name? It seems much easier and also gives flexibility to implement the type in different ways if needed. Considering that similar approach is already used for some C++ types, it should be fine.


Repository:
  rL LLVM

https://reviews.llvm.org/D23086





More information about the cfe-commits mailing list