diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-14 19:38:39 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-14 19:38:39 +0000 |
| commit | a1b4ed8003d4f8bde8b4d459b8002e7e21e88456 (patch) | |
| tree | e75ded96ab1d4cffc2e4e31f5c32e8345477d11c /clang/lib/CodeGen | |
| parent | 3ab94df276ea939f05fc2395876a06a2e73f5ad4 (diff) | |
| download | bcm5719-llvm-a1b4ed8003d4f8bde8b4d459b8002e7e21e88456.tar.gz bcm5719-llvm-a1b4ed8003d4f8bde8b4d459b8002e7e21e88456.zip | |
Implementation of __builtin_shufflevector, a portable builtin capable of
expressing the full flexibility of the LLVM shufflevector instruction.
The expected immediate usage is in *mmintrin.h, so that they don't
depend on the mess of gcc-inherited (and not completely implemented)
shuffle builtins.
llvm-svn: 51113
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 4fb69d045e3..bdd7975fa0c 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -127,6 +127,7 @@ public: Value *VisitObjCMessageExpr(ObjCMessageExpr *E); Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E);} Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E); + Value *VisitShuffleVectorExpr(ShuffleVectorExpr *E); Value *VisitMemberExpr(Expr *E) { return EmitLoadOfLValue(E); } Value *VisitExtVectorElementExpr(Expr *E) { return EmitLoadOfLValue(E); } Value *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { return EmitLoadOfLValue(E); } @@ -449,6 +450,17 @@ Value *ScalarExprEmitter::VisitExpr(Expr *E) { return llvm::UndefValue::get(CGF.ConvertType(E->getType())); } +Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { + llvm::SmallVector<llvm::Constant*, 32> indices; + for (unsigned i = 2; i < E->getNumSubExprs(); i++) { + indices.push_back(cast<llvm::Constant>(CGF.EmitScalarExpr(E->getExpr(i)))); + } + Value* V1 = CGF.EmitScalarExpr(E->getExpr(0)); + Value* V2 = CGF.EmitScalarExpr(E->getExpr(1)); + Value* SV = llvm::ConstantVector::get(indices.begin(), indices.size()); + return Builder.CreateShuffleVector(V1, V2, SV, "shuffle"); +} + Value *ScalarExprEmitter::VisitObjCMessageExpr(ObjCMessageExpr *E) { // Only the lookup mechanism and first two arguments of the method // implementation vary between runtimes. We can get the receiver and |

