CGBuiltin.cpp revision 2c62a1aa398d5582db00d2bad6b2d999ee50ec14
1022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson//===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===// 2022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// 3022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// The LLVM Compiler Infrastructure 4022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 7022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// 8022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson//===----------------------------------------------------------------------===// 9022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// 10022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// This contains code to emit Builtin calls as LLVM code. 11022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson// 12022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson//===----------------------------------------------------------------------===// 13022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson 14022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson#include "CodeGenFunction.h" 15022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson#include "CodeGenModule.h" 16ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson#include "clang/Basic/TargetInfo.h" 17bef20ac367a09555b30d6eb3847a81ec164caf88Chris Lattner#include "clang/AST/ASTContext.h" 18022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson#include "clang/AST/Builtins.h" 19022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson#include "clang/AST/Expr.h" 20564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson#include "clang/AST/TargetBuiltins.h" 216de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner#include "llvm/Constants.h" 22c5e940fa551840ecd71e8116c316c9131490f5faChris Lattner#include "llvm/Function.h" 23793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson#include "llvm/Intrinsics.h" 24022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlssonusing namespace clang; 25022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlssonusing namespace CodeGen; 26ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlssonusing namespace llvm; 27ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 286de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris LattnerRValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { 296de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner switch (BuiltinID) { 30ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson default: { 31c5e940fa551840ecd71e8116c316c9131490f5faChris Lattner if (getContext().BuiltinInfo.isLibFunction(BuiltinID)) 32eed50586435ce4d2690f44ceabd69ad531d80970Nate Begeman return EmitCallExpr(CGM.getBuiltinLibFunction(BuiltinID), 335193b8a3e57c4f696161aeddfe8227c294c0a7feEli Friedman E->getCallee()->getType(), E->arg_begin(), 345193b8a3e57c4f696161aeddfe8227c294c0a7feEli Friedman E->getNumArgs()); 35ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 36ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson // See if we have a target specific intrinsic. 371feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Intrinsic::ID IntrinsicID; 38ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson const char *TargetPrefix = Target.getTargetPrefix(); 39ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson const char *BuiltinName = getContext().BuiltinInfo.GetName(BuiltinID); 40ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson#define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN 41ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson#include "llvm/Intrinsics.gen" 42ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson#undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN 43ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 44ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson if (IntrinsicID != Intrinsic::not_intrinsic) { 451feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner SmallVector<Value*, 16> Args; 46ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 477acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner Function *F = CGM.getIntrinsic(IntrinsicID); 48ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson const llvm::FunctionType *FTy = F->getFunctionType(); 49ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 50ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) { 511feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *ArgValue = EmitScalarExpr(E->getArg(i)); 52ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 53ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson // If the intrinsic arg type is different from the builtin arg type 54ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson // we need to do a bit cast. 55ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson const llvm::Type *PTy = FTy->getParamType(i); 56ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson if (PTy != ArgValue->getType()) { 57ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson assert(PTy->canLosslesslyBitCastTo(FTy->getParamType(i)) && 58ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson "Must be able to losslessly bit cast to param"); 59ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson ArgValue = Builder.CreateBitCast(ArgValue, PTy); 60ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson } 61ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 62ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson Args.push_back(ArgValue); 63ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson } 64ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 651feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *V = Builder.CreateCall(F, &Args[0], &Args[0] + Args.size()); 66ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson QualType BuiltinRetType = E->getType(); 67ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 681feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner const llvm::Type *RetTy = llvm::Type::VoidTy; 691feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner if (!BuiltinRetType->isVoidType()) RetTy = ConvertType(BuiltinRetType); 70ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 71ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson if (RetTy != V->getType()) { 72ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson assert(V->getType()->canLosslesslyBitCastTo(RetTy) && 73ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson "Must be able to losslessly bit cast result type"); 74ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson V = Builder.CreateBitCast(V, RetTy); 75ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson } 76ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson 77ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson return RValue::get(V); 78ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson } 79564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson 80564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson // See if we have a target specific builtin that needs to be lowered. 811feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *V = 0; 82564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson 83564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson if (strcmp(TargetPrefix, "x86") == 0) 84564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson V = EmitX86BuiltinExpr(BuiltinID, E); 85564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson else if (strcmp(TargetPrefix, "ppc") == 0) 86564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson V = EmitPPCBuiltinExpr(BuiltinID, E); 87564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson 88564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson if (V) 89564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson return RValue::get(V); 90c5e940fa551840ecd71e8116c316c9131490f5faChris Lattner 91dc4d280136d3301fcbf3c7b4b2782c8bd804342cChris Lattner WarnUnsupported(E, "builtin function"); 926de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner 936de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner // Unknown builtin, for now just dump it out and return undef. 946de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner if (hasAggregateLLVMType(E->getType())) 956de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner return RValue::getAggregate(CreateTempAlloca(ConvertType(E->getType()))); 961feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner return RValue::get(UndefValue::get(ConvertType(E->getType()))); 97ca6fcfad547dcec3fdd17790b4fab0918df74b37Anders Carlsson } 986de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner case Builtin::BI__builtin___CFStringMakeConstantString: { 996de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner const Expr *Arg = E->getArg(0); 1006de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner 101d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson while (1) { 102d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson if (const ParenExpr *PE = dyn_cast<ParenExpr>(Arg)) 103d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson Arg = PE->getSubExpr(); 104d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson else if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(Arg)) 105d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson Arg = CE->getSubExpr(); 106d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson else 107d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson break; 108d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson } 1096de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner 1106de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner const StringLiteral *Literal = cast<StringLiteral>(Arg); 1116de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner std::string S(Literal->getStrData(), Literal->getByteLength()); 1126de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner 1136de93ff81c5fe89b96a589ef13ea2beb4d7c3775Chris Lattner return RValue::get(CGM.GetAddrOfConstantCFString(S)); 114793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson } 115793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson case Builtin::BI__builtin_va_start: 116793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson case Builtin::BI__builtin_va_end: { 1171feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *ArgValue = EmitScalarExpr(E->getArg(0)); 118ddc23f3e6fdc4f83dd46ef7e20394cfbd6063ff9Christopher Lamb const llvm::Type *DestType = 119ddc23f3e6fdc4f83dd46ef7e20394cfbd6063ff9Christopher Lamb llvm::PointerType::getUnqual(llvm::Type::Int8Ty); 120793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson if (ArgValue->getType() != DestType) 121793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson ArgValue = Builder.CreateBitCast(ArgValue, DestType, 122793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson ArgValue->getNameStart()); 123793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson 1241feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Intrinsic::ID inst = (BuiltinID == Builtin::BI__builtin_va_start) ? 1251feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Intrinsic::vastart : Intrinsic::vaend; 1267acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return RValue::get(Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue)); 127793680ed8104bf088d1b382b963a8badcb3f07deAnders Carlsson } 128a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson case Builtin::BI__builtin_va_copy: { 129a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson // FIXME: This does not yet handle architectures where va_list is a struct. 130a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson Value *DstPtr = EmitScalarExpr(E->getArg(0)); 131a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson Value *SrcValue = EmitScalarExpr(E->getArg(1)); 132a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson 133a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson Value *SrcPtr = CreateTempAlloca(SrcValue->getType(), "dst_ptr"); 134a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson 135a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson // FIXME: Volatile 136a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson Builder.CreateStore(SrcValue, SrcPtr, false); 137a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson 138a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson const llvm::Type *Type = 139a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson llvm::PointerType::getUnqual(llvm::Type::Int8Ty); 140a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson 141a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson DstPtr = Builder.CreateBitCast(DstPtr, Type); 142a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson SrcPtr = Builder.CreateBitCast(SrcPtr, Type); 143a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson Value *Args[] = { DstPtr, SrcPtr }; 144a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson return RValue::get(Builder.CreateCall(CGM.getIntrinsic(Intrinsic::vacopy), 145a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson &Args[0], &Args[2])); 146a28ef8b5c6ea452472d89041128fac8b683fe968Anders Carlsson } 14789799cf254c91ca110f113a33eebe8b1b4d1a761Anders Carlsson case Builtin::BI__builtin_classify_type: { 1481feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner APSInt Result(32); 14989799cf254c91ca110f113a33eebe8b1b4d1a761Anders Carlsson if (!E->isBuiltinClassifyType(Result)) 15089799cf254c91ca110f113a33eebe8b1b4d1a761Anders Carlsson assert(0 && "Expr not __builtin_classify_type!"); 1511feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner return RValue::get(ConstantInt::get(Result)); 15289799cf254c91ca110f113a33eebe8b1b4d1a761Anders Carlsson } 153d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson case Builtin::BI__builtin_constant_p: { 1541feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner APSInt Result(32); 155d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson // FIXME: Analyze the parameter and check if it is a constant. 156d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson Result = 0; 1571feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner return RValue::get(ConstantInt::get(Result)); 158d6a275f9a27d1c91e4084398d04030719b5b8f18Anders Carlsson } 159c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson case Builtin::BI__builtin_abs: { 1601feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *ArgValue = EmitScalarExpr(E->getArg(0)); 161c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson 162c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson llvm::BinaryOperator *NegOp = 163c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson Builder.CreateNeg(ArgValue, (ArgValue->getName() + "neg").c_str()); 1641feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *CmpResult = 165c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson Builder.CreateICmpSGE(ArgValue, NegOp->getOperand(0), "abscond"); 1661feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *Result = 167c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson Builder.CreateSelect(CmpResult, ArgValue, NegOp, "abs"); 168c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson 169c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson return RValue::get(Result); 170c2251dc59b0edc28f9303637dec970a7520939adAnders Carlsson } 1713a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson case Builtin::BI__builtin_ctz: 1723a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson case Builtin::BI__builtin_ctzl: 1733a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson case Builtin::BI__builtin_ctzll: { 1743a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson Value *ArgValue = EmitScalarExpr(E->getArg(0)); 1753a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson 1763a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson const llvm::Type *ArgType = ArgValue->getType(); 1773a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson Value *F = CGM.getIntrinsic(Intrinsic::cttz, &ArgType, 1); 1783a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson 1793a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson const llvm::Type *ResultType = ConvertType(E->getType()); 1803a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson Value *Result = Builder.CreateCall(F, ArgValue, "tmp"); 1813a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson if (Result->getType() != ResultType) 1823a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson Result = Builder.CreateIntCast(Result, ResultType, "cast"); 1833a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson return RValue::get(Result); 1843a31d60cffedfb7c9e6d129a5c9ba15fa74f179aAnders Carlsson } 1851feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner case Builtin::BI__builtin_expect: 1861feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner return RValue::get(EmitScalarExpr(E->getArg(0))); 187df4852ac816e6050d53b808b86d7c1c9738eb99eAnders Carlsson case Builtin::BI__builtin_bswap32: 188df4852ac816e6050d53b808b86d7c1c9738eb99eAnders Carlsson case Builtin::BI__builtin_bswap64: { 1891feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner Value *ArgValue = EmitScalarExpr(E->getArg(0)); 190df4852ac816e6050d53b808b86d7c1c9738eb99eAnders Carlsson const llvm::Type *ArgType = ArgValue->getType(); 1917acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner Value *F = CGM.getIntrinsic(Intrinsic::bswap, &ArgType, 1); 1921feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner return RValue::get(Builder.CreateCall(F, ArgValue, "tmp")); 193df4852ac816e6050d53b808b86d7c1c9738eb99eAnders Carlsson } 194c8ee7988c4ea9ec784625d2a47a8575feb191421Anders Carlsson case Builtin::BI__builtin_inff: { 1951feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner APFloat f(APFloat::IEEEsingle, APFloat::fcInfinity, false); 1962c62a1aa398d5582db00d2bad6b2d999ee50ec14Chris Lattner return RValue::get(ConstantFP::get(f)); 197c8ee7988c4ea9ec784625d2a47a8575feb191421Anders Carlsson } 198478547cd2163d86ed9d691aa8fe45949eebf6cbfAnders Carlsson case Builtin::BI__builtin_huge_val: 199c8ee7988c4ea9ec784625d2a47a8575feb191421Anders Carlsson case Builtin::BI__builtin_inf: 200c8ee7988c4ea9ec784625d2a47a8575feb191421Anders Carlsson // FIXME: mapping long double onto double. 201c8ee7988c4ea9ec784625d2a47a8575feb191421Anders Carlsson case Builtin::BI__builtin_infl: { 2021feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner APFloat f(APFloat::IEEEdouble, APFloat::fcInfinity, false); 2032c62a1aa398d5582db00d2bad6b2d999ee50ec14Chris Lattner return RValue::get(ConstantFP::get(f)); 204c8ee7988c4ea9ec784625d2a47a8575feb191421Anders Carlsson } 205fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isgreater: 206fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isgreaterequal: 207fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isless: 208fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_islessequal: 209fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_islessgreater: 210fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isunordered: { 211fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner // Ordered comparisons: we know the arguments to these are matching scalar 212fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner // floating point values. 213fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner Value *LHS = EmitScalarExpr(E->getArg(0)); 214fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner Value *RHS = EmitScalarExpr(E->getArg(1)); 215fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner 216fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner switch (BuiltinID) { 217fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner default: assert(0 && "Unknown ordered comparison"); 218fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isgreater: 219fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner LHS = Builder.CreateFCmpOGT(LHS, RHS, "cmp"); 220fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner break; 221fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isgreaterequal: 222fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner LHS = Builder.CreateFCmpOGE(LHS, RHS, "cmp"); 223fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner break; 224fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isless: 225fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner LHS = Builder.CreateFCmpOLT(LHS, RHS, "cmp"); 226fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner break; 227fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_islessequal: 228fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner LHS = Builder.CreateFCmpOLE(LHS, RHS, "cmp"); 229fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner break; 230fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_islessgreater: 231fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner LHS = Builder.CreateFCmpONE(LHS, RHS, "cmp"); 232fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner break; 233fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner case Builtin::BI__builtin_isunordered: 234fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner LHS = Builder.CreateFCmpUNO(LHS, RHS, "cmp"); 235fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner break; 236fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner } 237fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner // ZExt bool to int type. 238fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner return RValue::get(Builder.CreateZExt(LHS, ConvertType(E->getType()), 239fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner "tmp")); 240fe23e217774aaec350086fab839210d7d9e1e3f4Chris Lattner } 2414efe45919836728a2a38a50b8d79cd36432e1708Nate Begeman case Builtin::BI__builtin_alloca: 2424efe45919836728a2a38a50b8d79cd36432e1708Nate Begeman return RValue::get(Builder.CreateAlloca(llvm::Type::Int8Ty, 2434efe45919836728a2a38a50b8d79cd36432e1708Nate Begeman EmitScalarExpr(E->getArg(0)), 2444efe45919836728a2a38a50b8d79cd36432e1708Nate Begeman "tmp")); 245022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson } 246022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson return RValue::get(0); 247022012e6e5626c3372e1a5493c0929dfc1fa9e47Anders Carlsson} 248564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson 2491feedd84221e8dbcc3faf3de27cc42b559db845dChris LattnerValue *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, 2501feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner const CallExpr *E) { 2512929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson 2522929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson llvm::SmallVector<Value*, 4> Ops; 2532929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson 2542929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) 2552929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson Ops.push_back(EmitScalarExpr(E->getArg(i))); 2562929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson 257564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson switch (BuiltinID) { 25846a26b0b0e2ec1557bad9b70e8e20836524ebdfcAnders Carlsson default: return 0; 25946a26b0b0e2ec1557bad9b70e8e20836524ebdfcAnders Carlsson case X86::BI__builtin_ia32_mulps: 2602929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson return Builder.CreateMul(Ops[0], Ops[1], "mulps"); 261e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_mulpd: 262e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateMul(Ops[0], Ops[1], "mulpd"); 2634e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_pand: 264e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pand128: 2652929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson return Builder.CreateAnd(Ops[0], Ops[1], "pand"); 2664e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_por: 267e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_por128: 268e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateOr(Ops[0], Ops[1], "por"); 2694e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_pxor: 270e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pxor128: 271e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateXor(Ops[0], Ops[1], "pxor"); 272e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pandn: 273e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pandn128: 2742929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson Ops[0] = Builder.CreateNot(Ops[0], "tmp"); 2752929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson return Builder.CreateAnd(Ops[0], Ops[1], "pandn"); 2764e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_paddb: 277e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_paddb128: 2784e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_paddd: 279e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_paddd128: 2804e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_paddq: 281e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_paddq128: 2824e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_paddw: 283e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_paddw128: 284cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_addps: 285e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_addpd: 286cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return Builder.CreateAdd(Ops[0], Ops[1], "add"); 2874e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_psubb: 288e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psubb128: 2894e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_psubd: 290e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psubd128: 2914e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_psubq: 292e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psubq128: 2934e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson case X86::BI__builtin_ia32_psubw: 294e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psubw128: 295cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_subps: 296e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_subpd: 297cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return Builder.CreateSub(Ops[0], Ops[1], "sub"); 298cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_divps: 299cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return Builder.CreateFDiv(Ops[0], Ops[1], "divps"); 300e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_divpd: 301e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateFDiv(Ops[0], Ops[1], "divpd"); 302db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_pmullw: 303e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pmullw128: 3042929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson return Builder.CreateMul(Ops[0], Ops[1], "pmul"); 305db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_punpckhbw: 3067acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return EmitShuffleVector(Ops[0], Ops[1], 4, 12, 5, 13, 6, 14, 7, 15, 307db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson "punpckhbw"); 308e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_punpckhbw128: 309e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 8, 24, 9, 25, 10, 26, 11, 27, 310e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 12, 28, 13, 29, 14, 30, 15, 31, 311e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman "punpckhbw"); 312db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_punpckhwd: 3137acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return EmitShuffleVector(Ops[0], Ops[1], 2, 6, 3, 7, "punpckhwd"); 314e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_punpckhwd128: 315e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 4, 12, 5, 13, 6, 14, 7, 15, 316e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman "punpckhwd"); 317db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_punpckhdq: 3187acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return EmitShuffleVector(Ops[0], Ops[1], 1, 3, "punpckhdq"); 319e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_punpckhdq128: 320e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 2, 6, 3, 7, "punpckhdq"); 321db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_punpcklbw: 3227acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return EmitShuffleVector(Ops[0], Ops[1], 0, 8, 1, 9, 2, 10, 3, 11, 323db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson "punpcklbw"); 324db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_punpcklwd: 3257acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return EmitShuffleVector(Ops[0], Ops[1], 0, 4, 1, 5, "punpcklwd"); 326db832305d35a7c9ef08bbafcf79d8da162af3374Anders Carlsson case X86::BI__builtin_ia32_punpckldq: 3277acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner return EmitShuffleVector(Ops[0], Ops[1], 0, 2, "punpckldq"); 328e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_punpckldq128: 329e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 0, 4, 1, 5, "punpckldq"); 330e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pslldi128: 331e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psllqi128: 332e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psllwi128: 333e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psradi128: 334e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrawi128: 335e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrldi128: 336e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrlqi128: 337e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrlwi128: { 338e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateZExt(Ops[1], llvm::Type::Int64Ty, "zext"); 339e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *Ty = llvm::VectorType::get(llvm::Type::Int64Ty, 2); 340e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Value *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0); 341e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateInsertElement(llvm::UndefValue::get(Ty), 342e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1], Zero, "insert"); 343e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "bitcast"); 344e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const char *name = 0; 345e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Intrinsic::ID ID = Intrinsic::not_intrinsic; 346e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 347e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman switch (BuiltinID) { 348e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman default: assert(0 && "Unsupported shift intrinsic!"); 349e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pslldi128: 350e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "pslldi"; 351e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psll_d; 352e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 353e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psllqi128: 354e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psllqi"; 355e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psll_q; 356e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 357e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psllwi128: 358e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psllwi"; 359e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psll_w; 360e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 361e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psradi128: 362e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psradi"; 363e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psra_d; 364e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 365e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrawi128: 366e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrawi"; 367e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psra_w; 368e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 369e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrldi128: 370e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrldi"; 371e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psrl_d; 372e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 373e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrlqi128: 374e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrlqi"; 375e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psrl_q; 376e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 377e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrlwi128: 378e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrlwi"; 379e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psrl_w; 380e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 381e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 382e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Function *F = CGM.getIntrinsic(ID); 383e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name); 384e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 3852929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_pslldi: 3862929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psllqi: 3872929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psllwi: 3882929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psradi: 3892929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrawi: 3902929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrldi: 3912929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrlqi: 3922929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrlwi: { 3932929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson Ops[1] = Builder.CreateZExt(Ops[1], llvm::Type::Int64Ty, "zext"); 3942929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson const llvm::Type *Ty = llvm::VectorType::get(llvm::Type::Int64Ty, 1); 3952929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson Ops[1] = Builder.CreateBitCast(Ops[1], Ty, "bitcast"); 3962929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson const char *name = 0; 3972929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson Intrinsic::ID ID = Intrinsic::not_intrinsic; 3984e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson 3992929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson switch (BuiltinID) { 4002929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson default: assert(0 && "Unsupported shift intrinsic!"); 4012929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_pslldi: 4022929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "pslldi"; 4032929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psll_d; 4042929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4052929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psllqi: 4062929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psllqi"; 4072929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psll_q; 4082929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4092929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psllwi: 4102929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psllwi"; 4112929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psll_w; 4122929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4132929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psradi: 4142929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psradi"; 4152929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psra_d; 4162929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4172929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrawi: 4182929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psrawi"; 4192929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psra_w; 4202929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4212929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrldi: 4222929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psrldi"; 4232929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psrl_d; 4242929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4252929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrlqi: 4262929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psrlqi"; 4272929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psrl_q; 4282929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 4292929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_psrlwi: 4302929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson name = "psrlwi"; 4312929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson ID = Intrinsic::x86_mmx_psrl_w; 4322929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson break; 433e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_pslldi128: 434e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "pslldi"; 435e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psll_d; 436e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 437e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psllqi128: 438e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psllqi"; 439e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psll_q; 440e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 441e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psllwi128: 442e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psllwi"; 443e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psll_w; 444e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 445e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psradi128: 446e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psradi"; 447e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psra_d; 448e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 449e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrawi128: 450e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrawi"; 451e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psra_w; 452e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 453e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrldi128: 454e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrldi"; 455e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psrl_d; 456e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 457e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrlqi128: 458e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrlqi"; 459e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psrl_q; 460e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 461e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_psrlwi128: 462e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "psrlwi"; 463e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman ID = Intrinsic::x86_sse2_psrl_w; 464e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 4652929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson } 4667acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner llvm::Function *F = CGM.getIntrinsic(ID); 4672929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name); 4682929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson } 4692929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson case X86::BI__builtin_ia32_pshufd: { 4707acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner unsigned i = cast<ConstantInt>(Ops[1])->getZExtValue(); 4712929cfa9b7df1d5b0571b54161783e4d791a0b77Anders Carlsson return EmitShuffleVector(Ops[0], Ops[0], 4724e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson i & 0x3, (i & 0xc) >> 2, 4734e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson (i & 0x30) >> 4, (i & 0xc0) >> 6, 4744e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson "pshufd"); 4754e4ee211b56e3276df80b350a6194f7cbf04b92cAnders Carlsson } 4766086bbd1799e22e75561c3d31dc9b923f0508fa5Anders Carlsson case X86::BI__builtin_ia32_vec_init_v4hi: 4776086bbd1799e22e75561c3d31dc9b923f0508fa5Anders Carlsson case X86::BI__builtin_ia32_vec_init_v8qi: 4786086bbd1799e22e75561c3d31dc9b923f0508fa5Anders Carlsson case X86::BI__builtin_ia32_vec_init_v2si: 4796086bbd1799e22e75561c3d31dc9b923f0508fa5Anders Carlsson return EmitVector(&Ops[0], Ops.size()); 4806086bbd1799e22e75561c3d31dc9b923f0508fa5Anders Carlsson case X86::BI__builtin_ia32_vec_ext_v2si: 481e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_vec_ext_v2di: 482e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_vec_ext_v4sf: 483e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_vec_ext_v4si: 484e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_vec_ext_v2df: 4856086bbd1799e22e75561c3d31dc9b923f0508fa5Anders Carlsson return Builder.CreateExtractElement(Ops[0], Ops[1], "result"); 486cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpordss: 487e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpordsd: 488cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpunordss: 489e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpunordsd: 490e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpeqss: 491e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpeqsd: 492e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpltss: 493e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpltsd: 494cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpless: 495e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmplesd: 496cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpneqss: 497e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpneqsd: 498e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnltss: 499e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnltsd: 500e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnless: 501e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnlesd: { 5027acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner unsigned i = 0; 503cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson const char *name = 0; 504cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson switch (BuiltinID) { 505cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson default: assert(0 && "Unknown compare builtin!"); 506cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpeqss: 507e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpeqsd: 508cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 0; 509e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpeq"; 510cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 511cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpltss: 512e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpltsd: 513cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 1; 514e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmplt"; 515cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 516cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpless: 517e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmplesd: 518cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 2; 519e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmple"; 520cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 521cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpunordss: 522e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpunordsd: 523cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 3; 524e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpunord"; 525cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 526cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpneqss: 527e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpneqsd: 528cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 4; 529e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpneq"; 530cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 531cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpnltss: 532e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnltsd: 533cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 5; 534e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpntl"; 535cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 536cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpnless: 537e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnlesd: 538cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 6; 539e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpnle"; 540cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 541cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpordss: 542e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpordsd: 543cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 7; 544e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpord"; 545cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 546cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson } 547cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson 548e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Function *F; 549e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman if (cast<llvm::VectorType>(Ops[0]->getType())->getElementType() == 550e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type::FloatTy) 551e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman F = CGM.getIntrinsic(Intrinsic::x86_sse_cmp_ss); 552e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman else 553e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman F = CGM.getIntrinsic(Intrinsic::x86_sse2_cmp_sd); 554e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 555cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson Ops.push_back(llvm::ConstantInt::get(llvm::Type::Int8Ty, i)); 556cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name); 557cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson } 558e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_ldmxcsr: { 559e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); 560e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1); 561e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); 562e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman One = Builder.CreateBitCast(Tmp, PtrTy); 563e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Builder.CreateStore(Ops[0], Tmp); 564e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr), 565e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman &One, &One+1); 566e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 567e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_stmxcsr: { 568e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); 569e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Value *One = llvm::ConstantInt::get(llvm::Type::Int32Ty, 1); 570e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Value *Tmp = Builder.CreateAlloca(llvm::Type::Int32Ty, One, "tmp"); 571e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman One = Builder.CreateBitCast(Tmp, PtrTy); 572e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr), 573e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman &One, &One+1); 574e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateLoad(Tmp, "stmxcsr"); 575e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 576cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpordps: 577e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpordpd: 578cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpunordps: 579e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpunordpd: 580cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpeqps: 581e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpeqpd: 582cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpltps: 583e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpltpd: 584cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpleps: 585e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmplepd: 586cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpneqps: 587e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpneqpd: 588cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpngtps: 589e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpngtpd: 590cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpnltps: 591e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnltpd: 592cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpgtps: 593e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpgtpd: 594cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpgeps: 595e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpgepd: 596cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpngeps: 597e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpngepd: 598e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnleps: 599e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnlepd: { 6007acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner unsigned i = 0; 601cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson const char *name = 0; 602cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson bool ShouldSwap = false; 603cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson switch (BuiltinID) { 604cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson default: assert(0 && "Unknown compare builtin!"); 605e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpeqps: 606e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpeqpd: i = 0; name = "cmpeq"; break; 607e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpltps: 608e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpltpd: i = 1; name = "cmplt"; break; 609e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpleps: 610e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmplepd: i = 2; name = "cmple"; break; 611e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpunordps: 612e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpunordpd: i = 3; name = "cmpunord"; break; 613e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpneqps: 614e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpneqpd: i = 4; name = "cmpneq"; break; 615e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnltps: 616e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnltpd: i = 5; name = "cmpntl"; break; 617e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnleps: 618e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpnlepd: i = 6; name = "cmpnle"; break; 619e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpordps: 620e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpordpd: i = 7; name = "cmpord"; break; 621cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpgtps: 622e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpgtpd: 6237acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner ShouldSwap = true; 624cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 1; 625e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpgt"; 626cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 627cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpgeps: 628e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpgepd: 629cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 2; 630e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpge"; 631cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson ShouldSwap = true; 632cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 633cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpngtps: 634e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpngtpd: 635cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 5; 636e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpngt"; 637cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson ShouldSwap = true; 638cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 639cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_cmpngeps: 640e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_cmpngepd: 641cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i = 6; 642e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman name = "cmpnge"; 643cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson ShouldSwap = true; 644cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson break; 645cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson } 646cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson 647cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson if (ShouldSwap) 648cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson std::swap(Ops[0], Ops[1]); 649e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 650e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Function *F; 651e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman if (cast<llvm::VectorType>(Ops[0]->getType())->getElementType() == 652e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type::FloatTy) 653e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman F = CGM.getIntrinsic(Intrinsic::x86_sse_cmp_ps); 654e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman else 655e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman F = CGM.getIntrinsic(Intrinsic::x86_sse2_cmp_pd); 656cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson 657cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson Ops.push_back(llvm::ConstantInt::get(llvm::Type::Int8Ty, i)); 658cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), name); 659cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson } 660cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson case X86::BI__builtin_ia32_movss: 661cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return EmitShuffleVector(Ops[0], Ops[1], 4, 1, 2, 3, "movss"); 662730f2c13e8ff0a2a3cc54fce9913add68107cb51Torok Edwin case X86::BI__builtin_ia32_shufps: { 6637acda7c4a0e4aec6c003b3169ca45a5f3bc7e033Chris Lattner unsigned i = cast<ConstantInt>(Ops[2])->getZExtValue(); 664cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson return EmitShuffleVector(Ops[0], Ops[1], 665cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson i & 0x3, (i & 0xc) >> 2, 666cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson ((i & 0x30) >> 4) + 4, 667cc8b7f911892b3257e381677d0a82d43bf7b067cAnders Carlsson ((i & 0x60) >> 6) + 4, "shufps"); 668730f2c13e8ff0a2a3cc54fce9913add68107cb51Torok Edwin } 669dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman case X86::BI__builtin_ia32_punpcklbw128: 670dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 0, 16, 1, 17, 2, 18, 3, 19, 671dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman 4, 20, 5, 21, 6, 22, 7, 23, 672dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman "punpcklbw"); 673dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman case X86::BI__builtin_ia32_punpcklwd128: 674dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 0, 8, 1, 9, 2, 10, 3, 11, 675dbebb73b86d9fe56c2227bf75c13ea3a49248261Nate Begeman "punpcklwd"); 676e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_movlhps: 677e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 0, 1, 4, 5, "movlhps"); 678e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_movhlps: 679e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 6, 7, 2, 3, "movhlps"); 680e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_unpckhps: 681e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 2, 6, 3, 7, "unpckhps"); 682e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_unpcklps: 683e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return EmitShuffleVector(Ops[0], Ops[1], 0, 4, 1, 5, "unpcklps"); 684e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_movqv4si: { 685e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *Ty = llvm::VectorType::get(llvm::Type::Int64Ty, 2); 686e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateBitCast(Ops[0], Ty); 687e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 688e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_loadlps: 689e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_loadhps: { 690e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // FIXME: This should probably be represented as 691e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // shuffle (dst, (v4f32 (insert undef, (load i64), 0)), shuf mask hi/lo) 692e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *EltTy = llvm::Type::DoubleTy; 693e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *VecTy = llvm::VectorType::get(EltTy, 2); 694e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *OrigTy = Ops[0]->getType(); 695e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman unsigned Index = BuiltinID == X86::BI__builtin_ia32_loadlps ? 0 : 1; 696e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Index); 697e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateBitCast(Ops[1], llvm::PointerType::getUnqual(EltTy)); 698e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateLoad(Ops[1], "tmp"); 699e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateBitCast(Ops[0], VecTy, "cast"); 700e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateInsertElement(Ops[0], Ops[1], Idx, "loadps"); 701e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateBitCast(Ops[0], OrigTy, "loadps"); 702e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 703e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_storehps: 704e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_storelps: { 705e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *EltTy = llvm::Type::Int64Ty; 706e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *PtrTy = llvm::PointerType::getUnqual(EltTy); 707e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *VecTy = llvm::VectorType::get(EltTy, 2); 708e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 709e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // cast val v2i64 710e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateBitCast(Ops[1], VecTy, "cast"); 711e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 712e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // extract (0, 1) 713e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1; 714e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Value *Idx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Index); 715e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "extract"); 716e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 717e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // cast pointer to i64 & store 718e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateBitCast(Ops[0], PtrTy); 719e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateStore(Ops[1], Ops[0]); 720e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 721e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_loadlv4si: { 722e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // load i64 723e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *EltTy = llvm::Type::Int64Ty; 724e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *PtrTy = llvm::PointerType::getUnqual(EltTy); 725e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateBitCast(Ops[0], PtrTy); 726e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateLoad(Ops[0], "load"); 727e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 728e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // scalar to vector: insert i64 into 2 x i64 undef 729e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Type *VecTy = llvm::VectorType::get(EltTy, 2); 730e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Value *Zero = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0); 731e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateInsertElement(llvm::UndefValue::get(VecTy), 732e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0], Zero, "s2v"); 733e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 734e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // shuffle into zero vector. 735e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman std::vector<llvm::Constant *>Elts; 736e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Elts.resize(2, llvm::ConstantInt::get(EltTy, 0)); 737e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::Value *ZV = ConstantVector::get(Elts); 738e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = EmitShuffleVector(ZV, Ops[0], 2, 1, "loadl"); 739e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman 740e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman // bitcast to result. 741e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateBitCast(Ops[0], 742e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman llvm::VectorType::get(llvm::Type::Int32Ty, 4)); 743e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 744e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andps: 745e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andpd: 746e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andnps: 747e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andnpd: 748e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_orps: 749e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_orpd: 750e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_xorpd: 751e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_xorps: { 752e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *ITy = llvm::VectorType::get(llvm::Type::Int32Ty, 4); 753e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman const llvm::Type *FTy = Ops[0]->getType(); 754e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateBitCast(Ops[0], ITy, "bitcast"); 755e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[1] = Builder.CreateBitCast(Ops[1], ITy, "bitcast"); 756e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman switch (BuiltinID) { 757e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andps: 758e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateAnd(Ops[0], Ops[1], "andps"); 759e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 760e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andpd: 761e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateAnd(Ops[0], Ops[1], "andpd"); 762e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 763e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andnps: 764e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateNot(Ops[0], "not"); 765e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateAnd(Ops[0], Ops[1], "andnps"); 766e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 767e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_andnpd: 768e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateNot(Ops[0], "not"); 769e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateAnd(Ops[0], Ops[1], "andnpd"); 770e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 771e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_orps: 772e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateOr(Ops[0], Ops[1], "orps"); 773e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 774e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_orpd: 775e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateOr(Ops[0], Ops[1], "orpd"); 776e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 777e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_xorps: 778e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateXor(Ops[0], Ops[1], "xorps"); 779e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 780e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman case X86::BI__builtin_ia32_xorpd: 781e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman Ops[0] = Builder.CreateXor(Ops[0], Ops[1], "xorpd"); 782e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman break; 783e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 784e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman return Builder.CreateBitCast(Ops[0], FTy, "bitcast"); 785e7722103abc4583366c914374d6aa8560e145fa1Nate Begeman } 786564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson } 787564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson} 788564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson 7891feedd84221e8dbcc3faf3de27cc42b559db845dChris LattnerValue *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, 7901feedd84221e8dbcc3faf3de27cc42b559db845dChris Lattner const CallExpr *E) { 791564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson switch (BuiltinID) { 79246a26b0b0e2ec1557bad9b70e8e20836524ebdfcAnders Carlsson default: return 0; 793564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson } 794564f1de67d7ba43646b8740db86d6269e3dfbe0bAnders Carlsson} 795