On 24.01.2011 22:22, Douglas Gregor wrote:
> On Jan 22, 2011, at 4:32 AM, Anton Yartsev wrote:
>
>> On 14.12.2010 19:08, Douglas Gregor wrote:
>>> On Nov 28, 2010, at 7:56 PM, Anton Yartsev wrote:
>>>
>>>> Support of ++/-- for AltiVec vectors according to "C/C++ Language 
>>>> Extensions for CBEA(Version 2.6)" section 10.3
>>> A few comments.
>>>
>>> Index: lib/CodeGen/CGExprScalar.cpp
>>> ===================================================================
>>> --- lib/CodeGen/CGExprScalar.cpp    (revision 120239)
>>> +++ lib/CodeGen/CGExprScalar.cpp    (working copy)
>>> @@ -1257,10 +1257,11 @@
>>>       // An interesting aspect of this is that increment is always true.
>>>       // Decrement does not have this property.
>>>       NextVal = llvm::ConstantInt::getTrue(VMContext);
>>> -  } else if (isa<llvm::IntegerType>(InVal->getType())) {
>>> +  } else if (isa<llvm::IntegerType>(InVal->getType()) ||
>>> +             ValTy->isVectorType()&&   ValTy->hasIntegerRepresentation()) {
>>>       NextVal = llvm::ConstantInt::get(InVal->getType(), AmountVal);
>>> -
>>> -    if (!ValTy->isSignedIntegerType())
>>> +
>>> +    if (!ValTy->hasSignedIntegerRepresentation())
>>>         // Unsigned integer inc is always two's complement.
>>>         NextVal = Builder.CreateAdd(InVal, NextVal, isInc ? "inc" : "dec");
>>>       else {
>>> @@ -1292,6 +1293,8 @@
>>>         NextVal =
>>>         llvm::ConstantFP::get(VMContext,
>>>                               
>>> llvm::APFloat(static_cast<double>(AmountVal)));
>>> +    else if (ValTy->isVectorType()&&   ValTy->hasFloatingRepresentation())
>>> +      NextVal = llvm::ConstantFP::get(InVal->getType(), AmountVal);
>>>       else {
>>>         llvm::APFloat F(static_cast<float>(AmountVal));
>>>         bool ignored;
>>>
>>> This looks a bit tangled... please completely separate out the vector case, 
>>> rather than lumping it in with the integer case.
>>>
>>> Index: lib/Sema/SemaExpr.cpp
>>> ===================================================================
>>> --- lib/Sema/SemaExpr.cpp   (revision 120239)
>>> +++ lib/Sema/SemaExpr.cpp   (working copy)
>>> @@ -6931,6 +6931,8 @@
>>>       if (PR.isInvalid()) return QualType();
>>>       return CheckIncrementDecrementOperand(S, PR.take(), VK, OpLoc,
>>>                                             isInc, isPrefix);
>>> +  } else if (ResType->isVectorType()&&   S.getLangOptions().AltiVec) {
>>> +    // OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
>>>     } else {
>>>       S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
>>>         <<   ResType<<   int(isInc)<<   Op->getSourceRange();
>>>
>>> Please check S.getLangOptions().AltiVec first, since the isVectorType() 
>>> check is more expensive.
>>>
>>> Could you add some test cases that ensure that ++ and -- on vectors work 
>>> properly in C++? Things to consider:
>>>     - Test that the result is an lvalue, such that you can assign to it,  
>>> assign to its components, etc.
>>>     - Test that ++/-- work in templates, both with an arbitrary type 'T' 
>>> that gets instantiated to an AltiVec vector, and when we have an AltiVec 
>>> vector of dependent size (e.g., the size is N, a non-type template 
>>> parameter of type unsigned).
>>>
>>>     - Doug
>> Here is the new patch.
> Looks good, thanks! I've forgotten: do you have commit access?
>
>> Took into account the comments, but have not got how to create AltiVec 
>> vector of dependent size. Did you mean creating gcc vector with the 
>> vector_size attribute?
>
> I was thinking of:
>
> template<int N>
> struct X {
>    typedef float type __attribute__((ext_vector_type(N)));
> };
>
> X<4>::type v = { 1, 2, 3, 4};
>
> But I've completely forgotten how or if ext_vector_type relates to AltiVec 
> vectors! ;)
>
>       - Doug
Commited at 124146!

-- 
Anton

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to