[cfe-commits] [PATCH] OpenCL Kernel arg info metadata

Tanya Lattner lattner at apple.com
Wed Jul 11 16:02:44 PDT 2012


I made some of your changes suggested below, but kept a few that I felt strongly about. This is part of a bigger patch, so more to come.

Committed in r160092.

-Tanya

On Jun 28, 2012, at 8:32 AM, Anton Lokhmotov wrote:

> Hi Tanya,
> 
> Please see minor comments below.  Would it be possible for you to merge your
> patch after
> http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120625/059814.h
> tml?
> 
> Many thanks,
> Anton.
> 
> 
> +  unsigned EmitOpenCLArgMetadata : 1; /// Emit OpenCL kernel arg metadata.
> ///< Emit OpenCL kernel arg info metadata.
> (Note the opening angle bracket.)
> 
> 
> +// OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel arg
> +// information in the program executeable. The argument information store
> +// includes the argument name, its type, the address and access qualifiers
> used.
> arg -> argument
> executeable -> executable
> information store -> information stored
> 
> 
> +static void GenOpenCLArgMetaData(const FunctionDecl *FD, llvm::Function
> *Fn,
> GenOpenCLArgInfoMetadata (the only place where 'Metadata' is spelled as
> 'MetaData').
> 
> 
> +  // Create MDNodes that represents the kernel arg metadata.
> +  // Each MDNode is a list in the form of "key", N number of values which
> is
> +  // the same number of values as their are kernel arguments.
> // Create MDNodes that represent the kernel argument info.
> // Each MDNode is a list in the form of a key (e.g. "kernel_arg_names") 
> // followed by one metadata value per each kernel argument.
> 
> 
> +  // Metadata for arg name.
> +  SmallVector<llvm::Value*, 8> argNames;
> +  argNames.push_back(llvm::MDString::get(Context, "kernel_arg_name"));
> 
> // MDNode for the kernel argument names.
> SmallVector<llvm::Value*, 8> argNames;
> argNames.push_back(llvm::MDString::get(Context, "kernel_arg_names"));
> 
> 
> +  for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i) {
> +    
> +    const ParmVarDecl *parm = FD->getParamDecl(i);
> +    
> +    // Get arg name.
> +    argNames.push_back(llvm::MDString::get(Context, parm->getName()));
> +    
> +  }
> 
> How about shortening this to:
> 
>  for (unsigned i = 0, e = FD->getNumParams(); i != e; ++i)
>    argNames.push_back(llvm::MDString::get(Context, 
>                                           FD->getParamDecl(i)->getName()));
> 
> 
> 




More information about the cfe-commits mailing list