[cfe-dev] OpenCL patch: vector literals

Anton Lokhmotov Anton.Lokhmotov at arm.com
Thu Jun 30 05:04:37 PDT 2011


Please find attached the patch providing support for vector literals in
OpenCL.  

Two files with test cases are provided:
CodeGenOpenCL/vector_literals_valid.cl and
SemaOpenCL/vector_literals_invalid.cl.  One file is removed:
CodeGenOpenCL/2011-04-15-vec-init-from-vec.cl, because it contained invalid
OpenCL code (cast between vectors of different types: int2 and uchar8).

Please review!

Many thanks,
Anton.

P.S. The quote below is on page 164 in opencl-1.1-rev44
(http://www.khronos.org/registry/cl/specs/opencl-1.1.pdf).

> Date: Wed, 1 Jun 2011 11:13:10 +0200
> From: Alberto Magni <alberto.magni86 at gmail.com>
> Subject: Re: [cfe-dev] OpenCL vector initialization
> To: Anton.Lokhmotov at arm.com
> Cc: cfe-dev at cs.uiuc.edu
> Message-ID: <BANLkTik4ouTQ_WV--vnjNvBDmuj-cyYtMA at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> Ok, thank you Anton.
> 
> I'll wait for your patch.
> 
> Bye
> 
> 2011/6/1 Anton Lokhmotov <Anton.Lokhmotov at arm.com>:
> > Hi Alberto,
> >
> > Thanks for working on OpenCL support in Clang. It's an important
> > area we should aim to enable for the 3.0 release.
> >
> > The OpenCL requirement for vector literals is actually quite
> > involved.  To quote from a recent revision of the spec 
> > (to which you don't have access yet):
> >
> > "A vector literal is written as a parenthesized vector type followed
> > by a parenthesized comma delimited list of parameters. A vector 
> > literal operates as an overloaded function. The forms of the function
> > that are available is the set of possible argument lists for which all
> > arguments have the same element type as the result vector, and the 
> > total number of elements is equal to the number of elements in the 
> > result vector. In addition, a form with a single scalar of the same
> > type as the element type of the vector is available."
> >
> > "For example, the following forms are available for float4:
> > (float4)( float, float, float, float )
> > (float4)( float2, float, float )
> > (float4)( float, float2, float )
> > (float4)( float, float, float2 )
> > (float4)( float2, float2 )
> > (float4)( float3, float )
> > (float4)( float, float3 )
> > (float4)( float )"
> >
> > As I understand, your patch handles only the last case.  We are going 
> > to submit a patch shortly to accept valid cases and reject invalid
> > 
> > Thanks,
> > Anton.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arm-vector-literals.patch
Type: application/octet-stream
Size: 12371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110630/284458ed/attachment.obj>


More information about the cfe-dev mailing list