[cfe-commits] r91437 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/ext_vector_components.c

Daniel Dunbar daniel at zuster.org
Tue Dec 15 10:51:28 PST 2009


On Tue, Dec 15, 2009 at 10:33 AM, Douglas Gregor <dgregor at apple.com> wrote:
> On Dec 15, 2009, at 10:13 AM, Nate Begeman wrote:
>
>> Author: sampo
>> Date: Tue Dec 15 12:13:04 2009
>> New Revision: 91437
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=91437&view=rev
>> Log:
>> Support OpenCL 1.1 odd-length vector component accessors.
>>
>> For hi/odd of an odd-length vector, the last component is
>> undefined.  Since
>> we shuffle with an undef vector, no CodeGen needs to change to
>> support this.
>
> Do you want to differentiate between OpenCL 1.0 and 1.1? We could
> certainly have an OpenCL 1.1 dialect option, then diagnose this
> behavior as an extension if we're building for Open CL 1.0.

This seems like a worthwhile thing to do, even if just for tracking,
maintenance, and UI purposes.

 - Daniel

>        - Doug
>
>> Modified:
>>    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>    cfe/trunk/lib/Sema/SemaExpr.cpp
>>    cfe/trunk/test/Sema/ext_vector_components.c
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=91437&r1=91436&r2=91437&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> ======================================================================
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 15
>> 12:13:04 2009
>> @@ -639,8 +639,6 @@
>>   "unsupported type %0 for vector_size attribute, please use on
>> typedef">;
>> def err_ext_vector_component_exceeds_length : Error<
>>   "vector component access exceeds type %0">;
>> -def err_ext_vector_component_requires_even : Error<
>> -  "vector component access invalid for odd-sized type %0">;
>> def err_ext_vector_component_name_illegal : Error<
>>   "illegal vector component name '%0'">;
>> def err_attribute_address_space_not_int : Error<
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=91437&r1=91436&r2=91437&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> ======================================================================
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Dec 15 12:13:04 2009
>> @@ -2053,20 +2053,12 @@
>>     }
>>   }
>>
>> -  // If this is a halving swizzle, verify that the base type has an
>> even
>> -  // number of elements.
>> -  if (HalvingSwizzle && (vecType->getNumElements() & 1U)) {
>> -    Diag(OpLoc, diag::err_ext_vector_component_requires_even)
>> -      << baseType << SourceRange(CompLoc);
>> -    return QualType();
>> -  }
>> -
>>   // The component accessor looks fine - now we need to compute the
>> actual type.
>>   // The vector type is implied by the component accessor. For
>> example,
>>   // vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc.
>>   // vec4.s0 is a float, vec4.s23 is a vec3, etc.
>>   // vec4.hi, vec4.lo, vec4.e, and vec4.o all return vec2.
>> -  unsigned CompSize = HalvingSwizzle ? vecType->getNumElements() / 2
>> +  unsigned CompSize = HalvingSwizzle ? (vecType->getNumElements() +
>> 1) / 2
>>                                      : CompName->getLength();
>>   if (HexSwizzle)
>>     CompSize--;
>>
>> Modified: cfe/trunk/test/Sema/ext_vector_components.c
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/ext_vector_components.c?rev=91437&r1=91436&r2=91437&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> ======================================================================
>> --- cfe/trunk/test/Sema/ext_vector_components.c (original)
>> +++ cfe/trunk/test/Sema/ext_vector_components.c Tue Dec 15 12:13:04
>> 2009
>> @@ -26,8 +26,6 @@
>>     f = vec2.x; // legal, shorten
>>     f = vec4.xy.x; // legal, shorten
>>
>> -    vec2 = vec3.hi; // expected-error {{vector component access
>> invalid for odd-sized type 'float3'}}
>> -
>>     vec4_2.xyzx = vec4.xyzw; // expected-error {{vector is not
>> assignable (contains duplicate components)}}
>>     vec4_2.xyzz = vec4.xyzw; // expected-error {{vector is not
>> assignable (contains duplicate components)}}
>>     vec4_2.xyyw = vec4.xyzw; // expected-error {{vector is not
>> assignable (contains duplicate components)}}
>> @@ -42,3 +40,8 @@
>>
>>     vec4p->yz = vec4p->xy;
>> }
>> +
>> +float2 lo(float3 x) { return x.lo; }
>> +float2 hi(float3 x) { return x.hi; }
>> +float2 ev(float3 x) { return x.even; }
>> +float2 od(float3 x) { return x.odd; }
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list