[cfe-commits] r45062 - in /cfe/trunk/CodeGen: CGBuiltin.cpp CGExprScalar.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Sat Dec 15 13:23:30 PST 2007
Author: andersca
Date: Sat Dec 15 15:23:30 2007
New Revision: 45062
URL: http://llvm.org/viewvc/llvm-project?rev=45062&view=rev
Log:
We now support all MMX intrinsics. SSE intrinsics are next.
Modified:
cfe/trunk/CodeGen/CGBuiltin.cpp
cfe/trunk/CodeGen/CGExprScalar.cpp
cfe/trunk/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=45062&r1=45061&r2=45062&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Sat Dec 15 15:23:30 2007
@@ -293,6 +293,12 @@
(i & 0x30) >> 4, (i & 0xc0) >> 6,
"pshufd");
}
+ case X86::BI__builtin_ia32_vec_init_v4hi:
+ case X86::BI__builtin_ia32_vec_init_v8qi:
+ case X86::BI__builtin_ia32_vec_init_v2si:
+ return EmitVector(&Ops[0], Ops.size());
+ case X86::BI__builtin_ia32_vec_ext_v2si:
+ return Builder.CreateExtractElement(Ops[0], Ops[1], "result");
}
}
Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=45062&r1=45061&r2=45062&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Sat Dec 15 15:23:30 2007
@@ -1099,3 +1099,37 @@
return Builder.CreateShuffleVector(V1, V2, Mask, Name);
}
+llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals,
+ unsigned NumVals)
+{
+ bool AllConstElements = true;
+
+ for (unsigned i = 0; i < NumVals; i++) {
+ if (!isa<llvm::Constant>(Vals[i])) {
+ AllConstElements = false;
+ break;
+ }
+ }
+
+ assert(!(NumVals & NumVals - 1) &&
+ "Number of elements must be power of two!");
+
+ if (AllConstElements) {
+ llvm::SmallVector<llvm::Constant*, 16> Constants;
+
+ for (unsigned i = 0, e = NumVals; i != e; ++i)
+ Constants.push_back(cast<llvm::Constant>(Vals[i]));
+
+ return llvm::ConstantVector::get(&Constants[0], Constants.size());
+ }
+
+ llvm::Value *Vec
+ = llvm::UndefValue::get(llvm::VectorType::get(Vals[0]->getType(), NumVals));
+
+ for (unsigned i = 0, e = NumVals ; i != e; ++i) {
+ llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, i);
+ Vec = Builder.CreateInsertElement(Vec, Vals[i], Idx, "tmp");
+ }
+
+ return Vec;
+}
Modified: cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.h?rev=45062&r1=45061&r2=45062&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.h Sat Dec 15 15:23:30 2007
@@ -392,7 +392,8 @@
llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
llvm::Value *EmitShuffleVector(llvm::Value* V1, llvm::Value *V2, ...);
-
+ llvm::Value *EmitVector(llvm::Value * const *Vals, unsigned NumVals);
+
llvm::Value *EmitObjCStringLiteral(const ObjCStringLiteral *E);
//===--------------------------------------------------------------------===//
More information about the cfe-commits
mailing list