Anders Carlsson | 022012e | 2007-08-20 18:05:56 +0000 | [diff] [blame] | 1 | //===---- CGBuiltin.cpp - Emit LLVM Code for builtins ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Anders Carlsson | 022012e | 2007-08-20 18:05:56 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This contains code to emit Builtin calls as LLVM code. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 14 | #include "TargetInfo.h" |
Anders Carlsson | 022012e | 2007-08-20 18:05:56 +0000 | [diff] [blame] | 15 | #include "CodeGenFunction.h" |
| 16 | #include "CodeGenModule.h" |
Fariborz Jahanian | 55bcace | 2010-06-15 22:44:06 +0000 | [diff] [blame] | 17 | #include "CGObjCRuntime.h" |
Anders Carlsson | ca6fcfa | 2007-12-09 21:20:04 +0000 | [diff] [blame] | 18 | #include "clang/Basic/TargetInfo.h" |
Chris Lattner | bef20ac | 2007-08-31 04:31:45 +0000 | [diff] [blame] | 19 | #include "clang/AST/ASTContext.h" |
Daniel Dunbar | c4a1dea | 2008-08-11 05:35:13 +0000 | [diff] [blame] | 20 | #include "clang/AST/Decl.h" |
Chris Lattner | 6b15cdc | 2009-06-14 01:05:48 +0000 | [diff] [blame] | 21 | #include "clang/Basic/TargetBuiltins.h" |
Anders Carlsson | 793680e | 2007-10-12 23:56:29 +0000 | [diff] [blame] | 22 | #include "llvm/Intrinsics.h" |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetData.h" |
Jakub Staszak | 558229f | 2011-07-08 22:45:14 +0000 | [diff] [blame] | 24 | |
Anders Carlsson | 022012e | 2007-08-20 18:05:56 +0000 | [diff] [blame] | 25 | using namespace clang; |
| 26 | using namespace CodeGen; |
Anders Carlsson | ca6fcfa | 2007-12-09 21:20:04 +0000 | [diff] [blame] | 27 | using namespace llvm; |
| 28 | |
John McCall | a45680b | 2011-09-13 23:05:03 +0000 | [diff] [blame] | 29 | /// getBuiltinLibFunction - Given a builtin id for a function like |
| 30 | /// "__builtin_fabsf", return a Function* for "fabsf". |
| 31 | llvm::Value *CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD, |
| 32 | unsigned BuiltinID) { |
| 33 | assert(Context.BuiltinInfo.isLibFunction(BuiltinID)); |
| 34 | |
| 35 | // Get the name, skip over the __builtin_ prefix (if necessary). |
| 36 | StringRef Name; |
| 37 | GlobalDecl D(FD); |
| 38 | |
| 39 | // If the builtin has been declared explicitly with an assembler label, |
| 40 | // use the mangled name. This differs from the plain label on platforms |
| 41 | // that prefix labels. |
| 42 | if (FD->hasAttr<AsmLabelAttr>()) |
| 43 | Name = getMangledName(D); |
| 44 | else |
| 45 | Name = Context.BuiltinInfo.GetName(BuiltinID) + 10; |
| 46 | |
| 47 | llvm::FunctionType *Ty = |
| 48 | cast<llvm::FunctionType>(getTypes().ConvertType(FD->getType())); |
| 49 | |
| 50 | return GetOrCreateLLVMFunction(Name, Ty, D, /*ForVTable=*/false); |
| 51 | } |
| 52 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 53 | /// Emit the conversions required to turn the given value into an |
| 54 | /// integer of the given size. |
| 55 | static Value *EmitToInt(CodeGenFunction &CGF, llvm::Value *V, |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 56 | QualType T, llvm::IntegerType *IntType) { |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 57 | V = CGF.EmitToMemory(V, T); |
Chris Lattner | a1aa9e3 | 2010-10-01 23:43:16 +0000 | [diff] [blame] | 58 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 59 | if (V->getType()->isPointerTy()) |
| 60 | return CGF.Builder.CreatePtrToInt(V, IntType); |
| 61 | |
| 62 | assert(V->getType() == IntType); |
| 63 | return V; |
Chandler Carruth | db4325b | 2010-07-18 07:23:17 +0000 | [diff] [blame] | 64 | } |
| 65 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 66 | static Value *EmitFromInt(CodeGenFunction &CGF, llvm::Value *V, |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 67 | QualType T, llvm::Type *ResultType) { |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 68 | V = CGF.EmitFromMemory(V, T); |
| 69 | |
| 70 | if (ResultType->isPointerTy()) |
| 71 | return CGF.Builder.CreateIntToPtr(V, ResultType); |
| 72 | |
| 73 | assert(V->getType() == ResultType); |
| 74 | return V; |
Chandler Carruth | db4325b | 2010-07-18 07:23:17 +0000 | [diff] [blame] | 75 | } |
| 76 | |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 77 | /// Utility to insert an atomic instruction based on Instrinsic::ID |
| 78 | /// and the expression node. |
Daniel Dunbar | cb61a7b | 2010-03-20 07:04:11 +0000 | [diff] [blame] | 79 | static RValue EmitBinaryAtomic(CodeGenFunction &CGF, |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 80 | llvm::AtomicRMWInst::BinOp Kind, |
| 81 | const CallExpr *E) { |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 82 | QualType T = E->getType(); |
| 83 | assert(E->getArg(0)->getType()->isPointerType()); |
| 84 | assert(CGF.getContext().hasSameUnqualifiedType(T, |
| 85 | E->getArg(0)->getType()->getPointeeType())); |
| 86 | assert(CGF.getContext().hasSameUnqualifiedType(T, E->getArg(1)->getType())); |
| 87 | |
Chris Lattner | 4f20944 | 2010-09-21 23:40:48 +0000 | [diff] [blame] | 88 | llvm::Value *DestPtr = CGF.EmitScalarExpr(E->getArg(0)); |
| 89 | unsigned AddrSpace = |
| 90 | cast<llvm::PointerType>(DestPtr->getType())->getAddressSpace(); |
John McCall | 789a159 | 2010-10-26 22:09:15 +0000 | [diff] [blame] | 91 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 92 | llvm::IntegerType *IntType = |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 93 | llvm::IntegerType::get(CGF.getLLVMContext(), |
| 94 | CGF.getContext().getTypeSize(T)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 95 | llvm::Type *IntPtrType = IntType->getPointerTo(AddrSpace); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 96 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 97 | llvm::Value *Args[2]; |
| 98 | Args[0] = CGF.Builder.CreateBitCast(DestPtr, IntPtrType); |
| 99 | Args[1] = CGF.EmitScalarExpr(E->getArg(1)); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 100 | llvm::Type *ValueType = Args[1]->getType(); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 101 | Args[1] = EmitToInt(CGF, Args[1], T, IntType); |
| 102 | |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 103 | llvm::Value *Result = |
| 104 | CGF.Builder.CreateAtomicRMW(Kind, Args[0], Args[1], |
| 105 | llvm::SequentiallyConsistent); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 106 | Result = EmitFromInt(CGF, Result, T, ValueType); |
| 107 | return RValue::get(Result); |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | /// Utility to insert an atomic instruction based Instrinsic::ID and |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 111 | /// the expression node, where the return value is the result of the |
| 112 | /// operation. |
Chris Lattner | 420b118 | 2010-05-06 05:35:16 +0000 | [diff] [blame] | 113 | static RValue EmitBinaryAtomicPost(CodeGenFunction &CGF, |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 114 | llvm::AtomicRMWInst::BinOp Kind, |
| 115 | const CallExpr *E, |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 116 | Instruction::BinaryOps Op) { |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 117 | QualType T = E->getType(); |
| 118 | assert(E->getArg(0)->getType()->isPointerType()); |
| 119 | assert(CGF.getContext().hasSameUnqualifiedType(T, |
| 120 | E->getArg(0)->getType()->getPointeeType())); |
| 121 | assert(CGF.getContext().hasSameUnqualifiedType(T, E->getArg(1)->getType())); |
| 122 | |
Chris Lattner | 4f20944 | 2010-09-21 23:40:48 +0000 | [diff] [blame] | 123 | llvm::Value *DestPtr = CGF.EmitScalarExpr(E->getArg(0)); |
| 124 | unsigned AddrSpace = |
| 125 | cast<llvm::PointerType>(DestPtr->getType())->getAddressSpace(); |
John McCall | 789a159 | 2010-10-26 22:09:15 +0000 | [diff] [blame] | 126 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 127 | llvm::IntegerType *IntType = |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 128 | llvm::IntegerType::get(CGF.getLLVMContext(), |
| 129 | CGF.getContext().getTypeSize(T)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 130 | llvm::Type *IntPtrType = IntType->getPointerTo(AddrSpace); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 131 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 132 | llvm::Value *Args[2]; |
| 133 | Args[1] = CGF.EmitScalarExpr(E->getArg(1)); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 134 | llvm::Type *ValueType = Args[1]->getType(); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 135 | Args[1] = EmitToInt(CGF, Args[1], T, IntType); |
| 136 | Args[0] = CGF.Builder.CreateBitCast(DestPtr, IntPtrType); |
| 137 | |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 138 | llvm::Value *Result = |
| 139 | CGF.Builder.CreateAtomicRMW(Kind, Args[0], Args[1], |
| 140 | llvm::SequentiallyConsistent); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 141 | Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]); |
| 142 | Result = EmitFromInt(CGF, Result, T, ValueType); |
| 143 | return RValue::get(Result); |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Chris Lattner | 420b118 | 2010-05-06 05:35:16 +0000 | [diff] [blame] | 146 | /// EmitFAbs - Emit a call to fabs/fabsf/fabsl, depending on the type of ValTy, |
| 147 | /// which must be a scalar floating point type. |
| 148 | static Value *EmitFAbs(CodeGenFunction &CGF, Value *V, QualType ValTy) { |
| 149 | const BuiltinType *ValTyP = ValTy->getAs<BuiltinType>(); |
| 150 | assert(ValTyP && "isn't scalar fp type!"); |
| 151 | |
| 152 | StringRef FnName; |
| 153 | switch (ValTyP->getKind()) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 154 | default: llvm_unreachable("Isn't a scalar fp type!"); |
Chris Lattner | 420b118 | 2010-05-06 05:35:16 +0000 | [diff] [blame] | 155 | case BuiltinType::Float: FnName = "fabsf"; break; |
| 156 | case BuiltinType::Double: FnName = "fabs"; break; |
| 157 | case BuiltinType::LongDouble: FnName = "fabsl"; break; |
| 158 | } |
| 159 | |
| 160 | // The prototype is something that takes and returns whatever V's type is. |
Jay Foad | da549e8 | 2011-07-29 13:56:53 +0000 | [diff] [blame] | 161 | llvm::FunctionType *FT = llvm::FunctionType::get(V->getType(), V->getType(), |
Benjamin Kramer | 95d318c | 2011-05-28 14:26:31 +0000 | [diff] [blame] | 162 | false); |
Chris Lattner | 420b118 | 2010-05-06 05:35:16 +0000 | [diff] [blame] | 163 | llvm::Value *Fn = CGF.CGM.CreateRuntimeFunction(FT, FnName); |
| 164 | |
| 165 | return CGF.Builder.CreateCall(Fn, V, "abs"); |
| 166 | } |
| 167 | |
John McCall | a45680b | 2011-09-13 23:05:03 +0000 | [diff] [blame] | 168 | static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *Fn, |
| 169 | const CallExpr *E, llvm::Value *calleeValue) { |
| 170 | return CGF.EmitCall(E->getCallee()->getType(), calleeValue, |
| 171 | ReturnValueSlot(), E->arg_begin(), E->arg_end(), Fn); |
| 172 | } |
| 173 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 174 | RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 175 | unsigned BuiltinID, const CallExpr *E) { |
Chris Lattner | 564ea2a | 2008-10-06 06:56:41 +0000 | [diff] [blame] | 176 | // See if we can constant fold this builtin. If so, don't emit it at all. |
Anders Carlsson | f35d35a | 2008-12-01 02:31:41 +0000 | [diff] [blame] | 177 | Expr::EvalResult Result; |
Eli Friedman | 52a27f5 | 2012-01-06 20:03:09 +0000 | [diff] [blame] | 178 | if (E->EvaluateAsRValue(Result, CGM.getContext()) && |
Fariborz Jahanian | dd697bc | 2011-04-25 23:10:07 +0000 | [diff] [blame] | 179 | !Result.hasSideEffects()) { |
Anders Carlsson | f35d35a | 2008-12-01 02:31:41 +0000 | [diff] [blame] | 180 | if (Result.Val.isInt()) |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 181 | return RValue::get(llvm::ConstantInt::get(getLLVMContext(), |
Owen Anderson | 4a28d5d | 2009-07-24 23:12:58 +0000 | [diff] [blame] | 182 | Result.Val.getInt())); |
Chris Lattner | a1aa9e3 | 2010-10-01 23:43:16 +0000 | [diff] [blame] | 183 | if (Result.Val.isFloat()) |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 184 | return RValue::get(llvm::ConstantFP::get(getLLVMContext(), |
| 185 | Result.Val.getFloat())); |
Chris Lattner | 1f32999 | 2008-10-06 06:09:18 +0000 | [diff] [blame] | 186 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 187 | |
Chris Lattner | 564ea2a | 2008-10-06 06:56:41 +0000 | [diff] [blame] | 188 | switch (BuiltinID) { |
| 189 | default: break; // Handle intrinsics and libm functions below. |
Chris Lattner | 506ff88 | 2008-10-06 07:26:43 +0000 | [diff] [blame] | 190 | case Builtin::BI__builtin___CFStringMakeConstantString: |
David Chisnall | 0d13f6f | 2010-01-23 02:40:42 +0000 | [diff] [blame] | 191 | case Builtin::BI__builtin___NSStringMakeConstantString: |
Anders Carlsson | e9352cc | 2009-04-08 04:48:15 +0000 | [diff] [blame] | 192 | return RValue::get(CGM.EmitConstantExpr(E, E->getType(), 0)); |
Chris Lattner | 6a705f0 | 2008-07-09 17:28:44 +0000 | [diff] [blame] | 193 | case Builtin::BI__builtin_stdarg_start: |
Anders Carlsson | 793680e | 2007-10-12 23:56:29 +0000 | [diff] [blame] | 194 | case Builtin::BI__builtin_va_start: |
| 195 | case Builtin::BI__builtin_va_end: { |
Daniel Dunbar | 0785570 | 2009-02-11 22:25:55 +0000 | [diff] [blame] | 196 | Value *ArgValue = EmitVAListRef(E->getArg(0)); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 197 | llvm::Type *DestType = Int8PtrTy; |
Anders Carlsson | 793680e | 2007-10-12 23:56:29 +0000 | [diff] [blame] | 198 | if (ArgValue->getType() != DestType) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 199 | ArgValue = Builder.CreateBitCast(ArgValue, DestType, |
Daniel Dunbar | b27ffbe | 2009-07-26 09:28:40 +0000 | [diff] [blame] | 200 | ArgValue->getName().data()); |
Anders Carlsson | 793680e | 2007-10-12 23:56:29 +0000 | [diff] [blame] | 201 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 202 | Intrinsic::ID inst = (BuiltinID == Builtin::BI__builtin_va_end) ? |
Chris Lattner | 6a705f0 | 2008-07-09 17:28:44 +0000 | [diff] [blame] | 203 | Intrinsic::vaend : Intrinsic::vastart; |
Chris Lattner | 7acda7c | 2007-12-18 00:25:38 +0000 | [diff] [blame] | 204 | return RValue::get(Builder.CreateCall(CGM.getIntrinsic(inst), ArgValue)); |
Anders Carlsson | 793680e | 2007-10-12 23:56:29 +0000 | [diff] [blame] | 205 | } |
Anders Carlsson | a28ef8b | 2008-02-09 20:26:43 +0000 | [diff] [blame] | 206 | case Builtin::BI__builtin_va_copy: { |
Eli Friedman | 4fd0aa5 | 2009-01-20 17:46:04 +0000 | [diff] [blame] | 207 | Value *DstPtr = EmitVAListRef(E->getArg(0)); |
| 208 | Value *SrcPtr = EmitVAListRef(E->getArg(1)); |
Anders Carlsson | a28ef8b | 2008-02-09 20:26:43 +0000 | [diff] [blame] | 209 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 210 | llvm::Type *Type = Int8PtrTy; |
Anders Carlsson | a28ef8b | 2008-02-09 20:26:43 +0000 | [diff] [blame] | 211 | |
| 212 | DstPtr = Builder.CreateBitCast(DstPtr, Type); |
| 213 | SrcPtr = Builder.CreateBitCast(SrcPtr, Type); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 214 | return RValue::get(Builder.CreateCall2(CGM.getIntrinsic(Intrinsic::vacopy), |
Chris Lattner | 3eae03e | 2008-05-06 00:56:42 +0000 | [diff] [blame] | 215 | DstPtr, SrcPtr)); |
Anders Carlsson | a28ef8b | 2008-02-09 20:26:43 +0000 | [diff] [blame] | 216 | } |
Anders Carlsson | c2251dc | 2007-11-20 19:05:17 +0000 | [diff] [blame] | 217 | case Builtin::BI__builtin_abs: { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 218 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
| 219 | |
Chris Lattner | 9a847f5 | 2008-07-23 06:53:34 +0000 | [diff] [blame] | 220 | Value *NegOp = Builder.CreateNeg(ArgValue, "neg"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 221 | Value *CmpResult = |
| 222 | Builder.CreateICmpSGE(ArgValue, |
Owen Anderson | c9c88b4 | 2009-07-31 20:28:54 +0000 | [diff] [blame] | 223 | llvm::Constant::getNullValue(ArgValue->getType()), |
Chris Lattner | 9a847f5 | 2008-07-23 06:53:34 +0000 | [diff] [blame] | 224 | "abscond"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 225 | Value *Result = |
Anders Carlsson | c2251dc | 2007-11-20 19:05:17 +0000 | [diff] [blame] | 226 | Builder.CreateSelect(CmpResult, ArgValue, NegOp, "abs"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 227 | |
Anders Carlsson | c2251dc | 2007-11-20 19:05:17 +0000 | [diff] [blame] | 228 | return RValue::get(Result); |
| 229 | } |
Anders Carlsson | 3a31d60 | 2008-02-06 07:19:27 +0000 | [diff] [blame] | 230 | case Builtin::BI__builtin_ctz: |
| 231 | case Builtin::BI__builtin_ctzl: |
| 232 | case Builtin::BI__builtin_ctzll: { |
| 233 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 234 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 235 | llvm::Type *ArgType = ArgValue->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 236 | Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType); |
Anders Carlsson | 3a31d60 | 2008-02-06 07:19:27 +0000 | [diff] [blame] | 237 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 238 | llvm::Type *ResultType = ConvertType(E->getType()); |
Chandler Carruth | 50058ec | 2011-12-12 04:28:35 +0000 | [diff] [blame] | 239 | Value *Result = Builder.CreateCall2(F, ArgValue, Builder.getTrue()); |
Anders Carlsson | 3a31d60 | 2008-02-06 07:19:27 +0000 | [diff] [blame] | 240 | if (Result->getType() != ResultType) |
Duncan Sands | eac73e5 | 2009-11-16 13:11:21 +0000 | [diff] [blame] | 241 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 242 | "cast"); |
Anders Carlsson | 3a31d60 | 2008-02-06 07:19:27 +0000 | [diff] [blame] | 243 | return RValue::get(Result); |
| 244 | } |
Eli Friedman | f4e8533 | 2008-05-27 15:32:46 +0000 | [diff] [blame] | 245 | case Builtin::BI__builtin_clz: |
| 246 | case Builtin::BI__builtin_clzl: |
| 247 | case Builtin::BI__builtin_clzll: { |
| 248 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 249 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 250 | llvm::Type *ArgType = ArgValue->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 251 | Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType); |
Eli Friedman | f4e8533 | 2008-05-27 15:32:46 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 253 | llvm::Type *ResultType = ConvertType(E->getType()); |
Chandler Carruth | 50058ec | 2011-12-12 04:28:35 +0000 | [diff] [blame] | 254 | Value *Result = Builder.CreateCall2(F, ArgValue, Builder.getTrue()); |
Eli Friedman | f4e8533 | 2008-05-27 15:32:46 +0000 | [diff] [blame] | 255 | if (Result->getType() != ResultType) |
Duncan Sands | eac73e5 | 2009-11-16 13:11:21 +0000 | [diff] [blame] | 256 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 257 | "cast"); |
Eli Friedman | f4e8533 | 2008-05-27 15:32:46 +0000 | [diff] [blame] | 258 | return RValue::get(Result); |
| 259 | } |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 260 | case Builtin::BI__builtin_ffs: |
| 261 | case Builtin::BI__builtin_ffsl: |
| 262 | case Builtin::BI__builtin_ffsll: { |
| 263 | // ffs(x) -> x ? cttz(x) + 1 : 0 |
| 264 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 265 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 266 | llvm::Type *ArgType = ArgValue->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 267 | Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 268 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 269 | llvm::Type *ResultType = ConvertType(E->getType()); |
Chandler Carruth | 50058ec | 2011-12-12 04:28:35 +0000 | [diff] [blame] | 270 | Value *Tmp = Builder.CreateAdd(Builder.CreateCall2(F, ArgValue, |
| 271 | Builder.getTrue()), |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 272 | llvm::ConstantInt::get(ArgType, 1)); |
Owen Anderson | c9c88b4 | 2009-07-31 20:28:54 +0000 | [diff] [blame] | 273 | Value *Zero = llvm::Constant::getNullValue(ArgType); |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 274 | Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero"); |
| 275 | Value *Result = Builder.CreateSelect(IsZero, Zero, Tmp, "ffs"); |
| 276 | if (Result->getType() != ResultType) |
Duncan Sands | eac73e5 | 2009-11-16 13:11:21 +0000 | [diff] [blame] | 277 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 278 | "cast"); |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 279 | return RValue::get(Result); |
| 280 | } |
| 281 | case Builtin::BI__builtin_parity: |
| 282 | case Builtin::BI__builtin_parityl: |
| 283 | case Builtin::BI__builtin_parityll: { |
| 284 | // parity(x) -> ctpop(x) & 1 |
| 285 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 286 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 287 | llvm::Type *ArgType = ArgValue->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 288 | Value *F = CGM.getIntrinsic(Intrinsic::ctpop, ArgType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 289 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 290 | llvm::Type *ResultType = ConvertType(E->getType()); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 291 | Value *Tmp = Builder.CreateCall(F, ArgValue); |
| 292 | Value *Result = Builder.CreateAnd(Tmp, llvm::ConstantInt::get(ArgType, 1)); |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 293 | if (Result->getType() != ResultType) |
Duncan Sands | eac73e5 | 2009-11-16 13:11:21 +0000 | [diff] [blame] | 294 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 295 | "cast"); |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 296 | return RValue::get(Result); |
| 297 | } |
| 298 | case Builtin::BI__builtin_popcount: |
| 299 | case Builtin::BI__builtin_popcountl: |
| 300 | case Builtin::BI__builtin_popcountll: { |
| 301 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 302 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 303 | llvm::Type *ArgType = ArgValue->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 304 | Value *F = CGM.getIntrinsic(Intrinsic::ctpop, ArgType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 305 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 306 | llvm::Type *ResultType = ConvertType(E->getType()); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 307 | Value *Result = Builder.CreateCall(F, ArgValue); |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 308 | if (Result->getType() != ResultType) |
Duncan Sands | eac73e5 | 2009-11-16 13:11:21 +0000 | [diff] [blame] | 309 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 310 | "cast"); |
Daniel Dunbar | 04b2900 | 2008-07-21 17:19:41 +0000 | [diff] [blame] | 311 | return RValue::get(Result); |
| 312 | } |
Fariborz Jahanian | e42b8a5 | 2010-07-26 23:11:03 +0000 | [diff] [blame] | 313 | case Builtin::BI__builtin_expect: { |
Fariborz Jahanian | dd697bc | 2011-04-25 23:10:07 +0000 | [diff] [blame] | 314 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 315 | llvm::Type *ArgType = ArgValue->getType(); |
Jakub Staszak | 558229f | 2011-07-08 22:45:14 +0000 | [diff] [blame] | 316 | |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 317 | Value *FnExpect = CGM.getIntrinsic(Intrinsic::expect, ArgType); |
Jakub Staszak | 558229f | 2011-07-08 22:45:14 +0000 | [diff] [blame] | 318 | Value *ExpectedValue = EmitScalarExpr(E->getArg(1)); |
| 319 | |
| 320 | Value *Result = Builder.CreateCall2(FnExpect, ArgValue, ExpectedValue, |
| 321 | "expval"); |
| 322 | return RValue::get(Result); |
Fariborz Jahanian | e42b8a5 | 2010-07-26 23:11:03 +0000 | [diff] [blame] | 323 | } |
Anders Carlsson | df4852a | 2007-12-02 21:58:10 +0000 | [diff] [blame] | 324 | case Builtin::BI__builtin_bswap32: |
| 325 | case Builtin::BI__builtin_bswap64: { |
Chris Lattner | 1feedd8 | 2007-12-13 07:34:23 +0000 | [diff] [blame] | 326 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 327 | llvm::Type *ArgType = ArgValue->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 328 | Value *F = CGM.getIntrinsic(Intrinsic::bswap, ArgType); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 329 | return RValue::get(Builder.CreateCall(F, ArgValue)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 330 | } |
Daniel Dunbar | d5f8a4f | 2008-09-03 21:13:56 +0000 | [diff] [blame] | 331 | case Builtin::BI__builtin_object_size: { |
Mike Stump | b16d32f | 2009-10-26 23:39:48 +0000 | [diff] [blame] | 332 | // We pass this builtin onto the optimizer so that it can |
| 333 | // figure out the object size in more complex cases. |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 334 | llvm::Type *ResType = ConvertType(E->getType()); |
Eric Christopher | fee667f | 2009-12-23 03:49:37 +0000 | [diff] [blame] | 335 | |
| 336 | // LLVM only supports 0 and 2, make sure that we pass along that |
| 337 | // as a boolean. |
| 338 | Value *Ty = EmitScalarExpr(E->getArg(1)); |
| 339 | ConstantInt *CI = dyn_cast<ConstantInt>(Ty); |
| 340 | assert(CI); |
| 341 | uint64_t val = CI->getZExtValue(); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 342 | CI = ConstantInt::get(Builder.getInt1Ty(), (val & 0x2) >> 1); |
Eric Christopher | fee667f | 2009-12-23 03:49:37 +0000 | [diff] [blame] | 343 | |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 344 | Value *F = CGM.getIntrinsic(Intrinsic::objectsize, ResType); |
Mike Stump | c4c9045 | 2009-10-27 22:09:17 +0000 | [diff] [blame] | 345 | return RValue::get(Builder.CreateCall2(F, |
| 346 | EmitScalarExpr(E->getArg(0)), |
Eric Christopher | fee667f | 2009-12-23 03:49:37 +0000 | [diff] [blame] | 347 | CI)); |
Daniel Dunbar | d5f8a4f | 2008-09-03 21:13:56 +0000 | [diff] [blame] | 348 | } |
Daniel Dunbar | 4493f79 | 2008-07-21 22:59:13 +0000 | [diff] [blame] | 349 | case Builtin::BI__builtin_prefetch: { |
| 350 | Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0)); |
| 351 | // FIXME: Technically these constants should of type 'int', yes? |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 352 | RW = (E->getNumArgs() > 1) ? EmitScalarExpr(E->getArg(1)) : |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 353 | llvm::ConstantInt::get(Int32Ty, 0); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 354 | Locality = (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 355 | llvm::ConstantInt::get(Int32Ty, 3); |
Bruno Cardoso Lopes | 2eccb67 | 2011-06-14 05:00:30 +0000 | [diff] [blame] | 356 | Value *Data = llvm::ConstantInt::get(Int32Ty, 1); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 357 | Value *F = CGM.getIntrinsic(Intrinsic::prefetch); |
Bruno Cardoso Lopes | 2eccb67 | 2011-06-14 05:00:30 +0000 | [diff] [blame] | 358 | return RValue::get(Builder.CreateCall4(F, Address, RW, Locality, Data)); |
Anders Carlsson | df4852a | 2007-12-02 21:58:10 +0000 | [diff] [blame] | 359 | } |
Daniel Dunbar | 4493f79 | 2008-07-21 22:59:13 +0000 | [diff] [blame] | 360 | case Builtin::BI__builtin_trap: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 361 | Value *F = CGM.getIntrinsic(Intrinsic::trap); |
Daniel Dunbar | 4493f79 | 2008-07-21 22:59:13 +0000 | [diff] [blame] | 362 | return RValue::get(Builder.CreateCall(F)); |
| 363 | } |
Chris Lattner | 21190d5 | 2009-09-21 03:09:59 +0000 | [diff] [blame] | 364 | case Builtin::BI__builtin_unreachable: { |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 365 | if (CatchUndefined) |
Mike Stump | fba565d | 2009-12-16 03:07:12 +0000 | [diff] [blame] | 366 | EmitBranch(getTrapBB()); |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 367 | else |
| 368 | Builder.CreateUnreachable(); |
| 369 | |
| 370 | // We do need to preserve an insertion point. |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 371 | EmitBlock(createBasicBlock("unreachable.cont")); |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 372 | |
| 373 | return RValue::get(0); |
Chris Lattner | 21190d5 | 2009-09-21 03:09:59 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Daniel Dunbar | a933c3c | 2008-07-21 18:44:41 +0000 | [diff] [blame] | 376 | case Builtin::BI__builtin_powi: |
| 377 | case Builtin::BI__builtin_powif: |
| 378 | case Builtin::BI__builtin_powil: { |
| 379 | Value *Base = EmitScalarExpr(E->getArg(0)); |
| 380 | Value *Exponent = EmitScalarExpr(E->getArg(1)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 381 | llvm::Type *ArgType = Base->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 382 | Value *F = CGM.getIntrinsic(Intrinsic::powi, ArgType); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 383 | return RValue::get(Builder.CreateCall2(F, Base, Exponent)); |
Daniel Dunbar | a933c3c | 2008-07-21 18:44:41 +0000 | [diff] [blame] | 384 | } |
| 385 | |
Chris Lattner | fe23e21 | 2007-12-20 00:44:32 +0000 | [diff] [blame] | 386 | case Builtin::BI__builtin_isgreater: |
| 387 | case Builtin::BI__builtin_isgreaterequal: |
| 388 | case Builtin::BI__builtin_isless: |
| 389 | case Builtin::BI__builtin_islessequal: |
| 390 | case Builtin::BI__builtin_islessgreater: |
| 391 | case Builtin::BI__builtin_isunordered: { |
| 392 | // Ordered comparisons: we know the arguments to these are matching scalar |
| 393 | // floating point values. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 394 | Value *LHS = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | fe23e21 | 2007-12-20 00:44:32 +0000 | [diff] [blame] | 395 | Value *RHS = EmitScalarExpr(E->getArg(1)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 396 | |
Chris Lattner | fe23e21 | 2007-12-20 00:44:32 +0000 | [diff] [blame] | 397 | switch (BuiltinID) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 398 | default: llvm_unreachable("Unknown ordered comparison"); |
Chris Lattner | fe23e21 | 2007-12-20 00:44:32 +0000 | [diff] [blame] | 399 | case Builtin::BI__builtin_isgreater: |
| 400 | LHS = Builder.CreateFCmpOGT(LHS, RHS, "cmp"); |
| 401 | break; |
| 402 | case Builtin::BI__builtin_isgreaterequal: |
| 403 | LHS = Builder.CreateFCmpOGE(LHS, RHS, "cmp"); |
| 404 | break; |
| 405 | case Builtin::BI__builtin_isless: |
| 406 | LHS = Builder.CreateFCmpOLT(LHS, RHS, "cmp"); |
| 407 | break; |
| 408 | case Builtin::BI__builtin_islessequal: |
| 409 | LHS = Builder.CreateFCmpOLE(LHS, RHS, "cmp"); |
| 410 | break; |
| 411 | case Builtin::BI__builtin_islessgreater: |
| 412 | LHS = Builder.CreateFCmpONE(LHS, RHS, "cmp"); |
| 413 | break; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 414 | case Builtin::BI__builtin_isunordered: |
Chris Lattner | fe23e21 | 2007-12-20 00:44:32 +0000 | [diff] [blame] | 415 | LHS = Builder.CreateFCmpUNO(LHS, RHS, "cmp"); |
| 416 | break; |
| 417 | } |
| 418 | // ZExt bool to int type. |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 419 | return RValue::get(Builder.CreateZExt(LHS, ConvertType(E->getType()))); |
Chris Lattner | fe23e21 | 2007-12-20 00:44:32 +0000 | [diff] [blame] | 420 | } |
Eli Friedman | d613989 | 2009-09-01 04:19:44 +0000 | [diff] [blame] | 421 | case Builtin::BI__builtin_isnan: { |
| 422 | Value *V = EmitScalarExpr(E->getArg(0)); |
| 423 | V = Builder.CreateFCmpUNO(V, V, "cmp"); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 424 | return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); |
Eli Friedman | d613989 | 2009-09-01 04:19:44 +0000 | [diff] [blame] | 425 | } |
Chris Lattner | 420b118 | 2010-05-06 05:35:16 +0000 | [diff] [blame] | 426 | |
| 427 | case Builtin::BI__builtin_isinf: { |
| 428 | // isinf(x) --> fabs(x) == infinity |
| 429 | Value *V = EmitScalarExpr(E->getArg(0)); |
| 430 | V = EmitFAbs(*this, V, E->getArg(0)->getType()); |
| 431 | |
| 432 | V = Builder.CreateFCmpOEQ(V, ConstantFP::getInfinity(V->getType()),"isinf"); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 433 | return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); |
Chris Lattner | 420b118 | 2010-05-06 05:35:16 +0000 | [diff] [blame] | 434 | } |
Chris Lattner | 58ae5b4 | 2010-05-06 06:13:53 +0000 | [diff] [blame] | 435 | |
| 436 | // TODO: BI__builtin_isinf_sign |
| 437 | // isinf_sign(x) -> isinf(x) ? (signbit(x) ? -1 : 1) : 0 |
Benjamin Kramer | 6349ce9 | 2010-05-19 11:24:26 +0000 | [diff] [blame] | 438 | |
| 439 | case Builtin::BI__builtin_isnormal: { |
| 440 | // isnormal(x) --> x == x && fabsf(x) < infinity && fabsf(x) >= float_min |
| 441 | Value *V = EmitScalarExpr(E->getArg(0)); |
| 442 | Value *Eq = Builder.CreateFCmpOEQ(V, V, "iseq"); |
| 443 | |
| 444 | Value *Abs = EmitFAbs(*this, V, E->getArg(0)->getType()); |
| 445 | Value *IsLessThanInf = |
| 446 | Builder.CreateFCmpULT(Abs, ConstantFP::getInfinity(V->getType()),"isinf"); |
| 447 | APFloat Smallest = APFloat::getSmallestNormalized( |
| 448 | getContext().getFloatTypeSemantics(E->getArg(0)->getType())); |
| 449 | Value *IsNormal = |
| 450 | Builder.CreateFCmpUGE(Abs, ConstantFP::get(V->getContext(), Smallest), |
| 451 | "isnormal"); |
| 452 | V = Builder.CreateAnd(Eq, IsLessThanInf, "and"); |
| 453 | V = Builder.CreateAnd(V, IsNormal, "and"); |
| 454 | return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); |
| 455 | } |
| 456 | |
Chris Lattner | ed07415 | 2010-05-06 06:04:13 +0000 | [diff] [blame] | 457 | case Builtin::BI__builtin_isfinite: { |
Julien Lerouge | ef004ec | 2011-09-09 22:46:39 +0000 | [diff] [blame] | 458 | // isfinite(x) --> x == x && fabs(x) != infinity; |
Chris Lattner | ed07415 | 2010-05-06 06:04:13 +0000 | [diff] [blame] | 459 | Value *V = EmitScalarExpr(E->getArg(0)); |
| 460 | Value *Eq = Builder.CreateFCmpOEQ(V, V, "iseq"); |
| 461 | |
| 462 | Value *Abs = EmitFAbs(*this, V, E->getArg(0)->getType()); |
| 463 | Value *IsNotInf = |
| 464 | Builder.CreateFCmpUNE(Abs, ConstantFP::getInfinity(V->getType()),"isinf"); |
| 465 | |
| 466 | V = Builder.CreateAnd(Eq, IsNotInf, "and"); |
| 467 | return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType()))); |
| 468 | } |
Benjamin Kramer | 7867f1a | 2010-06-14 10:30:41 +0000 | [diff] [blame] | 469 | |
| 470 | case Builtin::BI__builtin_fpclassify: { |
| 471 | Value *V = EmitScalarExpr(E->getArg(5)); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 472 | llvm::Type *Ty = ConvertType(E->getArg(5)->getType()); |
Benjamin Kramer | 7867f1a | 2010-06-14 10:30:41 +0000 | [diff] [blame] | 473 | |
| 474 | // Create Result |
| 475 | BasicBlock *Begin = Builder.GetInsertBlock(); |
| 476 | BasicBlock *End = createBasicBlock("fpclassify_end", this->CurFn); |
| 477 | Builder.SetInsertPoint(End); |
| 478 | PHINode *Result = |
Jay Foad | bbf3bac | 2011-03-30 11:28:58 +0000 | [diff] [blame] | 479 | Builder.CreatePHI(ConvertType(E->getArg(0)->getType()), 4, |
Benjamin Kramer | 7867f1a | 2010-06-14 10:30:41 +0000 | [diff] [blame] | 480 | "fpclassify_result"); |
| 481 | |
| 482 | // if (V==0) return FP_ZERO |
| 483 | Builder.SetInsertPoint(Begin); |
| 484 | Value *IsZero = Builder.CreateFCmpOEQ(V, Constant::getNullValue(Ty), |
| 485 | "iszero"); |
| 486 | Value *ZeroLiteral = EmitScalarExpr(E->getArg(4)); |
| 487 | BasicBlock *NotZero = createBasicBlock("fpclassify_not_zero", this->CurFn); |
| 488 | Builder.CreateCondBr(IsZero, End, NotZero); |
| 489 | Result->addIncoming(ZeroLiteral, Begin); |
| 490 | |
| 491 | // if (V != V) return FP_NAN |
| 492 | Builder.SetInsertPoint(NotZero); |
| 493 | Value *IsNan = Builder.CreateFCmpUNO(V, V, "cmp"); |
| 494 | Value *NanLiteral = EmitScalarExpr(E->getArg(0)); |
| 495 | BasicBlock *NotNan = createBasicBlock("fpclassify_not_nan", this->CurFn); |
| 496 | Builder.CreateCondBr(IsNan, End, NotNan); |
| 497 | Result->addIncoming(NanLiteral, NotZero); |
| 498 | |
| 499 | // if (fabs(V) == infinity) return FP_INFINITY |
| 500 | Builder.SetInsertPoint(NotNan); |
| 501 | Value *VAbs = EmitFAbs(*this, V, E->getArg(5)->getType()); |
| 502 | Value *IsInf = |
| 503 | Builder.CreateFCmpOEQ(VAbs, ConstantFP::getInfinity(V->getType()), |
| 504 | "isinf"); |
| 505 | Value *InfLiteral = EmitScalarExpr(E->getArg(1)); |
| 506 | BasicBlock *NotInf = createBasicBlock("fpclassify_not_inf", this->CurFn); |
| 507 | Builder.CreateCondBr(IsInf, End, NotInf); |
| 508 | Result->addIncoming(InfLiteral, NotNan); |
| 509 | |
| 510 | // if (fabs(V) >= MIN_NORMAL) return FP_NORMAL else FP_SUBNORMAL |
| 511 | Builder.SetInsertPoint(NotInf); |
| 512 | APFloat Smallest = APFloat::getSmallestNormalized( |
| 513 | getContext().getFloatTypeSemantics(E->getArg(5)->getType())); |
| 514 | Value *IsNormal = |
| 515 | Builder.CreateFCmpUGE(VAbs, ConstantFP::get(V->getContext(), Smallest), |
| 516 | "isnormal"); |
| 517 | Value *NormalResult = |
| 518 | Builder.CreateSelect(IsNormal, EmitScalarExpr(E->getArg(2)), |
| 519 | EmitScalarExpr(E->getArg(3))); |
| 520 | Builder.CreateBr(End); |
| 521 | Result->addIncoming(NormalResult, NotInf); |
| 522 | |
| 523 | // return Result |
| 524 | Builder.SetInsertPoint(End); |
| 525 | return RValue::get(Result); |
| 526 | } |
Chris Lattner | ed07415 | 2010-05-06 06:04:13 +0000 | [diff] [blame] | 527 | |
Eli Friedman | b52fe9c | 2009-06-02 07:10:30 +0000 | [diff] [blame] | 528 | case Builtin::BIalloca: |
Chris Lattner | 9e800e3 | 2008-06-16 17:15:14 +0000 | [diff] [blame] | 529 | case Builtin::BI__builtin_alloca: { |
Chris Lattner | 9e800e3 | 2008-06-16 17:15:14 +0000 | [diff] [blame] | 530 | Value *Size = EmitScalarExpr(E->getArg(0)); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 531 | return RValue::get(Builder.CreateAlloca(Builder.getInt8Ty(), Size)); |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 532 | } |
Eli Friedman | e6dddfd | 2010-01-23 19:00:10 +0000 | [diff] [blame] | 533 | case Builtin::BIbzero: |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 534 | case Builtin::BI__builtin_bzero: { |
| 535 | Value *Address = EmitScalarExpr(E->getArg(0)); |
Mon P Wang | 3ecd785 | 2010-04-04 03:10:52 +0000 | [diff] [blame] | 536 | Value *SizeVal = EmitScalarExpr(E->getArg(1)); |
Benjamin Kramer | 9f0c7cc | 2010-12-30 00:13:21 +0000 | [diff] [blame] | 537 | Builder.CreateMemSet(Address, Builder.getInt8(0), SizeVal, 1, false); |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 538 | return RValue::get(Address); |
Chris Lattner | 9e800e3 | 2008-06-16 17:15:14 +0000 | [diff] [blame] | 539 | } |
Eli Friedman | e6ec205 | 2009-12-17 00:14:28 +0000 | [diff] [blame] | 540 | case Builtin::BImemcpy: |
Eli Friedman | d4b32e4 | 2008-05-19 23:27:48 +0000 | [diff] [blame] | 541 | case Builtin::BI__builtin_memcpy: { |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 542 | Value *Address = EmitScalarExpr(E->getArg(0)); |
Mon P Wang | 3ecd785 | 2010-04-04 03:10:52 +0000 | [diff] [blame] | 543 | Value *SrcAddr = EmitScalarExpr(E->getArg(1)); |
| 544 | Value *SizeVal = EmitScalarExpr(E->getArg(2)); |
Benjamin Kramer | 9f0c7cc | 2010-12-30 00:13:21 +0000 | [diff] [blame] | 545 | Builder.CreateMemCpy(Address, SrcAddr, SizeVal, 1, false); |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 546 | return RValue::get(Address); |
| 547 | } |
Fariborz Jahanian | 55bcace | 2010-06-15 22:44:06 +0000 | [diff] [blame] | 548 | |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 549 | case Builtin::BI__builtin___memcpy_chk: { |
| 550 | // fold __builtin_memcpy_chk(x, y, cst1, cst2) to memset iff cst1<=cst2. |
Richard Smith | a6b8b2c | 2011-10-10 18:28:20 +0000 | [diff] [blame] | 551 | llvm::APSInt Size, DstSize; |
| 552 | if (!E->getArg(2)->EvaluateAsInt(Size, CGM.getContext()) || |
| 553 | !E->getArg(3)->EvaluateAsInt(DstSize, CGM.getContext())) |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 554 | break; |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 555 | if (Size.ugt(DstSize)) |
| 556 | break; |
| 557 | Value *Dest = EmitScalarExpr(E->getArg(0)); |
| 558 | Value *Src = EmitScalarExpr(E->getArg(1)); |
| 559 | Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size); |
| 560 | Builder.CreateMemCpy(Dest, Src, SizeVal, 1, false); |
Chris Lattner | 42f681b | 2011-04-20 23:14:50 +0000 | [diff] [blame] | 561 | return RValue::get(Dest); |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Fariborz Jahanian | 8e2eab2 | 2010-06-16 16:22:04 +0000 | [diff] [blame] | 564 | case Builtin::BI__builtin_objc_memmove_collectable: { |
Fariborz Jahanian | 55bcace | 2010-06-15 22:44:06 +0000 | [diff] [blame] | 565 | Value *Address = EmitScalarExpr(E->getArg(0)); |
| 566 | Value *SrcAddr = EmitScalarExpr(E->getArg(1)); |
| 567 | Value *SizeVal = EmitScalarExpr(E->getArg(2)); |
| 568 | CGM.getObjCRuntime().EmitGCMemmoveCollectable(*this, |
| 569 | Address, SrcAddr, SizeVal); |
| 570 | return RValue::get(Address); |
| 571 | } |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 572 | |
| 573 | case Builtin::BI__builtin___memmove_chk: { |
| 574 | // fold __builtin_memmove_chk(x, y, cst1, cst2) to memset iff cst1<=cst2. |
Richard Smith | a6b8b2c | 2011-10-10 18:28:20 +0000 | [diff] [blame] | 575 | llvm::APSInt Size, DstSize; |
| 576 | if (!E->getArg(2)->EvaluateAsInt(Size, CGM.getContext()) || |
| 577 | !E->getArg(3)->EvaluateAsInt(DstSize, CGM.getContext())) |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 578 | break; |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 579 | if (Size.ugt(DstSize)) |
| 580 | break; |
| 581 | Value *Dest = EmitScalarExpr(E->getArg(0)); |
| 582 | Value *Src = EmitScalarExpr(E->getArg(1)); |
| 583 | Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size); |
| 584 | Builder.CreateMemMove(Dest, Src, SizeVal, 1, false); |
Chris Lattner | 42f681b | 2011-04-20 23:14:50 +0000 | [diff] [blame] | 585 | return RValue::get(Dest); |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 586 | } |
| 587 | |
Eli Friedman | e6ec205 | 2009-12-17 00:14:28 +0000 | [diff] [blame] | 588 | case Builtin::BImemmove: |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 589 | case Builtin::BI__builtin_memmove: { |
| 590 | Value *Address = EmitScalarExpr(E->getArg(0)); |
Mon P Wang | 3ecd785 | 2010-04-04 03:10:52 +0000 | [diff] [blame] | 591 | Value *SrcAddr = EmitScalarExpr(E->getArg(1)); |
| 592 | Value *SizeVal = EmitScalarExpr(E->getArg(2)); |
Benjamin Kramer | 9f0c7cc | 2010-12-30 00:13:21 +0000 | [diff] [blame] | 593 | Builder.CreateMemMove(Address, SrcAddr, SizeVal, 1, false); |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 594 | return RValue::get(Address); |
| 595 | } |
Eli Friedman | e6ec205 | 2009-12-17 00:14:28 +0000 | [diff] [blame] | 596 | case Builtin::BImemset: |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 597 | case Builtin::BI__builtin_memset: { |
| 598 | Value *Address = EmitScalarExpr(E->getArg(0)); |
Benjamin Kramer | 9f0c7cc | 2010-12-30 00:13:21 +0000 | [diff] [blame] | 599 | Value *ByteVal = Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)), |
| 600 | Builder.getInt8Ty()); |
Mon P Wang | 3ecd785 | 2010-04-04 03:10:52 +0000 | [diff] [blame] | 601 | Value *SizeVal = EmitScalarExpr(E->getArg(2)); |
Benjamin Kramer | 9f0c7cc | 2010-12-30 00:13:21 +0000 | [diff] [blame] | 602 | Builder.CreateMemSet(Address, ByteVal, SizeVal, 1, false); |
Daniel Dunbar | 1caae95 | 2008-07-22 00:26:45 +0000 | [diff] [blame] | 603 | return RValue::get(Address); |
Eli Friedman | d4b32e4 | 2008-05-19 23:27:48 +0000 | [diff] [blame] | 604 | } |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 605 | case Builtin::BI__builtin___memset_chk: { |
| 606 | // fold __builtin_memset_chk(x, y, cst1, cst2) to memset iff cst1<=cst2. |
Richard Smith | a6b8b2c | 2011-10-10 18:28:20 +0000 | [diff] [blame] | 607 | llvm::APSInt Size, DstSize; |
| 608 | if (!E->getArg(2)->EvaluateAsInt(Size, CGM.getContext()) || |
| 609 | !E->getArg(3)->EvaluateAsInt(DstSize, CGM.getContext())) |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 610 | break; |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 611 | if (Size.ugt(DstSize)) |
| 612 | break; |
| 613 | Value *Address = EmitScalarExpr(E->getArg(0)); |
| 614 | Value *ByteVal = Builder.CreateTrunc(EmitScalarExpr(E->getArg(1)), |
| 615 | Builder.getInt8Ty()); |
| 616 | Value *SizeVal = llvm::ConstantInt::get(Builder.getContext(), Size); |
| 617 | Builder.CreateMemSet(Address, ByteVal, SizeVal, 1, false); |
| 618 | |
Chris Lattner | 42f681b | 2011-04-20 23:14:50 +0000 | [diff] [blame] | 619 | return RValue::get(Address); |
Chris Lattner | a5e5e0f | 2011-04-17 00:40:24 +0000 | [diff] [blame] | 620 | } |
John McCall | fb17a56 | 2010-03-03 10:30:05 +0000 | [diff] [blame] | 621 | case Builtin::BI__builtin_dwarf_cfa: { |
| 622 | // The offset in bytes from the first argument to the CFA. |
| 623 | // |
| 624 | // Why on earth is this in the frontend? Is there any reason at |
| 625 | // all that the backend can't reasonably determine this while |
| 626 | // lowering llvm.eh.dwarf.cfa()? |
| 627 | // |
| 628 | // TODO: If there's a satisfactory reason, add a target hook for |
| 629 | // this instead of hard-coding 0, which is correct for most targets. |
| 630 | int32_t Offset = 0; |
| 631 | |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 632 | Value *F = CGM.getIntrinsic(Intrinsic::eh_dwarf_cfa); |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 633 | return RValue::get(Builder.CreateCall(F, |
| 634 | llvm::ConstantInt::get(Int32Ty, Offset))); |
John McCall | fb17a56 | 2010-03-03 10:30:05 +0000 | [diff] [blame] | 635 | } |
Eli Friedman | 256f77e | 2008-05-20 08:59:34 +0000 | [diff] [blame] | 636 | case Builtin::BI__builtin_return_address: { |
Anton Korobeynikov | 83c2a98 | 2009-12-27 14:27:22 +0000 | [diff] [blame] | 637 | Value *Depth = EmitScalarExpr(E->getArg(0)); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 638 | Depth = Builder.CreateIntCast(Depth, Int32Ty, false); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 639 | Value *F = CGM.getIntrinsic(Intrinsic::returnaddress); |
Anton Korobeynikov | 83c2a98 | 2009-12-27 14:27:22 +0000 | [diff] [blame] | 640 | return RValue::get(Builder.CreateCall(F, Depth)); |
Eli Friedman | 256f77e | 2008-05-20 08:59:34 +0000 | [diff] [blame] | 641 | } |
| 642 | case Builtin::BI__builtin_frame_address: { |
Anton Korobeynikov | 83c2a98 | 2009-12-27 14:27:22 +0000 | [diff] [blame] | 643 | Value *Depth = EmitScalarExpr(E->getArg(0)); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 644 | Depth = Builder.CreateIntCast(Depth, Int32Ty, false); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 645 | Value *F = CGM.getIntrinsic(Intrinsic::frameaddress); |
Anton Korobeynikov | 83c2a98 | 2009-12-27 14:27:22 +0000 | [diff] [blame] | 646 | return RValue::get(Builder.CreateCall(F, Depth)); |
Eli Friedman | 256f77e | 2008-05-20 08:59:34 +0000 | [diff] [blame] | 647 | } |
Eli Friedman | 3b660ef | 2009-05-03 19:23:23 +0000 | [diff] [blame] | 648 | case Builtin::BI__builtin_extract_return_addr: { |
John McCall | 492c4f9 | 2010-03-03 04:15:11 +0000 | [diff] [blame] | 649 | Value *Address = EmitScalarExpr(E->getArg(0)); |
| 650 | Value *Result = getTargetHooks().decodeReturnAddress(*this, Address); |
| 651 | return RValue::get(Result); |
| 652 | } |
| 653 | case Builtin::BI__builtin_frob_return_addr: { |
| 654 | Value *Address = EmitScalarExpr(E->getArg(0)); |
| 655 | Value *Result = getTargetHooks().encodeReturnAddress(*this, Address); |
| 656 | return RValue::get(Result); |
Eli Friedman | 3b660ef | 2009-05-03 19:23:23 +0000 | [diff] [blame] | 657 | } |
John McCall | 6374c33 | 2010-03-06 00:35:14 +0000 | [diff] [blame] | 658 | case Builtin::BI__builtin_dwarf_sp_column: { |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 659 | llvm::IntegerType *Ty |
John McCall | 6374c33 | 2010-03-06 00:35:14 +0000 | [diff] [blame] | 660 | = cast<llvm::IntegerType>(ConvertType(E->getType())); |
| 661 | int Column = getTargetHooks().getDwarfEHStackPointer(CGM); |
| 662 | if (Column == -1) { |
| 663 | CGM.ErrorUnsupported(E, "__builtin_dwarf_sp_column"); |
| 664 | return RValue::get(llvm::UndefValue::get(Ty)); |
| 665 | } |
| 666 | return RValue::get(llvm::ConstantInt::get(Ty, Column, true)); |
| 667 | } |
| 668 | case Builtin::BI__builtin_init_dwarf_reg_size_table: { |
| 669 | Value *Address = EmitScalarExpr(E->getArg(0)); |
| 670 | if (getTargetHooks().initDwarfEHRegSizeTable(*this, Address)) |
| 671 | CGM.ErrorUnsupported(E, "__builtin_init_dwarf_reg_size_table"); |
| 672 | return RValue::get(llvm::UndefValue::get(ConvertType(E->getType()))); |
| 673 | } |
John McCall | 7ada111 | 2010-03-03 05:38:58 +0000 | [diff] [blame] | 674 | case Builtin::BI__builtin_eh_return: { |
| 675 | Value *Int = EmitScalarExpr(E->getArg(0)); |
| 676 | Value *Ptr = EmitScalarExpr(E->getArg(1)); |
| 677 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 678 | llvm::IntegerType *IntTy = cast<llvm::IntegerType>(Int->getType()); |
John McCall | 7ada111 | 2010-03-03 05:38:58 +0000 | [diff] [blame] | 679 | assert((IntTy->getBitWidth() == 32 || IntTy->getBitWidth() == 64) && |
| 680 | "LLVM's __builtin_eh_return only supports 32- and 64-bit variants"); |
| 681 | Value *F = CGM.getIntrinsic(IntTy->getBitWidth() == 32 |
| 682 | ? Intrinsic::eh_return_i32 |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 683 | : Intrinsic::eh_return_i64); |
John McCall | 7ada111 | 2010-03-03 05:38:58 +0000 | [diff] [blame] | 684 | Builder.CreateCall2(F, Int, Ptr); |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 685 | Builder.CreateUnreachable(); |
| 686 | |
| 687 | // We do need to preserve an insertion point. |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 688 | EmitBlock(createBasicBlock("builtin_eh_return.cont")); |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 689 | |
| 690 | return RValue::get(0); |
John McCall | 7ada111 | 2010-03-03 05:38:58 +0000 | [diff] [blame] | 691 | } |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 692 | case Builtin::BI__builtin_unwind_init: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 693 | Value *F = CGM.getIntrinsic(Intrinsic::eh_unwind_init); |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 694 | return RValue::get(Builder.CreateCall(F)); |
| 695 | } |
John McCall | 5e11085 | 2010-03-02 02:31:24 +0000 | [diff] [blame] | 696 | case Builtin::BI__builtin_extend_pointer: { |
| 697 | // Extends a pointer to the size of an _Unwind_Word, which is |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 698 | // uint64_t on all platforms. Generally this gets poked into a |
| 699 | // register and eventually used as an address, so if the |
| 700 | // addressing registers are wider than pointers and the platform |
| 701 | // doesn't implicitly ignore high-order bits when doing |
| 702 | // addressing, we need to make sure we zext / sext based on |
| 703 | // the platform's expectations. |
John McCall | 5e11085 | 2010-03-02 02:31:24 +0000 | [diff] [blame] | 704 | // |
| 705 | // See: http://gcc.gnu.org/ml/gcc-bugs/2002-02/msg00237.html |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 706 | |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 707 | // Cast the pointer to intptr_t. |
John McCall | 5e11085 | 2010-03-02 02:31:24 +0000 | [diff] [blame] | 708 | Value *Ptr = EmitScalarExpr(E->getArg(0)); |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 709 | Value *Result = Builder.CreatePtrToInt(Ptr, IntPtrTy, "extend.cast"); |
| 710 | |
| 711 | // If that's 64 bits, we're done. |
| 712 | if (IntPtrTy->getBitWidth() == 64) |
| 713 | return RValue::get(Result); |
| 714 | |
| 715 | // Otherwise, ask the codegen data what to do. |
John McCall | 492c4f9 | 2010-03-03 04:15:11 +0000 | [diff] [blame] | 716 | if (getTargetHooks().extendPointerWithSExt()) |
John McCall | d0b76ca | 2010-03-02 03:50:12 +0000 | [diff] [blame] | 717 | return RValue::get(Builder.CreateSExt(Result, Int64Ty, "extend.sext")); |
| 718 | else |
| 719 | return RValue::get(Builder.CreateZExt(Result, Int64Ty, "extend.zext")); |
John McCall | 5e11085 | 2010-03-02 02:31:24 +0000 | [diff] [blame] | 720 | } |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 721 | case Builtin::BI__builtin_setjmp: { |
John McCall | 78673d9 | 2010-05-27 18:47:06 +0000 | [diff] [blame] | 722 | // Buffer is a void**. |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 723 | Value *Buf = EmitScalarExpr(E->getArg(0)); |
John McCall | 78673d9 | 2010-05-27 18:47:06 +0000 | [diff] [blame] | 724 | |
| 725 | // Store the frame pointer to the setjmp buffer. |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 726 | Value *FrameAddr = |
John McCall | 78673d9 | 2010-05-27 18:47:06 +0000 | [diff] [blame] | 727 | Builder.CreateCall(CGM.getIntrinsic(Intrinsic::frameaddress), |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 728 | ConstantInt::get(Int32Ty, 0)); |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 729 | Builder.CreateStore(FrameAddr, Buf); |
John McCall | 78673d9 | 2010-05-27 18:47:06 +0000 | [diff] [blame] | 730 | |
Jim Grosbach | 6d172e2 | 2010-05-27 23:54:20 +0000 | [diff] [blame] | 731 | // Store the stack pointer to the setjmp buffer. |
| 732 | Value *StackAddr = |
| 733 | Builder.CreateCall(CGM.getIntrinsic(Intrinsic::stacksave)); |
| 734 | Value *StackSaveSlot = |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 735 | Builder.CreateGEP(Buf, ConstantInt::get(Int32Ty, 2)); |
Jim Grosbach | 6d172e2 | 2010-05-27 23:54:20 +0000 | [diff] [blame] | 736 | Builder.CreateStore(StackAddr, StackSaveSlot); |
| 737 | |
John McCall | 78673d9 | 2010-05-27 18:47:06 +0000 | [diff] [blame] | 738 | // Call LLVM's EH setjmp, which is lightweight. |
| 739 | Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 740 | Buf = Builder.CreateBitCast(Buf, Int8PtrTy); |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 741 | return RValue::get(Builder.CreateCall(F, Buf)); |
| 742 | } |
| 743 | case Builtin::BI__builtin_longjmp: { |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 744 | Value *Buf = EmitScalarExpr(E->getArg(0)); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 745 | Buf = Builder.CreateBitCast(Buf, Int8PtrTy); |
John McCall | 78673d9 | 2010-05-27 18:47:06 +0000 | [diff] [blame] | 746 | |
| 747 | // Call LLVM's EH longjmp, which is lightweight. |
| 748 | Builder.CreateCall(CGM.getIntrinsic(Intrinsic::eh_sjlj_longjmp), Buf); |
| 749 | |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 750 | // longjmp doesn't return; mark this as unreachable. |
| 751 | Builder.CreateUnreachable(); |
| 752 | |
| 753 | // We do need to preserve an insertion point. |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 754 | EmitBlock(createBasicBlock("longjmp.cont")); |
John McCall | cd5b22e | 2011-01-12 03:41:02 +0000 | [diff] [blame] | 755 | |
| 756 | return RValue::get(0); |
Eli Friedman | a6d75c0 | 2009-06-02 09:37:50 +0000 | [diff] [blame] | 757 | } |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 758 | case Builtin::BI__sync_fetch_and_add: |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 759 | case Builtin::BI__sync_fetch_and_sub: |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 760 | case Builtin::BI__sync_fetch_and_or: |
| 761 | case Builtin::BI__sync_fetch_and_and: |
| 762 | case Builtin::BI__sync_fetch_and_xor: |
| 763 | case Builtin::BI__sync_add_and_fetch: |
| 764 | case Builtin::BI__sync_sub_and_fetch: |
| 765 | case Builtin::BI__sync_and_and_fetch: |
| 766 | case Builtin::BI__sync_or_and_fetch: |
| 767 | case Builtin::BI__sync_xor_and_fetch: |
| 768 | case Builtin::BI__sync_val_compare_and_swap: |
| 769 | case Builtin::BI__sync_bool_compare_and_swap: |
| 770 | case Builtin::BI__sync_lock_test_and_set: |
| 771 | case Builtin::BI__sync_lock_release: |
Chris Lattner | 23aa9c8 | 2011-04-09 03:57:26 +0000 | [diff] [blame] | 772 | case Builtin::BI__sync_swap: |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 773 | llvm_unreachable("Shouldn't make it through sema"); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 774 | case Builtin::BI__sync_fetch_and_add_1: |
| 775 | case Builtin::BI__sync_fetch_and_add_2: |
| 776 | case Builtin::BI__sync_fetch_and_add_4: |
| 777 | case Builtin::BI__sync_fetch_and_add_8: |
| 778 | case Builtin::BI__sync_fetch_and_add_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 779 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Add, E); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 780 | case Builtin::BI__sync_fetch_and_sub_1: |
| 781 | case Builtin::BI__sync_fetch_and_sub_2: |
| 782 | case Builtin::BI__sync_fetch_and_sub_4: |
| 783 | case Builtin::BI__sync_fetch_and_sub_8: |
| 784 | case Builtin::BI__sync_fetch_and_sub_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 785 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Sub, E); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 786 | case Builtin::BI__sync_fetch_and_or_1: |
| 787 | case Builtin::BI__sync_fetch_and_or_2: |
| 788 | case Builtin::BI__sync_fetch_and_or_4: |
| 789 | case Builtin::BI__sync_fetch_and_or_8: |
| 790 | case Builtin::BI__sync_fetch_and_or_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 791 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Or, E); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 792 | case Builtin::BI__sync_fetch_and_and_1: |
| 793 | case Builtin::BI__sync_fetch_and_and_2: |
| 794 | case Builtin::BI__sync_fetch_and_and_4: |
| 795 | case Builtin::BI__sync_fetch_and_and_8: |
| 796 | case Builtin::BI__sync_fetch_and_and_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 797 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::And, E); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 798 | case Builtin::BI__sync_fetch_and_xor_1: |
| 799 | case Builtin::BI__sync_fetch_and_xor_2: |
| 800 | case Builtin::BI__sync_fetch_and_xor_4: |
| 801 | case Builtin::BI__sync_fetch_and_xor_8: |
| 802 | case Builtin::BI__sync_fetch_and_xor_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 803 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xor, E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 804 | |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 805 | // Clang extensions: not overloaded yet. |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 806 | case Builtin::BI__sync_fetch_and_min: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 807 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Min, E); |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 808 | case Builtin::BI__sync_fetch_and_max: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 809 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Max, E); |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 810 | case Builtin::BI__sync_fetch_and_umin: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 811 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::UMin, E); |
Mon P Wang | 1ffe281 | 2008-05-09 22:40:52 +0000 | [diff] [blame] | 812 | case Builtin::BI__sync_fetch_and_umax: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 813 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::UMax, E); |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 814 | |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 815 | case Builtin::BI__sync_add_and_fetch_1: |
| 816 | case Builtin::BI__sync_add_and_fetch_2: |
| 817 | case Builtin::BI__sync_add_and_fetch_4: |
| 818 | case Builtin::BI__sync_add_and_fetch_8: |
| 819 | case Builtin::BI__sync_add_and_fetch_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 820 | return EmitBinaryAtomicPost(*this, llvm::AtomicRMWInst::Add, E, |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 821 | llvm::Instruction::Add); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 822 | case Builtin::BI__sync_sub_and_fetch_1: |
| 823 | case Builtin::BI__sync_sub_and_fetch_2: |
| 824 | case Builtin::BI__sync_sub_and_fetch_4: |
| 825 | case Builtin::BI__sync_sub_and_fetch_8: |
| 826 | case Builtin::BI__sync_sub_and_fetch_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 827 | return EmitBinaryAtomicPost(*this, llvm::AtomicRMWInst::Sub, E, |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 828 | llvm::Instruction::Sub); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 829 | case Builtin::BI__sync_and_and_fetch_1: |
| 830 | case Builtin::BI__sync_and_and_fetch_2: |
| 831 | case Builtin::BI__sync_and_and_fetch_4: |
| 832 | case Builtin::BI__sync_and_and_fetch_8: |
| 833 | case Builtin::BI__sync_and_and_fetch_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 834 | return EmitBinaryAtomicPost(*this, llvm::AtomicRMWInst::And, E, |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 835 | llvm::Instruction::And); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 836 | case Builtin::BI__sync_or_and_fetch_1: |
| 837 | case Builtin::BI__sync_or_and_fetch_2: |
| 838 | case Builtin::BI__sync_or_and_fetch_4: |
| 839 | case Builtin::BI__sync_or_and_fetch_8: |
| 840 | case Builtin::BI__sync_or_and_fetch_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 841 | return EmitBinaryAtomicPost(*this, llvm::AtomicRMWInst::Or, E, |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 842 | llvm::Instruction::Or); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 843 | case Builtin::BI__sync_xor_and_fetch_1: |
| 844 | case Builtin::BI__sync_xor_and_fetch_2: |
| 845 | case Builtin::BI__sync_xor_and_fetch_4: |
| 846 | case Builtin::BI__sync_xor_and_fetch_8: |
| 847 | case Builtin::BI__sync_xor_and_fetch_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 848 | return EmitBinaryAtomicPost(*this, llvm::AtomicRMWInst::Xor, E, |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 849 | llvm::Instruction::Xor); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 850 | |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 851 | case Builtin::BI__sync_val_compare_and_swap_1: |
| 852 | case Builtin::BI__sync_val_compare_and_swap_2: |
| 853 | case Builtin::BI__sync_val_compare_and_swap_4: |
| 854 | case Builtin::BI__sync_val_compare_and_swap_8: |
Daniel Dunbar | cb61a7b | 2010-03-20 07:04:11 +0000 | [diff] [blame] | 855 | case Builtin::BI__sync_val_compare_and_swap_16: { |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 856 | QualType T = E->getType(); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 857 | llvm::Value *DestPtr = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | 780a2eb | 2010-09-21 23:35:30 +0000 | [diff] [blame] | 858 | unsigned AddrSpace = |
Chris Lattner | 4f20944 | 2010-09-21 23:40:48 +0000 | [diff] [blame] | 859 | cast<llvm::PointerType>(DestPtr->getType())->getAddressSpace(); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 860 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 861 | llvm::IntegerType *IntType = |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 862 | llvm::IntegerType::get(getLLVMContext(), |
| 863 | getContext().getTypeSize(T)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 864 | llvm::Type *IntPtrType = IntType->getPointerTo(AddrSpace); |
Chandler Carruth | db4325b | 2010-07-18 07:23:17 +0000 | [diff] [blame] | 865 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 866 | Value *Args[3]; |
| 867 | Args[0] = Builder.CreateBitCast(DestPtr, IntPtrType); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 868 | Args[1] = EmitScalarExpr(E->getArg(1)); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 869 | llvm::Type *ValueType = Args[1]->getType(); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 870 | Args[1] = EmitToInt(*this, Args[1], T, IntType); |
| 871 | Args[2] = EmitToInt(*this, EmitScalarExpr(E->getArg(2)), T, IntType); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 872 | |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 873 | Value *Result = Builder.CreateAtomicCmpXchg(Args[0], Args[1], Args[2], |
| 874 | llvm::SequentiallyConsistent); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 875 | Result = EmitFromInt(*this, Result, T, ValueType); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 876 | return RValue::get(Result); |
Anders Carlsson | 89799cf | 2007-10-29 02:59:40 +0000 | [diff] [blame] | 877 | } |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 878 | |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 879 | case Builtin::BI__sync_bool_compare_and_swap_1: |
| 880 | case Builtin::BI__sync_bool_compare_and_swap_2: |
| 881 | case Builtin::BI__sync_bool_compare_and_swap_4: |
| 882 | case Builtin::BI__sync_bool_compare_and_swap_8: |
Daniel Dunbar | cb61a7b | 2010-03-20 07:04:11 +0000 | [diff] [blame] | 883 | case Builtin::BI__sync_bool_compare_and_swap_16: { |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 884 | QualType T = E->getArg(1)->getType(); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 885 | llvm::Value *DestPtr = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | f2b9527 | 2010-09-21 23:24:52 +0000 | [diff] [blame] | 886 | unsigned AddrSpace = |
Chris Lattner | 4f20944 | 2010-09-21 23:40:48 +0000 | [diff] [blame] | 887 | cast<llvm::PointerType>(DestPtr->getType())->getAddressSpace(); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 888 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 889 | llvm::IntegerType *IntType = |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 890 | llvm::IntegerType::get(getLLVMContext(), |
| 891 | getContext().getTypeSize(T)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 892 | llvm::Type *IntPtrType = IntType->getPointerTo(AddrSpace); |
Chandler Carruth | db4325b | 2010-07-18 07:23:17 +0000 | [diff] [blame] | 893 | |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 894 | Value *Args[3]; |
| 895 | Args[0] = Builder.CreateBitCast(DestPtr, IntPtrType); |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 896 | Args[1] = EmitToInt(*this, EmitScalarExpr(E->getArg(1)), T, IntType); |
| 897 | Args[2] = EmitToInt(*this, EmitScalarExpr(E->getArg(2)), T, IntType); |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 898 | |
Chandler Carruth | db4325b | 2010-07-18 07:23:17 +0000 | [diff] [blame] | 899 | Value *OldVal = Args[1]; |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 900 | Value *PrevVal = Builder.CreateAtomicCmpXchg(Args[0], Args[1], Args[2], |
| 901 | llvm::SequentiallyConsistent); |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 902 | Value *Result = Builder.CreateICmpEQ(PrevVal, OldVal); |
| 903 | // zext bool to int. |
John McCall | 26815d9 | 2010-10-27 20:58:56 +0000 | [diff] [blame] | 904 | Result = Builder.CreateZExt(Result, ConvertType(E->getType())); |
| 905 | return RValue::get(Result); |
Daniel Dunbar | 0002d23 | 2009-04-07 00:55:51 +0000 | [diff] [blame] | 906 | } |
| 907 | |
Chris Lattner | 23aa9c8 | 2011-04-09 03:57:26 +0000 | [diff] [blame] | 908 | case Builtin::BI__sync_swap_1: |
| 909 | case Builtin::BI__sync_swap_2: |
| 910 | case Builtin::BI__sync_swap_4: |
| 911 | case Builtin::BI__sync_swap_8: |
| 912 | case Builtin::BI__sync_swap_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 913 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E); |
Chris Lattner | 23aa9c8 | 2011-04-09 03:57:26 +0000 | [diff] [blame] | 914 | |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 915 | case Builtin::BI__sync_lock_test_and_set_1: |
| 916 | case Builtin::BI__sync_lock_test_and_set_2: |
| 917 | case Builtin::BI__sync_lock_test_and_set_4: |
| 918 | case Builtin::BI__sync_lock_test_and_set_8: |
| 919 | case Builtin::BI__sync_lock_test_and_set_16: |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 920 | return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E); |
Daniel Dunbar | cb61a7b | 2010-03-20 07:04:11 +0000 | [diff] [blame] | 921 | |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 922 | case Builtin::BI__sync_lock_release_1: |
| 923 | case Builtin::BI__sync_lock_release_2: |
| 924 | case Builtin::BI__sync_lock_release_4: |
| 925 | case Builtin::BI__sync_lock_release_8: |
Chris Lattner | f58cd9b | 2009-05-13 04:46:13 +0000 | [diff] [blame] | 926 | case Builtin::BI__sync_lock_release_16: { |
| 927 | Value *Ptr = EmitScalarExpr(E->getArg(0)); |
Eli Friedman | eb43f4a | 2011-09-13 22:21:56 +0000 | [diff] [blame] | 928 | llvm::Type *ElLLVMTy = |
Chris Lattner | f58cd9b | 2009-05-13 04:46:13 +0000 | [diff] [blame] | 929 | cast<llvm::PointerType>(Ptr->getType())->getElementType(); |
Daniel Dunbar | 007b567 | 2009-11-29 21:11:47 +0000 | [diff] [blame] | 930 | llvm::StoreInst *Store = |
Eli Friedman | eb43f4a | 2011-09-13 22:21:56 +0000 | [diff] [blame] | 931 | Builder.CreateStore(llvm::Constant::getNullValue(ElLLVMTy), Ptr); |
| 932 | QualType ElTy = E->getArg(0)->getType()->getPointeeType(); |
| 933 | CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy); |
| 934 | Store->setAlignment(StoreSize.getQuantity()); |
| 935 | Store->setAtomic(llvm::Release); |
Daniel Dunbar | eb4f81e | 2009-05-27 23:45:33 +0000 | [diff] [blame] | 936 | return RValue::get(0); |
Chris Lattner | f58cd9b | 2009-05-13 04:46:13 +0000 | [diff] [blame] | 937 | } |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 938 | |
Chris Lattner | f58cd9b | 2009-05-13 04:46:13 +0000 | [diff] [blame] | 939 | case Builtin::BI__sync_synchronize: { |
Eli Friedman | c83b975 | 2011-09-07 01:41:24 +0000 | [diff] [blame] | 940 | // We assume this is supposed to correspond to a C++0x-style |
| 941 | // sequentially-consistent fence (i.e. this is only usable for |
| 942 | // synchonization, not device I/O or anything like that). This intrinsic |
| 943 | // is really badly designed in the sense that in theory, there isn't |
| 944 | // any way to safely use it... but in practice, it mostly works |
| 945 | // to use it with non-atomic loads and stores to get acquire/release |
| 946 | // semantics. |
| 947 | Builder.CreateFence(llvm::SequentiallyConsistent); |
Daniel Dunbar | eb4f81e | 2009-05-27 23:45:33 +0000 | [diff] [blame] | 948 | return RValue::get(0); |
Chris Lattner | f58cd9b | 2009-05-13 04:46:13 +0000 | [diff] [blame] | 949 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 950 | |
Eli Friedman | 276b061 | 2011-10-11 02:20:01 +0000 | [diff] [blame] | 951 | case Builtin::BI__atomic_thread_fence: |
| 952 | case Builtin::BI__atomic_signal_fence: { |
| 953 | llvm::SynchronizationScope Scope; |
| 954 | if (BuiltinID == Builtin::BI__atomic_signal_fence) |
| 955 | Scope = llvm::SingleThread; |
| 956 | else |
| 957 | Scope = llvm::CrossThread; |
| 958 | Value *Order = EmitScalarExpr(E->getArg(0)); |
| 959 | if (isa<llvm::ConstantInt>(Order)) { |
| 960 | int ord = cast<llvm::ConstantInt>(Order)->getZExtValue(); |
| 961 | switch (ord) { |
| 962 | case 0: // memory_order_relaxed |
| 963 | default: // invalid order |
| 964 | break; |
| 965 | case 1: // memory_order_consume |
| 966 | case 2: // memory_order_acquire |
| 967 | Builder.CreateFence(llvm::Acquire, Scope); |
| 968 | break; |
| 969 | case 3: // memory_order_release |
| 970 | Builder.CreateFence(llvm::Release, Scope); |
| 971 | break; |
| 972 | case 4: // memory_order_acq_rel |
| 973 | Builder.CreateFence(llvm::AcquireRelease, Scope); |
| 974 | break; |
| 975 | case 5: // memory_order_seq_cst |
| 976 | Builder.CreateFence(llvm::SequentiallyConsistent, Scope); |
| 977 | break; |
| 978 | } |
| 979 | return RValue::get(0); |
| 980 | } |
| 981 | |
| 982 | llvm::BasicBlock *AcquireBB, *ReleaseBB, *AcqRelBB, *SeqCstBB; |
| 983 | AcquireBB = createBasicBlock("acquire", CurFn); |
| 984 | ReleaseBB = createBasicBlock("release", CurFn); |
| 985 | AcqRelBB = createBasicBlock("acqrel", CurFn); |
| 986 | SeqCstBB = createBasicBlock("seqcst", CurFn); |
| 987 | llvm::BasicBlock *ContBB = createBasicBlock("atomic.continue", CurFn); |
| 988 | |
| 989 | Order = Builder.CreateIntCast(Order, Builder.getInt32Ty(), false); |
| 990 | llvm::SwitchInst *SI = Builder.CreateSwitch(Order, ContBB); |
| 991 | |
| 992 | Builder.SetInsertPoint(AcquireBB); |
| 993 | Builder.CreateFence(llvm::Acquire, Scope); |
| 994 | Builder.CreateBr(ContBB); |
| 995 | SI->addCase(Builder.getInt32(1), AcquireBB); |
| 996 | SI->addCase(Builder.getInt32(2), AcquireBB); |
| 997 | |
| 998 | Builder.SetInsertPoint(ReleaseBB); |
| 999 | Builder.CreateFence(llvm::Release, Scope); |
| 1000 | Builder.CreateBr(ContBB); |
| 1001 | SI->addCase(Builder.getInt32(3), ReleaseBB); |
| 1002 | |
| 1003 | Builder.SetInsertPoint(AcqRelBB); |
| 1004 | Builder.CreateFence(llvm::AcquireRelease, Scope); |
| 1005 | Builder.CreateBr(ContBB); |
| 1006 | SI->addCase(Builder.getInt32(4), AcqRelBB); |
| 1007 | |
| 1008 | Builder.SetInsertPoint(SeqCstBB); |
| 1009 | Builder.CreateFence(llvm::SequentiallyConsistent, Scope); |
| 1010 | Builder.CreateBr(ContBB); |
| 1011 | SI->addCase(Builder.getInt32(5), SeqCstBB); |
| 1012 | |
| 1013 | Builder.SetInsertPoint(ContBB); |
| 1014 | return RValue::get(0); |
| 1015 | } |
| 1016 | |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 1017 | // Library functions with special handling. |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 1018 | case Builtin::BIsqrt: |
| 1019 | case Builtin::BIsqrtf: |
| 1020 | case Builtin::BIsqrtl: { |
John McCall | beb4128 | 2010-04-07 08:20:20 +0000 | [diff] [blame] | 1021 | // TODO: there is currently no set of optimizer flags |
| 1022 | // sufficient for us to rewrite sqrt to @llvm.sqrt. |
| 1023 | // -fmath-errno=0 is not good enough; we need finiteness. |
| 1024 | // We could probably precondition the call with an ult |
| 1025 | // against 0, but is that worth the complexity? |
| 1026 | break; |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | case Builtin::BIpow: |
| 1030 | case Builtin::BIpowf: |
| 1031 | case Builtin::BIpowl: { |
| 1032 | // Rewrite sqrt to intrinsic if allowed. |
Argyrios Kyrtzidis | 40b598e | 2009-06-30 02:34:44 +0000 | [diff] [blame] | 1033 | if (!FD->hasAttr<ConstAttr>()) |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 1034 | break; |
| 1035 | Value *Base = EmitScalarExpr(E->getArg(0)); |
| 1036 | Value *Exponent = EmitScalarExpr(E->getArg(1)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1037 | llvm::Type *ArgType = Base->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1038 | Value *F = CGM.getIntrinsic(Intrinsic::pow, ArgType); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 1039 | return RValue::get(Builder.CreateCall2(F, Base, Exponent)); |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 1040 | } |
Eli Friedman | ba68b08 | 2010-03-06 02:17:52 +0000 | [diff] [blame] | 1041 | |
Cameron Zwarich | 094240a | 2011-07-08 21:39:34 +0000 | [diff] [blame] | 1042 | case Builtin::BIfma: |
| 1043 | case Builtin::BIfmaf: |
| 1044 | case Builtin::BIfmal: |
| 1045 | case Builtin::BI__builtin_fma: |
| 1046 | case Builtin::BI__builtin_fmaf: |
| 1047 | case Builtin::BI__builtin_fmal: { |
| 1048 | // Rewrite fma to intrinsic. |
| 1049 | Value *FirstArg = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1050 | llvm::Type *ArgType = FirstArg->getType(); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1051 | Value *F = CGM.getIntrinsic(Intrinsic::fma, ArgType); |
Cameron Zwarich | 094240a | 2011-07-08 21:39:34 +0000 | [diff] [blame] | 1052 | return RValue::get(Builder.CreateCall3(F, FirstArg, |
| 1053 | EmitScalarExpr(E->getArg(1)), |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 1054 | EmitScalarExpr(E->getArg(2)))); |
Cameron Zwarich | 094240a | 2011-07-08 21:39:34 +0000 | [diff] [blame] | 1055 | } |
| 1056 | |
Eli Friedman | ba68b08 | 2010-03-06 02:17:52 +0000 | [diff] [blame] | 1057 | case Builtin::BI__builtin_signbit: |
| 1058 | case Builtin::BI__builtin_signbitf: |
| 1059 | case Builtin::BI__builtin_signbitl: { |
| 1060 | LLVMContext &C = CGM.getLLVMContext(); |
| 1061 | |
| 1062 | Value *Arg = EmitScalarExpr(E->getArg(0)); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1063 | llvm::Type *ArgTy = Arg->getType(); |
Eli Friedman | ba68b08 | 2010-03-06 02:17:52 +0000 | [diff] [blame] | 1064 | if (ArgTy->isPPC_FP128Ty()) |
| 1065 | break; // FIXME: I'm not sure what the right implementation is here. |
| 1066 | int ArgWidth = ArgTy->getPrimitiveSizeInBits(); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1067 | llvm::Type *ArgIntTy = llvm::IntegerType::get(C, ArgWidth); |
Eli Friedman | ba68b08 | 2010-03-06 02:17:52 +0000 | [diff] [blame] | 1068 | Value *BCArg = Builder.CreateBitCast(Arg, ArgIntTy); |
| 1069 | Value *ZeroCmp = llvm::Constant::getNullValue(ArgIntTy); |
| 1070 | Value *Result = Builder.CreateICmpSLT(BCArg, ZeroCmp); |
| 1071 | return RValue::get(Builder.CreateZExt(Result, ConvertType(E->getType()))); |
| 1072 | } |
Julien Lerouge | 77f68bb | 2011-09-09 22:41:49 +0000 | [diff] [blame] | 1073 | case Builtin::BI__builtin_annotation: { |
| 1074 | llvm::Value *AnnVal = EmitScalarExpr(E->getArg(0)); |
| 1075 | llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::annotation, |
| 1076 | AnnVal->getType()); |
| 1077 | |
| 1078 | // Get the annotation string, go through casts. Sema requires this to be a |
| 1079 | // non-wide string literal, potentially casted, so the cast<> is safe. |
| 1080 | const Expr *AnnotationStrExpr = E->getArg(1)->IgnoreParenCasts(); |
| 1081 | llvm::StringRef Str = cast<StringLiteral>(AnnotationStrExpr)->getString(); |
| 1082 | return RValue::get(EmitAnnotationCall(F, AnnVal, Str, E->getExprLoc())); |
| 1083 | } |
Nate Begeman | 7ea2e3f | 2008-05-15 07:38:03 +0000 | [diff] [blame] | 1084 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1085 | |
John McCall | a45680b | 2011-09-13 23:05:03 +0000 | [diff] [blame] | 1086 | // If this is an alias for a lib function (e.g. __builtin_sin), emit |
| 1087 | // the call using the normal call path, but using the unmangled |
| 1088 | // version of the function name. |
| 1089 | if (getContext().BuiltinInfo.isLibFunction(BuiltinID)) |
| 1090 | return emitLibraryCall(*this, FD, E, |
| 1091 | CGM.getBuiltinLibFunction(FD, BuiltinID)); |
| 1092 | |
| 1093 | // If this is a predefined lib function (e.g. malloc), emit the call |
| 1094 | // using exactly the normal call path. |
| 1095 | if (getContext().BuiltinInfo.isPredefinedLibFunction(BuiltinID)) |
| 1096 | return emitLibraryCall(*this, FD, E, EmitScalarExpr(E->getCallee())); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1097 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1098 | // See if we have a target specific intrinsic. |
Dale Johannesen | a6f80ef | 2009-02-05 01:50:47 +0000 | [diff] [blame] | 1099 | const char *Name = getContext().BuiltinInfo.GetName(BuiltinID); |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1100 | Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic; |
| 1101 | if (const char *Prefix = |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1102 | llvm::Triple::getArchTypePrefix(Target.getTriple().getArch())) |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1103 | IntrinsicID = Intrinsic::getIntrinsicForGCCBuiltin(Prefix, Name); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1104 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1105 | if (IntrinsicID != Intrinsic::not_intrinsic) { |
| 1106 | SmallVector<Value*, 16> Args; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1107 | |
Chris Lattner | 46c5591 | 2010-10-02 00:09:12 +0000 | [diff] [blame] | 1108 | // Find out if any arguments are required to be integer constant |
| 1109 | // expressions. |
| 1110 | unsigned ICEArguments = 0; |
| 1111 | ASTContext::GetBuiltinTypeError Error; |
| 1112 | getContext().GetBuiltinType(BuiltinID, Error, &ICEArguments); |
| 1113 | assert(Error == ASTContext::GE_None && "Should not codegen an error"); |
| 1114 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1115 | Function *F = CGM.getIntrinsic(IntrinsicID); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1116 | llvm::FunctionType *FTy = F->getFunctionType(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1117 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1118 | for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) { |
Chris Lattner | 46c5591 | 2010-10-02 00:09:12 +0000 | [diff] [blame] | 1119 | Value *ArgValue; |
| 1120 | // If this is a normal argument, just emit it as a scalar. |
| 1121 | if ((ICEArguments & (1 << i)) == 0) { |
| 1122 | ArgValue = EmitScalarExpr(E->getArg(i)); |
| 1123 | } else { |
| 1124 | // If this is required to be a constant, constant fold it so that we |
| 1125 | // know that the generated intrinsic gets a ConstantInt. |
| 1126 | llvm::APSInt Result; |
| 1127 | bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result,getContext()); |
| 1128 | assert(IsConst && "Constant arg isn't actually constant?"); |
| 1129 | (void)IsConst; |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 1130 | ArgValue = llvm::ConstantInt::get(getLLVMContext(), Result); |
Chris Lattner | 46c5591 | 2010-10-02 00:09:12 +0000 | [diff] [blame] | 1131 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1132 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1133 | // If the intrinsic arg type is different from the builtin arg type |
| 1134 | // we need to do a bit cast. |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1135 | llvm::Type *PTy = FTy->getParamType(i); |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1136 | if (PTy != ArgValue->getType()) { |
| 1137 | assert(PTy->canLosslesslyBitCastTo(FTy->getParamType(i)) && |
| 1138 | "Must be able to losslessly bit cast to param"); |
| 1139 | ArgValue = Builder.CreateBitCast(ArgValue, PTy); |
| 1140 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1141 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1142 | Args.push_back(ArgValue); |
| 1143 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1144 | |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 1145 | Value *V = Builder.CreateCall(F, Args); |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1146 | QualType BuiltinRetType = E->getType(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1147 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1148 | llvm::Type *RetTy = llvm::Type::getVoidTy(getLLVMContext()); |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1149 | if (!BuiltinRetType->isVoidType()) RetTy = ConvertType(BuiltinRetType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1150 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1151 | if (RetTy != V->getType()) { |
| 1152 | assert(V->getType()->canLosslesslyBitCastTo(RetTy) && |
| 1153 | "Must be able to losslessly bit cast result type"); |
| 1154 | V = Builder.CreateBitCast(V, RetTy); |
| 1155 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1156 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1157 | return RValue::get(V); |
| 1158 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1159 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1160 | // See if we have a target specific builtin that needs to be lowered. |
Daniel Dunbar | f02e9dd | 2008-10-10 00:24:54 +0000 | [diff] [blame] | 1161 | if (Value *V = EmitTargetBuiltinExpr(BuiltinID, E)) |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1162 | return RValue::get(V); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1163 | |
Daniel Dunbar | 488e993 | 2008-08-16 00:56:44 +0000 | [diff] [blame] | 1164 | ErrorUnsupported(E, "builtin function"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1165 | |
Chris Lattner | b7cfe88 | 2008-06-30 18:32:54 +0000 | [diff] [blame] | 1166 | // Unknown builtin, for now just dump it out and return undef. |
| 1167 | if (hasAggregateLLVMType(E->getType())) |
Daniel Dunbar | 195337d | 2010-02-09 02:48:28 +0000 | [diff] [blame] | 1168 | return RValue::getAggregate(CreateMemTemp(E->getType())); |
Owen Anderson | 03e2050 | 2009-07-30 23:11:26 +0000 | [diff] [blame] | 1169 | return RValue::get(llvm::UndefValue::get(ConvertType(E->getType()))); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1170 | } |
Anders Carlsson | 564f1de | 2007-12-09 23:17:02 +0000 | [diff] [blame] | 1171 | |
Daniel Dunbar | f02e9dd | 2008-10-10 00:24:54 +0000 | [diff] [blame] | 1172 | Value *CodeGenFunction::EmitTargetBuiltinExpr(unsigned BuiltinID, |
| 1173 | const CallExpr *E) { |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1174 | switch (Target.getTriple().getArch()) { |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 1175 | case llvm::Triple::arm: |
| 1176 | case llvm::Triple::thumb: |
| 1177 | return EmitARMBuiltinExpr(BuiltinID, E); |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1178 | case llvm::Triple::x86: |
| 1179 | case llvm::Triple::x86_64: |
Daniel Dunbar | f02e9dd | 2008-10-10 00:24:54 +0000 | [diff] [blame] | 1180 | return EmitX86BuiltinExpr(BuiltinID, E); |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1181 | case llvm::Triple::ppc: |
| 1182 | case llvm::Triple::ppc64: |
Daniel Dunbar | f02e9dd | 2008-10-10 00:24:54 +0000 | [diff] [blame] | 1183 | return EmitPPCBuiltinExpr(BuiltinID, E); |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 1184 | case llvm::Triple::hexagon: |
| 1185 | return EmitHexagonBuiltinExpr(BuiltinID, E); |
Daniel Dunbar | 55cc2ed | 2009-08-24 09:54:37 +0000 | [diff] [blame] | 1186 | default: |
| 1187 | return 0; |
| 1188 | } |
Daniel Dunbar | f02e9dd | 2008-10-10 00:24:54 +0000 | [diff] [blame] | 1189 | } |
| 1190 | |
NAKAMURA Takumi | 83084c8 | 2011-11-08 03:27:04 +0000 | [diff] [blame] | 1191 | static llvm::VectorType *GetNeonType(LLVMContext &C, NeonTypeFlags TypeFlags) { |
| 1192 | int IsQuad = TypeFlags.isQuad(); |
| 1193 | switch (TypeFlags.getEltType()) { |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1194 | default: break; |
| 1195 | case NeonTypeFlags::Int8: |
| 1196 | case NeonTypeFlags::Poly8: |
| 1197 | return llvm::VectorType::get(llvm::Type::getInt8Ty(C), 8 << IsQuad); |
| 1198 | case NeonTypeFlags::Int16: |
| 1199 | case NeonTypeFlags::Poly16: |
| 1200 | case NeonTypeFlags::Float16: |
| 1201 | return llvm::VectorType::get(llvm::Type::getInt16Ty(C), 4 << IsQuad); |
| 1202 | case NeonTypeFlags::Int32: |
| 1203 | return llvm::VectorType::get(llvm::Type::getInt32Ty(C), 2 << IsQuad); |
| 1204 | case NeonTypeFlags::Int64: |
| 1205 | return llvm::VectorType::get(llvm::Type::getInt64Ty(C), 1 << IsQuad); |
| 1206 | case NeonTypeFlags::Float32: |
| 1207 | return llvm::VectorType::get(llvm::Type::getFloatTy(C), 2 << IsQuad); |
Nate Begeman | 998622c | 2010-06-07 16:01:56 +0000 | [diff] [blame] | 1208 | }; |
| 1209 | return 0; |
| 1210 | } |
| 1211 | |
Bob Wilson | cf55652 | 2010-12-07 22:40:02 +0000 | [diff] [blame] | 1212 | Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) { |
Nate Begeman | d075c01 | 2010-06-10 00:17:56 +0000 | [diff] [blame] | 1213 | unsigned nElts = cast<llvm::VectorType>(V->getType())->getNumElements(); |
| 1214 | SmallVector<Constant*, 16> Indices(nElts, C); |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 1215 | Value* SV = llvm::ConstantVector::get(Indices); |
Nate Begeman | d075c01 | 2010-06-10 00:17:56 +0000 | [diff] [blame] | 1216 | return Builder.CreateShuffleVector(V, V, SV, "lane"); |
| 1217 | } |
| 1218 | |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1219 | Value *CodeGenFunction::EmitNeonCall(Function *F, SmallVectorImpl<Value*> &Ops, |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1220 | const char *name, |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1221 | unsigned shift, bool rightshift) { |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1222 | unsigned j = 0; |
| 1223 | for (Function::const_arg_iterator ai = F->arg_begin(), ae = F->arg_end(); |
| 1224 | ai != ae; ++ai, ++j) |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1225 | if (shift > 0 && shift == j) |
| 1226 | Ops[j] = EmitNeonShiftVector(Ops[j], ai->getType(), rightshift); |
| 1227 | else |
| 1228 | Ops[j] = Builder.CreateBitCast(Ops[j], ai->getType(), name); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1229 | |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 1230 | return Builder.CreateCall(F, Ops, name); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1231 | } |
| 1232 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1233 | Value *CodeGenFunction::EmitNeonShiftVector(Value *V, llvm::Type *Ty, |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1234 | bool neg) { |
| 1235 | ConstantInt *CI = cast<ConstantInt>(V); |
| 1236 | int SV = CI->getSExtValue(); |
| 1237 | |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1238 | llvm::VectorType *VTy = cast<llvm::VectorType>(Ty); |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1239 | llvm::Constant *C = ConstantInt::get(VTy->getElementType(), neg ? -SV : SV); |
| 1240 | SmallVector<llvm::Constant*, 16> CV(VTy->getNumElements(), C); |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 1241 | return llvm::ConstantVector::get(CV); |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1242 | } |
| 1243 | |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1244 | /// GetPointeeAlignment - Given an expression with a pointer type, find the |
| 1245 | /// alignment of the type referenced by the pointer. Skip over implicit |
| 1246 | /// casts. |
| 1247 | static Value *GetPointeeAlignment(CodeGenFunction &CGF, const Expr *Addr) { |
| 1248 | unsigned Align = 1; |
| 1249 | // Check if the type is a pointer. The implicit cast operand might not be. |
| 1250 | while (Addr->getType()->isPointerType()) { |
| 1251 | QualType PtTy = Addr->getType()->getPointeeType(); |
| 1252 | unsigned NewA = CGF.getContext().getTypeAlignInChars(PtTy).getQuantity(); |
| 1253 | if (NewA > Align) |
| 1254 | Align = NewA; |
| 1255 | |
| 1256 | // If the address is an implicit cast, repeat with the cast operand. |
| 1257 | if (const ImplicitCastExpr *CastAddr = dyn_cast<ImplicitCastExpr>(Addr)) { |
| 1258 | Addr = CastAddr->getSubExpr(); |
| 1259 | continue; |
| 1260 | } |
| 1261 | break; |
| 1262 | } |
| 1263 | return llvm::ConstantInt::get(CGF.Int32Ty, Align); |
| 1264 | } |
| 1265 | |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 1266 | Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID, |
| 1267 | const CallExpr *E) { |
Rafael Espindola | e140af3 | 2010-06-09 03:48:40 +0000 | [diff] [blame] | 1268 | if (BuiltinID == ARM::BI__clear_cache) { |
Rafael Espindola | 79ba509 | 2010-06-07 17:26:50 +0000 | [diff] [blame] | 1269 | const FunctionDecl *FD = E->getDirectCallee(); |
Eric Christopher | 8a37c79 | 2011-03-14 20:30:34 +0000 | [diff] [blame] | 1270 | // Oddly people write this call without args on occasion and gcc accepts |
| 1271 | // it - it's also marked as varargs in the description file. |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1272 | SmallVector<Value*, 2> Ops; |
Eric Christopher | 8a37c79 | 2011-03-14 20:30:34 +0000 | [diff] [blame] | 1273 | for (unsigned i = 0; i < E->getNumArgs(); i++) |
| 1274 | Ops.push_back(EmitScalarExpr(E->getArg(i))); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1275 | llvm::Type *Ty = CGM.getTypes().ConvertType(FD->getType()); |
| 1276 | llvm::FunctionType *FTy = cast<llvm::FunctionType>(Ty); |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1277 | StringRef Name = FD->getName(); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 1278 | return Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), Ops); |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 1279 | } |
Rafael Espindola | e140af3 | 2010-06-09 03:48:40 +0000 | [diff] [blame] | 1280 | |
Bruno Cardoso Lopes | 26c1b8d | 2011-05-28 04:11:33 +0000 | [diff] [blame] | 1281 | if (BuiltinID == ARM::BI__builtin_arm_ldrexd) { |
| 1282 | Function *F = CGM.getIntrinsic(Intrinsic::arm_ldrexd); |
| 1283 | |
| 1284 | Value *LdPtr = EmitScalarExpr(E->getArg(0)); |
| 1285 | Value *Val = Builder.CreateCall(F, LdPtr, "ldrexd"); |
| 1286 | |
| 1287 | Value *Val0 = Builder.CreateExtractValue(Val, 1); |
| 1288 | Value *Val1 = Builder.CreateExtractValue(Val, 0); |
| 1289 | Val0 = Builder.CreateZExt(Val0, Int64Ty); |
| 1290 | Val1 = Builder.CreateZExt(Val1, Int64Ty); |
| 1291 | |
| 1292 | Value *ShiftCst = llvm::ConstantInt::get(Int64Ty, 32); |
| 1293 | Val = Builder.CreateShl(Val0, ShiftCst, "shl", true /* nuw */); |
| 1294 | return Builder.CreateOr(Val, Val1); |
| 1295 | } |
| 1296 | |
| 1297 | if (BuiltinID == ARM::BI__builtin_arm_strexd) { |
| 1298 | Function *F = CGM.getIntrinsic(Intrinsic::arm_strexd); |
Chris Lattner | 7650d95 | 2011-06-18 22:49:11 +0000 | [diff] [blame] | 1299 | llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, NULL); |
Bruno Cardoso Lopes | 26c1b8d | 2011-05-28 04:11:33 +0000 | [diff] [blame] | 1300 | |
| 1301 | Value *One = llvm::ConstantInt::get(Int32Ty, 1); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 1302 | Value *Tmp = Builder.CreateAlloca(Int64Ty, One); |
Bruno Cardoso Lopes | 26c1b8d | 2011-05-28 04:11:33 +0000 | [diff] [blame] | 1303 | Value *Val = EmitScalarExpr(E->getArg(0)); |
| 1304 | Builder.CreateStore(Val, Tmp); |
| 1305 | |
| 1306 | Value *LdPtr = Builder.CreateBitCast(Tmp,llvm::PointerType::getUnqual(STy)); |
| 1307 | Val = Builder.CreateLoad(LdPtr); |
| 1308 | |
| 1309 | Value *Arg0 = Builder.CreateExtractValue(Val, 0); |
| 1310 | Value *Arg1 = Builder.CreateExtractValue(Val, 1); |
| 1311 | Value *StPtr = EmitScalarExpr(E->getArg(1)); |
| 1312 | return Builder.CreateCall3(F, Arg0, Arg1, StPtr, "strexd"); |
| 1313 | } |
| 1314 | |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 1315 | SmallVector<Value*, 4> Ops; |
Rafael Espindola | e140af3 | 2010-06-09 03:48:40 +0000 | [diff] [blame] | 1316 | for (unsigned i = 0, e = E->getNumArgs() - 1; i != e; i++) |
| 1317 | Ops.push_back(EmitScalarExpr(E->getArg(i))); |
| 1318 | |
Bob Wilson | 83bbba1 | 2011-08-13 05:03:46 +0000 | [diff] [blame] | 1319 | // vget_lane and vset_lane are not overloaded and do not have an extra |
| 1320 | // argument that specifies the vector type. |
| 1321 | switch (BuiltinID) { |
| 1322 | default: break; |
| 1323 | case ARM::BI__builtin_neon_vget_lane_i8: |
| 1324 | case ARM::BI__builtin_neon_vget_lane_i16: |
| 1325 | case ARM::BI__builtin_neon_vget_lane_i32: |
| 1326 | case ARM::BI__builtin_neon_vget_lane_i64: |
| 1327 | case ARM::BI__builtin_neon_vget_lane_f32: |
| 1328 | case ARM::BI__builtin_neon_vgetq_lane_i8: |
| 1329 | case ARM::BI__builtin_neon_vgetq_lane_i16: |
| 1330 | case ARM::BI__builtin_neon_vgetq_lane_i32: |
| 1331 | case ARM::BI__builtin_neon_vgetq_lane_i64: |
| 1332 | case ARM::BI__builtin_neon_vgetq_lane_f32: |
| 1333 | return Builder.CreateExtractElement(Ops[0], EmitScalarExpr(E->getArg(1)), |
| 1334 | "vget_lane"); |
| 1335 | case ARM::BI__builtin_neon_vset_lane_i8: |
| 1336 | case ARM::BI__builtin_neon_vset_lane_i16: |
| 1337 | case ARM::BI__builtin_neon_vset_lane_i32: |
| 1338 | case ARM::BI__builtin_neon_vset_lane_i64: |
| 1339 | case ARM::BI__builtin_neon_vset_lane_f32: |
| 1340 | case ARM::BI__builtin_neon_vsetq_lane_i8: |
| 1341 | case ARM::BI__builtin_neon_vsetq_lane_i16: |
| 1342 | case ARM::BI__builtin_neon_vsetq_lane_i32: |
| 1343 | case ARM::BI__builtin_neon_vsetq_lane_i64: |
| 1344 | case ARM::BI__builtin_neon_vsetq_lane_f32: |
| 1345 | Ops.push_back(EmitScalarExpr(E->getArg(2))); |
| 1346 | return Builder.CreateInsertElement(Ops[1], Ops[0], Ops[2], "vset_lane"); |
| 1347 | } |
| 1348 | |
| 1349 | // Get the last argument, which specifies the vector type. |
Rafael Espindola | e140af3 | 2010-06-09 03:48:40 +0000 | [diff] [blame] | 1350 | llvm::APSInt Result; |
| 1351 | const Expr *Arg = E->getArg(E->getNumArgs()-1); |
| 1352 | if (!Arg->isIntegerConstantExpr(Result, getContext())) |
| 1353 | return 0; |
| 1354 | |
Nate Begeman | 99c40bb | 2010-08-03 21:32:34 +0000 | [diff] [blame] | 1355 | if (BuiltinID == ARM::BI__builtin_arm_vcvtr_f || |
| 1356 | BuiltinID == ARM::BI__builtin_arm_vcvtr_d) { |
| 1357 | // Determine the overloaded type of this builtin. |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1358 | llvm::Type *Ty; |
Nate Begeman | 99c40bb | 2010-08-03 21:32:34 +0000 | [diff] [blame] | 1359 | if (BuiltinID == ARM::BI__builtin_arm_vcvtr_f) |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 1360 | Ty = llvm::Type::getFloatTy(getLLVMContext()); |
Nate Begeman | 99c40bb | 2010-08-03 21:32:34 +0000 | [diff] [blame] | 1361 | else |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 1362 | Ty = llvm::Type::getDoubleTy(getLLVMContext()); |
Nate Begeman | 99c40bb | 2010-08-03 21:32:34 +0000 | [diff] [blame] | 1363 | |
| 1364 | // Determine whether this is an unsigned conversion or not. |
| 1365 | bool usgn = Result.getZExtValue() == 1; |
| 1366 | unsigned Int = usgn ? Intrinsic::arm_vcvtru : Intrinsic::arm_vcvtr; |
| 1367 | |
| 1368 | // Call the appropriate intrinsic. |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1369 | Function *F = CGM.getIntrinsic(Int, Ty); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 1370 | return Builder.CreateCall(F, Ops, "vcvtr"); |
Nate Begeman | 99c40bb | 2010-08-03 21:32:34 +0000 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | // Determine the type of this overloaded NEON intrinsic. |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1374 | NeonTypeFlags Type(Result.getZExtValue()); |
| 1375 | bool usgn = Type.isUnsigned(); |
| 1376 | bool quad = Type.isQuad(); |
Bob Wilson | 7965396 | 2010-12-03 17:10:22 +0000 | [diff] [blame] | 1377 | bool rightShift = false; |
Rafael Espindola | e140af3 | 2010-06-09 03:48:40 +0000 | [diff] [blame] | 1378 | |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1379 | llvm::VectorType *VTy = GetNeonType(getLLVMContext(), Type); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1380 | llvm::Type *Ty = VTy; |
Rafael Espindola | e140af3 | 2010-06-09 03:48:40 +0000 | [diff] [blame] | 1381 | if (!Ty) |
| 1382 | return 0; |
| 1383 | |
| 1384 | unsigned Int; |
| 1385 | switch (BuiltinID) { |
| 1386 | default: return 0; |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1387 | case ARM::BI__builtin_neon_vabd_v: |
| 1388 | case ARM::BI__builtin_neon_vabdq_v: |
Nate Begeman | 998622c | 2010-06-07 16:01:56 +0000 | [diff] [blame] | 1389 | Int = usgn ? Intrinsic::arm_neon_vabdu : Intrinsic::arm_neon_vabds; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1390 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vabd"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1391 | case ARM::BI__builtin_neon_vabs_v: |
| 1392 | case ARM::BI__builtin_neon_vabsq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1393 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vabs, Ty), |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1394 | Ops, "vabs"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1395 | case ARM::BI__builtin_neon_vaddhn_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1396 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vaddhn, Ty), |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1397 | Ops, "vaddhn"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1398 | case ARM::BI__builtin_neon_vcale_v: |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1399 | std::swap(Ops[0], Ops[1]); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1400 | case ARM::BI__builtin_neon_vcage_v: { |
Bob Wilson | d185035 | 2010-12-10 01:11:38 +0000 | [diff] [blame] | 1401 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vacged); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1402 | return EmitNeonCall(F, Ops, "vcage"); |
| 1403 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1404 | case ARM::BI__builtin_neon_vcaleq_v: |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1405 | std::swap(Ops[0], Ops[1]); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1406 | case ARM::BI__builtin_neon_vcageq_v: { |
Bob Wilson | d185035 | 2010-12-10 01:11:38 +0000 | [diff] [blame] | 1407 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vacgeq); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1408 | return EmitNeonCall(F, Ops, "vcage"); |
| 1409 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1410 | case ARM::BI__builtin_neon_vcalt_v: |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1411 | std::swap(Ops[0], Ops[1]); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1412 | case ARM::BI__builtin_neon_vcagt_v: { |
Bob Wilson | d185035 | 2010-12-10 01:11:38 +0000 | [diff] [blame] | 1413 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vacgtd); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1414 | return EmitNeonCall(F, Ops, "vcagt"); |
| 1415 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1416 | case ARM::BI__builtin_neon_vcaltq_v: |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1417 | std::swap(Ops[0], Ops[1]); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1418 | case ARM::BI__builtin_neon_vcagtq_v: { |
Bob Wilson | d185035 | 2010-12-10 01:11:38 +0000 | [diff] [blame] | 1419 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vacgtq); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1420 | return EmitNeonCall(F, Ops, "vcagt"); |
| 1421 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1422 | case ARM::BI__builtin_neon_vcls_v: |
| 1423 | case ARM::BI__builtin_neon_vclsq_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1424 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vcls, Ty); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1425 | return EmitNeonCall(F, Ops, "vcls"); |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1426 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1427 | case ARM::BI__builtin_neon_vclz_v: |
| 1428 | case ARM::BI__builtin_neon_vclzq_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1429 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vclz, Ty); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1430 | return EmitNeonCall(F, Ops, "vclz"); |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1431 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1432 | case ARM::BI__builtin_neon_vcnt_v: |
| 1433 | case ARM::BI__builtin_neon_vcntq_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1434 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vcnt, Ty); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1435 | return EmitNeonCall(F, Ops, "vcnt"); |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1436 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1437 | case ARM::BI__builtin_neon_vcvt_f16_v: { |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1438 | assert(Type.getEltType() == NeonTypeFlags::Float16 && !quad && |
| 1439 | "unexpected vcvt_f16_v builtin"); |
Bob Wilson | 46e392a | 2010-12-15 23:36:44 +0000 | [diff] [blame] | 1440 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vcvtfp2hf); |
| 1441 | return EmitNeonCall(F, Ops, "vcvt"); |
| 1442 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1443 | case ARM::BI__builtin_neon_vcvt_f32_f16: { |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1444 | assert(Type.getEltType() == NeonTypeFlags::Float16 && !quad && |
| 1445 | "unexpected vcvt_f32_f16 builtin"); |
Bob Wilson | 46e392a | 2010-12-15 23:36:44 +0000 | [diff] [blame] | 1446 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vcvthf2fp); |
| 1447 | return EmitNeonCall(F, Ops, "vcvt"); |
| 1448 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1449 | case ARM::BI__builtin_neon_vcvt_f32_v: |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1450 | case ARM::BI__builtin_neon_vcvtq_f32_v: |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1451 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1452 | Ty = GetNeonType(getLLVMContext(), |
| 1453 | NeonTypeFlags(NeonTypeFlags::Float32, false, quad)); |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1454 | return usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt") |
| 1455 | : Builder.CreateSIToFP(Ops[0], Ty, "vcvt"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1456 | case ARM::BI__builtin_neon_vcvt_s32_v: |
| 1457 | case ARM::BI__builtin_neon_vcvt_u32_v: |
| 1458 | case ARM::BI__builtin_neon_vcvtq_s32_v: |
| 1459 | case ARM::BI__builtin_neon_vcvtq_u32_v: { |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1460 | llvm::Type *FloatTy = |
| 1461 | GetNeonType(getLLVMContext(), |
| 1462 | NeonTypeFlags(NeonTypeFlags::Float32, false, quad)); |
| 1463 | Ops[0] = Builder.CreateBitCast(Ops[0], FloatTy); |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1464 | return usgn ? Builder.CreateFPToUI(Ops[0], Ty, "vcvt") |
| 1465 | : Builder.CreateFPToSI(Ops[0], Ty, "vcvt"); |
| 1466 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1467 | case ARM::BI__builtin_neon_vcvt_n_f32_v: |
| 1468 | case ARM::BI__builtin_neon_vcvtq_n_f32_v: { |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1469 | llvm::Type *FloatTy = |
| 1470 | GetNeonType(getLLVMContext(), |
| 1471 | NeonTypeFlags(NeonTypeFlags::Float32, false, quad)); |
| 1472 | llvm::Type *Tys[2] = { FloatTy, Ty }; |
| 1473 | Int = usgn ? Intrinsic::arm_neon_vcvtfxu2fp |
| 1474 | : Intrinsic::arm_neon_vcvtfxs2fp; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1475 | Function *F = CGM.getIntrinsic(Int, Tys); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1476 | return EmitNeonCall(F, Ops, "vcvt_n"); |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 1477 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1478 | case ARM::BI__builtin_neon_vcvt_n_s32_v: |
| 1479 | case ARM::BI__builtin_neon_vcvt_n_u32_v: |
| 1480 | case ARM::BI__builtin_neon_vcvtq_n_s32_v: |
| 1481 | case ARM::BI__builtin_neon_vcvtq_n_u32_v: { |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1482 | llvm::Type *FloatTy = |
| 1483 | GetNeonType(getLLVMContext(), |
| 1484 | NeonTypeFlags(NeonTypeFlags::Float32, false, quad)); |
| 1485 | llvm::Type *Tys[2] = { Ty, FloatTy }; |
| 1486 | Int = usgn ? Intrinsic::arm_neon_vcvtfp2fxu |
| 1487 | : Intrinsic::arm_neon_vcvtfp2fxs; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1488 | Function *F = CGM.getIntrinsic(Int, Tys); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1489 | return EmitNeonCall(F, Ops, "vcvt_n"); |
| 1490 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1491 | case ARM::BI__builtin_neon_vext_v: |
| 1492 | case ARM::BI__builtin_neon_vextq_v: { |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 1493 | int CV = cast<ConstantInt>(Ops[2])->getSExtValue(); |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1494 | SmallVector<Constant*, 16> Indices; |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1495 | for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 1496 | Indices.push_back(ConstantInt::get(Int32Ty, i+CV)); |
Nate Begeman | 30d9171 | 2010-06-08 06:03:01 +0000 | [diff] [blame] | 1497 | |
| 1498 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1499 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 1500 | Value *SV = llvm::ConstantVector::get(Indices); |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1501 | return Builder.CreateShuffleVector(Ops[0], Ops[1], SV, "vext"); |
| 1502 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1503 | case ARM::BI__builtin_neon_vhadd_v: |
| 1504 | case ARM::BI__builtin_neon_vhaddq_v: |
Nate Begeman | df98e1d | 2010-06-09 18:04:15 +0000 | [diff] [blame] | 1505 | Int = usgn ? Intrinsic::arm_neon_vhaddu : Intrinsic::arm_neon_vhadds; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1506 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vhadd"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1507 | case ARM::BI__builtin_neon_vhsub_v: |
| 1508 | case ARM::BI__builtin_neon_vhsubq_v: |
Nate Begeman | df98e1d | 2010-06-09 18:04:15 +0000 | [diff] [blame] | 1509 | Int = usgn ? Intrinsic::arm_neon_vhsubu : Intrinsic::arm_neon_vhsubs; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1510 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vhsub"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1511 | case ARM::BI__builtin_neon_vld1_v: |
| 1512 | case ARM::BI__builtin_neon_vld1q_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1513 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1514 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vld1, Ty), |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1515 | Ops, "vld1"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1516 | case ARM::BI__builtin_neon_vld1_lane_v: |
| 1517 | case ARM::BI__builtin_neon_vld1q_lane_v: |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1518 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
| 1519 | Ty = llvm::PointerType::getUnqual(VTy->getElementType()); |
| 1520 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1521 | Ops[0] = Builder.CreateLoad(Ops[0]); |
| 1522 | return Builder.CreateInsertElement(Ops[1], Ops[0], Ops[2], "vld1_lane"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1523 | case ARM::BI__builtin_neon_vld1_dup_v: |
| 1524 | case ARM::BI__builtin_neon_vld1q_dup_v: { |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1525 | Value *V = UndefValue::get(Ty); |
| 1526 | Ty = llvm::PointerType::getUnqual(VTy->getElementType()); |
| 1527 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1528 | Ops[0] = Builder.CreateLoad(Ops[0]); |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 1529 | llvm::Constant *CI = ConstantInt::get(Int32Ty, 0); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1530 | Ops[0] = Builder.CreateInsertElement(V, Ops[0], CI); |
| 1531 | return EmitNeonSplat(Ops[0], CI); |
| 1532 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1533 | case ARM::BI__builtin_neon_vld2_v: |
| 1534 | case ARM::BI__builtin_neon_vld2q_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1535 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vld2, Ty); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1536 | Value *Align = GetPointeeAlignment(*this, E->getArg(1)); |
| 1537 | Ops[1] = Builder.CreateCall2(F, Ops[1], Align, "vld2"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1538 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1539 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1540 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1541 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1542 | case ARM::BI__builtin_neon_vld3_v: |
| 1543 | case ARM::BI__builtin_neon_vld3q_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1544 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vld3, Ty); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1545 | Value *Align = GetPointeeAlignment(*this, E->getArg(1)); |
| 1546 | Ops[1] = Builder.CreateCall2(F, Ops[1], Align, "vld3"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1547 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1548 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1549 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1550 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1551 | case ARM::BI__builtin_neon_vld4_v: |
| 1552 | case ARM::BI__builtin_neon_vld4q_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1553 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vld4, Ty); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1554 | Value *Align = GetPointeeAlignment(*this, E->getArg(1)); |
| 1555 | Ops[1] = Builder.CreateCall2(F, Ops[1], Align, "vld4"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1556 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1557 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1558 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1559 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1560 | case ARM::BI__builtin_neon_vld2_lane_v: |
| 1561 | case ARM::BI__builtin_neon_vld2q_lane_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1562 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vld2lane, Ty); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1563 | Ops[2] = Builder.CreateBitCast(Ops[2], Ty); |
| 1564 | Ops[3] = Builder.CreateBitCast(Ops[3], Ty); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1565 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(1))); |
Frits van Bommel | 1cbac8a | 2011-07-25 15:13:01 +0000 | [diff] [blame] | 1566 | Ops[1] = Builder.CreateCall(F, makeArrayRef(Ops).slice(1), "vld2_lane"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1567 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1568 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1569 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1570 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1571 | case ARM::BI__builtin_neon_vld3_lane_v: |
| 1572 | case ARM::BI__builtin_neon_vld3q_lane_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1573 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vld3lane, Ty); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1574 | Ops[2] = Builder.CreateBitCast(Ops[2], Ty); |
| 1575 | Ops[3] = Builder.CreateBitCast(Ops[3], Ty); |
| 1576 | Ops[4] = Builder.CreateBitCast(Ops[4], Ty); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1577 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(1))); |
Frits van Bommel | 1cbac8a | 2011-07-25 15:13:01 +0000 | [diff] [blame] | 1578 | Ops[1] = Builder.CreateCall(F, makeArrayRef(Ops).slice(1), "vld3_lane"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1579 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1580 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1581 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1582 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1583 | case ARM::BI__builtin_neon_vld4_lane_v: |
| 1584 | case ARM::BI__builtin_neon_vld4q_lane_v: { |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1585 | Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vld4lane, Ty); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1586 | Ops[2] = Builder.CreateBitCast(Ops[2], Ty); |
| 1587 | Ops[3] = Builder.CreateBitCast(Ops[3], Ty); |
| 1588 | Ops[4] = Builder.CreateBitCast(Ops[4], Ty); |
| 1589 | Ops[5] = Builder.CreateBitCast(Ops[5], Ty); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1590 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(1))); |
Frits van Bommel | 1cbac8a | 2011-07-25 15:13:01 +0000 | [diff] [blame] | 1591 | Ops[1] = Builder.CreateCall(F, makeArrayRef(Ops).slice(1), "vld3_lane"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1592 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1593 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1594 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1595 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1596 | case ARM::BI__builtin_neon_vld2_dup_v: |
| 1597 | case ARM::BI__builtin_neon_vld3_dup_v: |
| 1598 | case ARM::BI__builtin_neon_vld4_dup_v: { |
Bob Wilson | a0eb23b | 2010-12-10 22:54:58 +0000 | [diff] [blame] | 1599 | // Handle 64-bit elements as a special-case. There is no "dup" needed. |
| 1600 | if (VTy->getElementType()->getPrimitiveSizeInBits() == 64) { |
| 1601 | switch (BuiltinID) { |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1602 | case ARM::BI__builtin_neon_vld2_dup_v: |
Bob Wilson | a0eb23b | 2010-12-10 22:54:58 +0000 | [diff] [blame] | 1603 | Int = Intrinsic::arm_neon_vld2; |
| 1604 | break; |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1605 | case ARM::BI__builtin_neon_vld3_dup_v: |
Bob Wilson | a0eb23b | 2010-12-10 22:54:58 +0000 | [diff] [blame] | 1606 | Int = Intrinsic::arm_neon_vld2; |
| 1607 | break; |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1608 | case ARM::BI__builtin_neon_vld4_dup_v: |
Bob Wilson | a0eb23b | 2010-12-10 22:54:58 +0000 | [diff] [blame] | 1609 | Int = Intrinsic::arm_neon_vld2; |
| 1610 | break; |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1611 | default: llvm_unreachable("unknown vld_dup intrinsic?"); |
Bob Wilson | a0eb23b | 2010-12-10 22:54:58 +0000 | [diff] [blame] | 1612 | } |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1613 | Function *F = CGM.getIntrinsic(Int, Ty); |
Bob Wilson | a0eb23b | 2010-12-10 22:54:58 +0000 | [diff] [blame] | 1614 | Value *Align = GetPointeeAlignment(*this, E->getArg(1)); |
| 1615 | Ops[1] = Builder.CreateCall2(F, Ops[1], Align, "vld_dup"); |
| 1616 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1617 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1618 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1619 | } |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1620 | switch (BuiltinID) { |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1621 | case ARM::BI__builtin_neon_vld2_dup_v: |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1622 | Int = Intrinsic::arm_neon_vld2lane; |
| 1623 | break; |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1624 | case ARM::BI__builtin_neon_vld3_dup_v: |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1625 | Int = Intrinsic::arm_neon_vld2lane; |
| 1626 | break; |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1627 | case ARM::BI__builtin_neon_vld4_dup_v: |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1628 | Int = Intrinsic::arm_neon_vld2lane; |
| 1629 | break; |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 1630 | default: llvm_unreachable("unknown vld_dup intrinsic?"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1631 | } |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1632 | Function *F = CGM.getIntrinsic(Int, Ty); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1633 | llvm::StructType *STy = cast<llvm::StructType>(F->getReturnType()); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1634 | |
| 1635 | SmallVector<Value*, 6> Args; |
| 1636 | Args.push_back(Ops[1]); |
| 1637 | Args.append(STy->getNumElements(), UndefValue::get(Ty)); |
| 1638 | |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 1639 | llvm::Constant *CI = ConstantInt::get(Int32Ty, 0); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1640 | Args.push_back(CI); |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1641 | Args.push_back(GetPointeeAlignment(*this, E->getArg(1))); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1642 | |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 1643 | Ops[1] = Builder.CreateCall(F, Args, "vld_dup"); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1644 | // splat lane 0 to all elts in each vector of the result. |
| 1645 | for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { |
| 1646 | Value *Val = Builder.CreateExtractValue(Ops[1], i); |
| 1647 | Value *Elt = Builder.CreateBitCast(Val, Ty); |
| 1648 | Elt = EmitNeonSplat(Elt, CI); |
| 1649 | Elt = Builder.CreateBitCast(Elt, Val->getType()); |
| 1650 | Ops[1] = Builder.CreateInsertValue(Ops[1], Elt, i); |
| 1651 | } |
| 1652 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1653 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1654 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 1655 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1656 | case ARM::BI__builtin_neon_vmax_v: |
| 1657 | case ARM::BI__builtin_neon_vmaxq_v: |
Nate Begeman | df98e1d | 2010-06-09 18:04:15 +0000 | [diff] [blame] | 1658 | Int = usgn ? Intrinsic::arm_neon_vmaxu : Intrinsic::arm_neon_vmaxs; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1659 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vmax"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1660 | case ARM::BI__builtin_neon_vmin_v: |
| 1661 | case ARM::BI__builtin_neon_vminq_v: |
Nate Begeman | df98e1d | 2010-06-09 18:04:15 +0000 | [diff] [blame] | 1662 | Int = usgn ? Intrinsic::arm_neon_vminu : Intrinsic::arm_neon_vmins; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1663 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vmin"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1664 | case ARM::BI__builtin_neon_vmovl_v: { |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1665 | llvm::Type *DTy =llvm::VectorType::getTruncatedElementVectorType(VTy); |
Bob Wilson | 2235941 | 2010-09-02 22:37:30 +0000 | [diff] [blame] | 1666 | Ops[0] = Builder.CreateBitCast(Ops[0], DTy); |
Bob Wilson | 7cea322 | 2010-08-20 03:36:08 +0000 | [diff] [blame] | 1667 | if (usgn) |
| 1668 | return Builder.CreateZExt(Ops[0], Ty, "vmovl"); |
| 1669 | return Builder.CreateSExt(Ops[0], Ty, "vmovl"); |
Bob Wilson | 2235941 | 2010-09-02 22:37:30 +0000 | [diff] [blame] | 1670 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1671 | case ARM::BI__builtin_neon_vmovn_v: { |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1672 | llvm::Type *QTy = llvm::VectorType::getExtendedElementVectorType(VTy); |
Bob Wilson | 2235941 | 2010-09-02 22:37:30 +0000 | [diff] [blame] | 1673 | Ops[0] = Builder.CreateBitCast(Ops[0], QTy); |
Bob Wilson | 3b6081b | 2010-08-30 19:57:13 +0000 | [diff] [blame] | 1674 | return Builder.CreateTrunc(Ops[0], Ty, "vmovn"); |
Bob Wilson | 2235941 | 2010-09-02 22:37:30 +0000 | [diff] [blame] | 1675 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1676 | case ARM::BI__builtin_neon_vmul_v: |
| 1677 | case ARM::BI__builtin_neon_vmulq_v: |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1678 | assert(Type.isPoly() && "vmul builtin only supported for polynomial types"); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1679 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vmulp, Ty), |
Bob Wilson | 953d513 | 2010-12-03 17:29:39 +0000 | [diff] [blame] | 1680 | Ops, "vmul"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1681 | case ARM::BI__builtin_neon_vmull_v: |
Bob Wilson | 2d33e42 | 2011-03-31 00:09:00 +0000 | [diff] [blame] | 1682 | Int = usgn ? Intrinsic::arm_neon_vmullu : Intrinsic::arm_neon_vmulls; |
Bob Wilson | da95f73 | 2011-11-08 01:16:11 +0000 | [diff] [blame] | 1683 | Int = Type.isPoly() ? (unsigned)Intrinsic::arm_neon_vmullp : Int; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1684 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vmull"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1685 | case ARM::BI__builtin_neon_vpadal_v: |
| 1686 | case ARM::BI__builtin_neon_vpadalq_v: { |
Nate Begeman | df98e1d | 2010-06-09 18:04:15 +0000 | [diff] [blame] | 1687 | Int = usgn ? Intrinsic::arm_neon_vpadalu : Intrinsic::arm_neon_vpadals; |
Bob Wilson | c1fa01b | 2010-12-10 05:51:07 +0000 | [diff] [blame] | 1688 | // The source operand type has twice as many elements of half the size. |
| 1689 | unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits(); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1690 | llvm::Type *EltTy = |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 1691 | llvm::IntegerType::get(getLLVMContext(), EltBits / 2); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1692 | llvm::Type *NarrowTy = |
Bob Wilson | c1fa01b | 2010-12-10 05:51:07 +0000 | [diff] [blame] | 1693 | llvm::VectorType::get(EltTy, VTy->getNumElements() * 2); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1694 | llvm::Type *Tys[2] = { Ty, NarrowTy }; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1695 | return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, "vpadal"); |
Bob Wilson | c1fa01b | 2010-12-10 05:51:07 +0000 | [diff] [blame] | 1696 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1697 | case ARM::BI__builtin_neon_vpadd_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1698 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vpadd, Ty), |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1699 | Ops, "vpadd"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1700 | case ARM::BI__builtin_neon_vpaddl_v: |
| 1701 | case ARM::BI__builtin_neon_vpaddlq_v: { |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1702 | Int = usgn ? Intrinsic::arm_neon_vpaddlu : Intrinsic::arm_neon_vpaddls; |
Bob Wilson | c1fa01b | 2010-12-10 05:51:07 +0000 | [diff] [blame] | 1703 | // The source operand type has twice as many elements of half the size. |
| 1704 | unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits(); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 1705 | llvm::Type *EltTy = llvm::IntegerType::get(getLLVMContext(), EltBits / 2); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1706 | llvm::Type *NarrowTy = |
Bob Wilson | c1fa01b | 2010-12-10 05:51:07 +0000 | [diff] [blame] | 1707 | llvm::VectorType::get(EltTy, VTy->getNumElements() * 2); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 1708 | llvm::Type *Tys[2] = { Ty, NarrowTy }; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1709 | return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, "vpaddl"); |
Bob Wilson | c1fa01b | 2010-12-10 05:51:07 +0000 | [diff] [blame] | 1710 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1711 | case ARM::BI__builtin_neon_vpmax_v: |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1712 | Int = usgn ? Intrinsic::arm_neon_vpmaxu : Intrinsic::arm_neon_vpmaxs; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1713 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vpmax"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1714 | case ARM::BI__builtin_neon_vpmin_v: |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1715 | Int = usgn ? Intrinsic::arm_neon_vpminu : Intrinsic::arm_neon_vpmins; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1716 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vpmin"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1717 | case ARM::BI__builtin_neon_vqabs_v: |
| 1718 | case ARM::BI__builtin_neon_vqabsq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1719 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqabs, Ty), |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1720 | Ops, "vqabs"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1721 | case ARM::BI__builtin_neon_vqadd_v: |
| 1722 | case ARM::BI__builtin_neon_vqaddq_v: |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1723 | Int = usgn ? Intrinsic::arm_neon_vqaddu : Intrinsic::arm_neon_vqadds; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1724 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqadd"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1725 | case ARM::BI__builtin_neon_vqdmlal_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1726 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqdmlal, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1727 | Ops, "vqdmlal"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1728 | case ARM::BI__builtin_neon_vqdmlsl_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1729 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqdmlsl, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1730 | Ops, "vqdmlsl"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1731 | case ARM::BI__builtin_neon_vqdmulh_v: |
| 1732 | case ARM::BI__builtin_neon_vqdmulhq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1733 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqdmulh, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1734 | Ops, "vqdmulh"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1735 | case ARM::BI__builtin_neon_vqdmull_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1736 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqdmull, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1737 | Ops, "vqdmull"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1738 | case ARM::BI__builtin_neon_vqmovn_v: |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1739 | Int = usgn ? Intrinsic::arm_neon_vqmovnu : Intrinsic::arm_neon_vqmovns; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1740 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqmovn"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1741 | case ARM::BI__builtin_neon_vqmovun_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1742 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqmovnsu, Ty), |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1743 | Ops, "vqdmull"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1744 | case ARM::BI__builtin_neon_vqneg_v: |
| 1745 | case ARM::BI__builtin_neon_vqnegq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1746 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqneg, Ty), |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1747 | Ops, "vqneg"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1748 | case ARM::BI__builtin_neon_vqrdmulh_v: |
| 1749 | case ARM::BI__builtin_neon_vqrdmulhq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1750 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqrdmulh, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1751 | Ops, "vqrdmulh"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1752 | case ARM::BI__builtin_neon_vqrshl_v: |
| 1753 | case ARM::BI__builtin_neon_vqrshlq_v: |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1754 | Int = usgn ? Intrinsic::arm_neon_vqrshiftu : Intrinsic::arm_neon_vqrshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1755 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqrshl"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1756 | case ARM::BI__builtin_neon_vqrshrn_n_v: |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1757 | Int = usgn ? Intrinsic::arm_neon_vqrshiftnu : Intrinsic::arm_neon_vqrshiftns; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1758 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqrshrn_n", |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1759 | 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1760 | case ARM::BI__builtin_neon_vqrshrun_n_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1761 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqrshiftnsu, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1762 | Ops, "vqrshrun_n", 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1763 | case ARM::BI__builtin_neon_vqshl_v: |
| 1764 | case ARM::BI__builtin_neon_vqshlq_v: |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1765 | Int = usgn ? Intrinsic::arm_neon_vqshiftu : Intrinsic::arm_neon_vqshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1766 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqshl"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1767 | case ARM::BI__builtin_neon_vqshl_n_v: |
| 1768 | case ARM::BI__builtin_neon_vqshlq_n_v: |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1769 | Int = usgn ? Intrinsic::arm_neon_vqshiftu : Intrinsic::arm_neon_vqshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1770 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqshl_n", |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1771 | 1, false); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1772 | case ARM::BI__builtin_neon_vqshlu_n_v: |
| 1773 | case ARM::BI__builtin_neon_vqshluq_n_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1774 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqshiftsu, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1775 | Ops, "vqshlu", 1, false); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1776 | case ARM::BI__builtin_neon_vqshrn_n_v: |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1777 | Int = usgn ? Intrinsic::arm_neon_vqshiftnu : Intrinsic::arm_neon_vqshiftns; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1778 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqshrn_n", |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1779 | 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1780 | case ARM::BI__builtin_neon_vqshrun_n_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1781 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vqshiftnsu, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1782 | Ops, "vqshrun_n", 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1783 | case ARM::BI__builtin_neon_vqsub_v: |
| 1784 | case ARM::BI__builtin_neon_vqsubq_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1785 | Int = usgn ? Intrinsic::arm_neon_vqsubu : Intrinsic::arm_neon_vqsubs; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1786 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vqsub"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1787 | case ARM::BI__builtin_neon_vraddhn_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1788 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vraddhn, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1789 | Ops, "vraddhn"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1790 | case ARM::BI__builtin_neon_vrecpe_v: |
| 1791 | case ARM::BI__builtin_neon_vrecpeq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1792 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vrecpe, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1793 | Ops, "vrecpe"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1794 | case ARM::BI__builtin_neon_vrecps_v: |
| 1795 | case ARM::BI__builtin_neon_vrecpsq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1796 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vrecps, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1797 | Ops, "vrecps"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1798 | case ARM::BI__builtin_neon_vrhadd_v: |
| 1799 | case ARM::BI__builtin_neon_vrhaddq_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1800 | Int = usgn ? Intrinsic::arm_neon_vrhaddu : Intrinsic::arm_neon_vrhadds; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1801 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vrhadd"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1802 | case ARM::BI__builtin_neon_vrshl_v: |
| 1803 | case ARM::BI__builtin_neon_vrshlq_v: |
Nate Begeman | 5af93ef | 2010-06-12 06:06:07 +0000 | [diff] [blame] | 1804 | Int = usgn ? Intrinsic::arm_neon_vrshiftu : Intrinsic::arm_neon_vrshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1805 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vrshl"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1806 | case ARM::BI__builtin_neon_vrshrn_n_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1807 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vrshiftn, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1808 | Ops, "vrshrn_n", 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1809 | case ARM::BI__builtin_neon_vrshr_n_v: |
| 1810 | case ARM::BI__builtin_neon_vrshrq_n_v: |
Nate Begeman | 5af93ef | 2010-06-12 06:06:07 +0000 | [diff] [blame] | 1811 | Int = usgn ? Intrinsic::arm_neon_vrshiftu : Intrinsic::arm_neon_vrshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1812 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vrshr_n", 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1813 | case ARM::BI__builtin_neon_vrsqrte_v: |
| 1814 | case ARM::BI__builtin_neon_vrsqrteq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1815 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vrsqrte, Ty), |
Nate Begeman | 5af93ef | 2010-06-12 06:06:07 +0000 | [diff] [blame] | 1816 | Ops, "vrsqrte"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1817 | case ARM::BI__builtin_neon_vrsqrts_v: |
| 1818 | case ARM::BI__builtin_neon_vrsqrtsq_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1819 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vrsqrts, Ty), |
Nate Begeman | 5af93ef | 2010-06-12 06:06:07 +0000 | [diff] [blame] | 1820 | Ops, "vrsqrts"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1821 | case ARM::BI__builtin_neon_vrsra_n_v: |
| 1822 | case ARM::BI__builtin_neon_vrsraq_n_v: |
Nate Begeman | 5af93ef | 2010-06-12 06:06:07 +0000 | [diff] [blame] | 1823 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1824 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
| 1825 | Ops[2] = EmitNeonShiftVector(Ops[2], Ty, true); |
| 1826 | Int = usgn ? Intrinsic::arm_neon_vrshiftu : Intrinsic::arm_neon_vrshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1827 | Ops[1] = Builder.CreateCall2(CGM.getIntrinsic(Int, Ty), Ops[1], Ops[2]); |
Nate Begeman | 5af93ef | 2010-06-12 06:06:07 +0000 | [diff] [blame] | 1828 | return Builder.CreateAdd(Ops[0], Ops[1], "vrsra_n"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1829 | case ARM::BI__builtin_neon_vrsubhn_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1830 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vrsubhn, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1831 | Ops, "vrsubhn"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1832 | case ARM::BI__builtin_neon_vshl_v: |
| 1833 | case ARM::BI__builtin_neon_vshlq_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1834 | Int = usgn ? Intrinsic::arm_neon_vshiftu : Intrinsic::arm_neon_vshifts; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1835 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vshl"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1836 | case ARM::BI__builtin_neon_vshll_n_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1837 | Int = usgn ? Intrinsic::arm_neon_vshiftlu : Intrinsic::arm_neon_vshiftls; |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1838 | return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vshll", 1); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1839 | case ARM::BI__builtin_neon_vshl_n_v: |
| 1840 | case ARM::BI__builtin_neon_vshlq_n_v: |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1841 | Ops[1] = EmitNeonShiftVector(Ops[1], Ty, false); |
| 1842 | return Builder.CreateShl(Builder.CreateBitCast(Ops[0],Ty), Ops[1], "vshl_n"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1843 | case ARM::BI__builtin_neon_vshrn_n_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1844 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vshiftn, Ty), |
Bob Wilson | db3d4d0 | 2010-12-08 22:37:56 +0000 | [diff] [blame] | 1845 | Ops, "vshrn_n", 1, true); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1846 | case ARM::BI__builtin_neon_vshr_n_v: |
| 1847 | case ARM::BI__builtin_neon_vshrq_n_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1848 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1849 | Ops[1] = EmitNeonShiftVector(Ops[1], Ty, false); |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1850 | if (usgn) |
| 1851 | return Builder.CreateLShr(Ops[0], Ops[1], "vshr_n"); |
| 1852 | else |
| 1853 | return Builder.CreateAShr(Ops[0], Ops[1], "vshr_n"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1854 | case ARM::BI__builtin_neon_vsri_n_v: |
| 1855 | case ARM::BI__builtin_neon_vsriq_n_v: |
Bob Wilson | 7965396 | 2010-12-03 17:10:22 +0000 | [diff] [blame] | 1856 | rightShift = true; |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1857 | case ARM::BI__builtin_neon_vsli_n_v: |
| 1858 | case ARM::BI__builtin_neon_vsliq_n_v: |
Bob Wilson | 7965396 | 2010-12-03 17:10:22 +0000 | [diff] [blame] | 1859 | Ops[2] = EmitNeonShiftVector(Ops[2], Ty, rightShift); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1860 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vshiftins, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1861 | Ops, "vsli_n"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1862 | case ARM::BI__builtin_neon_vsra_n_v: |
| 1863 | case ARM::BI__builtin_neon_vsraq_n_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1864 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1865 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
Nate Begeman | 61eecf5 | 2010-06-14 05:21:25 +0000 | [diff] [blame] | 1866 | Ops[2] = EmitNeonShiftVector(Ops[2], Ty, false); |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1867 | if (usgn) |
| 1868 | Ops[1] = Builder.CreateLShr(Ops[1], Ops[2], "vsra_n"); |
| 1869 | else |
| 1870 | Ops[1] = Builder.CreateAShr(Ops[1], Ops[2], "vsra_n"); |
| 1871 | return Builder.CreateAdd(Ops[0], Ops[1]); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1872 | case ARM::BI__builtin_neon_vst1_v: |
| 1873 | case ARM::BI__builtin_neon_vst1q_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1874 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1875 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst1, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1876 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1877 | case ARM::BI__builtin_neon_vst1_lane_v: |
| 1878 | case ARM::BI__builtin_neon_vst1q_lane_v: |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1879 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
| 1880 | Ops[1] = Builder.CreateExtractElement(Ops[1], Ops[2]); |
| 1881 | Ty = llvm::PointerType::getUnqual(Ops[1]->getType()); |
| 1882 | return Builder.CreateStore(Ops[1], Builder.CreateBitCast(Ops[0], Ty)); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1883 | case ARM::BI__builtin_neon_vst2_v: |
| 1884 | case ARM::BI__builtin_neon_vst2q_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1885 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1886 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst2, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1887 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1888 | case ARM::BI__builtin_neon_vst2_lane_v: |
| 1889 | case ARM::BI__builtin_neon_vst2q_lane_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1890 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1891 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst2lane, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1892 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1893 | case ARM::BI__builtin_neon_vst3_v: |
| 1894 | case ARM::BI__builtin_neon_vst3q_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1895 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1896 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst3, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1897 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1898 | case ARM::BI__builtin_neon_vst3_lane_v: |
| 1899 | case ARM::BI__builtin_neon_vst3q_lane_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1900 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1901 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst3lane, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1902 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1903 | case ARM::BI__builtin_neon_vst4_v: |
| 1904 | case ARM::BI__builtin_neon_vst4q_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1905 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1906 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst4, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1907 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1908 | case ARM::BI__builtin_neon_vst4_lane_v: |
| 1909 | case ARM::BI__builtin_neon_vst4q_lane_v: |
Bob Wilson | 06b6c58 | 2010-08-27 17:14:29 +0000 | [diff] [blame] | 1910 | Ops.push_back(GetPointeeAlignment(*this, E->getArg(0))); |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1911 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vst4lane, Ty), |
Nate Begeman | 464ccb6 | 2010-06-11 22:57:12 +0000 | [diff] [blame] | 1912 | Ops, ""); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1913 | case ARM::BI__builtin_neon_vsubhn_v: |
Benjamin Kramer | 8dd55a3 | 2011-07-14 17:45:50 +0000 | [diff] [blame] | 1914 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vsubhn, Ty), |
Nate Begeman | 548f7da | 2010-06-10 18:11:55 +0000 | [diff] [blame] | 1915 | Ops, "vsubhn"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1916 | case ARM::BI__builtin_neon_vtbl1_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1917 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbl1), |
| 1918 | Ops, "vtbl1"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1919 | case ARM::BI__builtin_neon_vtbl2_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1920 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbl2), |
| 1921 | Ops, "vtbl2"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1922 | case ARM::BI__builtin_neon_vtbl3_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1923 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbl3), |
| 1924 | Ops, "vtbl3"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1925 | case ARM::BI__builtin_neon_vtbl4_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1926 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbl4), |
| 1927 | Ops, "vtbl4"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1928 | case ARM::BI__builtin_neon_vtbx1_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1929 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbx1), |
| 1930 | Ops, "vtbx1"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1931 | case ARM::BI__builtin_neon_vtbx2_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1932 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbx2), |
| 1933 | Ops, "vtbx2"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1934 | case ARM::BI__builtin_neon_vtbx3_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1935 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbx3), |
| 1936 | Ops, "vtbx3"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1937 | case ARM::BI__builtin_neon_vtbx4_v: |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1938 | return EmitNeonCall(CGM.getIntrinsic(Intrinsic::arm_neon_vtbx4), |
| 1939 | Ops, "vtbx4"); |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1940 | case ARM::BI__builtin_neon_vtst_v: |
| 1941 | case ARM::BI__builtin_neon_vtstq_v: { |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1942 | Ops[0] = Builder.CreateBitCast(Ops[0], Ty); |
| 1943 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
| 1944 | Ops[0] = Builder.CreateAnd(Ops[0], Ops[1]); |
| 1945 | Ops[0] = Builder.CreateICmp(ICmpInst::ICMP_NE, Ops[0], |
| 1946 | ConstantAggregateZero::get(Ty)); |
| 1947 | return Builder.CreateSExt(Ops[0], Ty, "vtst"); |
| 1948 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1949 | case ARM::BI__builtin_neon_vtrn_v: |
| 1950 | case ARM::BI__builtin_neon_vtrnq_v: { |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1951 | Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1952 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1953 | Ops[2] = Builder.CreateBitCast(Ops[2], Ty); |
Ted Kremenek | 9577abc | 2011-01-23 17:04:59 +0000 | [diff] [blame] | 1954 | Value *SV = 0; |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1955 | |
| 1956 | for (unsigned vi = 0; vi != 2; ++vi) { |
| 1957 | SmallVector<Constant*, 16> Indices; |
| 1958 | for (unsigned i = 0, e = VTy->getNumElements(); i != e; i += 2) { |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 1959 | Indices.push_back(ConstantInt::get(Int32Ty, i+vi)); |
| 1960 | Indices.push_back(ConstantInt::get(Int32Ty, i+e+vi)); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1961 | } |
| 1962 | Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi); |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 1963 | SV = llvm::ConstantVector::get(Indices); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1964 | SV = Builder.CreateShuffleVector(Ops[1], Ops[2], SV, "vtrn"); |
| 1965 | SV = Builder.CreateStore(SV, Addr); |
| 1966 | } |
| 1967 | return SV; |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1968 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1969 | case ARM::BI__builtin_neon_vuzp_v: |
| 1970 | case ARM::BI__builtin_neon_vuzpq_v: { |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1971 | Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1972 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1973 | Ops[2] = Builder.CreateBitCast(Ops[2], Ty); |
Ted Kremenek | 9577abc | 2011-01-23 17:04:59 +0000 | [diff] [blame] | 1974 | Value *SV = 0; |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1975 | |
| 1976 | for (unsigned vi = 0; vi != 2; ++vi) { |
| 1977 | SmallVector<Constant*, 16> Indices; |
| 1978 | for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 1979 | Indices.push_back(ConstantInt::get(Int32Ty, 2*i+vi)); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1980 | |
| 1981 | Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi); |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 1982 | SV = llvm::ConstantVector::get(Indices); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1983 | SV = Builder.CreateShuffleVector(Ops[1], Ops[2], SV, "vuzp"); |
| 1984 | SV = Builder.CreateStore(SV, Addr); |
| 1985 | } |
| 1986 | return SV; |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1987 | } |
Bob Wilson | 537c34611 | 2011-06-24 22:13:26 +0000 | [diff] [blame] | 1988 | case ARM::BI__builtin_neon_vzip_v: |
| 1989 | case ARM::BI__builtin_neon_vzipq_v: { |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1990 | Ops[0] = Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty)); |
Nate Begeman | 1c2a88c | 2010-06-09 01:10:23 +0000 | [diff] [blame] | 1991 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1992 | Ops[2] = Builder.CreateBitCast(Ops[2], Ty); |
Ted Kremenek | 9577abc | 2011-01-23 17:04:59 +0000 | [diff] [blame] | 1993 | Value *SV = 0; |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 1994 | |
| 1995 | for (unsigned vi = 0; vi != 2; ++vi) { |
| 1996 | SmallVector<Constant*, 16> Indices; |
| 1997 | for (unsigned i = 0, e = VTy->getNumElements(); i != e; i += 2) { |
Daniel Dunbar | e361cc3 | 2010-08-26 00:55:57 +0000 | [diff] [blame] | 1998 | Indices.push_back(ConstantInt::get(Int32Ty, (i + vi*e) >> 1)); |
| 1999 | Indices.push_back(ConstantInt::get(Int32Ty, ((i + vi*e) >> 1)+e)); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 2000 | } |
| 2001 | Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi); |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 2002 | SV = llvm::ConstantVector::get(Indices); |
Nate Begeman | 4be5430 | 2010-06-20 23:05:28 +0000 | [diff] [blame] | 2003 | SV = Builder.CreateShuffleVector(Ops[1], Ops[2], SV, "vzip"); |
| 2004 | SV = Builder.CreateStore(SV, Addr); |
| 2005 | } |
| 2006 | return SV; |
Nate Begeman | 9eb65a5 | 2010-06-08 00:17:19 +0000 | [diff] [blame] | 2007 | } |
Chris Lattner | 2752c01 | 2010-03-03 19:03:45 +0000 | [diff] [blame] | 2008 | } |
| 2009 | } |
| 2010 | |
Bill Wendling | aa51e51 | 2010-10-09 08:47:25 +0000 | [diff] [blame] | 2011 | llvm::Value *CodeGenFunction:: |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2012 | BuildVector(const SmallVectorImpl<llvm::Value*> &Ops) { |
Bill Wendling | aa51e51 | 2010-10-09 08:47:25 +0000 | [diff] [blame] | 2013 | assert((Ops.size() & (Ops.size() - 1)) == 0 && |
| 2014 | "Not a power-of-two sized vector!"); |
| 2015 | bool AllConstants = true; |
| 2016 | for (unsigned i = 0, e = Ops.size(); i != e && AllConstants; ++i) |
| 2017 | AllConstants &= isa<Constant>(Ops[i]); |
| 2018 | |
| 2019 | // If this is a constant vector, create a ConstantVector. |
| 2020 | if (AllConstants) { |
| 2021 | std::vector<llvm::Constant*> CstOps; |
| 2022 | for (unsigned i = 0, e = Ops.size(); i != e; ++i) |
| 2023 | CstOps.push_back(cast<Constant>(Ops[i])); |
| 2024 | return llvm::ConstantVector::get(CstOps); |
| 2025 | } |
| 2026 | |
| 2027 | // Otherwise, insertelement the values to build the vector. |
| 2028 | Value *Result = |
| 2029 | llvm::UndefValue::get(llvm::VectorType::get(Ops[0]->getType(), Ops.size())); |
| 2030 | |
| 2031 | for (unsigned i = 0, e = Ops.size(); i != e; ++i) |
| 2032 | Result = Builder.CreateInsertElement(Result, Ops[i], |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 2033 | llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), i)); |
Bill Wendling | aa51e51 | 2010-10-09 08:47:25 +0000 | [diff] [blame] | 2034 | |
| 2035 | return Result; |
| 2036 | } |
| 2037 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2038 | Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, |
Chris Lattner | 1feedd8 | 2007-12-13 07:34:23 +0000 | [diff] [blame] | 2039 | const CallExpr *E) { |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2040 | SmallVector<Value*, 4> Ops; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2041 | |
Chris Lattner | 46c5591 | 2010-10-02 00:09:12 +0000 | [diff] [blame] | 2042 | // Find out if any arguments are required to be integer constant expressions. |
| 2043 | unsigned ICEArguments = 0; |
| 2044 | ASTContext::GetBuiltinTypeError Error; |
| 2045 | getContext().GetBuiltinType(BuiltinID, Error, &ICEArguments); |
| 2046 | assert(Error == ASTContext::GE_None && "Should not codegen an error"); |
| 2047 | |
| 2048 | for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) { |
| 2049 | // If this is a normal argument, just emit it as a scalar. |
| 2050 | if ((ICEArguments & (1 << i)) == 0) { |
| 2051 | Ops.push_back(EmitScalarExpr(E->getArg(i))); |
| 2052 | continue; |
| 2053 | } |
| 2054 | |
| 2055 | // If this is required to be a constant, constant fold it so that we know |
| 2056 | // that the generated intrinsic gets a ConstantInt. |
| 2057 | llvm::APSInt Result; |
| 2058 | bool IsConst = E->getArg(i)->isIntegerConstantExpr(Result, getContext()); |
| 2059 | assert(IsConst && "Constant arg isn't actually constant?"); (void)IsConst; |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 2060 | Ops.push_back(llvm::ConstantInt::get(getLLVMContext(), Result)); |
Chris Lattner | 46c5591 | 2010-10-02 00:09:12 +0000 | [diff] [blame] | 2061 | } |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2062 | |
Anders Carlsson | 564f1de | 2007-12-09 23:17:02 +0000 | [diff] [blame] | 2063 | switch (BuiltinID) { |
Anders Carlsson | 46a26b0 | 2007-12-09 23:39:18 +0000 | [diff] [blame] | 2064 | default: return 0; |
Craig Topper | 5c75208 | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 2065 | case X86::BI__builtin_clzs: { |
| 2066 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
| 2067 | |
| 2068 | llvm::Type *ArgType = ArgValue->getType(); |
| 2069 | Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType); |
| 2070 | |
| 2071 | llvm::Type *ResultType = ConvertType(E->getType()); |
| 2072 | Value *Result = Builder.CreateCall2(F, ArgValue, Builder.getTrue()); |
| 2073 | if (Result->getType() != ResultType) |
| 2074 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 2075 | "cast"); |
| 2076 | return Result; |
| 2077 | } |
| 2078 | case X86::BI__builtin_ctzs: { |
| 2079 | Value *ArgValue = EmitScalarExpr(E->getArg(0)); |
| 2080 | |
| 2081 | llvm::Type *ArgType = ArgValue->getType(); |
| 2082 | Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType); |
| 2083 | |
| 2084 | llvm::Type *ResultType = ConvertType(E->getType()); |
| 2085 | Value *Result = Builder.CreateCall2(F, ArgValue, Builder.getTrue()); |
| 2086 | if (Result->getType() != ResultType) |
| 2087 | Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, |
| 2088 | "cast"); |
| 2089 | return Result; |
| 2090 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2091 | case X86::BI__builtin_ia32_pslldi128: |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2092 | case X86::BI__builtin_ia32_psllqi128: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2093 | case X86::BI__builtin_ia32_psllwi128: |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2094 | case X86::BI__builtin_ia32_psradi128: |
| 2095 | case X86::BI__builtin_ia32_psrawi128: |
| 2096 | case X86::BI__builtin_ia32_psrldi128: |
| 2097 | case X86::BI__builtin_ia32_psrlqi128: |
| 2098 | case X86::BI__builtin_ia32_psrlwi128: { |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2099 | Ops[1] = Builder.CreateZExt(Ops[1], Int64Ty, "zext"); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 2100 | llvm::Type *Ty = llvm::VectorType::get(Int64Ty, 2); |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2101 | llvm::Value *Zero = llvm::ConstantInt::get(Int32Ty, 0); |
Owen Anderson | 03e2050 | 2009-07-30 23:11:26 +0000 | [diff] [blame] | 2102 | Ops[1] = Builder.CreateInsertElement(llvm::UndefValue::get(Ty), |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2103 | Ops[1], Zero, "insert"); |
| 2104 | Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType(), "bitcast"); |
| 2105 | const char *name = 0; |
| 2106 | Intrinsic::ID ID = Intrinsic::not_intrinsic; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2107 | |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2108 | switch (BuiltinID) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 2109 | default: llvm_unreachable("Unsupported shift intrinsic!"); |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2110 | case X86::BI__builtin_ia32_pslldi128: |
| 2111 | name = "pslldi"; |
| 2112 | ID = Intrinsic::x86_sse2_psll_d; |
| 2113 | break; |
| 2114 | case X86::BI__builtin_ia32_psllqi128: |
| 2115 | name = "psllqi"; |
| 2116 | ID = Intrinsic::x86_sse2_psll_q; |
| 2117 | break; |
| 2118 | case X86::BI__builtin_ia32_psllwi128: |
| 2119 | name = "psllwi"; |
| 2120 | ID = Intrinsic::x86_sse2_psll_w; |
| 2121 | break; |
| 2122 | case X86::BI__builtin_ia32_psradi128: |
| 2123 | name = "psradi"; |
| 2124 | ID = Intrinsic::x86_sse2_psra_d; |
| 2125 | break; |
| 2126 | case X86::BI__builtin_ia32_psrawi128: |
| 2127 | name = "psrawi"; |
| 2128 | ID = Intrinsic::x86_sse2_psra_w; |
| 2129 | break; |
| 2130 | case X86::BI__builtin_ia32_psrldi128: |
| 2131 | name = "psrldi"; |
| 2132 | ID = Intrinsic::x86_sse2_psrl_d; |
| 2133 | break; |
| 2134 | case X86::BI__builtin_ia32_psrlqi128: |
| 2135 | name = "psrlqi"; |
| 2136 | ID = Intrinsic::x86_sse2_psrl_q; |
| 2137 | break; |
| 2138 | case X86::BI__builtin_ia32_psrlwi128: |
| 2139 | name = "psrlwi"; |
| 2140 | ID = Intrinsic::x86_sse2_psrl_w; |
| 2141 | break; |
| 2142 | } |
| 2143 | llvm::Function *F = CGM.getIntrinsic(ID); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2144 | return Builder.CreateCall(F, Ops, name); |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2145 | } |
Bill Wendling | aa51e51 | 2010-10-09 08:47:25 +0000 | [diff] [blame] | 2146 | case X86::BI__builtin_ia32_vec_init_v8qi: |
| 2147 | case X86::BI__builtin_ia32_vec_init_v4hi: |
| 2148 | case X86::BI__builtin_ia32_vec_init_v2si: |
| 2149 | return Builder.CreateBitCast(BuildVector(Ops), |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 2150 | llvm::Type::getX86_MMXTy(getLLVMContext())); |
Argyrios Kyrtzidis | 1944ec1 | 2010-10-10 03:19:11 +0000 | [diff] [blame] | 2151 | case X86::BI__builtin_ia32_vec_ext_v2si: |
| 2152 | return Builder.CreateExtractElement(Ops[0], |
| 2153 | llvm::ConstantInt::get(Ops[1]->getType(), 0)); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2154 | case X86::BI__builtin_ia32_pslldi: |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2155 | case X86::BI__builtin_ia32_psllqi: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2156 | case X86::BI__builtin_ia32_psllwi: |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2157 | case X86::BI__builtin_ia32_psradi: |
| 2158 | case X86::BI__builtin_ia32_psrawi: |
| 2159 | case X86::BI__builtin_ia32_psrldi: |
| 2160 | case X86::BI__builtin_ia32_psrlqi: |
| 2161 | case X86::BI__builtin_ia32_psrlwi: { |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2162 | Ops[1] = Builder.CreateZExt(Ops[1], Int64Ty, "zext"); |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 2163 | llvm::Type *Ty = llvm::VectorType::get(Int64Ty, 1); |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2164 | Ops[1] = Builder.CreateBitCast(Ops[1], Ty, "bitcast"); |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2165 | const char *name = 0; |
| 2166 | Intrinsic::ID ID = Intrinsic::not_intrinsic; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2167 | |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2168 | switch (BuiltinID) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 2169 | default: llvm_unreachable("Unsupported shift intrinsic!"); |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2170 | case X86::BI__builtin_ia32_pslldi: |
| 2171 | name = "pslldi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2172 | ID = Intrinsic::x86_mmx_psll_d; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2173 | break; |
| 2174 | case X86::BI__builtin_ia32_psllqi: |
| 2175 | name = "psllqi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2176 | ID = Intrinsic::x86_mmx_psll_q; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2177 | break; |
| 2178 | case X86::BI__builtin_ia32_psllwi: |
| 2179 | name = "psllwi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2180 | ID = Intrinsic::x86_mmx_psll_w; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2181 | break; |
| 2182 | case X86::BI__builtin_ia32_psradi: |
| 2183 | name = "psradi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2184 | ID = Intrinsic::x86_mmx_psra_d; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2185 | break; |
| 2186 | case X86::BI__builtin_ia32_psrawi: |
| 2187 | name = "psrawi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2188 | ID = Intrinsic::x86_mmx_psra_w; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2189 | break; |
| 2190 | case X86::BI__builtin_ia32_psrldi: |
| 2191 | name = "psrldi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2192 | ID = Intrinsic::x86_mmx_psrl_d; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2193 | break; |
| 2194 | case X86::BI__builtin_ia32_psrlqi: |
| 2195 | name = "psrlqi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2196 | ID = Intrinsic::x86_mmx_psrl_q; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2197 | break; |
| 2198 | case X86::BI__builtin_ia32_psrlwi: |
| 2199 | name = "psrlwi"; |
Bill Wendling | df4d482 | 2010-09-27 21:22:25 +0000 | [diff] [blame] | 2200 | ID = Intrinsic::x86_mmx_psrl_w; |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2201 | break; |
| 2202 | } |
Chris Lattner | 7acda7c | 2007-12-18 00:25:38 +0000 | [diff] [blame] | 2203 | llvm::Function *F = CGM.getIntrinsic(ID); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2204 | return Builder.CreateCall(F, Ops, name); |
Anders Carlsson | 2929cfa | 2007-12-14 17:48:24 +0000 | [diff] [blame] | 2205 | } |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 2206 | case X86::BI__builtin_ia32_cmpps: { |
| 2207 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_sse_cmp_ps); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2208 | return Builder.CreateCall(F, Ops, "cmpps"); |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 2209 | } |
| 2210 | case X86::BI__builtin_ia32_cmpss: { |
| 2211 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_sse_cmp_ss); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2212 | return Builder.CreateCall(F, Ops, "cmpss"); |
Anders Carlsson | cc8b7f9 | 2007-12-16 22:33:50 +0000 | [diff] [blame] | 2213 | } |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2214 | case X86::BI__builtin_ia32_ldmxcsr: { |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 2215 | llvm::Type *PtrTy = Int8PtrTy; |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2216 | Value *One = llvm::ConstantInt::get(Int32Ty, 1); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 2217 | Value *Tmp = Builder.CreateAlloca(Int32Ty, One); |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2218 | Builder.CreateStore(Ops[0], Tmp); |
| 2219 | return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_ldmxcsr), |
Chris Lattner | 3eae03e | 2008-05-06 00:56:42 +0000 | [diff] [blame] | 2220 | Builder.CreateBitCast(Tmp, PtrTy)); |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2221 | } |
| 2222 | case X86::BI__builtin_ia32_stmxcsr: { |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 2223 | llvm::Type *PtrTy = Int8PtrTy; |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2224 | Value *One = llvm::ConstantInt::get(Int32Ty, 1); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 2225 | Value *Tmp = Builder.CreateAlloca(Int32Ty, One); |
Ted Kremenek | 012614e | 2011-08-17 21:04:19 +0000 | [diff] [blame] | 2226 | Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr), |
| 2227 | Builder.CreateBitCast(Tmp, PtrTy)); |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2228 | return Builder.CreateLoad(Tmp, "stmxcsr"); |
| 2229 | } |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 2230 | case X86::BI__builtin_ia32_cmppd: { |
| 2231 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_sse2_cmp_pd); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2232 | return Builder.CreateCall(F, Ops, "cmppd"); |
Anders Carlsson | 79dcf5f | 2009-05-18 19:16:46 +0000 | [diff] [blame] | 2233 | } |
| 2234 | case X86::BI__builtin_ia32_cmpsd: { |
| 2235 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_sse2_cmp_sd); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2236 | return Builder.CreateCall(F, Ops, "cmpsd"); |
Anders Carlsson | cc8b7f9 | 2007-12-16 22:33:50 +0000 | [diff] [blame] | 2237 | } |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2238 | case X86::BI__builtin_ia32_storehps: |
| 2239 | case X86::BI__builtin_ia32_storelps: { |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2240 | llvm::Type *PtrTy = llvm::PointerType::getUnqual(Int64Ty); |
| 2241 | llvm::Type *VecTy = llvm::VectorType::get(Int64Ty, 2); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2242 | |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2243 | // cast val v2i64 |
| 2244 | Ops[1] = Builder.CreateBitCast(Ops[1], VecTy, "cast"); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2245 | |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2246 | // extract (0, 1) |
| 2247 | unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1; |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2248 | llvm::Value *Idx = llvm::ConstantInt::get(Int32Ty, Index); |
Nate Begeman | e772210 | 2008-04-14 04:49:57 +0000 | [diff] [blame] | 2249 | Ops[1] = Builder.CreateExtractElement(Ops[1], Idx, "extract"); |
| 2250 | |
| 2251 | // cast pointer to i64 & store |
| 2252 | Ops[0] = Builder.CreateBitCast(Ops[0], PtrTy); |
| 2253 | return Builder.CreateStore(Ops[1], Ops[0]); |
| 2254 | } |
Bill Wendling | 28cab38 | 2010-09-28 01:28:56 +0000 | [diff] [blame] | 2255 | case X86::BI__builtin_ia32_palignr: { |
| 2256 | unsigned shiftVal = cast<llvm::ConstantInt>(Ops[2])->getZExtValue(); |
| 2257 | |
| 2258 | // If palignr is shifting the pair of input vectors less than 9 bytes, |
| 2259 | // emit a shuffle instruction. |
| 2260 | if (shiftVal <= 8) { |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2261 | SmallVector<llvm::Constant*, 8> Indices; |
Bill Wendling | 28cab38 | 2010-09-28 01:28:56 +0000 | [diff] [blame] | 2262 | for (unsigned i = 0; i != 8; ++i) |
| 2263 | Indices.push_back(llvm::ConstantInt::get(Int32Ty, shiftVal + i)); |
| 2264 | |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 2265 | Value* SV = llvm::ConstantVector::get(Indices); |
Bill Wendling | 28cab38 | 2010-09-28 01:28:56 +0000 | [diff] [blame] | 2266 | return Builder.CreateShuffleVector(Ops[1], Ops[0], SV, "palignr"); |
| 2267 | } |
| 2268 | |
| 2269 | // If palignr is shifting the pair of input vectors more than 8 but less |
| 2270 | // than 16 bytes, emit a logical right shift of the destination. |
| 2271 | if (shiftVal < 16) { |
| 2272 | // MMX has these as 1 x i64 vectors for some odd optimization reasons. |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 2273 | llvm::Type *VecTy = llvm::VectorType::get(Int64Ty, 1); |
Bill Wendling | 28cab38 | 2010-09-28 01:28:56 +0000 | [diff] [blame] | 2274 | |
| 2275 | Ops[0] = Builder.CreateBitCast(Ops[0], VecTy, "cast"); |
| 2276 | Ops[1] = llvm::ConstantInt::get(VecTy, (shiftVal-8) * 8); |
| 2277 | |
| 2278 | // create i32 constant |
| 2279 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_mmx_psrl_q); |
Frits van Bommel | e9c0265 | 2011-07-18 12:00:32 +0000 | [diff] [blame] | 2280 | return Builder.CreateCall(F, makeArrayRef(&Ops[0], 2), "palignr"); |
Bill Wendling | 28cab38 | 2010-09-28 01:28:56 +0000 | [diff] [blame] | 2281 | } |
| 2282 | |
Eli Friedman | 5c22ad2 | 2011-09-14 00:52:45 +0000 | [diff] [blame] | 2283 | // If palignr is shifting the pair of vectors more than 16 bytes, emit zero. |
Bill Wendling | 28cab38 | 2010-09-28 01:28:56 +0000 | [diff] [blame] | 2284 | return llvm::Constant::getNullValue(ConvertType(E->getType())); |
| 2285 | } |
Nate Begeman | c3420ff | 2009-12-14 05:15:02 +0000 | [diff] [blame] | 2286 | case X86::BI__builtin_ia32_palignr128: { |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2287 | unsigned shiftVal = cast<llvm::ConstantInt>(Ops[2])->getZExtValue(); |
| 2288 | |
| 2289 | // If palignr is shifting the pair of input vectors less than 17 bytes, |
| 2290 | // emit a shuffle instruction. |
| 2291 | if (shiftVal <= 16) { |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 2292 | SmallVector<llvm::Constant*, 16> Indices; |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2293 | for (unsigned i = 0; i != 16; ++i) |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2294 | Indices.push_back(llvm::ConstantInt::get(Int32Ty, shiftVal + i)); |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2295 | |
Chris Lattner | fb018d1 | 2011-02-15 00:14:06 +0000 | [diff] [blame] | 2296 | Value* SV = llvm::ConstantVector::get(Indices); |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2297 | return Builder.CreateShuffleVector(Ops[1], Ops[0], SV, "palignr"); |
| 2298 | } |
| 2299 | |
| 2300 | // If palignr is shifting the pair of input vectors more than 16 but less |
| 2301 | // than 32 bytes, emit a logical right shift of the destination. |
| 2302 | if (shiftVal < 32) { |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 2303 | llvm::Type *VecTy = llvm::VectorType::get(Int64Ty, 2); |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2304 | |
| 2305 | Ops[0] = Builder.CreateBitCast(Ops[0], VecTy, "cast"); |
Chris Lattner | 77b89b8 | 2010-06-27 07:15:29 +0000 | [diff] [blame] | 2306 | Ops[1] = llvm::ConstantInt::get(Int32Ty, (shiftVal-16) * 8); |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2307 | |
| 2308 | // create i32 constant |
| 2309 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_sse2_psrl_dq); |
Frits van Bommel | e9c0265 | 2011-07-18 12:00:32 +0000 | [diff] [blame] | 2310 | return Builder.CreateCall(F, makeArrayRef(&Ops[0], 2), "palignr"); |
Nate Begeman | ce5818a | 2009-12-14 04:57:03 +0000 | [diff] [blame] | 2311 | } |
| 2312 | |
| 2313 | // If palignr is shifting the pair of vectors more than 32 bytes, emit zero. |
| 2314 | return llvm::Constant::getNullValue(ConvertType(E->getType())); |
Eric Christopher | 91b5927 | 2009-12-01 05:00:51 +0000 | [diff] [blame] | 2315 | } |
Craig Topper | 9c2ffd8 | 2011-12-19 07:03:25 +0000 | [diff] [blame] | 2316 | case X86::BI__builtin_ia32_palignr256: { |
| 2317 | unsigned shiftVal = cast<llvm::ConstantInt>(Ops[2])->getZExtValue(); |
| 2318 | |
| 2319 | // If palignr is shifting the pair of input vectors less than 17 bytes, |
| 2320 | // emit a shuffle instruction. |
| 2321 | if (shiftVal <= 16) { |
| 2322 | SmallVector<llvm::Constant*, 32> Indices; |
| 2323 | // 256-bit palignr operates on 128-bit lanes so we need to handle that |
| 2324 | for (unsigned l = 0; l != 2; ++l) { |
| 2325 | unsigned LaneStart = l * 16; |
| 2326 | unsigned LaneEnd = (l+1) * 16; |
| 2327 | for (unsigned i = 0; i != 16; ++i) { |
| 2328 | unsigned Idx = shiftVal + i + LaneStart; |
| 2329 | if (Idx >= LaneEnd) Idx += 16; // end of lane, switch operand |
| 2330 | Indices.push_back(llvm::ConstantInt::get(Int32Ty, Idx)); |
| 2331 | } |
| 2332 | } |
| 2333 | |
| 2334 | Value* SV = llvm::ConstantVector::get(Indices); |
| 2335 | return Builder.CreateShuffleVector(Ops[1], Ops[0], SV, "palignr"); |
| 2336 | } |
| 2337 | |
| 2338 | // If palignr is shifting the pair of input vectors more than 16 but less |
| 2339 | // than 32 bytes, emit a logical right shift of the destination. |
| 2340 | if (shiftVal < 32) { |
| 2341 | llvm::Type *VecTy = llvm::VectorType::get(Int64Ty, 4); |
| 2342 | |
| 2343 | Ops[0] = Builder.CreateBitCast(Ops[0], VecTy, "cast"); |
| 2344 | Ops[1] = llvm::ConstantInt::get(Int32Ty, (shiftVal-16) * 8); |
| 2345 | |
| 2346 | // create i32 constant |
| 2347 | llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_avx2_psrl_dq); |
| 2348 | return Builder.CreateCall(F, makeArrayRef(&Ops[0], 2), "palignr"); |
| 2349 | } |
| 2350 | |
| 2351 | // If palignr is shifting the pair of vectors more than 32 bytes, emit zero. |
| 2352 | return llvm::Constant::getNullValue(ConvertType(E->getType())); |
| 2353 | } |
Bill Wendling | b51bdda | 2011-05-04 02:40:38 +0000 | [diff] [blame] | 2354 | case X86::BI__builtin_ia32_movntps: |
| 2355 | case X86::BI__builtin_ia32_movntpd: |
| 2356 | case X86::BI__builtin_ia32_movntdq: |
| 2357 | case X86::BI__builtin_ia32_movnti: { |
Bill Wendling | b107dd0 | 2011-05-04 20:28:12 +0000 | [diff] [blame] | 2358 | llvm::MDNode *Node = llvm::MDNode::get(getLLVMContext(), |
| 2359 | Builder.getInt32(1)); |
Bill Wendling | b51bdda | 2011-05-04 02:40:38 +0000 | [diff] [blame] | 2360 | |
| 2361 | // Convert the type of the pointer to a pointer to the stored type. |
| 2362 | Value *BC = Builder.CreateBitCast(Ops[0], |
| 2363 | llvm::PointerType::getUnqual(Ops[1]->getType()), |
| 2364 | "cast"); |
| 2365 | StoreInst *SI = Builder.CreateStore(Ops[1], BC); |
| 2366 | SI->setMetadata(CGM.getModule().getMDKindID("nontemporal"), Node); |
| 2367 | SI->setAlignment(16); |
| 2368 | return SI; |
| 2369 | } |
Michael J. Spencer | 8b36a9e | 2011-04-15 15:07:13 +0000 | [diff] [blame] | 2370 | // 3DNow! |
| 2371 | case X86::BI__builtin_ia32_pavgusb: |
| 2372 | case X86::BI__builtin_ia32_pf2id: |
| 2373 | case X86::BI__builtin_ia32_pfacc: |
| 2374 | case X86::BI__builtin_ia32_pfadd: |
| 2375 | case X86::BI__builtin_ia32_pfcmpeq: |
| 2376 | case X86::BI__builtin_ia32_pfcmpge: |
| 2377 | case X86::BI__builtin_ia32_pfcmpgt: |
| 2378 | case X86::BI__builtin_ia32_pfmax: |
| 2379 | case X86::BI__builtin_ia32_pfmin: |
| 2380 | case X86::BI__builtin_ia32_pfmul: |
| 2381 | case X86::BI__builtin_ia32_pfrcp: |
| 2382 | case X86::BI__builtin_ia32_pfrcpit1: |
| 2383 | case X86::BI__builtin_ia32_pfrcpit2: |
| 2384 | case X86::BI__builtin_ia32_pfrsqrt: |
| 2385 | case X86::BI__builtin_ia32_pfrsqit1: |
| 2386 | case X86::BI__builtin_ia32_pfrsqrtit1: |
| 2387 | case X86::BI__builtin_ia32_pfsub: |
| 2388 | case X86::BI__builtin_ia32_pfsubr: |
| 2389 | case X86::BI__builtin_ia32_pi2fd: |
| 2390 | case X86::BI__builtin_ia32_pmulhrw: |
| 2391 | case X86::BI__builtin_ia32_pf2iw: |
| 2392 | case X86::BI__builtin_ia32_pfnacc: |
| 2393 | case X86::BI__builtin_ia32_pfpnacc: |
| 2394 | case X86::BI__builtin_ia32_pi2fw: |
| 2395 | case X86::BI__builtin_ia32_pswapdsf: |
| 2396 | case X86::BI__builtin_ia32_pswapdsi: { |
| 2397 | const char *name = 0; |
| 2398 | Intrinsic::ID ID = Intrinsic::not_intrinsic; |
| 2399 | switch(BuiltinID) { |
| 2400 | case X86::BI__builtin_ia32_pavgusb: |
| 2401 | name = "pavgusb"; |
| 2402 | ID = Intrinsic::x86_3dnow_pavgusb; |
| 2403 | break; |
| 2404 | case X86::BI__builtin_ia32_pf2id: |
| 2405 | name = "pf2id"; |
| 2406 | ID = Intrinsic::x86_3dnow_pf2id; |
| 2407 | break; |
| 2408 | case X86::BI__builtin_ia32_pfacc: |
| 2409 | name = "pfacc"; |
| 2410 | ID = Intrinsic::x86_3dnow_pfacc; |
| 2411 | break; |
| 2412 | case X86::BI__builtin_ia32_pfadd: |
| 2413 | name = "pfadd"; |
| 2414 | ID = Intrinsic::x86_3dnow_pfadd; |
| 2415 | break; |
| 2416 | case X86::BI__builtin_ia32_pfcmpeq: |
| 2417 | name = "pfcmpeq"; |
| 2418 | ID = Intrinsic::x86_3dnow_pfcmpeq; |
| 2419 | break; |
| 2420 | case X86::BI__builtin_ia32_pfcmpge: |
| 2421 | name = "pfcmpge"; |
| 2422 | ID = Intrinsic::x86_3dnow_pfcmpge; |
| 2423 | break; |
| 2424 | case X86::BI__builtin_ia32_pfcmpgt: |
| 2425 | name = "pfcmpgt"; |
| 2426 | ID = Intrinsic::x86_3dnow_pfcmpgt; |
| 2427 | break; |
| 2428 | case X86::BI__builtin_ia32_pfmax: |
| 2429 | name = "pfmax"; |
| 2430 | ID = Intrinsic::x86_3dnow_pfmax; |
| 2431 | break; |
| 2432 | case X86::BI__builtin_ia32_pfmin: |
| 2433 | name = "pfmin"; |
| 2434 | ID = Intrinsic::x86_3dnow_pfmin; |
| 2435 | break; |
| 2436 | case X86::BI__builtin_ia32_pfmul: |
| 2437 | name = "pfmul"; |
| 2438 | ID = Intrinsic::x86_3dnow_pfmul; |
| 2439 | break; |
| 2440 | case X86::BI__builtin_ia32_pfrcp: |
| 2441 | name = "pfrcp"; |
| 2442 | ID = Intrinsic::x86_3dnow_pfrcp; |
| 2443 | break; |
| 2444 | case X86::BI__builtin_ia32_pfrcpit1: |
| 2445 | name = "pfrcpit1"; |
| 2446 | ID = Intrinsic::x86_3dnow_pfrcpit1; |
| 2447 | break; |
| 2448 | case X86::BI__builtin_ia32_pfrcpit2: |
| 2449 | name = "pfrcpit2"; |
| 2450 | ID = Intrinsic::x86_3dnow_pfrcpit2; |
| 2451 | break; |
| 2452 | case X86::BI__builtin_ia32_pfrsqrt: |
| 2453 | name = "pfrsqrt"; |
| 2454 | ID = Intrinsic::x86_3dnow_pfrsqrt; |
| 2455 | break; |
| 2456 | case X86::BI__builtin_ia32_pfrsqit1: |
| 2457 | case X86::BI__builtin_ia32_pfrsqrtit1: |
| 2458 | name = "pfrsqit1"; |
| 2459 | ID = Intrinsic::x86_3dnow_pfrsqit1; |
| 2460 | break; |
| 2461 | case X86::BI__builtin_ia32_pfsub: |
| 2462 | name = "pfsub"; |
| 2463 | ID = Intrinsic::x86_3dnow_pfsub; |
| 2464 | break; |
| 2465 | case X86::BI__builtin_ia32_pfsubr: |
| 2466 | name = "pfsubr"; |
| 2467 | ID = Intrinsic::x86_3dnow_pfsubr; |
| 2468 | break; |
| 2469 | case X86::BI__builtin_ia32_pi2fd: |
| 2470 | name = "pi2fd"; |
| 2471 | ID = Intrinsic::x86_3dnow_pi2fd; |
| 2472 | break; |
| 2473 | case X86::BI__builtin_ia32_pmulhrw: |
| 2474 | name = "pmulhrw"; |
| 2475 | ID = Intrinsic::x86_3dnow_pmulhrw; |
| 2476 | break; |
| 2477 | case X86::BI__builtin_ia32_pf2iw: |
| 2478 | name = "pf2iw"; |
| 2479 | ID = Intrinsic::x86_3dnowa_pf2iw; |
| 2480 | break; |
| 2481 | case X86::BI__builtin_ia32_pfnacc: |
| 2482 | name = "pfnacc"; |
| 2483 | ID = Intrinsic::x86_3dnowa_pfnacc; |
| 2484 | break; |
| 2485 | case X86::BI__builtin_ia32_pfpnacc: |
| 2486 | name = "pfpnacc"; |
| 2487 | ID = Intrinsic::x86_3dnowa_pfpnacc; |
| 2488 | break; |
| 2489 | case X86::BI__builtin_ia32_pi2fw: |
| 2490 | name = "pi2fw"; |
| 2491 | ID = Intrinsic::x86_3dnowa_pi2fw; |
| 2492 | break; |
| 2493 | case X86::BI__builtin_ia32_pswapdsf: |
| 2494 | case X86::BI__builtin_ia32_pswapdsi: |
| 2495 | name = "pswapd"; |
| 2496 | ID = Intrinsic::x86_3dnowa_pswapd; |
| 2497 | break; |
| 2498 | } |
| 2499 | llvm::Function *F = CGM.getIntrinsic(ID); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 2500 | return Builder.CreateCall(F, Ops, name); |
Michael J. Spencer | 8b36a9e | 2011-04-15 15:07:13 +0000 | [diff] [blame] | 2501 | } |
Anders Carlsson | 564f1de | 2007-12-09 23:17:02 +0000 | [diff] [blame] | 2502 | } |
| 2503 | } |
| 2504 | |
Tony Linthicum | 9631939 | 2011-12-12 21:14:55 +0000 | [diff] [blame] | 2505 | |
| 2506 | Value *CodeGenFunction::EmitHexagonBuiltinExpr(unsigned BuiltinID, |
| 2507 | const CallExpr *E) { |
| 2508 | llvm::SmallVector<Value*, 4> Ops; |
| 2509 | |
| 2510 | for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) |
| 2511 | Ops.push_back(EmitScalarExpr(E->getArg(i))); |
| 2512 | |
| 2513 | Intrinsic::ID ID = Intrinsic::not_intrinsic; |
| 2514 | |
| 2515 | switch (BuiltinID) { |
| 2516 | default: return 0; |
| 2517 | |
| 2518 | case Hexagon::BI__builtin_HEXAGON_C2_cmpeq: |
| 2519 | ID = Intrinsic::hexagon_C2_cmpeq; break; |
| 2520 | |
| 2521 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgt: |
| 2522 | ID = Intrinsic::hexagon_C2_cmpgt; break; |
| 2523 | |
| 2524 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgtu: |
| 2525 | ID = Intrinsic::hexagon_C2_cmpgtu; break; |
| 2526 | |
| 2527 | case Hexagon::BI__builtin_HEXAGON_C2_cmpeqp: |
| 2528 | ID = Intrinsic::hexagon_C2_cmpeqp; break; |
| 2529 | |
| 2530 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgtp: |
| 2531 | ID = Intrinsic::hexagon_C2_cmpgtp; break; |
| 2532 | |
| 2533 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgtup: |
| 2534 | ID = Intrinsic::hexagon_C2_cmpgtup; break; |
| 2535 | |
| 2536 | case Hexagon::BI__builtin_HEXAGON_C2_bitsset: |
| 2537 | ID = Intrinsic::hexagon_C2_bitsset; break; |
| 2538 | |
| 2539 | case Hexagon::BI__builtin_HEXAGON_C2_bitsclr: |
| 2540 | ID = Intrinsic::hexagon_C2_bitsclr; break; |
| 2541 | |
| 2542 | case Hexagon::BI__builtin_HEXAGON_C2_cmpeqi: |
| 2543 | ID = Intrinsic::hexagon_C2_cmpeqi; break; |
| 2544 | |
| 2545 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgti: |
| 2546 | ID = Intrinsic::hexagon_C2_cmpgti; break; |
| 2547 | |
| 2548 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgtui: |
| 2549 | ID = Intrinsic::hexagon_C2_cmpgtui; break; |
| 2550 | |
| 2551 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgei: |
| 2552 | ID = Intrinsic::hexagon_C2_cmpgei; break; |
| 2553 | |
| 2554 | case Hexagon::BI__builtin_HEXAGON_C2_cmpgeui: |
| 2555 | ID = Intrinsic::hexagon_C2_cmpgeui; break; |
| 2556 | |
| 2557 | case Hexagon::BI__builtin_HEXAGON_C2_cmplt: |
| 2558 | ID = Intrinsic::hexagon_C2_cmplt; break; |
| 2559 | |
| 2560 | case Hexagon::BI__builtin_HEXAGON_C2_cmpltu: |
| 2561 | ID = Intrinsic::hexagon_C2_cmpltu; break; |
| 2562 | |
| 2563 | case Hexagon::BI__builtin_HEXAGON_C2_bitsclri: |
| 2564 | ID = Intrinsic::hexagon_C2_bitsclri; break; |
| 2565 | |
| 2566 | case Hexagon::BI__builtin_HEXAGON_C2_and: |
| 2567 | ID = Intrinsic::hexagon_C2_and; break; |
| 2568 | |
| 2569 | case Hexagon::BI__builtin_HEXAGON_C2_or: |
| 2570 | ID = Intrinsic::hexagon_C2_or; break; |
| 2571 | |
| 2572 | case Hexagon::BI__builtin_HEXAGON_C2_xor: |
| 2573 | ID = Intrinsic::hexagon_C2_xor; break; |
| 2574 | |
| 2575 | case Hexagon::BI__builtin_HEXAGON_C2_andn: |
| 2576 | ID = Intrinsic::hexagon_C2_andn; break; |
| 2577 | |
| 2578 | case Hexagon::BI__builtin_HEXAGON_C2_not: |
| 2579 | ID = Intrinsic::hexagon_C2_not; break; |
| 2580 | |
| 2581 | case Hexagon::BI__builtin_HEXAGON_C2_orn: |
| 2582 | ID = Intrinsic::hexagon_C2_orn; break; |
| 2583 | |
| 2584 | case Hexagon::BI__builtin_HEXAGON_C2_pxfer_map: |
| 2585 | ID = Intrinsic::hexagon_C2_pxfer_map; break; |
| 2586 | |
| 2587 | case Hexagon::BI__builtin_HEXAGON_C2_any8: |
| 2588 | ID = Intrinsic::hexagon_C2_any8; break; |
| 2589 | |
| 2590 | case Hexagon::BI__builtin_HEXAGON_C2_all8: |
| 2591 | ID = Intrinsic::hexagon_C2_all8; break; |
| 2592 | |
| 2593 | case Hexagon::BI__builtin_HEXAGON_C2_vitpack: |
| 2594 | ID = Intrinsic::hexagon_C2_vitpack; break; |
| 2595 | |
| 2596 | case Hexagon::BI__builtin_HEXAGON_C2_mux: |
| 2597 | ID = Intrinsic::hexagon_C2_mux; break; |
| 2598 | |
| 2599 | case Hexagon::BI__builtin_HEXAGON_C2_muxii: |
| 2600 | ID = Intrinsic::hexagon_C2_muxii; break; |
| 2601 | |
| 2602 | case Hexagon::BI__builtin_HEXAGON_C2_muxir: |
| 2603 | ID = Intrinsic::hexagon_C2_muxir; break; |
| 2604 | |
| 2605 | case Hexagon::BI__builtin_HEXAGON_C2_muxri: |
| 2606 | ID = Intrinsic::hexagon_C2_muxri; break; |
| 2607 | |
| 2608 | case Hexagon::BI__builtin_HEXAGON_C2_vmux: |
| 2609 | ID = Intrinsic::hexagon_C2_vmux; break; |
| 2610 | |
| 2611 | case Hexagon::BI__builtin_HEXAGON_C2_mask: |
| 2612 | ID = Intrinsic::hexagon_C2_mask; break; |
| 2613 | |
| 2614 | case Hexagon::BI__builtin_HEXAGON_A2_vcmpbeq: |
| 2615 | ID = Intrinsic::hexagon_A2_vcmpbeq; break; |
| 2616 | |
| 2617 | case Hexagon::BI__builtin_HEXAGON_A2_vcmpbgtu: |
| 2618 | ID = Intrinsic::hexagon_A2_vcmpbgtu; break; |
| 2619 | |
| 2620 | case Hexagon::BI__builtin_HEXAGON_A2_vcmpheq: |
| 2621 | ID = Intrinsic::hexagon_A2_vcmpheq; break; |
| 2622 | |
| 2623 | case Hexagon::BI__builtin_HEXAGON_A2_vcmphgt: |
| 2624 | ID = Intrinsic::hexagon_A2_vcmphgt; break; |
| 2625 | |
| 2626 | case Hexagon::BI__builtin_HEXAGON_A2_vcmphgtu: |
| 2627 | ID = Intrinsic::hexagon_A2_vcmphgtu; break; |
| 2628 | |
| 2629 | case Hexagon::BI__builtin_HEXAGON_A2_vcmpweq: |
| 2630 | ID = Intrinsic::hexagon_A2_vcmpweq; break; |
| 2631 | |
| 2632 | case Hexagon::BI__builtin_HEXAGON_A2_vcmpwgt: |
| 2633 | ID = Intrinsic::hexagon_A2_vcmpwgt; break; |
| 2634 | |
| 2635 | case Hexagon::BI__builtin_HEXAGON_A2_vcmpwgtu: |
| 2636 | ID = Intrinsic::hexagon_A2_vcmpwgtu; break; |
| 2637 | |
| 2638 | case Hexagon::BI__builtin_HEXAGON_C2_tfrpr: |
| 2639 | ID = Intrinsic::hexagon_C2_tfrpr; break; |
| 2640 | |
| 2641 | case Hexagon::BI__builtin_HEXAGON_C2_tfrrp: |
| 2642 | ID = Intrinsic::hexagon_C2_tfrrp; break; |
| 2643 | |
| 2644 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hh_s0: |
| 2645 | ID = Intrinsic::hexagon_M2_mpy_acc_hh_s0; break; |
| 2646 | |
| 2647 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hh_s1: |
| 2648 | ID = Intrinsic::hexagon_M2_mpy_acc_hh_s1; break; |
| 2649 | |
| 2650 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hl_s0: |
| 2651 | ID = Intrinsic::hexagon_M2_mpy_acc_hl_s0; break; |
| 2652 | |
| 2653 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_hl_s1: |
| 2654 | ID = Intrinsic::hexagon_M2_mpy_acc_hl_s1; break; |
| 2655 | |
| 2656 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_lh_s0: |
| 2657 | ID = Intrinsic::hexagon_M2_mpy_acc_lh_s0; break; |
| 2658 | |
| 2659 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_lh_s1: |
| 2660 | ID = Intrinsic::hexagon_M2_mpy_acc_lh_s1; break; |
| 2661 | |
| 2662 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_ll_s0: |
| 2663 | ID = Intrinsic::hexagon_M2_mpy_acc_ll_s0; break; |
| 2664 | |
| 2665 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_ll_s1: |
| 2666 | ID = Intrinsic::hexagon_M2_mpy_acc_ll_s1; break; |
| 2667 | |
| 2668 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hh_s0: |
| 2669 | ID = Intrinsic::hexagon_M2_mpy_nac_hh_s0; break; |
| 2670 | |
| 2671 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hh_s1: |
| 2672 | ID = Intrinsic::hexagon_M2_mpy_nac_hh_s1; break; |
| 2673 | |
| 2674 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hl_s0: |
| 2675 | ID = Intrinsic::hexagon_M2_mpy_nac_hl_s0; break; |
| 2676 | |
| 2677 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_hl_s1: |
| 2678 | ID = Intrinsic::hexagon_M2_mpy_nac_hl_s1; break; |
| 2679 | |
| 2680 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_lh_s0: |
| 2681 | ID = Intrinsic::hexagon_M2_mpy_nac_lh_s0; break; |
| 2682 | |
| 2683 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_lh_s1: |
| 2684 | ID = Intrinsic::hexagon_M2_mpy_nac_lh_s1; break; |
| 2685 | |
| 2686 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_ll_s0: |
| 2687 | ID = Intrinsic::hexagon_M2_mpy_nac_ll_s0; break; |
| 2688 | |
| 2689 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_ll_s1: |
| 2690 | ID = Intrinsic::hexagon_M2_mpy_nac_ll_s1; break; |
| 2691 | |
| 2692 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hh_s0: |
| 2693 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_hh_s0; break; |
| 2694 | |
| 2695 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hh_s1: |
| 2696 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_hh_s1; break; |
| 2697 | |
| 2698 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hl_s0: |
| 2699 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_hl_s0; break; |
| 2700 | |
| 2701 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_hl_s1: |
| 2702 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_hl_s1; break; |
| 2703 | |
| 2704 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_lh_s0: |
| 2705 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_lh_s0; break; |
| 2706 | |
| 2707 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_lh_s1: |
| 2708 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_lh_s1; break; |
| 2709 | |
| 2710 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_ll_s0: |
| 2711 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_ll_s0; break; |
| 2712 | |
| 2713 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_acc_sat_ll_s1: |
| 2714 | ID = Intrinsic::hexagon_M2_mpy_acc_sat_ll_s1; break; |
| 2715 | |
| 2716 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hh_s0: |
| 2717 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_hh_s0; break; |
| 2718 | |
| 2719 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hh_s1: |
| 2720 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_hh_s1; break; |
| 2721 | |
| 2722 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hl_s0: |
| 2723 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_hl_s0; break; |
| 2724 | |
| 2725 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_hl_s1: |
| 2726 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_hl_s1; break; |
| 2727 | |
| 2728 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_lh_s0: |
| 2729 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_lh_s0; break; |
| 2730 | |
| 2731 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_lh_s1: |
| 2732 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_lh_s1; break; |
| 2733 | |
| 2734 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_ll_s0: |
| 2735 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_ll_s0; break; |
| 2736 | |
| 2737 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_nac_sat_ll_s1: |
| 2738 | ID = Intrinsic::hexagon_M2_mpy_nac_sat_ll_s1; break; |
| 2739 | |
| 2740 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_hh_s0: |
| 2741 | ID = Intrinsic::hexagon_M2_mpy_hh_s0; break; |
| 2742 | |
| 2743 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_hh_s1: |
| 2744 | ID = Intrinsic::hexagon_M2_mpy_hh_s1; break; |
| 2745 | |
| 2746 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_hl_s0: |
| 2747 | ID = Intrinsic::hexagon_M2_mpy_hl_s0; break; |
| 2748 | |
| 2749 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_hl_s1: |
| 2750 | ID = Intrinsic::hexagon_M2_mpy_hl_s1; break; |
| 2751 | |
| 2752 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_lh_s0: |
| 2753 | ID = Intrinsic::hexagon_M2_mpy_lh_s0; break; |
| 2754 | |
| 2755 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_lh_s1: |
| 2756 | ID = Intrinsic::hexagon_M2_mpy_lh_s1; break; |
| 2757 | |
| 2758 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_ll_s0: |
| 2759 | ID = Intrinsic::hexagon_M2_mpy_ll_s0; break; |
| 2760 | |
| 2761 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_ll_s1: |
| 2762 | ID = Intrinsic::hexagon_M2_mpy_ll_s1; break; |
| 2763 | |
| 2764 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hh_s0: |
| 2765 | ID = Intrinsic::hexagon_M2_mpy_sat_hh_s0; break; |
| 2766 | |
| 2767 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hh_s1: |
| 2768 | ID = Intrinsic::hexagon_M2_mpy_sat_hh_s1; break; |
| 2769 | |
| 2770 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hl_s0: |
| 2771 | ID = Intrinsic::hexagon_M2_mpy_sat_hl_s0; break; |
| 2772 | |
| 2773 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_hl_s1: |
| 2774 | ID = Intrinsic::hexagon_M2_mpy_sat_hl_s1; break; |
| 2775 | |
| 2776 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_lh_s0: |
| 2777 | ID = Intrinsic::hexagon_M2_mpy_sat_lh_s0; break; |
| 2778 | |
| 2779 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_lh_s1: |
| 2780 | ID = Intrinsic::hexagon_M2_mpy_sat_lh_s1; break; |
| 2781 | |
| 2782 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_ll_s0: |
| 2783 | ID = Intrinsic::hexagon_M2_mpy_sat_ll_s0; break; |
| 2784 | |
| 2785 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_ll_s1: |
| 2786 | ID = Intrinsic::hexagon_M2_mpy_sat_ll_s1; break; |
| 2787 | |
| 2788 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hh_s0: |
| 2789 | ID = Intrinsic::hexagon_M2_mpy_rnd_hh_s0; break; |
| 2790 | |
| 2791 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hh_s1: |
| 2792 | ID = Intrinsic::hexagon_M2_mpy_rnd_hh_s1; break; |
| 2793 | |
| 2794 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hl_s0: |
| 2795 | ID = Intrinsic::hexagon_M2_mpy_rnd_hl_s0; break; |
| 2796 | |
| 2797 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_hl_s1: |
| 2798 | ID = Intrinsic::hexagon_M2_mpy_rnd_hl_s1; break; |
| 2799 | |
| 2800 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_lh_s0: |
| 2801 | ID = Intrinsic::hexagon_M2_mpy_rnd_lh_s0; break; |
| 2802 | |
| 2803 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_lh_s1: |
| 2804 | ID = Intrinsic::hexagon_M2_mpy_rnd_lh_s1; break; |
| 2805 | |
| 2806 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_ll_s0: |
| 2807 | ID = Intrinsic::hexagon_M2_mpy_rnd_ll_s0; break; |
| 2808 | |
| 2809 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_rnd_ll_s1: |
| 2810 | ID = Intrinsic::hexagon_M2_mpy_rnd_ll_s1; break; |
| 2811 | |
| 2812 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s0: |
| 2813 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hh_s0; break; |
| 2814 | |
| 2815 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hh_s1: |
| 2816 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hh_s1; break; |
| 2817 | |
| 2818 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s0: |
| 2819 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hl_s0; break; |
| 2820 | |
| 2821 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_hl_s1: |
| 2822 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_hl_s1; break; |
| 2823 | |
| 2824 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s0: |
| 2825 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_lh_s0; break; |
| 2826 | |
| 2827 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_lh_s1: |
| 2828 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_lh_s1; break; |
| 2829 | |
| 2830 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s0: |
| 2831 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_ll_s0; break; |
| 2832 | |
| 2833 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_sat_rnd_ll_s1: |
| 2834 | ID = Intrinsic::hexagon_M2_mpy_sat_rnd_ll_s1; break; |
| 2835 | |
| 2836 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hh_s0: |
| 2837 | ID = Intrinsic::hexagon_M2_mpyd_acc_hh_s0; break; |
| 2838 | |
| 2839 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hh_s1: |
| 2840 | ID = Intrinsic::hexagon_M2_mpyd_acc_hh_s1; break; |
| 2841 | |
| 2842 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hl_s0: |
| 2843 | ID = Intrinsic::hexagon_M2_mpyd_acc_hl_s0; break; |
| 2844 | |
| 2845 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_hl_s1: |
| 2846 | ID = Intrinsic::hexagon_M2_mpyd_acc_hl_s1; break; |
| 2847 | |
| 2848 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_lh_s0: |
| 2849 | ID = Intrinsic::hexagon_M2_mpyd_acc_lh_s0; break; |
| 2850 | |
| 2851 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_lh_s1: |
| 2852 | ID = Intrinsic::hexagon_M2_mpyd_acc_lh_s1; break; |
| 2853 | |
| 2854 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_ll_s0: |
| 2855 | ID = Intrinsic::hexagon_M2_mpyd_acc_ll_s0; break; |
| 2856 | |
| 2857 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_acc_ll_s1: |
| 2858 | ID = Intrinsic::hexagon_M2_mpyd_acc_ll_s1; break; |
| 2859 | |
| 2860 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hh_s0: |
| 2861 | ID = Intrinsic::hexagon_M2_mpyd_nac_hh_s0; break; |
| 2862 | |
| 2863 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hh_s1: |
| 2864 | ID = Intrinsic::hexagon_M2_mpyd_nac_hh_s1; break; |
| 2865 | |
| 2866 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hl_s0: |
| 2867 | ID = Intrinsic::hexagon_M2_mpyd_nac_hl_s0; break; |
| 2868 | |
| 2869 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_hl_s1: |
| 2870 | ID = Intrinsic::hexagon_M2_mpyd_nac_hl_s1; break; |
| 2871 | |
| 2872 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_lh_s0: |
| 2873 | ID = Intrinsic::hexagon_M2_mpyd_nac_lh_s0; break; |
| 2874 | |
| 2875 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_lh_s1: |
| 2876 | ID = Intrinsic::hexagon_M2_mpyd_nac_lh_s1; break; |
| 2877 | |
| 2878 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_ll_s0: |
| 2879 | ID = Intrinsic::hexagon_M2_mpyd_nac_ll_s0; break; |
| 2880 | |
| 2881 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_nac_ll_s1: |
| 2882 | ID = Intrinsic::hexagon_M2_mpyd_nac_ll_s1; break; |
| 2883 | |
| 2884 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hh_s0: |
| 2885 | ID = Intrinsic::hexagon_M2_mpyd_hh_s0; break; |
| 2886 | |
| 2887 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hh_s1: |
| 2888 | ID = Intrinsic::hexagon_M2_mpyd_hh_s1; break; |
| 2889 | |
| 2890 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hl_s0: |
| 2891 | ID = Intrinsic::hexagon_M2_mpyd_hl_s0; break; |
| 2892 | |
| 2893 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_hl_s1: |
| 2894 | ID = Intrinsic::hexagon_M2_mpyd_hl_s1; break; |
| 2895 | |
| 2896 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_lh_s0: |
| 2897 | ID = Intrinsic::hexagon_M2_mpyd_lh_s0; break; |
| 2898 | |
| 2899 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_lh_s1: |
| 2900 | ID = Intrinsic::hexagon_M2_mpyd_lh_s1; break; |
| 2901 | |
| 2902 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_ll_s0: |
| 2903 | ID = Intrinsic::hexagon_M2_mpyd_ll_s0; break; |
| 2904 | |
| 2905 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_ll_s1: |
| 2906 | ID = Intrinsic::hexagon_M2_mpyd_ll_s1; break; |
| 2907 | |
| 2908 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hh_s0: |
| 2909 | ID = Intrinsic::hexagon_M2_mpyd_rnd_hh_s0; break; |
| 2910 | |
| 2911 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hh_s1: |
| 2912 | ID = Intrinsic::hexagon_M2_mpyd_rnd_hh_s1; break; |
| 2913 | |
| 2914 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hl_s0: |
| 2915 | ID = Intrinsic::hexagon_M2_mpyd_rnd_hl_s0; break; |
| 2916 | |
| 2917 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_hl_s1: |
| 2918 | ID = Intrinsic::hexagon_M2_mpyd_rnd_hl_s1; break; |
| 2919 | |
| 2920 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_lh_s0: |
| 2921 | ID = Intrinsic::hexagon_M2_mpyd_rnd_lh_s0; break; |
| 2922 | |
| 2923 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_lh_s1: |
| 2924 | ID = Intrinsic::hexagon_M2_mpyd_rnd_lh_s1; break; |
| 2925 | |
| 2926 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_ll_s0: |
| 2927 | ID = Intrinsic::hexagon_M2_mpyd_rnd_ll_s0; break; |
| 2928 | |
| 2929 | case Hexagon::BI__builtin_HEXAGON_M2_mpyd_rnd_ll_s1: |
| 2930 | ID = Intrinsic::hexagon_M2_mpyd_rnd_ll_s1; break; |
| 2931 | |
| 2932 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hh_s0: |
| 2933 | ID = Intrinsic::hexagon_M2_mpyu_acc_hh_s0; break; |
| 2934 | |
| 2935 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hh_s1: |
| 2936 | ID = Intrinsic::hexagon_M2_mpyu_acc_hh_s1; break; |
| 2937 | |
| 2938 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hl_s0: |
| 2939 | ID = Intrinsic::hexagon_M2_mpyu_acc_hl_s0; break; |
| 2940 | |
| 2941 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_hl_s1: |
| 2942 | ID = Intrinsic::hexagon_M2_mpyu_acc_hl_s1; break; |
| 2943 | |
| 2944 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_lh_s0: |
| 2945 | ID = Intrinsic::hexagon_M2_mpyu_acc_lh_s0; break; |
| 2946 | |
| 2947 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_lh_s1: |
| 2948 | ID = Intrinsic::hexagon_M2_mpyu_acc_lh_s1; break; |
| 2949 | |
| 2950 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_ll_s0: |
| 2951 | ID = Intrinsic::hexagon_M2_mpyu_acc_ll_s0; break; |
| 2952 | |
| 2953 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_acc_ll_s1: |
| 2954 | ID = Intrinsic::hexagon_M2_mpyu_acc_ll_s1; break; |
| 2955 | |
| 2956 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hh_s0: |
| 2957 | ID = Intrinsic::hexagon_M2_mpyu_nac_hh_s0; break; |
| 2958 | |
| 2959 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hh_s1: |
| 2960 | ID = Intrinsic::hexagon_M2_mpyu_nac_hh_s1; break; |
| 2961 | |
| 2962 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hl_s0: |
| 2963 | ID = Intrinsic::hexagon_M2_mpyu_nac_hl_s0; break; |
| 2964 | |
| 2965 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_hl_s1: |
| 2966 | ID = Intrinsic::hexagon_M2_mpyu_nac_hl_s1; break; |
| 2967 | |
| 2968 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_lh_s0: |
| 2969 | ID = Intrinsic::hexagon_M2_mpyu_nac_lh_s0; break; |
| 2970 | |
| 2971 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_lh_s1: |
| 2972 | ID = Intrinsic::hexagon_M2_mpyu_nac_lh_s1; break; |
| 2973 | |
| 2974 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_ll_s0: |
| 2975 | ID = Intrinsic::hexagon_M2_mpyu_nac_ll_s0; break; |
| 2976 | |
| 2977 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_nac_ll_s1: |
| 2978 | ID = Intrinsic::hexagon_M2_mpyu_nac_ll_s1; break; |
| 2979 | |
| 2980 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hh_s0: |
| 2981 | ID = Intrinsic::hexagon_M2_mpyu_hh_s0; break; |
| 2982 | |
| 2983 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hh_s1: |
| 2984 | ID = Intrinsic::hexagon_M2_mpyu_hh_s1; break; |
| 2985 | |
| 2986 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hl_s0: |
| 2987 | ID = Intrinsic::hexagon_M2_mpyu_hl_s0; break; |
| 2988 | |
| 2989 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_hl_s1: |
| 2990 | ID = Intrinsic::hexagon_M2_mpyu_hl_s1; break; |
| 2991 | |
| 2992 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_lh_s0: |
| 2993 | ID = Intrinsic::hexagon_M2_mpyu_lh_s0; break; |
| 2994 | |
| 2995 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_lh_s1: |
| 2996 | ID = Intrinsic::hexagon_M2_mpyu_lh_s1; break; |
| 2997 | |
| 2998 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_ll_s0: |
| 2999 | ID = Intrinsic::hexagon_M2_mpyu_ll_s0; break; |
| 3000 | |
| 3001 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_ll_s1: |
| 3002 | ID = Intrinsic::hexagon_M2_mpyu_ll_s1; break; |
| 3003 | |
| 3004 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hh_s0: |
| 3005 | ID = Intrinsic::hexagon_M2_mpyud_acc_hh_s0; break; |
| 3006 | |
| 3007 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hh_s1: |
| 3008 | ID = Intrinsic::hexagon_M2_mpyud_acc_hh_s1; break; |
| 3009 | |
| 3010 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hl_s0: |
| 3011 | ID = Intrinsic::hexagon_M2_mpyud_acc_hl_s0; break; |
| 3012 | |
| 3013 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_hl_s1: |
| 3014 | ID = Intrinsic::hexagon_M2_mpyud_acc_hl_s1; break; |
| 3015 | |
| 3016 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_lh_s0: |
| 3017 | ID = Intrinsic::hexagon_M2_mpyud_acc_lh_s0; break; |
| 3018 | |
| 3019 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_lh_s1: |
| 3020 | ID = Intrinsic::hexagon_M2_mpyud_acc_lh_s1; break; |
| 3021 | |
| 3022 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_ll_s0: |
| 3023 | ID = Intrinsic::hexagon_M2_mpyud_acc_ll_s0; break; |
| 3024 | |
| 3025 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_acc_ll_s1: |
| 3026 | ID = Intrinsic::hexagon_M2_mpyud_acc_ll_s1; break; |
| 3027 | |
| 3028 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hh_s0: |
| 3029 | ID = Intrinsic::hexagon_M2_mpyud_nac_hh_s0; break; |
| 3030 | |
| 3031 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hh_s1: |
| 3032 | ID = Intrinsic::hexagon_M2_mpyud_nac_hh_s1; break; |
| 3033 | |
| 3034 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hl_s0: |
| 3035 | ID = Intrinsic::hexagon_M2_mpyud_nac_hl_s0; break; |
| 3036 | |
| 3037 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_hl_s1: |
| 3038 | ID = Intrinsic::hexagon_M2_mpyud_nac_hl_s1; break; |
| 3039 | |
| 3040 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_lh_s0: |
| 3041 | ID = Intrinsic::hexagon_M2_mpyud_nac_lh_s0; break; |
| 3042 | |
| 3043 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_lh_s1: |
| 3044 | ID = Intrinsic::hexagon_M2_mpyud_nac_lh_s1; break; |
| 3045 | |
| 3046 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_ll_s0: |
| 3047 | ID = Intrinsic::hexagon_M2_mpyud_nac_ll_s0; break; |
| 3048 | |
| 3049 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_nac_ll_s1: |
| 3050 | ID = Intrinsic::hexagon_M2_mpyud_nac_ll_s1; break; |
| 3051 | |
| 3052 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hh_s0: |
| 3053 | ID = Intrinsic::hexagon_M2_mpyud_hh_s0; break; |
| 3054 | |
| 3055 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hh_s1: |
| 3056 | ID = Intrinsic::hexagon_M2_mpyud_hh_s1; break; |
| 3057 | |
| 3058 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hl_s0: |
| 3059 | ID = Intrinsic::hexagon_M2_mpyud_hl_s0; break; |
| 3060 | |
| 3061 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_hl_s1: |
| 3062 | ID = Intrinsic::hexagon_M2_mpyud_hl_s1; break; |
| 3063 | |
| 3064 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_lh_s0: |
| 3065 | ID = Intrinsic::hexagon_M2_mpyud_lh_s0; break; |
| 3066 | |
| 3067 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_lh_s1: |
| 3068 | ID = Intrinsic::hexagon_M2_mpyud_lh_s1; break; |
| 3069 | |
| 3070 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_ll_s0: |
| 3071 | ID = Intrinsic::hexagon_M2_mpyud_ll_s0; break; |
| 3072 | |
| 3073 | case Hexagon::BI__builtin_HEXAGON_M2_mpyud_ll_s1: |
| 3074 | ID = Intrinsic::hexagon_M2_mpyud_ll_s1; break; |
| 3075 | |
| 3076 | case Hexagon::BI__builtin_HEXAGON_M2_mpysmi: |
| 3077 | ID = Intrinsic::hexagon_M2_mpysmi; break; |
| 3078 | |
| 3079 | case Hexagon::BI__builtin_HEXAGON_M2_macsip: |
| 3080 | ID = Intrinsic::hexagon_M2_macsip; break; |
| 3081 | |
| 3082 | case Hexagon::BI__builtin_HEXAGON_M2_macsin: |
| 3083 | ID = Intrinsic::hexagon_M2_macsin; break; |
| 3084 | |
| 3085 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_s0: |
| 3086 | ID = Intrinsic::hexagon_M2_dpmpyss_s0; break; |
| 3087 | |
| 3088 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_acc_s0: |
| 3089 | ID = Intrinsic::hexagon_M2_dpmpyss_acc_s0; break; |
| 3090 | |
| 3091 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_nac_s0: |
| 3092 | ID = Intrinsic::hexagon_M2_dpmpyss_nac_s0; break; |
| 3093 | |
| 3094 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyuu_s0: |
| 3095 | ID = Intrinsic::hexagon_M2_dpmpyuu_s0; break; |
| 3096 | |
| 3097 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyuu_acc_s0: |
| 3098 | ID = Intrinsic::hexagon_M2_dpmpyuu_acc_s0; break; |
| 3099 | |
| 3100 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyuu_nac_s0: |
| 3101 | ID = Intrinsic::hexagon_M2_dpmpyuu_nac_s0; break; |
| 3102 | |
| 3103 | case Hexagon::BI__builtin_HEXAGON_M2_mpy_up: |
| 3104 | ID = Intrinsic::hexagon_M2_mpy_up; break; |
| 3105 | |
| 3106 | case Hexagon::BI__builtin_HEXAGON_M2_mpyu_up: |
| 3107 | ID = Intrinsic::hexagon_M2_mpyu_up; break; |
| 3108 | |
| 3109 | case Hexagon::BI__builtin_HEXAGON_M2_dpmpyss_rnd_s0: |
| 3110 | ID = Intrinsic::hexagon_M2_dpmpyss_rnd_s0; break; |
| 3111 | |
| 3112 | case Hexagon::BI__builtin_HEXAGON_M2_mpyi: |
| 3113 | ID = Intrinsic::hexagon_M2_mpyi; break; |
| 3114 | |
| 3115 | case Hexagon::BI__builtin_HEXAGON_M2_mpyui: |
| 3116 | ID = Intrinsic::hexagon_M2_mpyui; break; |
| 3117 | |
| 3118 | case Hexagon::BI__builtin_HEXAGON_M2_maci: |
| 3119 | ID = Intrinsic::hexagon_M2_maci; break; |
| 3120 | |
| 3121 | case Hexagon::BI__builtin_HEXAGON_M2_acci: |
| 3122 | ID = Intrinsic::hexagon_M2_acci; break; |
| 3123 | |
| 3124 | case Hexagon::BI__builtin_HEXAGON_M2_accii: |
| 3125 | ID = Intrinsic::hexagon_M2_accii; break; |
| 3126 | |
| 3127 | case Hexagon::BI__builtin_HEXAGON_M2_nacci: |
| 3128 | ID = Intrinsic::hexagon_M2_nacci; break; |
| 3129 | |
| 3130 | case Hexagon::BI__builtin_HEXAGON_M2_naccii: |
| 3131 | ID = Intrinsic::hexagon_M2_naccii; break; |
| 3132 | |
| 3133 | case Hexagon::BI__builtin_HEXAGON_M2_subacc: |
| 3134 | ID = Intrinsic::hexagon_M2_subacc; break; |
| 3135 | |
| 3136 | case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s0: |
| 3137 | ID = Intrinsic::hexagon_M2_vmpy2s_s0; break; |
| 3138 | |
| 3139 | case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s1: |
| 3140 | ID = Intrinsic::hexagon_M2_vmpy2s_s1; break; |
| 3141 | |
| 3142 | case Hexagon::BI__builtin_HEXAGON_M2_vmac2s_s0: |
| 3143 | ID = Intrinsic::hexagon_M2_vmac2s_s0; break; |
| 3144 | |
| 3145 | case Hexagon::BI__builtin_HEXAGON_M2_vmac2s_s1: |
| 3146 | ID = Intrinsic::hexagon_M2_vmac2s_s1; break; |
| 3147 | |
| 3148 | case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s0pack: |
| 3149 | ID = Intrinsic::hexagon_M2_vmpy2s_s0pack; break; |
| 3150 | |
| 3151 | case Hexagon::BI__builtin_HEXAGON_M2_vmpy2s_s1pack: |
| 3152 | ID = Intrinsic::hexagon_M2_vmpy2s_s1pack; break; |
| 3153 | |
| 3154 | case Hexagon::BI__builtin_HEXAGON_M2_vmac2: |
| 3155 | ID = Intrinsic::hexagon_M2_vmac2; break; |
| 3156 | |
| 3157 | case Hexagon::BI__builtin_HEXAGON_M2_vmpy2es_s0: |
| 3158 | ID = Intrinsic::hexagon_M2_vmpy2es_s0; break; |
| 3159 | |
| 3160 | case Hexagon::BI__builtin_HEXAGON_M2_vmpy2es_s1: |
| 3161 | ID = Intrinsic::hexagon_M2_vmpy2es_s1; break; |
| 3162 | |
| 3163 | case Hexagon::BI__builtin_HEXAGON_M2_vmac2es_s0: |
| 3164 | ID = Intrinsic::hexagon_M2_vmac2es_s0; break; |
| 3165 | |
| 3166 | case Hexagon::BI__builtin_HEXAGON_M2_vmac2es_s1: |
| 3167 | ID = Intrinsic::hexagon_M2_vmac2es_s1; break; |
| 3168 | |
| 3169 | case Hexagon::BI__builtin_HEXAGON_M2_vmac2es: |
| 3170 | ID = Intrinsic::hexagon_M2_vmac2es; break; |
| 3171 | |
| 3172 | case Hexagon::BI__builtin_HEXAGON_M2_vrmac_s0: |
| 3173 | ID = Intrinsic::hexagon_M2_vrmac_s0; break; |
| 3174 | |
| 3175 | case Hexagon::BI__builtin_HEXAGON_M2_vrmpy_s0: |
| 3176 | ID = Intrinsic::hexagon_M2_vrmpy_s0; break; |
| 3177 | |
| 3178 | case Hexagon::BI__builtin_HEXAGON_M2_vdmpyrs_s0: |
| 3179 | ID = Intrinsic::hexagon_M2_vdmpyrs_s0; break; |
| 3180 | |
| 3181 | case Hexagon::BI__builtin_HEXAGON_M2_vdmpyrs_s1: |
| 3182 | ID = Intrinsic::hexagon_M2_vdmpyrs_s1; break; |
| 3183 | |
| 3184 | case Hexagon::BI__builtin_HEXAGON_M2_vdmacs_s0: |
| 3185 | ID = Intrinsic::hexagon_M2_vdmacs_s0; break; |
| 3186 | |
| 3187 | case Hexagon::BI__builtin_HEXAGON_M2_vdmacs_s1: |
| 3188 | ID = Intrinsic::hexagon_M2_vdmacs_s1; break; |
| 3189 | |
| 3190 | case Hexagon::BI__builtin_HEXAGON_M2_vdmpys_s0: |
| 3191 | ID = Intrinsic::hexagon_M2_vdmpys_s0; break; |
| 3192 | |
| 3193 | case Hexagon::BI__builtin_HEXAGON_M2_vdmpys_s1: |
| 3194 | ID = Intrinsic::hexagon_M2_vdmpys_s1; break; |
| 3195 | |
| 3196 | case Hexagon::BI__builtin_HEXAGON_M2_cmpyrs_s0: |
| 3197 | ID = Intrinsic::hexagon_M2_cmpyrs_s0; break; |
| 3198 | |
| 3199 | case Hexagon::BI__builtin_HEXAGON_M2_cmpyrs_s1: |
| 3200 | ID = Intrinsic::hexagon_M2_cmpyrs_s1; break; |
| 3201 | |
| 3202 | case Hexagon::BI__builtin_HEXAGON_M2_cmpyrsc_s0: |
| 3203 | ID = Intrinsic::hexagon_M2_cmpyrsc_s0; break; |
| 3204 | |
| 3205 | case Hexagon::BI__builtin_HEXAGON_M2_cmpyrsc_s1: |
| 3206 | ID = Intrinsic::hexagon_M2_cmpyrsc_s1; break; |
| 3207 | |
| 3208 | case Hexagon::BI__builtin_HEXAGON_M2_cmacs_s0: |
| 3209 | ID = Intrinsic::hexagon_M2_cmacs_s0; break; |
| 3210 | |
| 3211 | case Hexagon::BI__builtin_HEXAGON_M2_cmacs_s1: |
| 3212 | ID = Intrinsic::hexagon_M2_cmacs_s1; break; |
| 3213 | |
| 3214 | case Hexagon::BI__builtin_HEXAGON_M2_cmacsc_s0: |
| 3215 | ID = Intrinsic::hexagon_M2_cmacsc_s0; break; |
| 3216 | |
| 3217 | case Hexagon::BI__builtin_HEXAGON_M2_cmacsc_s1: |
| 3218 | ID = Intrinsic::hexagon_M2_cmacsc_s1; break; |
| 3219 | |
| 3220 | case Hexagon::BI__builtin_HEXAGON_M2_cmpys_s0: |
| 3221 | ID = Intrinsic::hexagon_M2_cmpys_s0; break; |
| 3222 | |
| 3223 | case Hexagon::BI__builtin_HEXAGON_M2_cmpys_s1: |
| 3224 | ID = Intrinsic::hexagon_M2_cmpys_s1; break; |
| 3225 | |
| 3226 | case Hexagon::BI__builtin_HEXAGON_M2_cmpysc_s0: |
| 3227 | ID = Intrinsic::hexagon_M2_cmpysc_s0; break; |
| 3228 | |
| 3229 | case Hexagon::BI__builtin_HEXAGON_M2_cmpysc_s1: |
| 3230 | ID = Intrinsic::hexagon_M2_cmpysc_s1; break; |
| 3231 | |
| 3232 | case Hexagon::BI__builtin_HEXAGON_M2_cnacs_s0: |
| 3233 | ID = Intrinsic::hexagon_M2_cnacs_s0; break; |
| 3234 | |
| 3235 | case Hexagon::BI__builtin_HEXAGON_M2_cnacs_s1: |
| 3236 | ID = Intrinsic::hexagon_M2_cnacs_s1; break; |
| 3237 | |
| 3238 | case Hexagon::BI__builtin_HEXAGON_M2_cnacsc_s0: |
| 3239 | ID = Intrinsic::hexagon_M2_cnacsc_s0; break; |
| 3240 | |
| 3241 | case Hexagon::BI__builtin_HEXAGON_M2_cnacsc_s1: |
| 3242 | ID = Intrinsic::hexagon_M2_cnacsc_s1; break; |
| 3243 | |
| 3244 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpys_s1: |
| 3245 | ID = Intrinsic::hexagon_M2_vrcmpys_s1; break; |
| 3246 | |
| 3247 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpys_acc_s1: |
| 3248 | ID = Intrinsic::hexagon_M2_vrcmpys_acc_s1; break; |
| 3249 | |
| 3250 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpys_s1rp: |
| 3251 | ID = Intrinsic::hexagon_M2_vrcmpys_s1rp; break; |
| 3252 | |
| 3253 | case Hexagon::BI__builtin_HEXAGON_M2_mmacls_s0: |
| 3254 | ID = Intrinsic::hexagon_M2_mmacls_s0; break; |
| 3255 | |
| 3256 | case Hexagon::BI__builtin_HEXAGON_M2_mmacls_s1: |
| 3257 | ID = Intrinsic::hexagon_M2_mmacls_s1; break; |
| 3258 | |
| 3259 | case Hexagon::BI__builtin_HEXAGON_M2_mmachs_s0: |
| 3260 | ID = Intrinsic::hexagon_M2_mmachs_s0; break; |
| 3261 | |
| 3262 | case Hexagon::BI__builtin_HEXAGON_M2_mmachs_s1: |
| 3263 | ID = Intrinsic::hexagon_M2_mmachs_s1; break; |
| 3264 | |
| 3265 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_s0: |
| 3266 | ID = Intrinsic::hexagon_M2_mmpyl_s0; break; |
| 3267 | |
| 3268 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_s1: |
| 3269 | ID = Intrinsic::hexagon_M2_mmpyl_s1; break; |
| 3270 | |
| 3271 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_s0: |
| 3272 | ID = Intrinsic::hexagon_M2_mmpyh_s0; break; |
| 3273 | |
| 3274 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_s1: |
| 3275 | ID = Intrinsic::hexagon_M2_mmpyh_s1; break; |
| 3276 | |
| 3277 | case Hexagon::BI__builtin_HEXAGON_M2_mmacls_rs0: |
| 3278 | ID = Intrinsic::hexagon_M2_mmacls_rs0; break; |
| 3279 | |
| 3280 | case Hexagon::BI__builtin_HEXAGON_M2_mmacls_rs1: |
| 3281 | ID = Intrinsic::hexagon_M2_mmacls_rs1; break; |
| 3282 | |
| 3283 | case Hexagon::BI__builtin_HEXAGON_M2_mmachs_rs0: |
| 3284 | ID = Intrinsic::hexagon_M2_mmachs_rs0; break; |
| 3285 | |
| 3286 | case Hexagon::BI__builtin_HEXAGON_M2_mmachs_rs1: |
| 3287 | ID = Intrinsic::hexagon_M2_mmachs_rs1; break; |
| 3288 | |
| 3289 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_rs0: |
| 3290 | ID = Intrinsic::hexagon_M2_mmpyl_rs0; break; |
| 3291 | |
| 3292 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyl_rs1: |
| 3293 | ID = Intrinsic::hexagon_M2_mmpyl_rs1; break; |
| 3294 | |
| 3295 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_rs0: |
| 3296 | ID = Intrinsic::hexagon_M2_mmpyh_rs0; break; |
| 3297 | |
| 3298 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyh_rs1: |
| 3299 | ID = Intrinsic::hexagon_M2_mmpyh_rs1; break; |
| 3300 | |
| 3301 | case Hexagon::BI__builtin_HEXAGON_M2_hmmpyl_rs1: |
| 3302 | ID = Intrinsic::hexagon_M2_hmmpyl_rs1; break; |
| 3303 | |
| 3304 | case Hexagon::BI__builtin_HEXAGON_M2_hmmpyh_rs1: |
| 3305 | ID = Intrinsic::hexagon_M2_hmmpyh_rs1; break; |
| 3306 | |
| 3307 | case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_s0: |
| 3308 | ID = Intrinsic::hexagon_M2_mmaculs_s0; break; |
| 3309 | |
| 3310 | case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_s1: |
| 3311 | ID = Intrinsic::hexagon_M2_mmaculs_s1; break; |
| 3312 | |
| 3313 | case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_s0: |
| 3314 | ID = Intrinsic::hexagon_M2_mmacuhs_s0; break; |
| 3315 | |
| 3316 | case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_s1: |
| 3317 | ID = Intrinsic::hexagon_M2_mmacuhs_s1; break; |
| 3318 | |
| 3319 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_s0: |
| 3320 | ID = Intrinsic::hexagon_M2_mmpyul_s0; break; |
| 3321 | |
| 3322 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_s1: |
| 3323 | ID = Intrinsic::hexagon_M2_mmpyul_s1; break; |
| 3324 | |
| 3325 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_s0: |
| 3326 | ID = Intrinsic::hexagon_M2_mmpyuh_s0; break; |
| 3327 | |
| 3328 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_s1: |
| 3329 | ID = Intrinsic::hexagon_M2_mmpyuh_s1; break; |
| 3330 | |
| 3331 | case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_rs0: |
| 3332 | ID = Intrinsic::hexagon_M2_mmaculs_rs0; break; |
| 3333 | |
| 3334 | case Hexagon::BI__builtin_HEXAGON_M2_mmaculs_rs1: |
| 3335 | ID = Intrinsic::hexagon_M2_mmaculs_rs1; break; |
| 3336 | |
| 3337 | case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_rs0: |
| 3338 | ID = Intrinsic::hexagon_M2_mmacuhs_rs0; break; |
| 3339 | |
| 3340 | case Hexagon::BI__builtin_HEXAGON_M2_mmacuhs_rs1: |
| 3341 | ID = Intrinsic::hexagon_M2_mmacuhs_rs1; break; |
| 3342 | |
| 3343 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_rs0: |
| 3344 | ID = Intrinsic::hexagon_M2_mmpyul_rs0; break; |
| 3345 | |
| 3346 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyul_rs1: |
| 3347 | ID = Intrinsic::hexagon_M2_mmpyul_rs1; break; |
| 3348 | |
| 3349 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_rs0: |
| 3350 | ID = Intrinsic::hexagon_M2_mmpyuh_rs0; break; |
| 3351 | |
| 3352 | case Hexagon::BI__builtin_HEXAGON_M2_mmpyuh_rs1: |
| 3353 | ID = Intrinsic::hexagon_M2_mmpyuh_rs1; break; |
| 3354 | |
| 3355 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmaci_s0: |
| 3356 | ID = Intrinsic::hexagon_M2_vrcmaci_s0; break; |
| 3357 | |
| 3358 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmacr_s0: |
| 3359 | ID = Intrinsic::hexagon_M2_vrcmacr_s0; break; |
| 3360 | |
| 3361 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmaci_s0c: |
| 3362 | ID = Intrinsic::hexagon_M2_vrcmaci_s0c; break; |
| 3363 | |
| 3364 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmacr_s0c: |
| 3365 | ID = Intrinsic::hexagon_M2_vrcmacr_s0c; break; |
| 3366 | |
| 3367 | case Hexagon::BI__builtin_HEXAGON_M2_cmaci_s0: |
| 3368 | ID = Intrinsic::hexagon_M2_cmaci_s0; break; |
| 3369 | |
| 3370 | case Hexagon::BI__builtin_HEXAGON_M2_cmacr_s0: |
| 3371 | ID = Intrinsic::hexagon_M2_cmacr_s0; break; |
| 3372 | |
| 3373 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyi_s0: |
| 3374 | ID = Intrinsic::hexagon_M2_vrcmpyi_s0; break; |
| 3375 | |
| 3376 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyr_s0: |
| 3377 | ID = Intrinsic::hexagon_M2_vrcmpyr_s0; break; |
| 3378 | |
| 3379 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyi_s0c: |
| 3380 | ID = Intrinsic::hexagon_M2_vrcmpyi_s0c; break; |
| 3381 | |
| 3382 | case Hexagon::BI__builtin_HEXAGON_M2_vrcmpyr_s0c: |
| 3383 | ID = Intrinsic::hexagon_M2_vrcmpyr_s0c; break; |
| 3384 | |
| 3385 | case Hexagon::BI__builtin_HEXAGON_M2_cmpyi_s0: |
| 3386 | ID = Intrinsic::hexagon_M2_cmpyi_s0; break; |
| 3387 | |
| 3388 | case Hexagon::BI__builtin_HEXAGON_M2_cmpyr_s0: |
| 3389 | ID = Intrinsic::hexagon_M2_cmpyr_s0; break; |
| 3390 | |
| 3391 | case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s0_sat_i: |
| 3392 | ID = Intrinsic::hexagon_M2_vcmpy_s0_sat_i; break; |
| 3393 | |
| 3394 | case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s0_sat_r: |
| 3395 | ID = Intrinsic::hexagon_M2_vcmpy_s0_sat_r; break; |
| 3396 | |
| 3397 | case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s1_sat_i: |
| 3398 | ID = Intrinsic::hexagon_M2_vcmpy_s1_sat_i; break; |
| 3399 | |
| 3400 | case Hexagon::BI__builtin_HEXAGON_M2_vcmpy_s1_sat_r: |
| 3401 | ID = Intrinsic::hexagon_M2_vcmpy_s1_sat_r; break; |
| 3402 | |
| 3403 | case Hexagon::BI__builtin_HEXAGON_M2_vcmac_s0_sat_i: |
| 3404 | ID = Intrinsic::hexagon_M2_vcmac_s0_sat_i; break; |
| 3405 | |
| 3406 | case Hexagon::BI__builtin_HEXAGON_M2_vcmac_s0_sat_r: |
| 3407 | ID = Intrinsic::hexagon_M2_vcmac_s0_sat_r; break; |
| 3408 | |
| 3409 | case Hexagon::BI__builtin_HEXAGON_S2_vcrotate: |
| 3410 | ID = Intrinsic::hexagon_S2_vcrotate; break; |
| 3411 | |
| 3412 | case Hexagon::BI__builtin_HEXAGON_A2_add: |
| 3413 | ID = Intrinsic::hexagon_A2_add; break; |
| 3414 | |
| 3415 | case Hexagon::BI__builtin_HEXAGON_A2_sub: |
| 3416 | ID = Intrinsic::hexagon_A2_sub; break; |
| 3417 | |
| 3418 | case Hexagon::BI__builtin_HEXAGON_A2_addsat: |
| 3419 | ID = Intrinsic::hexagon_A2_addsat; break; |
| 3420 | |
| 3421 | case Hexagon::BI__builtin_HEXAGON_A2_subsat: |
| 3422 | ID = Intrinsic::hexagon_A2_subsat; break; |
| 3423 | |
| 3424 | case Hexagon::BI__builtin_HEXAGON_A2_addi: |
| 3425 | ID = Intrinsic::hexagon_A2_addi; break; |
| 3426 | |
| 3427 | case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_ll: |
| 3428 | ID = Intrinsic::hexagon_A2_addh_l16_ll; break; |
| 3429 | |
| 3430 | case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_hl: |
| 3431 | ID = Intrinsic::hexagon_A2_addh_l16_hl; break; |
| 3432 | |
| 3433 | case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_sat_ll: |
| 3434 | ID = Intrinsic::hexagon_A2_addh_l16_sat_ll; break; |
| 3435 | |
| 3436 | case Hexagon::BI__builtin_HEXAGON_A2_addh_l16_sat_hl: |
| 3437 | ID = Intrinsic::hexagon_A2_addh_l16_sat_hl; break; |
| 3438 | |
| 3439 | case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_ll: |
| 3440 | ID = Intrinsic::hexagon_A2_subh_l16_ll; break; |
| 3441 | |
| 3442 | case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_hl: |
| 3443 | ID = Intrinsic::hexagon_A2_subh_l16_hl; break; |
| 3444 | |
| 3445 | case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_sat_ll: |
| 3446 | ID = Intrinsic::hexagon_A2_subh_l16_sat_ll; break; |
| 3447 | |
| 3448 | case Hexagon::BI__builtin_HEXAGON_A2_subh_l16_sat_hl: |
| 3449 | ID = Intrinsic::hexagon_A2_subh_l16_sat_hl; break; |
| 3450 | |
| 3451 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_ll: |
| 3452 | ID = Intrinsic::hexagon_A2_addh_h16_ll; break; |
| 3453 | |
| 3454 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_lh: |
| 3455 | ID = Intrinsic::hexagon_A2_addh_h16_lh; break; |
| 3456 | |
| 3457 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_hl: |
| 3458 | ID = Intrinsic::hexagon_A2_addh_h16_hl; break; |
| 3459 | |
| 3460 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_hh: |
| 3461 | ID = Intrinsic::hexagon_A2_addh_h16_hh; break; |
| 3462 | |
| 3463 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_ll: |
| 3464 | ID = Intrinsic::hexagon_A2_addh_h16_sat_ll; break; |
| 3465 | |
| 3466 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_lh: |
| 3467 | ID = Intrinsic::hexagon_A2_addh_h16_sat_lh; break; |
| 3468 | |
| 3469 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_hl: |
| 3470 | ID = Intrinsic::hexagon_A2_addh_h16_sat_hl; break; |
| 3471 | |
| 3472 | case Hexagon::BI__builtin_HEXAGON_A2_addh_h16_sat_hh: |
| 3473 | ID = Intrinsic::hexagon_A2_addh_h16_sat_hh; break; |
| 3474 | |
| 3475 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_ll: |
| 3476 | ID = Intrinsic::hexagon_A2_subh_h16_ll; break; |
| 3477 | |
| 3478 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_lh: |
| 3479 | ID = Intrinsic::hexagon_A2_subh_h16_lh; break; |
| 3480 | |
| 3481 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_hl: |
| 3482 | ID = Intrinsic::hexagon_A2_subh_h16_hl; break; |
| 3483 | |
| 3484 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_hh: |
| 3485 | ID = Intrinsic::hexagon_A2_subh_h16_hh; break; |
| 3486 | |
| 3487 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_ll: |
| 3488 | ID = Intrinsic::hexagon_A2_subh_h16_sat_ll; break; |
| 3489 | |
| 3490 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_lh: |
| 3491 | ID = Intrinsic::hexagon_A2_subh_h16_sat_lh; break; |
| 3492 | |
| 3493 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_hl: |
| 3494 | ID = Intrinsic::hexagon_A2_subh_h16_sat_hl; break; |
| 3495 | |
| 3496 | case Hexagon::BI__builtin_HEXAGON_A2_subh_h16_sat_hh: |
| 3497 | ID = Intrinsic::hexagon_A2_subh_h16_sat_hh; break; |
| 3498 | |
| 3499 | case Hexagon::BI__builtin_HEXAGON_A2_aslh: |
| 3500 | ID = Intrinsic::hexagon_A2_aslh; break; |
| 3501 | |
| 3502 | case Hexagon::BI__builtin_HEXAGON_A2_asrh: |
| 3503 | ID = Intrinsic::hexagon_A2_asrh; break; |
| 3504 | |
| 3505 | case Hexagon::BI__builtin_HEXAGON_A2_addp: |
| 3506 | ID = Intrinsic::hexagon_A2_addp; break; |
| 3507 | |
| 3508 | case Hexagon::BI__builtin_HEXAGON_A2_addpsat: |
| 3509 | ID = Intrinsic::hexagon_A2_addpsat; break; |
| 3510 | |
| 3511 | case Hexagon::BI__builtin_HEXAGON_A2_addsp: |
| 3512 | ID = Intrinsic::hexagon_A2_addsp; break; |
| 3513 | |
| 3514 | case Hexagon::BI__builtin_HEXAGON_A2_subp: |
| 3515 | ID = Intrinsic::hexagon_A2_subp; break; |
| 3516 | |
| 3517 | case Hexagon::BI__builtin_HEXAGON_A2_neg: |
| 3518 | ID = Intrinsic::hexagon_A2_neg; break; |
| 3519 | |
| 3520 | case Hexagon::BI__builtin_HEXAGON_A2_negsat: |
| 3521 | ID = Intrinsic::hexagon_A2_negsat; break; |
| 3522 | |
| 3523 | case Hexagon::BI__builtin_HEXAGON_A2_abs: |
| 3524 | ID = Intrinsic::hexagon_A2_abs; break; |
| 3525 | |
| 3526 | case Hexagon::BI__builtin_HEXAGON_A2_abssat: |
| 3527 | ID = Intrinsic::hexagon_A2_abssat; break; |
| 3528 | |
| 3529 | case Hexagon::BI__builtin_HEXAGON_A2_vconj: |
| 3530 | ID = Intrinsic::hexagon_A2_vconj; break; |
| 3531 | |
| 3532 | case Hexagon::BI__builtin_HEXAGON_A2_negp: |
| 3533 | ID = Intrinsic::hexagon_A2_negp; break; |
| 3534 | |
| 3535 | case Hexagon::BI__builtin_HEXAGON_A2_absp: |
| 3536 | ID = Intrinsic::hexagon_A2_absp; break; |
| 3537 | |
| 3538 | case Hexagon::BI__builtin_HEXAGON_A2_max: |
| 3539 | ID = Intrinsic::hexagon_A2_max; break; |
| 3540 | |
| 3541 | case Hexagon::BI__builtin_HEXAGON_A2_maxu: |
| 3542 | ID = Intrinsic::hexagon_A2_maxu; break; |
| 3543 | |
| 3544 | case Hexagon::BI__builtin_HEXAGON_A2_min: |
| 3545 | ID = Intrinsic::hexagon_A2_min; break; |
| 3546 | |
| 3547 | case Hexagon::BI__builtin_HEXAGON_A2_minu: |
| 3548 | ID = Intrinsic::hexagon_A2_minu; break; |
| 3549 | |
| 3550 | case Hexagon::BI__builtin_HEXAGON_A2_maxp: |
| 3551 | ID = Intrinsic::hexagon_A2_maxp; break; |
| 3552 | |
| 3553 | case Hexagon::BI__builtin_HEXAGON_A2_maxup: |
| 3554 | ID = Intrinsic::hexagon_A2_maxup; break; |
| 3555 | |
| 3556 | case Hexagon::BI__builtin_HEXAGON_A2_minp: |
| 3557 | ID = Intrinsic::hexagon_A2_minp; break; |
| 3558 | |
| 3559 | case Hexagon::BI__builtin_HEXAGON_A2_minup: |
| 3560 | ID = Intrinsic::hexagon_A2_minup; break; |
| 3561 | |
| 3562 | case Hexagon::BI__builtin_HEXAGON_A2_tfr: |
| 3563 | ID = Intrinsic::hexagon_A2_tfr; break; |
| 3564 | |
| 3565 | case Hexagon::BI__builtin_HEXAGON_A2_tfrsi: |
| 3566 | ID = Intrinsic::hexagon_A2_tfrsi; break; |
| 3567 | |
| 3568 | case Hexagon::BI__builtin_HEXAGON_A2_tfrp: |
| 3569 | ID = Intrinsic::hexagon_A2_tfrp; break; |
| 3570 | |
| 3571 | case Hexagon::BI__builtin_HEXAGON_A2_tfrpi: |
| 3572 | ID = Intrinsic::hexagon_A2_tfrpi; break; |
| 3573 | |
| 3574 | case Hexagon::BI__builtin_HEXAGON_A2_zxtb: |
| 3575 | ID = Intrinsic::hexagon_A2_zxtb; break; |
| 3576 | |
| 3577 | case Hexagon::BI__builtin_HEXAGON_A2_sxtb: |
| 3578 | ID = Intrinsic::hexagon_A2_sxtb; break; |
| 3579 | |
| 3580 | case Hexagon::BI__builtin_HEXAGON_A2_zxth: |
| 3581 | ID = Intrinsic::hexagon_A2_zxth; break; |
| 3582 | |
| 3583 | case Hexagon::BI__builtin_HEXAGON_A2_sxth: |
| 3584 | ID = Intrinsic::hexagon_A2_sxth; break; |
| 3585 | |
| 3586 | case Hexagon::BI__builtin_HEXAGON_A2_combinew: |
| 3587 | ID = Intrinsic::hexagon_A2_combinew; break; |
| 3588 | |
| 3589 | case Hexagon::BI__builtin_HEXAGON_A2_combineii: |
| 3590 | ID = Intrinsic::hexagon_A2_combineii; break; |
| 3591 | |
| 3592 | case Hexagon::BI__builtin_HEXAGON_A2_combine_hh: |
| 3593 | ID = Intrinsic::hexagon_A2_combine_hh; break; |
| 3594 | |
| 3595 | case Hexagon::BI__builtin_HEXAGON_A2_combine_hl: |
| 3596 | ID = Intrinsic::hexagon_A2_combine_hl; break; |
| 3597 | |
| 3598 | case Hexagon::BI__builtin_HEXAGON_A2_combine_lh: |
| 3599 | ID = Intrinsic::hexagon_A2_combine_lh; break; |
| 3600 | |
| 3601 | case Hexagon::BI__builtin_HEXAGON_A2_combine_ll: |
| 3602 | ID = Intrinsic::hexagon_A2_combine_ll; break; |
| 3603 | |
| 3604 | case Hexagon::BI__builtin_HEXAGON_A2_tfril: |
| 3605 | ID = Intrinsic::hexagon_A2_tfril; break; |
| 3606 | |
| 3607 | case Hexagon::BI__builtin_HEXAGON_A2_tfrih: |
| 3608 | ID = Intrinsic::hexagon_A2_tfrih; break; |
| 3609 | |
| 3610 | case Hexagon::BI__builtin_HEXAGON_A2_and: |
| 3611 | ID = Intrinsic::hexagon_A2_and; break; |
| 3612 | |
| 3613 | case Hexagon::BI__builtin_HEXAGON_A2_or: |
| 3614 | ID = Intrinsic::hexagon_A2_or; break; |
| 3615 | |
| 3616 | case Hexagon::BI__builtin_HEXAGON_A2_xor: |
| 3617 | ID = Intrinsic::hexagon_A2_xor; break; |
| 3618 | |
| 3619 | case Hexagon::BI__builtin_HEXAGON_A2_not: |
| 3620 | ID = Intrinsic::hexagon_A2_not; break; |
| 3621 | |
| 3622 | case Hexagon::BI__builtin_HEXAGON_M2_xor_xacc: |
| 3623 | ID = Intrinsic::hexagon_M2_xor_xacc; break; |
| 3624 | |
| 3625 | case Hexagon::BI__builtin_HEXAGON_A2_subri: |
| 3626 | ID = Intrinsic::hexagon_A2_subri; break; |
| 3627 | |
| 3628 | case Hexagon::BI__builtin_HEXAGON_A2_andir: |
| 3629 | ID = Intrinsic::hexagon_A2_andir; break; |
| 3630 | |
| 3631 | case Hexagon::BI__builtin_HEXAGON_A2_orir: |
| 3632 | ID = Intrinsic::hexagon_A2_orir; break; |
| 3633 | |
| 3634 | case Hexagon::BI__builtin_HEXAGON_A2_andp: |
| 3635 | ID = Intrinsic::hexagon_A2_andp; break; |
| 3636 | |
| 3637 | case Hexagon::BI__builtin_HEXAGON_A2_orp: |
| 3638 | ID = Intrinsic::hexagon_A2_orp; break; |
| 3639 | |
| 3640 | case Hexagon::BI__builtin_HEXAGON_A2_xorp: |
| 3641 | ID = Intrinsic::hexagon_A2_xorp; break; |
| 3642 | |
| 3643 | case Hexagon::BI__builtin_HEXAGON_A2_notp: |
| 3644 | ID = Intrinsic::hexagon_A2_notp; break; |
| 3645 | |
| 3646 | case Hexagon::BI__builtin_HEXAGON_A2_sxtw: |
| 3647 | ID = Intrinsic::hexagon_A2_sxtw; break; |
| 3648 | |
| 3649 | case Hexagon::BI__builtin_HEXAGON_A2_sat: |
| 3650 | ID = Intrinsic::hexagon_A2_sat; break; |
| 3651 | |
| 3652 | case Hexagon::BI__builtin_HEXAGON_A2_sath: |
| 3653 | ID = Intrinsic::hexagon_A2_sath; break; |
| 3654 | |
| 3655 | case Hexagon::BI__builtin_HEXAGON_A2_satuh: |
| 3656 | ID = Intrinsic::hexagon_A2_satuh; break; |
| 3657 | |
| 3658 | case Hexagon::BI__builtin_HEXAGON_A2_satub: |
| 3659 | ID = Intrinsic::hexagon_A2_satub; break; |
| 3660 | |
| 3661 | case Hexagon::BI__builtin_HEXAGON_A2_satb: |
| 3662 | ID = Intrinsic::hexagon_A2_satb; break; |
| 3663 | |
| 3664 | case Hexagon::BI__builtin_HEXAGON_A2_vaddub: |
| 3665 | ID = Intrinsic::hexagon_A2_vaddub; break; |
| 3666 | |
| 3667 | case Hexagon::BI__builtin_HEXAGON_A2_vaddubs: |
| 3668 | ID = Intrinsic::hexagon_A2_vaddubs; break; |
| 3669 | |
| 3670 | case Hexagon::BI__builtin_HEXAGON_A2_vaddh: |
| 3671 | ID = Intrinsic::hexagon_A2_vaddh; break; |
| 3672 | |
| 3673 | case Hexagon::BI__builtin_HEXAGON_A2_vaddhs: |
| 3674 | ID = Intrinsic::hexagon_A2_vaddhs; break; |
| 3675 | |
| 3676 | case Hexagon::BI__builtin_HEXAGON_A2_vadduhs: |
| 3677 | ID = Intrinsic::hexagon_A2_vadduhs; break; |
| 3678 | |
| 3679 | case Hexagon::BI__builtin_HEXAGON_A2_vaddw: |
| 3680 | ID = Intrinsic::hexagon_A2_vaddw; break; |
| 3681 | |
| 3682 | case Hexagon::BI__builtin_HEXAGON_A2_vaddws: |
| 3683 | ID = Intrinsic::hexagon_A2_vaddws; break; |
| 3684 | |
| 3685 | case Hexagon::BI__builtin_HEXAGON_A2_svavgh: |
| 3686 | ID = Intrinsic::hexagon_A2_svavgh; break; |
| 3687 | |
| 3688 | case Hexagon::BI__builtin_HEXAGON_A2_svavghs: |
| 3689 | ID = Intrinsic::hexagon_A2_svavghs; break; |
| 3690 | |
| 3691 | case Hexagon::BI__builtin_HEXAGON_A2_svnavgh: |
| 3692 | ID = Intrinsic::hexagon_A2_svnavgh; break; |
| 3693 | |
| 3694 | case Hexagon::BI__builtin_HEXAGON_A2_svaddh: |
| 3695 | ID = Intrinsic::hexagon_A2_svaddh; break; |
| 3696 | |
| 3697 | case Hexagon::BI__builtin_HEXAGON_A2_svaddhs: |
| 3698 | ID = Intrinsic::hexagon_A2_svaddhs; break; |
| 3699 | |
| 3700 | case Hexagon::BI__builtin_HEXAGON_A2_svadduhs: |
| 3701 | ID = Intrinsic::hexagon_A2_svadduhs; break; |
| 3702 | |
| 3703 | case Hexagon::BI__builtin_HEXAGON_A2_svsubh: |
| 3704 | ID = Intrinsic::hexagon_A2_svsubh; break; |
| 3705 | |
| 3706 | case Hexagon::BI__builtin_HEXAGON_A2_svsubhs: |
| 3707 | ID = Intrinsic::hexagon_A2_svsubhs; break; |
| 3708 | |
| 3709 | case Hexagon::BI__builtin_HEXAGON_A2_svsubuhs: |
| 3710 | ID = Intrinsic::hexagon_A2_svsubuhs; break; |
| 3711 | |
| 3712 | case Hexagon::BI__builtin_HEXAGON_A2_vraddub: |
| 3713 | ID = Intrinsic::hexagon_A2_vraddub; break; |
| 3714 | |
| 3715 | case Hexagon::BI__builtin_HEXAGON_A2_vraddub_acc: |
| 3716 | ID = Intrinsic::hexagon_A2_vraddub_acc; break; |
| 3717 | |
| 3718 | case Hexagon::BI__builtin_HEXAGON_M2_vradduh: |
| 3719 | ID = Intrinsic::hexagon_M2_vradduh; break; |
| 3720 | |
| 3721 | case Hexagon::BI__builtin_HEXAGON_A2_vsubub: |
| 3722 | ID = Intrinsic::hexagon_A2_vsubub; break; |
| 3723 | |
| 3724 | case Hexagon::BI__builtin_HEXAGON_A2_vsububs: |
| 3725 | ID = Intrinsic::hexagon_A2_vsububs; break; |
| 3726 | |
| 3727 | case Hexagon::BI__builtin_HEXAGON_A2_vsubh: |
| 3728 | ID = Intrinsic::hexagon_A2_vsubh; break; |
| 3729 | |
| 3730 | case Hexagon::BI__builtin_HEXAGON_A2_vsubhs: |
| 3731 | ID = Intrinsic::hexagon_A2_vsubhs; break; |
| 3732 | |
| 3733 | case Hexagon::BI__builtin_HEXAGON_A2_vsubuhs: |
| 3734 | ID = Intrinsic::hexagon_A2_vsubuhs; break; |
| 3735 | |
| 3736 | case Hexagon::BI__builtin_HEXAGON_A2_vsubw: |
| 3737 | ID = Intrinsic::hexagon_A2_vsubw; break; |
| 3738 | |
| 3739 | case Hexagon::BI__builtin_HEXAGON_A2_vsubws: |
| 3740 | ID = Intrinsic::hexagon_A2_vsubws; break; |
| 3741 | |
| 3742 | case Hexagon::BI__builtin_HEXAGON_A2_vabsh: |
| 3743 | ID = Intrinsic::hexagon_A2_vabsh; break; |
| 3744 | |
| 3745 | case Hexagon::BI__builtin_HEXAGON_A2_vabshsat: |
| 3746 | ID = Intrinsic::hexagon_A2_vabshsat; break; |
| 3747 | |
| 3748 | case Hexagon::BI__builtin_HEXAGON_A2_vabsw: |
| 3749 | ID = Intrinsic::hexagon_A2_vabsw; break; |
| 3750 | |
| 3751 | case Hexagon::BI__builtin_HEXAGON_A2_vabswsat: |
| 3752 | ID = Intrinsic::hexagon_A2_vabswsat; break; |
| 3753 | |
| 3754 | case Hexagon::BI__builtin_HEXAGON_M2_vabsdiffw: |
| 3755 | ID = Intrinsic::hexagon_M2_vabsdiffw; break; |
| 3756 | |
| 3757 | case Hexagon::BI__builtin_HEXAGON_M2_vabsdiffh: |
| 3758 | ID = Intrinsic::hexagon_M2_vabsdiffh; break; |
| 3759 | |
| 3760 | case Hexagon::BI__builtin_HEXAGON_A2_vrsadub: |
| 3761 | ID = Intrinsic::hexagon_A2_vrsadub; break; |
| 3762 | |
| 3763 | case Hexagon::BI__builtin_HEXAGON_A2_vrsadub_acc: |
| 3764 | ID = Intrinsic::hexagon_A2_vrsadub_acc; break; |
| 3765 | |
| 3766 | case Hexagon::BI__builtin_HEXAGON_A2_vavgub: |
| 3767 | ID = Intrinsic::hexagon_A2_vavgub; break; |
| 3768 | |
| 3769 | case Hexagon::BI__builtin_HEXAGON_A2_vavguh: |
| 3770 | ID = Intrinsic::hexagon_A2_vavguh; break; |
| 3771 | |
| 3772 | case Hexagon::BI__builtin_HEXAGON_A2_vavgh: |
| 3773 | ID = Intrinsic::hexagon_A2_vavgh; break; |
| 3774 | |
| 3775 | case Hexagon::BI__builtin_HEXAGON_A2_vnavgh: |
| 3776 | ID = Intrinsic::hexagon_A2_vnavgh; break; |
| 3777 | |
| 3778 | case Hexagon::BI__builtin_HEXAGON_A2_vavgw: |
| 3779 | ID = Intrinsic::hexagon_A2_vavgw; break; |
| 3780 | |
| 3781 | case Hexagon::BI__builtin_HEXAGON_A2_vnavgw: |
| 3782 | ID = Intrinsic::hexagon_A2_vnavgw; break; |
| 3783 | |
| 3784 | case Hexagon::BI__builtin_HEXAGON_A2_vavgwr: |
| 3785 | ID = Intrinsic::hexagon_A2_vavgwr; break; |
| 3786 | |
| 3787 | case Hexagon::BI__builtin_HEXAGON_A2_vnavgwr: |
| 3788 | ID = Intrinsic::hexagon_A2_vnavgwr; break; |
| 3789 | |
| 3790 | case Hexagon::BI__builtin_HEXAGON_A2_vavgwcr: |
| 3791 | ID = Intrinsic::hexagon_A2_vavgwcr; break; |
| 3792 | |
| 3793 | case Hexagon::BI__builtin_HEXAGON_A2_vnavgwcr: |
| 3794 | ID = Intrinsic::hexagon_A2_vnavgwcr; break; |
| 3795 | |
| 3796 | case Hexagon::BI__builtin_HEXAGON_A2_vavghcr: |
| 3797 | ID = Intrinsic::hexagon_A2_vavghcr; break; |
| 3798 | |
| 3799 | case Hexagon::BI__builtin_HEXAGON_A2_vnavghcr: |
| 3800 | ID = Intrinsic::hexagon_A2_vnavghcr; break; |
| 3801 | |
| 3802 | case Hexagon::BI__builtin_HEXAGON_A2_vavguw: |
| 3803 | ID = Intrinsic::hexagon_A2_vavguw; break; |
| 3804 | |
| 3805 | case Hexagon::BI__builtin_HEXAGON_A2_vavguwr: |
| 3806 | ID = Intrinsic::hexagon_A2_vavguwr; break; |
| 3807 | |
| 3808 | case Hexagon::BI__builtin_HEXAGON_A2_vavgubr: |
| 3809 | ID = Intrinsic::hexagon_A2_vavgubr; break; |
| 3810 | |
| 3811 | case Hexagon::BI__builtin_HEXAGON_A2_vavguhr: |
| 3812 | ID = Intrinsic::hexagon_A2_vavguhr; break; |
| 3813 | |
| 3814 | case Hexagon::BI__builtin_HEXAGON_A2_vavghr: |
| 3815 | ID = Intrinsic::hexagon_A2_vavghr; break; |
| 3816 | |
| 3817 | case Hexagon::BI__builtin_HEXAGON_A2_vnavghr: |
| 3818 | ID = Intrinsic::hexagon_A2_vnavghr; break; |
| 3819 | |
| 3820 | case Hexagon::BI__builtin_HEXAGON_A2_vminh: |
| 3821 | ID = Intrinsic::hexagon_A2_vminh; break; |
| 3822 | |
| 3823 | case Hexagon::BI__builtin_HEXAGON_A2_vmaxh: |
| 3824 | ID = Intrinsic::hexagon_A2_vmaxh; break; |
| 3825 | |
| 3826 | case Hexagon::BI__builtin_HEXAGON_A2_vminub: |
| 3827 | ID = Intrinsic::hexagon_A2_vminub; break; |
| 3828 | |
| 3829 | case Hexagon::BI__builtin_HEXAGON_A2_vmaxub: |
| 3830 | ID = Intrinsic::hexagon_A2_vmaxub; break; |
| 3831 | |
| 3832 | case Hexagon::BI__builtin_HEXAGON_A2_vminuh: |
| 3833 | ID = Intrinsic::hexagon_A2_vminuh; break; |
| 3834 | |
| 3835 | case Hexagon::BI__builtin_HEXAGON_A2_vmaxuh: |
| 3836 | ID = Intrinsic::hexagon_A2_vmaxuh; break; |
| 3837 | |
| 3838 | case Hexagon::BI__builtin_HEXAGON_A2_vminw: |
| 3839 | ID = Intrinsic::hexagon_A2_vminw; break; |
| 3840 | |
| 3841 | case Hexagon::BI__builtin_HEXAGON_A2_vmaxw: |
| 3842 | ID = Intrinsic::hexagon_A2_vmaxw; break; |
| 3843 | |
| 3844 | case Hexagon::BI__builtin_HEXAGON_A2_vminuw: |
| 3845 | ID = Intrinsic::hexagon_A2_vminuw; break; |
| 3846 | |
| 3847 | case Hexagon::BI__builtin_HEXAGON_A2_vmaxuw: |
| 3848 | ID = Intrinsic::hexagon_A2_vmaxuw; break; |
| 3849 | |
| 3850 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r: |
| 3851 | ID = Intrinsic::hexagon_S2_asr_r_r; break; |
| 3852 | |
| 3853 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r: |
| 3854 | ID = Intrinsic::hexagon_S2_asl_r_r; break; |
| 3855 | |
| 3856 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r: |
| 3857 | ID = Intrinsic::hexagon_S2_lsr_r_r; break; |
| 3858 | |
| 3859 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r: |
| 3860 | ID = Intrinsic::hexagon_S2_lsl_r_r; break; |
| 3861 | |
| 3862 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p: |
| 3863 | ID = Intrinsic::hexagon_S2_asr_r_p; break; |
| 3864 | |
| 3865 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p: |
| 3866 | ID = Intrinsic::hexagon_S2_asl_r_p; break; |
| 3867 | |
| 3868 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p: |
| 3869 | ID = Intrinsic::hexagon_S2_lsr_r_p; break; |
| 3870 | |
| 3871 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p: |
| 3872 | ID = Intrinsic::hexagon_S2_lsl_r_p; break; |
| 3873 | |
| 3874 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_acc: |
| 3875 | ID = Intrinsic::hexagon_S2_asr_r_r_acc; break; |
| 3876 | |
| 3877 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_acc: |
| 3878 | ID = Intrinsic::hexagon_S2_asl_r_r_acc; break; |
| 3879 | |
| 3880 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_acc: |
| 3881 | ID = Intrinsic::hexagon_S2_lsr_r_r_acc; break; |
| 3882 | |
| 3883 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_acc: |
| 3884 | ID = Intrinsic::hexagon_S2_lsl_r_r_acc; break; |
| 3885 | |
| 3886 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_acc: |
| 3887 | ID = Intrinsic::hexagon_S2_asr_r_p_acc; break; |
| 3888 | |
| 3889 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_acc: |
| 3890 | ID = Intrinsic::hexagon_S2_asl_r_p_acc; break; |
| 3891 | |
| 3892 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_acc: |
| 3893 | ID = Intrinsic::hexagon_S2_lsr_r_p_acc; break; |
| 3894 | |
| 3895 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_acc: |
| 3896 | ID = Intrinsic::hexagon_S2_lsl_r_p_acc; break; |
| 3897 | |
| 3898 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_nac: |
| 3899 | ID = Intrinsic::hexagon_S2_asr_r_r_nac; break; |
| 3900 | |
| 3901 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_nac: |
| 3902 | ID = Intrinsic::hexagon_S2_asl_r_r_nac; break; |
| 3903 | |
| 3904 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_nac: |
| 3905 | ID = Intrinsic::hexagon_S2_lsr_r_r_nac; break; |
| 3906 | |
| 3907 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_nac: |
| 3908 | ID = Intrinsic::hexagon_S2_lsl_r_r_nac; break; |
| 3909 | |
| 3910 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_nac: |
| 3911 | ID = Intrinsic::hexagon_S2_asr_r_p_nac; break; |
| 3912 | |
| 3913 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_nac: |
| 3914 | ID = Intrinsic::hexagon_S2_asl_r_p_nac; break; |
| 3915 | |
| 3916 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_nac: |
| 3917 | ID = Intrinsic::hexagon_S2_lsr_r_p_nac; break; |
| 3918 | |
| 3919 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_nac: |
| 3920 | ID = Intrinsic::hexagon_S2_lsl_r_p_nac; break; |
| 3921 | |
| 3922 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_and: |
| 3923 | ID = Intrinsic::hexagon_S2_asr_r_r_and; break; |
| 3924 | |
| 3925 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_and: |
| 3926 | ID = Intrinsic::hexagon_S2_asl_r_r_and; break; |
| 3927 | |
| 3928 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_and: |
| 3929 | ID = Intrinsic::hexagon_S2_lsr_r_r_and; break; |
| 3930 | |
| 3931 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_and: |
| 3932 | ID = Intrinsic::hexagon_S2_lsl_r_r_and; break; |
| 3933 | |
| 3934 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_or: |
| 3935 | ID = Intrinsic::hexagon_S2_asr_r_r_or; break; |
| 3936 | |
| 3937 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_or: |
| 3938 | ID = Intrinsic::hexagon_S2_asl_r_r_or; break; |
| 3939 | |
| 3940 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_r_or: |
| 3941 | ID = Intrinsic::hexagon_S2_lsr_r_r_or; break; |
| 3942 | |
| 3943 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_r_or: |
| 3944 | ID = Intrinsic::hexagon_S2_lsl_r_r_or; break; |
| 3945 | |
| 3946 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_and: |
| 3947 | ID = Intrinsic::hexagon_S2_asr_r_p_and; break; |
| 3948 | |
| 3949 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_and: |
| 3950 | ID = Intrinsic::hexagon_S2_asl_r_p_and; break; |
| 3951 | |
| 3952 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_and: |
| 3953 | ID = Intrinsic::hexagon_S2_lsr_r_p_and; break; |
| 3954 | |
| 3955 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_and: |
| 3956 | ID = Intrinsic::hexagon_S2_lsl_r_p_and; break; |
| 3957 | |
| 3958 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_p_or: |
| 3959 | ID = Intrinsic::hexagon_S2_asr_r_p_or; break; |
| 3960 | |
| 3961 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_p_or: |
| 3962 | ID = Intrinsic::hexagon_S2_asl_r_p_or; break; |
| 3963 | |
| 3964 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_p_or: |
| 3965 | ID = Intrinsic::hexagon_S2_lsr_r_p_or; break; |
| 3966 | |
| 3967 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_p_or: |
| 3968 | ID = Intrinsic::hexagon_S2_lsl_r_p_or; break; |
| 3969 | |
| 3970 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_r_sat: |
| 3971 | ID = Intrinsic::hexagon_S2_asr_r_r_sat; break; |
| 3972 | |
| 3973 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_r_sat: |
| 3974 | ID = Intrinsic::hexagon_S2_asl_r_r_sat; break; |
| 3975 | |
| 3976 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r: |
| 3977 | ID = Intrinsic::hexagon_S2_asr_i_r; break; |
| 3978 | |
| 3979 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r: |
| 3980 | ID = Intrinsic::hexagon_S2_lsr_i_r; break; |
| 3981 | |
| 3982 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r: |
| 3983 | ID = Intrinsic::hexagon_S2_asl_i_r; break; |
| 3984 | |
| 3985 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p: |
| 3986 | ID = Intrinsic::hexagon_S2_asr_i_p; break; |
| 3987 | |
| 3988 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p: |
| 3989 | ID = Intrinsic::hexagon_S2_lsr_i_p; break; |
| 3990 | |
| 3991 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p: |
| 3992 | ID = Intrinsic::hexagon_S2_asl_i_p; break; |
| 3993 | |
| 3994 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc: |
| 3995 | ID = Intrinsic::hexagon_S2_asr_i_r_acc; break; |
| 3996 | |
| 3997 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc: |
| 3998 | ID = Intrinsic::hexagon_S2_lsr_i_r_acc; break; |
| 3999 | |
| 4000 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc: |
| 4001 | ID = Intrinsic::hexagon_S2_asl_i_r_acc; break; |
| 4002 | |
| 4003 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc: |
| 4004 | ID = Intrinsic::hexagon_S2_asr_i_p_acc; break; |
| 4005 | |
| 4006 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc: |
| 4007 | ID = Intrinsic::hexagon_S2_lsr_i_p_acc; break; |
| 4008 | |
| 4009 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc: |
| 4010 | ID = Intrinsic::hexagon_S2_asl_i_p_acc; break; |
| 4011 | |
| 4012 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac: |
| 4013 | ID = Intrinsic::hexagon_S2_asr_i_r_nac; break; |
| 4014 | |
| 4015 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac: |
| 4016 | ID = Intrinsic::hexagon_S2_lsr_i_r_nac; break; |
| 4017 | |
| 4018 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac: |
| 4019 | ID = Intrinsic::hexagon_S2_asl_i_r_nac; break; |
| 4020 | |
| 4021 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac: |
| 4022 | ID = Intrinsic::hexagon_S2_asr_i_p_nac; break; |
| 4023 | |
| 4024 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac: |
| 4025 | ID = Intrinsic::hexagon_S2_lsr_i_p_nac; break; |
| 4026 | |
| 4027 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac: |
| 4028 | ID = Intrinsic::hexagon_S2_asl_i_p_nac; break; |
| 4029 | |
| 4030 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc: |
| 4031 | ID = Intrinsic::hexagon_S2_lsr_i_r_xacc; break; |
| 4032 | |
| 4033 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc: |
| 4034 | ID = Intrinsic::hexagon_S2_asl_i_r_xacc; break; |
| 4035 | |
| 4036 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc: |
| 4037 | ID = Intrinsic::hexagon_S2_lsr_i_p_xacc; break; |
| 4038 | |
| 4039 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc: |
| 4040 | ID = Intrinsic::hexagon_S2_asl_i_p_xacc; break; |
| 4041 | |
| 4042 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and: |
| 4043 | ID = Intrinsic::hexagon_S2_asr_i_r_and; break; |
| 4044 | |
| 4045 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and: |
| 4046 | ID = Intrinsic::hexagon_S2_lsr_i_r_and; break; |
| 4047 | |
| 4048 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and: |
| 4049 | ID = Intrinsic::hexagon_S2_asl_i_r_and; break; |
| 4050 | |
| 4051 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or: |
| 4052 | ID = Intrinsic::hexagon_S2_asr_i_r_or; break; |
| 4053 | |
| 4054 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or: |
| 4055 | ID = Intrinsic::hexagon_S2_lsr_i_r_or; break; |
| 4056 | |
| 4057 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or: |
| 4058 | ID = Intrinsic::hexagon_S2_asl_i_r_or; break; |
| 4059 | |
| 4060 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and: |
| 4061 | ID = Intrinsic::hexagon_S2_asr_i_p_and; break; |
| 4062 | |
| 4063 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and: |
| 4064 | ID = Intrinsic::hexagon_S2_lsr_i_p_and; break; |
| 4065 | |
| 4066 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and: |
| 4067 | ID = Intrinsic::hexagon_S2_asl_i_p_and; break; |
| 4068 | |
| 4069 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or: |
| 4070 | ID = Intrinsic::hexagon_S2_asr_i_p_or; break; |
| 4071 | |
| 4072 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or: |
| 4073 | ID = Intrinsic::hexagon_S2_lsr_i_p_or; break; |
| 4074 | |
| 4075 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or: |
| 4076 | ID = Intrinsic::hexagon_S2_asl_i_p_or; break; |
| 4077 | |
| 4078 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat: |
| 4079 | ID = Intrinsic::hexagon_S2_asl_i_r_sat; break; |
| 4080 | |
| 4081 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd: |
| 4082 | ID = Intrinsic::hexagon_S2_asr_i_r_rnd; break; |
| 4083 | |
| 4084 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax: |
| 4085 | ID = Intrinsic::hexagon_S2_asr_i_r_rnd_goodsyntax; break; |
| 4086 | |
| 4087 | case Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri: |
| 4088 | ID = Intrinsic::hexagon_S2_addasl_rrri; break; |
| 4089 | |
| 4090 | case Hexagon::BI__builtin_HEXAGON_S2_valignib: |
| 4091 | ID = Intrinsic::hexagon_S2_valignib; break; |
| 4092 | |
| 4093 | case Hexagon::BI__builtin_HEXAGON_S2_valignrb: |
| 4094 | ID = Intrinsic::hexagon_S2_valignrb; break; |
| 4095 | |
| 4096 | case Hexagon::BI__builtin_HEXAGON_S2_vspliceib: |
| 4097 | ID = Intrinsic::hexagon_S2_vspliceib; break; |
| 4098 | |
| 4099 | case Hexagon::BI__builtin_HEXAGON_S2_vsplicerb: |
| 4100 | ID = Intrinsic::hexagon_S2_vsplicerb; break; |
| 4101 | |
| 4102 | case Hexagon::BI__builtin_HEXAGON_S2_vsplatrh: |
| 4103 | ID = Intrinsic::hexagon_S2_vsplatrh; break; |
| 4104 | |
| 4105 | case Hexagon::BI__builtin_HEXAGON_S2_vsplatrb: |
| 4106 | ID = Intrinsic::hexagon_S2_vsplatrb; break; |
| 4107 | |
| 4108 | case Hexagon::BI__builtin_HEXAGON_S2_insert: |
| 4109 | ID = Intrinsic::hexagon_S2_insert; break; |
| 4110 | |
| 4111 | case Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax: |
| 4112 | ID = Intrinsic::hexagon_S2_tableidxb_goodsyntax; break; |
| 4113 | |
| 4114 | case Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax: |
| 4115 | ID = Intrinsic::hexagon_S2_tableidxh_goodsyntax; break; |
| 4116 | |
| 4117 | case Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax: |
| 4118 | ID = Intrinsic::hexagon_S2_tableidxw_goodsyntax; break; |
| 4119 | |
| 4120 | case Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax: |
| 4121 | ID = Intrinsic::hexagon_S2_tableidxd_goodsyntax; break; |
| 4122 | |
| 4123 | case Hexagon::BI__builtin_HEXAGON_S2_extractu: |
| 4124 | ID = Intrinsic::hexagon_S2_extractu; break; |
| 4125 | |
| 4126 | case Hexagon::BI__builtin_HEXAGON_S2_insertp: |
| 4127 | ID = Intrinsic::hexagon_S2_insertp; break; |
| 4128 | |
| 4129 | case Hexagon::BI__builtin_HEXAGON_S2_extractup: |
| 4130 | ID = Intrinsic::hexagon_S2_extractup; break; |
| 4131 | |
| 4132 | case Hexagon::BI__builtin_HEXAGON_S2_insert_rp: |
| 4133 | ID = Intrinsic::hexagon_S2_insert_rp; break; |
| 4134 | |
| 4135 | case Hexagon::BI__builtin_HEXAGON_S2_extractu_rp: |
| 4136 | ID = Intrinsic::hexagon_S2_extractu_rp; break; |
| 4137 | |
| 4138 | case Hexagon::BI__builtin_HEXAGON_S2_insertp_rp: |
| 4139 | ID = Intrinsic::hexagon_S2_insertp_rp; break; |
| 4140 | |
| 4141 | case Hexagon::BI__builtin_HEXAGON_S2_extractup_rp: |
| 4142 | ID = Intrinsic::hexagon_S2_extractup_rp; break; |
| 4143 | |
| 4144 | case Hexagon::BI__builtin_HEXAGON_S2_tstbit_i: |
| 4145 | ID = Intrinsic::hexagon_S2_tstbit_i; break; |
| 4146 | |
| 4147 | case Hexagon::BI__builtin_HEXAGON_S2_setbit_i: |
| 4148 | ID = Intrinsic::hexagon_S2_setbit_i; break; |
| 4149 | |
| 4150 | case Hexagon::BI__builtin_HEXAGON_S2_togglebit_i: |
| 4151 | ID = Intrinsic::hexagon_S2_togglebit_i; break; |
| 4152 | |
| 4153 | case Hexagon::BI__builtin_HEXAGON_S2_clrbit_i: |
| 4154 | ID = Intrinsic::hexagon_S2_clrbit_i; break; |
| 4155 | |
| 4156 | case Hexagon::BI__builtin_HEXAGON_S2_tstbit_r: |
| 4157 | ID = Intrinsic::hexagon_S2_tstbit_r; break; |
| 4158 | |
| 4159 | case Hexagon::BI__builtin_HEXAGON_S2_setbit_r: |
| 4160 | ID = Intrinsic::hexagon_S2_setbit_r; break; |
| 4161 | |
| 4162 | case Hexagon::BI__builtin_HEXAGON_S2_togglebit_r: |
| 4163 | ID = Intrinsic::hexagon_S2_togglebit_r; break; |
| 4164 | |
| 4165 | case Hexagon::BI__builtin_HEXAGON_S2_clrbit_r: |
| 4166 | ID = Intrinsic::hexagon_S2_clrbit_r; break; |
| 4167 | |
| 4168 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh: |
| 4169 | ID = Intrinsic::hexagon_S2_asr_i_vh; break; |
| 4170 | |
| 4171 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh: |
| 4172 | ID = Intrinsic::hexagon_S2_lsr_i_vh; break; |
| 4173 | |
| 4174 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh: |
| 4175 | ID = Intrinsic::hexagon_S2_asl_i_vh; break; |
| 4176 | |
| 4177 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_vh: |
| 4178 | ID = Intrinsic::hexagon_S2_asr_r_vh; break; |
| 4179 | |
| 4180 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_vh: |
| 4181 | ID = Intrinsic::hexagon_S2_asl_r_vh; break; |
| 4182 | |
| 4183 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_vh: |
| 4184 | ID = Intrinsic::hexagon_S2_lsr_r_vh; break; |
| 4185 | |
| 4186 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_vh: |
| 4187 | ID = Intrinsic::hexagon_S2_lsl_r_vh; break; |
| 4188 | |
| 4189 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw: |
| 4190 | ID = Intrinsic::hexagon_S2_asr_i_vw; break; |
| 4191 | |
| 4192 | case Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun: |
| 4193 | ID = Intrinsic::hexagon_S2_asr_i_svw_trun; break; |
| 4194 | |
| 4195 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_svw_trun: |
| 4196 | ID = Intrinsic::hexagon_S2_asr_r_svw_trun; break; |
| 4197 | |
| 4198 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw: |
| 4199 | ID = Intrinsic::hexagon_S2_lsr_i_vw; break; |
| 4200 | |
| 4201 | case Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw: |
| 4202 | ID = Intrinsic::hexagon_S2_asl_i_vw; break; |
| 4203 | |
| 4204 | case Hexagon::BI__builtin_HEXAGON_S2_asr_r_vw: |
| 4205 | ID = Intrinsic::hexagon_S2_asr_r_vw; break; |
| 4206 | |
| 4207 | case Hexagon::BI__builtin_HEXAGON_S2_asl_r_vw: |
| 4208 | ID = Intrinsic::hexagon_S2_asl_r_vw; break; |
| 4209 | |
| 4210 | case Hexagon::BI__builtin_HEXAGON_S2_lsr_r_vw: |
| 4211 | ID = Intrinsic::hexagon_S2_lsr_r_vw; break; |
| 4212 | |
| 4213 | case Hexagon::BI__builtin_HEXAGON_S2_lsl_r_vw: |
| 4214 | ID = Intrinsic::hexagon_S2_lsl_r_vw; break; |
| 4215 | |
| 4216 | case Hexagon::BI__builtin_HEXAGON_S2_vrndpackwh: |
| 4217 | ID = Intrinsic::hexagon_S2_vrndpackwh; break; |
| 4218 | |
| 4219 | case Hexagon::BI__builtin_HEXAGON_S2_vrndpackwhs: |
| 4220 | ID = Intrinsic::hexagon_S2_vrndpackwhs; break; |
| 4221 | |
| 4222 | case Hexagon::BI__builtin_HEXAGON_S2_vsxtbh: |
| 4223 | ID = Intrinsic::hexagon_S2_vsxtbh; break; |
| 4224 | |
| 4225 | case Hexagon::BI__builtin_HEXAGON_S2_vzxtbh: |
| 4226 | ID = Intrinsic::hexagon_S2_vzxtbh; break; |
| 4227 | |
| 4228 | case Hexagon::BI__builtin_HEXAGON_S2_vsathub: |
| 4229 | ID = Intrinsic::hexagon_S2_vsathub; break; |
| 4230 | |
| 4231 | case Hexagon::BI__builtin_HEXAGON_S2_svsathub: |
| 4232 | ID = Intrinsic::hexagon_S2_svsathub; break; |
| 4233 | |
| 4234 | case Hexagon::BI__builtin_HEXAGON_S2_svsathb: |
| 4235 | ID = Intrinsic::hexagon_S2_svsathb; break; |
| 4236 | |
| 4237 | case Hexagon::BI__builtin_HEXAGON_S2_vsathb: |
| 4238 | ID = Intrinsic::hexagon_S2_vsathb; break; |
| 4239 | |
| 4240 | case Hexagon::BI__builtin_HEXAGON_S2_vtrunohb: |
| 4241 | ID = Intrinsic::hexagon_S2_vtrunohb; break; |
| 4242 | |
| 4243 | case Hexagon::BI__builtin_HEXAGON_S2_vtrunewh: |
| 4244 | ID = Intrinsic::hexagon_S2_vtrunewh; break; |
| 4245 | |
| 4246 | case Hexagon::BI__builtin_HEXAGON_S2_vtrunowh: |
| 4247 | ID = Intrinsic::hexagon_S2_vtrunowh; break; |
| 4248 | |
| 4249 | case Hexagon::BI__builtin_HEXAGON_S2_vtrunehb: |
| 4250 | ID = Intrinsic::hexagon_S2_vtrunehb; break; |
| 4251 | |
| 4252 | case Hexagon::BI__builtin_HEXAGON_S2_vsxthw: |
| 4253 | ID = Intrinsic::hexagon_S2_vsxthw; break; |
| 4254 | |
| 4255 | case Hexagon::BI__builtin_HEXAGON_S2_vzxthw: |
| 4256 | ID = Intrinsic::hexagon_S2_vzxthw; break; |
| 4257 | |
| 4258 | case Hexagon::BI__builtin_HEXAGON_S2_vsatwh: |
| 4259 | ID = Intrinsic::hexagon_S2_vsatwh; break; |
| 4260 | |
| 4261 | case Hexagon::BI__builtin_HEXAGON_S2_vsatwuh: |
| 4262 | ID = Intrinsic::hexagon_S2_vsatwuh; break; |
| 4263 | |
| 4264 | case Hexagon::BI__builtin_HEXAGON_S2_packhl: |
| 4265 | ID = Intrinsic::hexagon_S2_packhl; break; |
| 4266 | |
| 4267 | case Hexagon::BI__builtin_HEXAGON_A2_swiz: |
| 4268 | ID = Intrinsic::hexagon_A2_swiz; break; |
| 4269 | |
| 4270 | case Hexagon::BI__builtin_HEXAGON_S2_vsathub_nopack: |
| 4271 | ID = Intrinsic::hexagon_S2_vsathub_nopack; break; |
| 4272 | |
| 4273 | case Hexagon::BI__builtin_HEXAGON_S2_vsathb_nopack: |
| 4274 | ID = Intrinsic::hexagon_S2_vsathb_nopack; break; |
| 4275 | |
| 4276 | case Hexagon::BI__builtin_HEXAGON_S2_vsatwh_nopack: |
| 4277 | ID = Intrinsic::hexagon_S2_vsatwh_nopack; break; |
| 4278 | |
| 4279 | case Hexagon::BI__builtin_HEXAGON_S2_vsatwuh_nopack: |
| 4280 | ID = Intrinsic::hexagon_S2_vsatwuh_nopack; break; |
| 4281 | |
| 4282 | case Hexagon::BI__builtin_HEXAGON_S2_shuffob: |
| 4283 | ID = Intrinsic::hexagon_S2_shuffob; break; |
| 4284 | |
| 4285 | case Hexagon::BI__builtin_HEXAGON_S2_shuffeb: |
| 4286 | ID = Intrinsic::hexagon_S2_shuffeb; break; |
| 4287 | |
| 4288 | case Hexagon::BI__builtin_HEXAGON_S2_shuffoh: |
| 4289 | ID = Intrinsic::hexagon_S2_shuffoh; break; |
| 4290 | |
| 4291 | case Hexagon::BI__builtin_HEXAGON_S2_shuffeh: |
| 4292 | ID = Intrinsic::hexagon_S2_shuffeh; break; |
| 4293 | |
| 4294 | case Hexagon::BI__builtin_HEXAGON_S2_parityp: |
| 4295 | ID = Intrinsic::hexagon_S2_parityp; break; |
| 4296 | |
| 4297 | case Hexagon::BI__builtin_HEXAGON_S2_lfsp: |
| 4298 | ID = Intrinsic::hexagon_S2_lfsp; break; |
| 4299 | |
| 4300 | case Hexagon::BI__builtin_HEXAGON_S2_clbnorm: |
| 4301 | ID = Intrinsic::hexagon_S2_clbnorm; break; |
| 4302 | |
| 4303 | case Hexagon::BI__builtin_HEXAGON_S2_clb: |
| 4304 | ID = Intrinsic::hexagon_S2_clb; break; |
| 4305 | |
| 4306 | case Hexagon::BI__builtin_HEXAGON_S2_cl0: |
| 4307 | ID = Intrinsic::hexagon_S2_cl0; break; |
| 4308 | |
| 4309 | case Hexagon::BI__builtin_HEXAGON_S2_cl1: |
| 4310 | ID = Intrinsic::hexagon_S2_cl1; break; |
| 4311 | |
| 4312 | case Hexagon::BI__builtin_HEXAGON_S2_clbp: |
| 4313 | ID = Intrinsic::hexagon_S2_clbp; break; |
| 4314 | |
| 4315 | case Hexagon::BI__builtin_HEXAGON_S2_cl0p: |
| 4316 | ID = Intrinsic::hexagon_S2_cl0p; break; |
| 4317 | |
| 4318 | case Hexagon::BI__builtin_HEXAGON_S2_cl1p: |
| 4319 | ID = Intrinsic::hexagon_S2_cl1p; break; |
| 4320 | |
| 4321 | case Hexagon::BI__builtin_HEXAGON_S2_brev: |
| 4322 | ID = Intrinsic::hexagon_S2_brev; break; |
| 4323 | |
| 4324 | case Hexagon::BI__builtin_HEXAGON_S2_ct0: |
| 4325 | ID = Intrinsic::hexagon_S2_ct0; break; |
| 4326 | |
| 4327 | case Hexagon::BI__builtin_HEXAGON_S2_ct1: |
| 4328 | ID = Intrinsic::hexagon_S2_ct1; break; |
| 4329 | |
| 4330 | case Hexagon::BI__builtin_HEXAGON_S2_interleave: |
| 4331 | ID = Intrinsic::hexagon_S2_interleave; break; |
| 4332 | |
| 4333 | case Hexagon::BI__builtin_HEXAGON_S2_deinterleave: |
| 4334 | ID = Intrinsic::hexagon_S2_deinterleave; break; |
| 4335 | |
| 4336 | case Hexagon::BI__builtin_SI_to_SXTHI_asrh: |
| 4337 | ID = Intrinsic::hexagon_SI_to_SXTHI_asrh; break; |
| 4338 | |
| 4339 | case Hexagon::BI__builtin_HEXAGON_A4_orn: |
| 4340 | ID = Intrinsic::hexagon_A4_orn; break; |
| 4341 | |
| 4342 | case Hexagon::BI__builtin_HEXAGON_A4_andn: |
| 4343 | ID = Intrinsic::hexagon_A4_andn; break; |
| 4344 | |
| 4345 | case Hexagon::BI__builtin_HEXAGON_A4_ornp: |
| 4346 | ID = Intrinsic::hexagon_A4_ornp; break; |
| 4347 | |
| 4348 | case Hexagon::BI__builtin_HEXAGON_A4_andnp: |
| 4349 | ID = Intrinsic::hexagon_A4_andnp; break; |
| 4350 | |
| 4351 | case Hexagon::BI__builtin_HEXAGON_A4_combineir: |
| 4352 | ID = Intrinsic::hexagon_A4_combineir; break; |
| 4353 | |
| 4354 | case Hexagon::BI__builtin_HEXAGON_A4_combineri: |
| 4355 | ID = Intrinsic::hexagon_A4_combineri; break; |
| 4356 | |
| 4357 | case Hexagon::BI__builtin_HEXAGON_C4_cmpneqi: |
| 4358 | ID = Intrinsic::hexagon_C4_cmpneqi; break; |
| 4359 | |
| 4360 | case Hexagon::BI__builtin_HEXAGON_C4_cmpneq: |
| 4361 | ID = Intrinsic::hexagon_C4_cmpneq; break; |
| 4362 | |
| 4363 | case Hexagon::BI__builtin_HEXAGON_C4_cmpltei: |
| 4364 | ID = Intrinsic::hexagon_C4_cmpltei; break; |
| 4365 | |
| 4366 | case Hexagon::BI__builtin_HEXAGON_C4_cmplte: |
| 4367 | ID = Intrinsic::hexagon_C4_cmplte; break; |
| 4368 | |
| 4369 | case Hexagon::BI__builtin_HEXAGON_C4_cmplteui: |
| 4370 | ID = Intrinsic::hexagon_C4_cmplteui; break; |
| 4371 | |
| 4372 | case Hexagon::BI__builtin_HEXAGON_C4_cmplteu: |
| 4373 | ID = Intrinsic::hexagon_C4_cmplteu; break; |
| 4374 | |
| 4375 | case Hexagon::BI__builtin_HEXAGON_A4_rcmpneq: |
| 4376 | ID = Intrinsic::hexagon_A4_rcmpneq; break; |
| 4377 | |
| 4378 | case Hexagon::BI__builtin_HEXAGON_A4_rcmpneqi: |
| 4379 | ID = Intrinsic::hexagon_A4_rcmpneqi; break; |
| 4380 | |
| 4381 | case Hexagon::BI__builtin_HEXAGON_A4_rcmpeq: |
| 4382 | ID = Intrinsic::hexagon_A4_rcmpeq; break; |
| 4383 | |
| 4384 | case Hexagon::BI__builtin_HEXAGON_A4_rcmpeqi: |
| 4385 | ID = Intrinsic::hexagon_A4_rcmpeqi; break; |
| 4386 | |
| 4387 | case Hexagon::BI__builtin_HEXAGON_C4_fastcorner9: |
| 4388 | ID = Intrinsic::hexagon_C4_fastcorner9; break; |
| 4389 | |
| 4390 | case Hexagon::BI__builtin_HEXAGON_C4_fastcorner9_not: |
| 4391 | ID = Intrinsic::hexagon_C4_fastcorner9_not; break; |
| 4392 | |
| 4393 | case Hexagon::BI__builtin_HEXAGON_C4_and_andn: |
| 4394 | ID = Intrinsic::hexagon_C4_and_andn; break; |
| 4395 | |
| 4396 | case Hexagon::BI__builtin_HEXAGON_C4_and_and: |
| 4397 | ID = Intrinsic::hexagon_C4_and_and; break; |
| 4398 | |
| 4399 | case Hexagon::BI__builtin_HEXAGON_C4_and_orn: |
| 4400 | ID = Intrinsic::hexagon_C4_and_orn; break; |
| 4401 | |
| 4402 | case Hexagon::BI__builtin_HEXAGON_C4_and_or: |
| 4403 | ID = Intrinsic::hexagon_C4_and_or; break; |
| 4404 | |
| 4405 | case Hexagon::BI__builtin_HEXAGON_C4_or_andn: |
| 4406 | ID = Intrinsic::hexagon_C4_or_andn; break; |
| 4407 | |
| 4408 | case Hexagon::BI__builtin_HEXAGON_C4_or_and: |
| 4409 | ID = Intrinsic::hexagon_C4_or_and; break; |
| 4410 | |
| 4411 | case Hexagon::BI__builtin_HEXAGON_C4_or_orn: |
| 4412 | ID = Intrinsic::hexagon_C4_or_orn; break; |
| 4413 | |
| 4414 | case Hexagon::BI__builtin_HEXAGON_C4_or_or: |
| 4415 | ID = Intrinsic::hexagon_C4_or_or; break; |
| 4416 | |
| 4417 | case Hexagon::BI__builtin_HEXAGON_S4_addaddi: |
| 4418 | ID = Intrinsic::hexagon_S4_addaddi; break; |
| 4419 | |
| 4420 | case Hexagon::BI__builtin_HEXAGON_S4_subaddi: |
| 4421 | ID = Intrinsic::hexagon_S4_subaddi; break; |
| 4422 | |
| 4423 | case Hexagon::BI__builtin_HEXAGON_M4_xor_xacc: |
| 4424 | ID = Intrinsic::hexagon_M4_xor_xacc; break; |
| 4425 | |
| 4426 | case Hexagon::BI__builtin_HEXAGON_M4_and_and: |
| 4427 | ID = Intrinsic::hexagon_M4_and_and; break; |
| 4428 | |
| 4429 | case Hexagon::BI__builtin_HEXAGON_M4_and_or: |
| 4430 | ID = Intrinsic::hexagon_M4_and_or; break; |
| 4431 | |
| 4432 | case Hexagon::BI__builtin_HEXAGON_M4_and_xor: |
| 4433 | ID = Intrinsic::hexagon_M4_and_xor; break; |
| 4434 | |
| 4435 | case Hexagon::BI__builtin_HEXAGON_M4_and_andn: |
| 4436 | ID = Intrinsic::hexagon_M4_and_andn; break; |
| 4437 | |
| 4438 | case Hexagon::BI__builtin_HEXAGON_M4_xor_and: |
| 4439 | ID = Intrinsic::hexagon_M4_xor_and; break; |
| 4440 | |
| 4441 | case Hexagon::BI__builtin_HEXAGON_M4_xor_or: |
| 4442 | ID = Intrinsic::hexagon_M4_xor_or; break; |
| 4443 | |
| 4444 | case Hexagon::BI__builtin_HEXAGON_M4_xor_andn: |
| 4445 | ID = Intrinsic::hexagon_M4_xor_andn; break; |
| 4446 | |
| 4447 | case Hexagon::BI__builtin_HEXAGON_M4_or_and: |
| 4448 | ID = Intrinsic::hexagon_M4_or_and; break; |
| 4449 | |
| 4450 | case Hexagon::BI__builtin_HEXAGON_M4_or_or: |
| 4451 | ID = Intrinsic::hexagon_M4_or_or; break; |
| 4452 | |
| 4453 | case Hexagon::BI__builtin_HEXAGON_M4_or_xor: |
| 4454 | ID = Intrinsic::hexagon_M4_or_xor; break; |
| 4455 | |
| 4456 | case Hexagon::BI__builtin_HEXAGON_M4_or_andn: |
| 4457 | ID = Intrinsic::hexagon_M4_or_andn; break; |
| 4458 | |
| 4459 | case Hexagon::BI__builtin_HEXAGON_S4_or_andix: |
| 4460 | ID = Intrinsic::hexagon_S4_or_andix; break; |
| 4461 | |
| 4462 | case Hexagon::BI__builtin_HEXAGON_S4_or_andi: |
| 4463 | ID = Intrinsic::hexagon_S4_or_andi; break; |
| 4464 | |
| 4465 | case Hexagon::BI__builtin_HEXAGON_S4_or_ori: |
| 4466 | ID = Intrinsic::hexagon_S4_or_ori; break; |
| 4467 | |
| 4468 | case Hexagon::BI__builtin_HEXAGON_A4_modwrapu: |
| 4469 | ID = Intrinsic::hexagon_A4_modwrapu; break; |
| 4470 | |
| 4471 | case Hexagon::BI__builtin_HEXAGON_A4_cround_rr: |
| 4472 | ID = Intrinsic::hexagon_A4_cround_rr; break; |
| 4473 | |
| 4474 | case Hexagon::BI__builtin_HEXAGON_A4_round_ri: |
| 4475 | ID = Intrinsic::hexagon_A4_round_ri; break; |
| 4476 | |
| 4477 | case Hexagon::BI__builtin_HEXAGON_A4_round_rr: |
| 4478 | ID = Intrinsic::hexagon_A4_round_rr; break; |
| 4479 | |
| 4480 | case Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat: |
| 4481 | ID = Intrinsic::hexagon_A4_round_ri_sat; break; |
| 4482 | |
| 4483 | case Hexagon::BI__builtin_HEXAGON_A4_round_rr_sat: |
| 4484 | ID = Intrinsic::hexagon_A4_round_rr_sat; break; |
| 4485 | |
| 4486 | } |
| 4487 | |
| 4488 | llvm::Function *F = CGM.getIntrinsic(ID); |
| 4489 | return Builder.CreateCall(F, Ops, ""); |
| 4490 | } |
| 4491 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 4492 | Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, |
Chris Lattner | 1feedd8 | 2007-12-13 07:34:23 +0000 | [diff] [blame] | 4493 | const CallExpr *E) { |
Chris Lattner | 5f9e272 | 2011-07-23 10:55:15 +0000 | [diff] [blame] | 4494 | SmallVector<Value*, 4> Ops; |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 4495 | |
| 4496 | for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) |
| 4497 | Ops.push_back(EmitScalarExpr(E->getArg(i))); |
| 4498 | |
| 4499 | Intrinsic::ID ID = Intrinsic::not_intrinsic; |
| 4500 | |
| 4501 | switch (BuiltinID) { |
| 4502 | default: return 0; |
| 4503 | |
Anton Korobeynikov | 4d3a7b0 | 2010-06-19 09:47:18 +0000 | [diff] [blame] | 4504 | // vec_ld, vec_lvsl, vec_lvsr |
| 4505 | case PPC::BI__builtin_altivec_lvx: |
| 4506 | case PPC::BI__builtin_altivec_lvxl: |
| 4507 | case PPC::BI__builtin_altivec_lvebx: |
| 4508 | case PPC::BI__builtin_altivec_lvehx: |
| 4509 | case PPC::BI__builtin_altivec_lvewx: |
| 4510 | case PPC::BI__builtin_altivec_lvsl: |
| 4511 | case PPC::BI__builtin_altivec_lvsr: |
| 4512 | { |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 4513 | Ops[1] = Builder.CreateBitCast(Ops[1], Int8PtrTy); |
Anton Korobeynikov | 4d3a7b0 | 2010-06-19 09:47:18 +0000 | [diff] [blame] | 4514 | |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 4515 | Ops[0] = Builder.CreateGEP(Ops[1], Ops[0]); |
Anton Korobeynikov | 4d3a7b0 | 2010-06-19 09:47:18 +0000 | [diff] [blame] | 4516 | Ops.pop_back(); |
| 4517 | |
| 4518 | switch (BuiltinID) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 4519 | default: llvm_unreachable("Unsupported ld/lvsl/lvsr intrinsic!"); |
Anton Korobeynikov | 4d3a7b0 | 2010-06-19 09:47:18 +0000 | [diff] [blame] | 4520 | case PPC::BI__builtin_altivec_lvx: |
| 4521 | ID = Intrinsic::ppc_altivec_lvx; |
| 4522 | break; |
| 4523 | case PPC::BI__builtin_altivec_lvxl: |
| 4524 | ID = Intrinsic::ppc_altivec_lvxl; |
| 4525 | break; |
| 4526 | case PPC::BI__builtin_altivec_lvebx: |
| 4527 | ID = Intrinsic::ppc_altivec_lvebx; |
| 4528 | break; |
| 4529 | case PPC::BI__builtin_altivec_lvehx: |
| 4530 | ID = Intrinsic::ppc_altivec_lvehx; |
| 4531 | break; |
| 4532 | case PPC::BI__builtin_altivec_lvewx: |
| 4533 | ID = Intrinsic::ppc_altivec_lvewx; |
| 4534 | break; |
| 4535 | case PPC::BI__builtin_altivec_lvsl: |
| 4536 | ID = Intrinsic::ppc_altivec_lvsl; |
| 4537 | break; |
| 4538 | case PPC::BI__builtin_altivec_lvsr: |
| 4539 | ID = Intrinsic::ppc_altivec_lvsr; |
| 4540 | break; |
| 4541 | } |
| 4542 | llvm::Function *F = CGM.getIntrinsic(ID); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 4543 | return Builder.CreateCall(F, Ops, ""); |
Anton Korobeynikov | 4d3a7b0 | 2010-06-19 09:47:18 +0000 | [diff] [blame] | 4544 | } |
| 4545 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 4546 | // vec_st |
| 4547 | case PPC::BI__builtin_altivec_stvx: |
| 4548 | case PPC::BI__builtin_altivec_stvxl: |
| 4549 | case PPC::BI__builtin_altivec_stvebx: |
| 4550 | case PPC::BI__builtin_altivec_stvehx: |
| 4551 | case PPC::BI__builtin_altivec_stvewx: |
| 4552 | { |
John McCall | d16c2cf | 2011-02-08 08:22:06 +0000 | [diff] [blame] | 4553 | Ops[2] = Builder.CreateBitCast(Ops[2], Int8PtrTy); |
Benjamin Kramer | 578faa8 | 2011-09-27 21:06:10 +0000 | [diff] [blame] | 4554 | Ops[1] = Builder.CreateGEP(Ops[2], Ops[1]); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 4555 | Ops.pop_back(); |
| 4556 | |
| 4557 | switch (BuiltinID) { |
David Blaikie | b219cfc | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 4558 | default: llvm_unreachable("Unsupported st intrinsic!"); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 4559 | case PPC::BI__builtin_altivec_stvx: |
| 4560 | ID = Intrinsic::ppc_altivec_stvx; |
| 4561 | break; |
| 4562 | case PPC::BI__builtin_altivec_stvxl: |
| 4563 | ID = Intrinsic::ppc_altivec_stvxl; |
| 4564 | break; |
| 4565 | case PPC::BI__builtin_altivec_stvebx: |
| 4566 | ID = Intrinsic::ppc_altivec_stvebx; |
| 4567 | break; |
| 4568 | case PPC::BI__builtin_altivec_stvehx: |
| 4569 | ID = Intrinsic::ppc_altivec_stvehx; |
| 4570 | break; |
| 4571 | case PPC::BI__builtin_altivec_stvewx: |
| 4572 | ID = Intrinsic::ppc_altivec_stvewx; |
| 4573 | break; |
| 4574 | } |
| 4575 | llvm::Function *F = CGM.getIntrinsic(ID); |
Jay Foad | 4c7d9f1 | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 4576 | return Builder.CreateCall(F, Ops, ""); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 4577 | } |
| 4578 | } |
Daniel Dunbar | b0b8438 | 2009-12-18 20:58:47 +0000 | [diff] [blame] | 4579 | return 0; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 4580 | } |