Support of ++/-- for AltiVec vectors according to "C/C++ Language
Extensions for CBEA(Version 2.6)" section 10.3
--
Anton
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;
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();
Index: test/CodeGen/builtins-ppc-altivec.c
===================================================================
--- test/CodeGen/builtins-ppc-altivec.c (revision 120281)
+++ test/CodeGen/builtins-ppc-altivec.c (working copy)
@@ -3113,3 +3113,14 @@
res_i = (vf1 <= vf2); // CHECK:
@llvm.ppc.altivec.vcmpgefp.p(i32 2
res_i = (vf1 >= vf2); // CHECK:
@llvm.ppc.altivec.vcmpgefp.p(i32 2
}
+
+/* ------------------------------- increment/decrement:
----------------------------- */
+// CHECK: define void @test8
+void test8() {
+ vector int vi;
+ vi++; // CHECK: add nsw <4 x i32> {{.*}}
<i32 1, i32 1, i32 1, i32 1>
+ vector unsigned int vui;
+ --vui; // CHECK: add <4 x i32> {{.*}} <i32
-1, i32 -1, i32 -1, i32 -1>
+ vector float vf;
+ vf++; // CHECK: fadd <4 x float> {{.*}}
<float 1.000000e+000, float 1.000000e+000, float 1.000000e+000, float
1.000000e+000>
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits