Lines Matching refs:CGF
29 CodeGenFunction &CGF;
40 AtomicInfo(CodeGenFunction &CGF, LValue &lvalue) : CGF(CGF) {
45 EvaluationKind = CGF.getEvaluationKind(ValueTy);
47 ASTContext &C = CGF.getContext();
90 CharUnits size = CGF.getContext().toCharUnitsFromBits(AtomicSizeInBits);
91 return CGF.CGM.getSize(size);
110 addr = CGF.Builder.CreateStructGEP(addr, 0);
113 CGF.getContext(), lvalue.getTBAAInfo());
124 static RValue emitAtomicLibcall(CodeGenFunction &CGF,
129 CGF.CGM.getTypes().arrangeFreeFunctionCall(resultType, args,
131 llvm::FunctionType *fnTy = CGF.CGM.getTypes().GetFunctionType(fnInfo);
132 llvm::Constant *fn = CGF.CGM.CreateRuntimeFunction(fnTy, fnName);
133 return CGF.EmitCall(fnInfo, fn, ReturnValueSlot(), args);
154 return !isFullSizeType(CGF.CGM, type, AtomicSizeInBits);
156 return !isFullSizeType(CGF.CGM, type->getStructElementType(0),
171 CGF.Builder.CreateMemSet(addr, llvm::ConstantInt::get(CGF.Int8Ty, 0),
177 static void emitAtomicCmpXchg(CodeGenFunction &CGF, AtomicExpr *E, bool IsWeak,
184 llvm::LoadInst *Expected = CGF.Builder.CreateLoad(Val1);
186 llvm::LoadInst *Desired = CGF.Builder.CreateLoad(Val2);
189 llvm::AtomicCmpXchgInst *Pair = CGF.Builder.CreateAtomicCmpXchg(
196 llvm::Value *Old = CGF.Builder.CreateExtractValue(Pair, 0);
197 llvm::Value *Cmp = CGF.Builder.CreateExtractValue(Pair, 1);
202 CGF.createBasicBlock("cmpxchg.store_expected", CGF.CurFn);
207 CGF.createBasicBlock("cmpxchg.continue", CGF.CurFn);
211 CGF.Builder.CreateCondBr(Cmp, ContinueBB, StoreExpectedBB);
213 CGF.Builder.SetInsertPoint(StoreExpectedBB);
215 llvm::StoreInst *StoreExpected = CGF.Builder.CreateStore(Old, Val1);
218 CGF.Builder.CreateBr(ContinueBB);
220 CGF.Builder.SetInsertPoint(ContinueBB);
222 CGF.EmitStoreOfScalar(Cmp, CGF.MakeAddrLValue(Dest, E->getType()));
229 static void emitAtomicCmpXchgFailureSet(CodeGenFunction &CGF, AtomicExpr *E,
255 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2, Size, Align,
263 MonotonicBB = CGF.createBasicBlock("monotonic_fail", CGF.CurFn);
265 AcquireBB = CGF.createBasicBlock("acquire_fail", CGF.CurFn);
267 SeqCstBB = CGF.createBasicBlock("seqcst_fail", CGF.CurFn);
269 llvm::BasicBlock *ContBB = CGF.createBasicBlock("atomic.continue", CGF.CurFn);
271 llvm::SwitchInst *SI = CGF.Builder.CreateSwitch(FailureOrderVal, MonotonicBB);
278 CGF.Builder.SetInsertPoint(MonotonicBB);
279 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2,
281 CGF.Builder.CreateBr(ContBB);
284 CGF.Builder.SetInsertPoint(AcquireBB);
285 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2,
287 CGF.Builder.CreateBr(ContBB);
288 SI->addCase(CGF.Builder.getInt32(AtomicExpr::AO_ABI_memory_order_consume),
290 SI->addCase(CGF.Builder.getInt32(AtomicExpr::AO_ABI_memory_order_acquire),
294 CGF.Builder.SetInsertPoint(SeqCstBB);
295 emitAtomicCmpXchg(CGF, E, IsWeak, Dest, Ptr, Val1, Val2,
297 CGF.Builder.CreateBr(ContBB);
298 SI->addCase(CGF.Builder.getInt32(AtomicExpr::AO_ABI_memory_order_seq_cst),
302 CGF.Builder.SetInsertPoint(ContBB);
305 static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, llvm::Value *Dest,
318 emitAtomicCmpXchgFailureSet(CGF, E, false, Dest, Ptr, Val1, Val2,
322 emitAtomicCmpXchgFailureSet(CGF, E, true, Dest, Ptr, Val1, Val2,
328 emitAtomicCmpXchgFailureSet(CGF, E, IsWeakC->getZExtValue(), Dest, Ptr,
333 CGF.createBasicBlock("cmpxchg.strong", CGF.CurFn);
334 llvm::BasicBlock *WeakBB = CGF.createBasicBlock("cmxchg.weak", CGF.CurFn);
336 CGF.createBasicBlock("cmpxchg.continue", CGF.CurFn);
338 llvm::SwitchInst *SI = CGF.Builder.CreateSwitch(IsWeak, WeakBB);
339 SI->addCase(CGF.Builder.getInt1(false), StrongBB);
341 CGF.Builder.SetInsertPoint(StrongBB);
342 emitAtomicCmpXchgFailureSet(CGF, E, false, Dest, Ptr, Val1, Val2,
344 CGF.Builder.CreateBr(ContBB);
346 CGF.Builder.SetInsertPoint(WeakBB);
347 emitAtomicCmpXchgFailureSet(CGF, E, true, Dest, Ptr, Val1, Val2,
349 CGF.Builder.CreateBr(ContBB);
351 CGF.Builder.SetInsertPoint(ContBB);
358 llvm::LoadInst *Load = CGF.Builder.CreateLoad(Ptr);
362 llvm::StoreInst *StoreDest = CGF.Builder.CreateStore(Load, Dest);
371 llvm::LoadInst *LoadVal1 = CGF.Builder.CreateLoad(Val1);
373 llvm::StoreInst *Store = CGF.Builder.CreateStore(LoadVal1, Ptr);
434 llvm::LoadInst *LoadVal1 = CGF.Builder.CreateLoad(Val1);
437 CGF.Builder.CreateAtomicRMW(Op, Ptr, LoadVal1, Order);
444 Result = CGF.Builder.CreateBinOp(PostOp, RMWI, LoadVal1);
446 Result = CGF.Builder.CreateNot(Result);
447 llvm::StoreInst *StoreDest = CGF.Builder.CreateStore(Result, Dest);
454 EmitValToTemp(CodeGenFunction &CGF, Expr *E) {
455 llvm::Value *DeclPtr = CGF.CreateMemTemp(E->getType(), ".atomictmp");
456 CGF.EmitAnyExprToMem(E, DeclPtr, E->getType().getQualifiers(),
462 AddDirectArgument(CodeGenFunction &CGF, CallArgList &Args,
467 unsigned Align = CGF.getContext().getTypeAlignInChars(ValTy).getQuantity();
468 Val = CGF.EmitLoadOfScalar(Val, false, Align, ValTy, Loc);
472 Args.add(RValue::get(CGF.EmitCastToVoidPtr(Val)),
473 CGF.getContext().VoidPtrTy);
866 llvm::IntegerType::get(CGF.getLLVMContext(), AtomicSizeInBits);
867 return CGF.Builder.CreateBitCast(addr, ty->getPointerTo(addrspace));
878 addr = CGF.Builder.CreateStructGEP(addr, 0);
882 return CGF.convertTempToRValue(addr, getValueType(), loc);
985 CGF.EmitAggregateCopy(dest.getAddress(),
1004 CGF.EmitStoreOfScalar(rvalue.getScalarVal(), dest, /*init*/ true);
1006 CGF.EmitStoreOfComplex(rvalue.getComplexVal(), dest, /*init*/ true);
1020 llvm::Value *temp = CGF.CreateMemTemp(getAtomicType(), "atomic-store-temp");
1021 LValue tempLV = CGF.MakeAddrLValue(temp, getAtomicType(), getAtomicAlignment());