[cfe-commits] r40782 - /cfe/trunk/CodeGen/CGExpr.cpp
Chris Lattner
sabre at nondot.org
Fri Aug 3 09:37:04 PDT 2007
Author: lattner
Date: Fri Aug 3 11:37:04 2007
New Revision: 40782
URL: http://llvm.org/viewvc/llvm-project?rev=40782&view=rev
Log:
implement codegen for multidest ocuvector expressions, like:
vec2.yx = vec2; // reverse
Modified:
cfe/trunk/CodeGen/CGExpr.cpp
Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=40782&r1=40781&r2=40782&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Fri Aug 3 11:37:04 2007
@@ -427,16 +427,25 @@
llvm::Value *SrcVal = Src.getVal();
- // If the Src is a scalar (not a vector) it must be updating a single element.
- if (!Ty->isVectorType()) {
+ if (const VectorType *VTy = Ty->getAsVectorType()) {
+ unsigned NumSrcElts = VTy->getNumElements();
+
+ // Extract/Insert each element.
+ for (unsigned i = 0; i != NumSrcElts; ++i) {
+ llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
+ Elt = Builder.CreateExtractElement(SrcVal, Elt, "tmp");
+
+ unsigned Idx = OCUVectorComponent::getAccessedFieldNo(i, EncFields);
+ llvm::Value *OutIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Idx);
+ Vec = Builder.CreateInsertElement(Vec, Elt, OutIdx, "tmp");
+ }
+ } else {
+ // If the Src is a scalar (not a vector) it must be updating one element.
unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(0, EncFields);
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp");
- } else {
-
}
-
Builder.CreateStore(Vec, Dst.getOCUVectorAddr());
}
More information about the cfe-commits
mailing list