[cfe-dev] improved vector bool/pixel support
Douglas Gregor
dgregor at apple.com
Fri Aug 6 03:15:29 PDT 2010
On Aug 5, 2010, at 9:01 PM, Anton Yartsev wrote:
> On 05.08.2010 15:12, Douglas Gregor wrote:
>> On Aug 5, 2010, at 1:52 AM, Anton Yartsev wrote:
>>
>>> Added code for an implicit conversion between GCC and AltiVec vectors to Sema. Also attached tests with the relaxed vector conversions turned off. Please review.
>>>
>> Index: lib/Sema/SemaExpr.cpp
>> ===================================================================
>> --- lib/Sema/SemaExpr.cpp (revision 110284)
>> +++ lib/Sema/SemaExpr.cpp (working copy)
>> @@ -4751,13 +4751,18 @@
>> }
>>
>> if (lhsType->isVectorType() || rhsType->isVectorType()) {
>> - // If we are allowing lax vector conversions, and LHS and RHS are both
>> - // vectors, the total size only needs to be the same. This is a bitcast;
>> - // no bits are changed but the result type is different.
>> - if (getLangOptions().LaxVectorConversions&&
>> - lhsType->isVectorType()&& rhsType->isVectorType()) {
>> - if (Context.getTypeSize(lhsType) == Context.getTypeSize(rhsType))
>> + if (lhsType->isVectorType()&& rhsType->isVectorType()) {
>> + // If we are allowing lax vector conversions, and LHS and RHS are both
>> + // vectors, the total size only needs to be the same. This is a bitcast;
>> + // no bits are changed but the result type is different.
>> + if (getLangOptions().LaxVectorConversions&&
>> + (Context.getTypeSize(lhsType) == Context.getTypeSize(rhsType)))
>> return IncompatibleVectors;
>> +
>> + // Allow assignments of an AltiVec vector type to an equivalent GCC
>> + // vector type and vice versa
>> + if (Context.areCompatibleVectorTypes(lhsType, rhsType))
>> + return IncompatibleVectors;
>> }
>>
>> I don't think that you want a warning when converting between AltiVec and GCC vector types, do you? If no, the "return IncompatibleVectors;" should be "return Compatible;".
>>
>> Why does the C++ test use __attribute__((overloadable))? Actually, why does the C test use it? It doesn't seem necessary in either case.
>>
>> It might make sense to test the ? : operator, which often gives us trouble with conversions.
>>
>> - Doug
> Changed "return IncompatibleVectors" to "return Compatible".
>
> Hmm.. The attribute is absolutely useless in both cases..
> I used it in the C test to reach the IsVectorConversion() finction in SemaOverloaded.cpp, but there should be at least two overloaded candidates to reach the desired code.
>
> Added "?:" operator to tests, no troubles.
Looks great, thanks! Committed as r110437.
- Doug
More information about the cfe-dev
mailing list