Home | History | Annotate | Download | only in CodeGen

Lines Matching full:cgf

62 static Value *EmitToInt(CodeGenFunction &CGF, llvm::Value *V,
64 V = CGF.EmitToMemory(V, T);
67 return CGF.Builder.CreatePtrToInt(V, IntType);
73 static Value *EmitFromInt(CodeGenFunction &CGF, llvm::Value *V,
75 V = CGF.EmitFromMemory(V, T);
78 return CGF.Builder.CreateIntToPtr(V, ResultType);
86 static Value *MakeBinaryAtomicValue(CodeGenFunction &CGF,
91 assert(CGF.getContext().hasSameUnqualifiedType(T,
93 assert(CGF.getContext().hasSameUnqualifiedType(T, E->getArg(1)->getType()));
95 llvm::Value *DestPtr = CGF.EmitScalarExpr(E->getArg(0));
99 llvm::IntegerType::get(CGF.getLLVMContext(),
100 CGF.getContext().getTypeSize(T));
104 Args[0] = CGF.Builder.CreateBitCast(DestPtr, IntPtrType);
105 Args[1] = CGF.EmitScalarExpr(E->getArg(1));
107 Args[1] = EmitToInt(CGF, Args[1], T, IntType);
109 llvm::Value *Result = CGF.Builder.CreateAtomicRMW(
111 return EmitFromInt(CGF, Result, T, ValueType);
114 static Value *EmitNontemporalStore(CodeGenFunction &CGF, const CallExpr *E) {
115 Value *Val = CGF.EmitScalarExpr(E->getArg(0));
116 Value *Address = CGF.EmitScalarExpr(E->getArg(1));
119 Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
120 Value *BC = CGF.Builder.CreateBitCast(
122 LValue LV = CGF.MakeNaturalAlignAddrLValue(BC, E->getArg(0)->getType());
124 CGF.EmitStoreOfScalar(Val, LV, false);
128 static Value *EmitNontemporalLoad(CodeGenFunction &CGF, const CallExpr *E) {
129 Value *Address = CGF.EmitScalarExpr(E->getArg(0));
131 LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getType());
133 return CGF.EmitLoadOfScalar(LV, E->getExprLoc());
136 static RValue EmitBinaryAtomic(CodeGenFunction &CGF,
139 return RValue::get(MakeBinaryAtomicValue(CGF, Kind, E));
145 static RValue EmitBinaryAtomicPost(CodeGenFunction &CGF,
152 assert(CGF.getContext().hasSameUnqualifiedType(T,
154 assert(CGF.getContext().hasSameUnqualifiedType(T, E->getArg(1)->getType()));
156 llvm::Value *DestPtr = CGF.EmitScalarExpr(E->getArg(0));
160 llvm::IntegerType::get(CGF.getLLVMContext(),
161 CGF.getContext().getTypeSize(T));
165 Args[1] = CGF.EmitScalarExpr(E->getArg(1));
167 Args[1] = EmitToInt(CGF, Args[1], T, IntType);
168 Args[0] = CGF.Builder.CreateBitCast(DestPtr, IntPtrType);
170 llvm::Value *Result = CGF.Builder.CreateAtomicRMW(
172 Result = CGF.Builder.CreateBinOp(Op, Result, Args[1]);
174 Result = CGF.Builder.CreateBinOp(llvm::Instruction::Xor, Result,
176 Result = EmitFromInt(CGF, Result, T, ValueType);
182 /// @param CGF The current codegen function.
191 static Value *MakeAtomicCmpXchgValue(CodeGenFunction &CGF, const CallExpr *E,
194 llvm::Value *DestPtr = CGF.EmitScalarExpr(E->getArg(0));
198 CGF.getLLVMContext(), CGF.getContext().getTypeSize(T));
202 Args[0] = CGF.Builder.CreateBitCast(DestPtr, IntPtrType);
203 Args[1] = CGF.EmitScalarExpr(E->getArg(1));
205 Args[1] = EmitToInt(CGF, Args[1], T, IntType);
206 Args[2] = EmitToInt(CGF, CGF.EmitScalarExpr(E->getArg(2)), T, IntType);
208 Value *Pair = CGF.Builder.CreateAtomicCmpXchg(
213 return CGF.Builder.CreateZExt(CGF.Builder.CreateExtractValue(Pair, 1),
214 CGF.ConvertType(E->getType()));
217 return EmitFromInt(CGF, CGF.Builder.CreateExtractValue(Pair, 0), T,
223 static Value *emitUnaryBuiltin(CodeGenFunction &CGF,
226 llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
228 Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
229 return CGF.Builder.CreateCall(F, Src0);
233 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
236 llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
237 llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
239 Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
240 return CGF.Builder.CreateCall(F, { Src0, Src1 });
244 static Value *emitTernaryBuiltin(CodeGenFunction &CGF,
247 llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
248 llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
249 llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
251 Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
252 return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
256 static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
259 llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
260 llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
262 Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
263 return CGF.Builder.CreateCall(F, {Src0, Src1});
267 static Value *EmitFAbs(CodeGenFunction &CGF, Value *V) {
268 Value *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
269 llvm::CallInst *Call = CGF.Builder.CreateCall(F, V);
276 static Value *EmitSignBit(CodeGenFunction &CGF, Value *V) {
277 LLVMContext &C = CGF.CGM.getLLVMContext();
282 V = CGF.Builder.CreateBitCast(V, IntTy);
292 if (CGF.getTarget().isBigEndian()) {
294 V = CGF.Builder.CreateLShr(V, ShiftCst);
299 V = CGF.Builder.CreateTrunc(V, IntTy);
302 return CGF.Builder.CreateICmpSLT(V, Zero);
305 static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *Fn,
307 return CGF.EmitCall(E->getCallee()->getType(), calleeValue, E,
314 /// \arg CGF The current codegen function.
320 static llvm::Value *EmitOverflowIntrinsic(CodeGenFunction &CGF,
329 llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, X->getType());
330 llvm::Value *Tmp = CGF.Builder.CreateCall(Callee, {X, Y});
331 Carry = CGF.Builder.CreateExtractValue(Tmp, 1);
332 return CGF.Builder.CreateExtractValue(Tmp, 0);
335 static Value *emitRangedBuiltin(CodeGenFunction &CGF,
338 llvm::MDBuilder MDHelper(CGF.getLLVMContext());
340 Value *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
341 llvm::Instruction *Call = CGF.Builder.CreateCall(F);
2475 static Value *EmitTargetArchBuiltinExpr(CodeGenFunction *CGF,
2483 return CGF->EmitARMBuiltinExpr(BuiltinID, E);
2486 return CGF->EmitAArch64BuiltinExpr(BuiltinID, E);
2489 return CGF->EmitX86BuiltinExpr(BuiltinID, E);
2493 return CGF->EmitPPCBuiltinExpr(BuiltinID, E);
2496 return CGF->EmitAMDGPUBuiltinExpr(BuiltinID, E);
2498 return CGF->EmitSystemZBuiltinExpr(BuiltinID, E);
2501 return CGF->EmitNVPTXBuiltinExpr(BuiltinID, E);
2504 return CGF->EmitWebAssemblyBuiltinExpr(BuiltinID, E);
2523 static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
2530 return llvm::VectorType::get(CGF->Int8Ty, V1Ty ? 1 : (8 << IsQuad));
2534 return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
2536 return llvm::VectorType::get(CGF->Int32Ty, V1Ty ? 1 : (2 << IsQuad));
2539 return llvm::VectorType::get(CGF->Int64Ty, V1Ty ? 1 : (1 << IsQuad));
2544 return llvm::VectorType::get(CGF->Int8Ty, 16);
2546 return llvm::VectorType::get(CGF->FloatTy, V1Ty ? 1 : (2 << IsQuad));
2548 return llvm::VectorType::get(CGF->DoubleTy, V1Ty ? 1 : (1 << IsQuad));
2553 static llvm::VectorType *GetFloatNeonType(CodeGenFunction *CGF,
2558 return llvm::VectorType::get(CGF->FloatTy, (2 << IsQuad));
2560 return llvm::VectorType::get(CGF->DoubleTy, (1 << IsQuad));
3271 static Value *EmitCommonNeonSISDBuiltinExpr(CodeGenFunction &CGF,
3304 llvm::Type *ArgTy = CGF.ConvertType(Arg->getType());
3305 Function *F = CGF.LookupNeonLLVMIntrinsic(Int, Modifier, ArgTy, E);
3308 ConstantInt *C0 = ConstantInt::get(CGF.SizeTy, 0);
3320 CGF.Builder.CreateTruncOrBitCast(Ops[j], ArgTy->getVectorElementType());
3322 CGF.Builder.CreateInsertElement(UndefValue::get(ArgTy), Ops[j], C0);
3325 Value *Result = CGF.EmitNeonCall(F, Ops, s);
3326 llvm::Type *ResultType = CGF.ConvertType(E->getType());
3329 return CGF.Builder.CreateExtractElement(Result, C0);
3331 return CGF.Builder.CreateBitCast(Result, ResultType, s);
3781 static Value *packTBLDVectorList(CodeGenFunction &CGF, ArrayRef<Value *> Ops,
3799 TblOps.push_back(CGF.Builder.CreateShuffleVector(Ops[PairPos],
3809 TblOps.push_back(CGF.Builder.CreateShuffleVector(Ops[PairPos],
3815 TblF = CGF.CGM.getIntrinsic(IntID, ResTy);
3817 return CGF.EmitNeonCall(TblF, TblOps, Name);
3857 static Value *EmitSpecialRegisterBuiltin(CodeGenFunction &CGF,
3867 CodeGen::CGBuilderTy &Builder = CGF.Builder;
3868 CodeGen::CodeGenModule &CGM = CGF.CGM;
3902 llvm::Value *ArgValue = CGF.EmitScalarExpr(E->getArg(1));
4628 static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID,
4670 if (!Arg->isIntegerConstantExpr(Result, CGF.getContext()))
4675 llvm::VectorType *Ty = GetNeonType(&CGF, Type);
4679 CodeGen::CGBuilderTy &Builder = CGF.Builder;
4685 return packTBLDVectorList(CGF, makeArrayRef(Ops).slice(0, 1), nullptr,
4690 return packTBLDVectorList(CGF, makeArrayRef(Ops).slice(0, 2), nullptr,
4695 return packTBLDVectorList(CGF, makeArrayRef(Ops).slice(0, 3), nullptr,
4700 return packTBLDVectorList(CGF, makeArrayRef(Ops).slice(0, 4), nullptr,
4706 packTBLDVectorList(CGF, makeArrayRef(Ops).slice(1, 1), nullptr, Ops[2],
4718 return packTBLDVectorList(CGF, makeArrayRef(Ops).slice(1, 2), Ops[0],
4724 packTBLDVectorList(CGF, makeArrayRef(Ops).slice(1, 3), nullptr, Ops[4],
4737 return packTBLDVectorList(CGF, makeArrayRef(Ops).slice(1, 4), Ops[0],
4771 Function *F = CGF.CGM.getIntrinsic(Int, Ty);
4772 return CGF.EmitNeonCall(F, Ops, s);
6567 static Value *getMaskVecValue(CodeGenFunction &CGF, Value *Mask,
6570 llvm::VectorType *MaskTy = llvm::VectorType::get(CGF.Builder.getInt1Ty(),
6572 Value *MaskVec = CGF.Builder.CreateBitCast(Mask, MaskTy);
6580 MaskVec = CGF.Builder.CreateShuffleVector(MaskVec, MaskVec,
6587 static Value *EmitX86MaskedStore(CodeGenFunction &CGF,
6591 Ops[0] = CGF.Builder.CreateBitCast(Ops[0],
6597 return CGF.Builder.CreateAlignedStore(Ops[1], Ops[0], Align);
6599 Value *MaskVec = getMaskVecValue(CGF, Ops[2],
6602 return CGF.Builder.CreateMaskedStore(Ops[1], Ops[0], Align, MaskVec);
6605 static Value *EmitX86MaskedLoad(CodeGenFunction &CGF,
6608 Ops[0] = CGF.Builder.CreateBitCast(Ops[0],
6614 return CGF.Builder.CreateAlignedLoad(Ops[0], Align);
6616 Value *MaskVec = getMaskVecValue(CGF, Ops[2],
6619 return CGF.Builder.CreateMaskedLoad(Ops[0], Align, MaskVec, Ops[1]);
6622 static Value *EmitX86Select(CodeGenFunction &CGF,
6630 Mask = getMaskVecValue(CGF, Mask, Op0->getType()->getVectorNumElements());
6632 return CGF.Builder.CreateSelect(Mask, Op0, Op1);
6635 static Value *EmitX86MaskedCompare(CodeGenFunction &CGF, unsigned CC,
6642 llvm::VectorType::get(CGF.Builder.getInt1Ty(), NumElts));
6645 llvm::VectorType::get(CGF.Builder.getInt1Ty(), NumElts));
6657 Cmp = CGF.Builder.CreateICmp(Pred, Ops[0], Ops[1]);
6662 Cmp = CGF.Builder.CreateAnd(Cmp, getMaskVecValue(CGF, Ops.back(), NumElts));
6670 Cmp = CGF.Builder.CreateShuffleVector(
6673 return CGF.Builder.CreateBitCast(Cmp,
6674 IntegerType::get(CGF.getLLVMContext(),
7709 static Value *EmitSystemZIntrinsicWithCC(CodeGenFunction &CGF,
7715 Args[I] = CGF.EmitScalarExpr(E->getArg(I));
7716 Address CCPtr = CGF.EmitPointerWithAlignment(E->getArg(NumArgs));
7717 Value *F = CGF.CGM.getIntrinsic(IntrinsicID);
7718 Value *Call = CGF.Builder.CreateCall(F, Args);
7719 Value *CC = CGF.Builder.CreateExtractValue(Call, 1);
7720 CGF.Builder.CreateStore(CC, CCPtr);
7721 return CGF.Builder.CreateExtractValue(Call, 0);