[cfe-dev] OpenCL patch: vector literals
lattner at apple.com
Wed Jul 6 17:44:52 PDT 2011
I do not this is all necessary. All the support already exists for all the valid test cases except the last one ((float4)( float )). One just has to modify ActOnCastOfParenListExpr which is now BuildVectorLiteral to handle the splat case. I have not modified our patch to match the recent changes in TOT, but will do shortly.
For the invalid cases, I don't see why one needs to modify the parser, but the last invalid case does crash the compiler which shouldn't ever happen.
Also, I'd really appreciate if you didn't just remove regression tests. Yes, you are 100% right that the test violates the OpenCL spec (my mistake and haste in making a patch), but its catching a nasty compiler crash and I'd rather try to modify the test instead of just removing it. I've fixed this in TOT.
Lastly, please make sure any unrelated code is not included (ie. lib/Frontend/CompilerInvocation.cpp changes).
On Jun 30, 2011, at 5:04 AM, Anton Lokhmotov wrote:
> Please find attached the patch providing support for vector literals in
> 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,
> P.S. The quote below is on page 164 in opencl-1.1-rev44
>> 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.
>> 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
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev