16 #include "llvm/ADT/STLExtras.h" 17 #include "llvm/IR/Constants.h" 18 #include "llvm/IR/Instructions.h" 19 #include "llvm/IR/MDBuilder.h" 20 #include "llvm/IR/Metadata.h" 22 using namespace clang;
23 using namespace CodeGen;
34 if (
const ComplexType *comp = dyn_cast<ComplexType>(type)) {
37 return cast<ComplexType>(cast<AtomicType>(
type)->getValueType());
42 class ComplexExprEmitter
43 :
public StmtVisitor<ComplexExprEmitter, ComplexPairTy> {
50 : CGF(cgf), Builder(CGF.Builder), IgnoreReal(ir), IgnoreImag(ii) {
58 bool TestAndClearIgnoreReal() {
63 bool TestAndClearIgnoreImag() {
73 return EmitLoadOfLValue(CGF.EmitLValue(E), E->
getExprLoc());
99 S->
dump(CGF.getContext().getSourceManager());
100 llvm_unreachable(
"Stmt can't have complex result type!");
116 return CGF.EmitCoawaitExpr(*S).getComplexVal();
119 return CGF.EmitCoyieldExpr(*S).getComplexVal();
127 assert(Constant &&
"not a constant");
132 llvm::Constant *pair = Constant.
getValue();
134 pair->getAggregateElement(1U));
140 return emitConstant(Constant, E);
141 return EmitLoadOfLValue(E);
144 return EmitLoadOfLValue(E);
147 return CGF.EmitObjCMessageExpr(E).getComplexVal();
152 CGF.tryEmitAsConstant(ME)) {
153 CGF.EmitIgnoredExpr(ME->
getBase());
154 return emitConstant(Constant, ME);
156 return EmitLoadOfLValue(ME);
160 return EmitLoadOfLValue(CGF.getOrCreateOpaqueLValueMapping(E),
162 return CGF.getOrCreateOpaqueRValueMapping(E).getComplexVal();
166 return CGF.EmitPseudoObjectRValue(E).getComplexVal();
178 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
179 CGF.CGM.EmitExplicitCastExprType(ECE, &CGF);
187 bool isInc,
bool isPre) {
189 return CGF.EmitComplexPrePostIncDec(E, LV, isInc, isPre);
192 return VisitPrePostIncDec(E,
false,
false);
195 return VisitPrePostIncDec(E,
true,
false);
198 return VisitPrePostIncDec(E,
false,
true);
201 return VisitPrePostIncDec(E,
true,
true);
205 TestAndClearIgnoreReal();
206 TestAndClearIgnoreImag();
224 CGF.enterFullExpression(E);
235 llvm::Constant *Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem));
241 llvm::Constant *Null =
242 llvm::Constant::getNullValue(CGF.ConvertType(Elem));
259 (
const BinOpInfo &));
267 const BinOpInfo &Op);
270 return EmitBinAdd(EmitBinOps(E));
273 return EmitBinSub(EmitBinOps(E));
276 return EmitBinMul(EmitBinOps(E));
279 return EmitBinDiv(EmitBinOps(E));
284 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd);
287 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub);
290 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul);
293 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv);
314 return EmitLoadOfLValue(E);
320 return CGF.EmitAtomicExpr(E).getComplexVal();
331 return Builder.CreateStructGEP(addr, 0, addr.
getName() +
".realp");
336 return Builder.CreateStructGEP(addr, 1, addr.
getName() +
".imagp");
343 assert(lvalue.
isSimple() &&
"non-simple complex l-value?");
345 return CGF.EmitAtomicLoad(lvalue, loc).getComplexVal();
352 if (!IgnoreReal || isVolatile) {
353 Address RealP = CGF.emitAddrOfRealComponent(SrcPtr, lvalue.
getType());
354 Real = Builder.CreateLoad(RealP, isVolatile, SrcPtr.
getName() +
".real");
357 if (!IgnoreImag || isVolatile) {
358 Address ImagP = CGF.emitAddrOfImagComponent(SrcPtr, lvalue.
getType());
359 Imag = Builder.CreateLoad(ImagP, isVolatile, SrcPtr.
getName() +
".imag");
370 (!isInit && CGF.LValueIsSuitableForInlineAtomic(lvalue)))
374 Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.
getType());
375 Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.
getType());
388 CGF.ErrorUnsupported(E,
"complex expression");
398 return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
404 return EmitLoadOfLValue(E);
406 return CGF.EmitCallExpr(E).getComplexVal();
412 assert(RetAlloca.
isValid() &&
"Expected complex return value");
413 return EmitLoadOfLValue(CGF.MakeAddrLValue(RetAlloca, E->
getType()),
429 Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
430 Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
440 Val = CGF.EmitScalarConversion(Val, SrcType, DestType, Loc);
443 return ComplexPairTy(Val, llvm::Constant::getNullValue(Val->getType()));
449 case CK_Dependent: llvm_unreachable(
"dependent cast kind in IR gen!");
453 case CK_AtomicToNonAtomic:
454 case CK_NonAtomicToAtomic:
456 case CK_LValueToRValue:
457 case CK_UserDefinedConversion:
460 case CK_LValueBitCast: {
461 LValue origLV = CGF.EmitLValue(Op);
463 V = Builder.CreateElementBitCast(V, CGF.ConvertType(DestTy));
464 return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), Op->
getExprLoc());
467 case CK_LValueToRValueBitCast: {
468 LValue SourceLVal = CGF.EmitLValue(Op);
470 CGF.ConvertTypeForMem(DestTy));
471 LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
473 return EmitLoadOfLValue(DestLV, Op->
getExprLoc());
477 case CK_BaseToDerived:
478 case CK_DerivedToBase:
479 case CK_UncheckedDerivedToBase:
482 case CK_ArrayToPointerDecay:
483 case CK_FunctionToPointerDecay:
484 case CK_NullToPointer:
485 case CK_NullToMemberPointer:
486 case CK_BaseToDerivedMemberPointer:
487 case CK_DerivedToBaseMemberPointer:
488 case CK_MemberPointerToBoolean:
489 case CK_ReinterpretMemberPointer:
490 case CK_ConstructorConversion:
491 case CK_IntegralToPointer:
492 case CK_PointerToIntegral:
493 case CK_PointerToBoolean:
496 case CK_IntegralCast:
497 case CK_BooleanToSignedIntegral:
498 case CK_IntegralToBoolean:
499 case CK_IntegralToFloating:
500 case CK_FloatingToIntegral:
501 case CK_FloatingToBoolean:
502 case CK_FloatingCast:
503 case CK_CPointerToObjCPointerCast:
504 case CK_BlockPointerToObjCPointerCast:
505 case CK_AnyPointerToBlockPointerCast:
506 case CK_ObjCObjectLValueCast:
507 case CK_FloatingComplexToReal:
508 case CK_FloatingComplexToBoolean:
509 case CK_IntegralComplexToReal:
510 case CK_IntegralComplexToBoolean:
511 case CK_ARCProduceObject:
512 case CK_ARCConsumeObject:
513 case CK_ARCReclaimReturnedObject:
514 case CK_ARCExtendBlockObject:
515 case CK_CopyAndAutoreleaseBlockObject:
516 case CK_BuiltinFnToFnPtr:
517 case CK_ZeroToOCLOpaqueType:
518 case CK_AddressSpaceConversion:
519 case CK_IntToOCLSampler:
520 case CK_FixedPointCast:
521 case CK_FixedPointToBoolean:
522 case CK_FixedPointToIntegral:
523 case CK_IntegralToFixedPoint:
524 llvm_unreachable(
"invalid cast kind for complex value");
526 case CK_FloatingRealToComplex:
527 case CK_IntegralRealToComplex:
528 return EmitScalarToComplexCast(CGF.EmitScalarExpr(Op), Op->
getType(),
531 case CK_FloatingComplexCast:
532 case CK_FloatingComplexToIntegralComplex:
533 case CK_IntegralComplexCast:
534 case CK_IntegralComplexToFloatingComplex:
535 return EmitComplexToComplexCast(Visit(Op), Op->
getType(), DestTy,
539 llvm_unreachable(
"unknown cast resulting in complex value");
543 TestAndClearIgnoreReal();
544 TestAndClearIgnoreImag();
548 if (Op.first->getType()->isFloatingPointTy()) {
549 ResR = Builder.CreateFNeg(Op.first,
"neg.r");
550 ResI = Builder.CreateFNeg(Op.second,
"neg.i");
552 ResR = Builder.CreateNeg(Op.first,
"neg.r");
553 ResI = Builder.CreateNeg(Op.second,
"neg.i");
559 TestAndClearIgnoreReal();
560 TestAndClearIgnoreImag();
564 if (Op.second->getType()->isFloatingPointTy())
565 ResI = Builder.CreateFNeg(Op.second,
"conj.i");
567 ResI = Builder.CreateNeg(Op.second,
"conj.i");
572 ComplexPairTy ComplexExprEmitter::EmitBinAdd(
const BinOpInfo &Op) {
575 if (Op.LHS.first->getType()->isFloatingPointTy()) {
576 ResR = Builder.CreateFAdd(Op.LHS.first, Op.RHS.first,
"add.r");
577 if (Op.LHS.second && Op.RHS.second)
578 ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second,
"add.i");
580 ResI = Op.LHS.second ? Op.LHS.second : Op.RHS.second;
581 assert(ResI &&
"Only one operand may be real!");
583 ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first,
"add.r");
584 assert(Op.LHS.second && Op.RHS.second &&
585 "Both operands of integer complex operators must be complex!");
586 ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second,
"add.i");
591 ComplexPairTy ComplexExprEmitter::EmitBinSub(
const BinOpInfo &Op) {
593 if (Op.LHS.first->getType()->isFloatingPointTy()) {
594 ResR = Builder.CreateFSub(Op.LHS.first, Op.RHS.first,
"sub.r");
595 if (Op.LHS.second && Op.RHS.second)
596 ResI = Builder.CreateFSub(Op.LHS.second, Op.RHS.second,
"sub.i");
598 ResI = Op.LHS.second ? Op.LHS.second
599 : Builder.CreateFNeg(Op.RHS.second,
"sub.i");
600 assert(ResI &&
"Only one operand may be real!");
602 ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first,
"sub.r");
603 assert(Op.LHS.second && Op.RHS.second &&
604 "Both operands of integer complex operators must be complex!");
605 ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second,
"sub.i");
611 ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
612 const BinOpInfo &Op) {
634 QualType FQTy = CGF.getContext().getFunctionType(Op.Ty, ArgsQTys, EPI);
635 const CGFunctionInfo &FuncInfo = CGF.CGM.getTypes().arrangeFreeFunctionCall(
636 Args, cast<FunctionType>(FQTy.getTypePtr()),
false);
638 llvm::FunctionType *FTy = CGF.CGM.getTypes().GetFunctionType(FuncInfo);
639 llvm::FunctionCallee Func = CGF.CGM.CreateRuntimeFunction(
640 FTy, LibCallName, llvm::AttributeList(),
true);
643 llvm::CallBase *Call;
645 Call->setCallingConv(CGF.CGM.getRuntimeCC());
652 switch (Ty->getTypeID()) {
654 llvm_unreachable(
"Unsupported floating point type!");
655 case llvm::Type::HalfTyID:
657 case llvm::Type::FloatTyID:
659 case llvm::Type::DoubleTyID:
661 case llvm::Type::PPC_FP128TyID:
663 case llvm::Type::X86_FP80TyID:
665 case llvm::Type::FP128TyID:
672 ComplexPairTy ComplexExprEmitter::EmitBinMul(
const BinOpInfo &Op) {
675 llvm::MDBuilder MDHelper(CGF.getLLVMContext());
677 if (Op.LHS.first->getType()->isFloatingPointTy()) {
686 if (Op.LHS.second && Op.RHS.second) {
697 Value *AC = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul_ac");
698 Value *BD = Builder.CreateFMul(Op.LHS.second, Op.RHS.second,
"mul_bd");
699 Value *AD = Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul_ad");
700 Value *BC = Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul_bc");
704 ResR = Builder.CreateFSub(AC, BD,
"mul_r");
705 ResI = Builder.CreateFAdd(AD, BC,
"mul_i");
709 Value *IsRNaN = Builder.CreateFCmpUNO(ResR, ResR,
"isnan_cmp");
710 llvm::BasicBlock *ContBB = CGF.createBasicBlock(
"complex_mul_cont");
711 llvm::BasicBlock *INaNBB = CGF.createBasicBlock(
"complex_mul_imag_nan");
712 llvm::Instruction *Branch = Builder.CreateCondBr(IsRNaN, INaNBB, ContBB);
713 llvm::BasicBlock *OrigBB = Branch->getParent();
717 llvm::MDNode *BrWeight = MDHelper.createBranchWeights(1, (1U << 20) - 1);
718 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
721 CGF.EmitBlock(INaNBB);
722 Value *IsINaN = Builder.CreateFCmpUNO(ResI, ResI,
"isnan_cmp");
723 llvm::BasicBlock *LibCallBB = CGF.createBasicBlock(
"complex_mul_libcall");
724 Branch = Builder.CreateCondBr(IsINaN, LibCallBB, ContBB);
725 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
728 CGF.EmitBlock(LibCallBB);
729 Value *LibCallR, *LibCallI;
730 std::tie(LibCallR, LibCallI) = EmitComplexBinOpLibCall(
732 Builder.CreateBr(ContBB);
736 CGF.EmitBlock(ContBB);
737 llvm::PHINode *RealPHI = Builder.CreatePHI(ResR->getType(), 3,
"real_mul_phi");
738 RealPHI->addIncoming(ResR, OrigBB);
739 RealPHI->addIncoming(ResR, INaNBB);
740 RealPHI->addIncoming(LibCallR, LibCallBB);
741 llvm::PHINode *ImagPHI = Builder.CreatePHI(ResI->getType(), 3,
"imag_mul_phi");
742 ImagPHI->addIncoming(ResI, OrigBB);
743 ImagPHI->addIncoming(ResI, INaNBB);
744 ImagPHI->addIncoming(LibCallI, LibCallBB);
747 assert((Op.LHS.second || Op.RHS.second) &&
748 "At least one operand must be complex!");
753 ResR = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
756 ? Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul.il")
757 : Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
759 assert(Op.LHS.second && Op.RHS.second &&
760 "Both operands of integer complex operators must be complex!");
761 Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
762 Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,
"mul.rr");
763 ResR = Builder.CreateSub(ResRl, ResRr,
"mul.r");
765 Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first,
"mul.il");
766 Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
767 ResI = Builder.CreateAdd(ResIl, ResIr,
"mul.i");
774 ComplexPairTy ComplexExprEmitter::EmitBinDiv(
const BinOpInfo &Op) {
775 llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second;
776 llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second;
779 if (LHSr->getType()->isFloatingPointTy()) {
787 if (RHSi && !CGF.getLangOpts().FastMath) {
788 BinOpInfo LibCallOp = Op;
791 LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType());
793 switch (LHSr->getType()->getTypeID()) {
795 llvm_unreachable(
"Unsupported floating point type!");
796 case llvm::Type::HalfTyID:
797 return EmitComplexBinOpLibCall(
"__divhc3", LibCallOp);
798 case llvm::Type::FloatTyID:
799 return EmitComplexBinOpLibCall(
"__divsc3", LibCallOp);
800 case llvm::Type::DoubleTyID:
801 return EmitComplexBinOpLibCall(
"__divdc3", LibCallOp);
802 case llvm::Type::PPC_FP128TyID:
803 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
804 case llvm::Type::X86_FP80TyID:
805 return EmitComplexBinOpLibCall(
"__divxc3", LibCallOp);
806 case llvm::Type::FP128TyID:
807 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
811 LHSi = llvm::Constant::getNullValue(RHSi->getType());
826 DSTr = Builder.CreateFDiv(ACpBD, CCpDD);
827 DSTi = Builder.CreateFDiv(BCmAD, CCpDD);
829 assert(LHSi &&
"Can have at most one non-complex operand!");
831 DSTr = Builder.CreateFDiv(LHSr, RHSr);
832 DSTi = Builder.CreateFDiv(LHSi, RHSr);
835 assert(Op.LHS.second && Op.RHS.second &&
836 "Both operands of integer complex operators must be complex!");
851 DSTr = Builder.CreateUDiv(Tmp3, Tmp6);
852 DSTi = Builder.CreateUDiv(Tmp9, Tmp6);
854 DSTr = Builder.CreateSDiv(Tmp3, Tmp6);
855 DSTi = Builder.CreateSDiv(Tmp9, Tmp6);
862 ComplexExprEmitter::BinOpInfo
864 TestAndClearIgnoreReal();
865 TestAndClearIgnoreImag();
870 Ops.LHS = Visit(E->
getLHS());
874 Ops.RHS = Visit(E->
getRHS());
881 LValue ComplexExprEmitter::
885 TestAndClearIgnoreReal();
886 TestAndClearIgnoreImag();
889 LHSTy = AT->getValueType();
897 QualType ComplexElementTy = cast<ComplexType>(OpInfo.Ty)->getElementType();
903 .hasSameUnqualifiedType(ComplexElementTy, E->
getRHS()->
getType()));
906 assert(CGF.getContext()
908 OpInfo.RHS = Visit(E->
getRHS());
917 OpInfo.LHS = EmitComplexToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
919 llvm::Value *LHSVal = CGF.EmitLoadOfScalar(LHS, Loc);
923 if (!CGF.getContext().hasSameUnqualifiedType(ComplexElementTy, LHSTy))
924 LHSVal = CGF.EmitScalarConversion(LHSVal, LHSTy, ComplexElementTy, Loc);
927 OpInfo.LHS = EmitScalarToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
937 EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy, Loc);
938 EmitStoreOfComplex(ResVal, LHS,
false);
942 CGF.EmitComplexToScalarConversion(Result, OpInfo.Ty, LHSTy, Loc);
943 CGF.EmitStoreOfScalar(ResVal, LHS,
false);
953 ComplexPairTy (ComplexExprEmitter::*Func)(
const BinOpInfo&)){
955 LValue LV = EmitCompoundAssignLValue(E, Func, Val);
958 if (!CGF.getLangOpts().CPlusPlus)
970 assert(CGF.getContext().hasSameUnqualifiedType(E->
getLHS()->
getType(),
972 "Invalid assignment");
973 TestAndClearIgnoreReal();
974 TestAndClearIgnoreImag();
983 EmitStoreOfComplex(Val, LHS,
false);
990 LValue LV = EmitBinAssignLValue(E, Val);
993 if (!CGF.getLangOpts().CPlusPlus)
1000 return EmitLoadOfLValue(LV, E->
getExprLoc());
1004 CGF.EmitIgnoredExpr(E->
getLHS());
1005 return Visit(E->
getRHS());
1010 TestAndClearIgnoreReal();
1011 TestAndClearIgnoreImag();
1012 llvm::BasicBlock *LHSBlock = CGF.createBasicBlock(
"cond.true");
1013 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock(
"cond.false");
1014 llvm::BasicBlock *ContBlock = CGF.createBasicBlock(
"cond.end");
1021 CGF.EmitBranchOnBoolExpr(E->
getCond(), LHSBlock, RHSBlock,
1022 CGF.getProfileCount(E));
1025 CGF.EmitBlock(LHSBlock);
1026 CGF.incrementProfileCounter(E);
1028 LHSBlock = Builder.GetInsertBlock();
1029 CGF.EmitBranch(ContBlock);
1033 CGF.EmitBlock(RHSBlock);
1035 RHSBlock = Builder.GetInsertBlock();
1036 CGF.EmitBlock(ContBlock);
1040 llvm::PHINode *RealPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.r");
1041 RealPN->addIncoming(LHS.first, LHSBlock);
1042 RealPN->addIncoming(RHS.first, RHSBlock);
1045 llvm::PHINode *ImagPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.i");
1046 ImagPN->addIncoming(LHS.second, LHSBlock);
1047 ImagPN->addIncoming(RHS.second, RHSBlock);
1057 bool Ignore = TestAndClearIgnoreReal();
1059 assert (Ignore ==
false &&
"init list ignored");
1060 Ignore = TestAndClearIgnoreImag();
1062 assert (Ignore ==
false &&
"init list ignored");
1073 assert(E->
getNumInits() == 0 &&
"Unexpected number of inits");
1076 llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy);
1082 Address ArgPtr = CGF.EmitVAArg(E, ArgValue);
1085 CGF.ErrorUnsupported(E,
"complex va_arg expression");
1092 return EmitLoadOfLValue(CGF.MakeAddrLValue(ArgPtr, E->
getType()),
1105 "Invalid complex expression to emit");
1107 return ComplexExprEmitter(*
this, IgnoreReal, IgnoreImag)
1108 .Visit(const_cast<Expr *>(E));
1114 "Invalid complex expression to emit");
1115 ComplexExprEmitter Emitter(*
this);
1117 Emitter.EmitStoreOfComplex(Val, dest, isInit);
1123 ComplexExprEmitter(*this).EmitStoreOfComplex(V, dest, isInit);
1129 return ComplexExprEmitter(*this).EmitLoadOfLValue(src, loc);
1135 return ComplexExprEmitter(*this).EmitBinAssignLValue(E, Val);
1139 const ComplexExprEmitter::BinOpInfo &);
1143 case BO_MulAssign:
return &ComplexExprEmitter::EmitBinMul;
1144 case BO_DivAssign:
return &ComplexExprEmitter::EmitBinDiv;
1145 case BO_SubAssign:
return &ComplexExprEmitter::EmitBinSub;
1146 case BO_AddAssign:
return &ComplexExprEmitter::EmitBinAdd;
1148 llvm_unreachable(
"unexpected complex compound assignment");
1156 return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1164 LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1165 Result = Val.getScalarVal();
const Expr * getSubExpr() const
ReturnValueSlot - Contains the address where the return value of a function can be stored...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
void end(CodeGenFunction &CGF)
LValue getReferenceLValue(CodeGenFunction &CGF, Expr *refExpr) const
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
llvm::Constant * getValue() const
A (possibly-)qualified type.
SourceLocation getExprLoc() const
Expr * getResultExpr()
Return the result expression of this controlling expression.
CompoundStmt * getSubStmt()
const Expr * getInit(unsigned Init) const
Stmt - This represents one statement.
bool isRealFloatingType() const
Floating point categories.
static StringRef getComplexMultiplyLibCallName(llvm::Type *Ty)
Lookup the libcall name for a given floating point type complex multiply.
ParenExpr - This represents a parethesized expression, e.g.
Expr * getFalseExpr() const
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
const Expr * getSubExpr() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
CompoundLiteralExpr - [C99 6.5.2.5].
const T * getAs() const
Member-template getAs<specific type>'.
Extra information about a function prototype.
LValue EmitComplexAssignmentLValue(const BinaryOperator *E)
Emit an l-value for an assignment (simple or compound) of complex type.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Address emitAddrOfImagComponent(Address complex, QualType complexType)
void add(RValue rvalue, QualType type)
An object to manage conditionally-evaluated expressions.
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
Address getAddress() const
QualType getComputationResultType() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
bool isVolatileQualified() const
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
const AstTypeMatcher< ComplexType > complexType
Matches C99 complex types.
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
Describes an C or C++ initializer list.
Address emitAddrOfRealComponent(Address complex, QualType complexType)
A builtin binary operation expression such as "x + y" or "x <= y".
Scope - A scope is a transient data structure that is used while parsing the program.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
void ForceCleanup(std::initializer_list< llvm::Value **> ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
ComplexPairTy(ComplexExprEmitter::* CompoundFunc)(const ComplexExprEmitter::BinOpInfo &)
A default argument (C++ [dcl.fct.default]).
void begin(CodeGenFunction &CGF)
const Expr * getExpr() const
Get the initialization expression that will be used.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
Represents a prototype with parameter type info, e.g.
CastKind
CastKind - The kind of operation required for a conversion.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Represents a call to the builtin function __builtin_va_arg.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
QualType getElementType() const
This represents one expression.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
const T * castAs() const
Member-template castAs<specific type>.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
unsigned getNumInits() const
bool isAnyComplexType() const
An RAII object to record that we're evaluating a statement expression.
An expression that sends a message to the given Objective-C object or class.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
The scope of a CXXDefaultInitExpr.
Expr * getTrueExpr() const
const Expr * getSubExpr() const
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
The l-value was considered opaque, so the alignment was determined from a type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getCanonicalType() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Encodes a location in the source.
Expr * getSubExpr() const
CastKind getCastKind() const
A scoped helper to set the current debug location to the specified location or preferred location of ...
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
static const ComplexType * getComplexType(QualType type)
Return the complex type that we are meant to emit.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
All available information about a concrete callee.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
CompoundAssignOperator - For compound assignments (e.g.
Represents a C11 generic selection.
CGFunctionInfo - Class to encapsulate the information about a function definition.
SourceLocation getExprLoc() const LLVM_READONLY
Dataflow Directional Tag Classes.
static CompoundFunc getComplexOp(BinaryOperatorKind Op)
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
CodeGenFunction::ComplexPairTy ComplexPairTy
Represents a 'co_yield' expression.
const Expr * getExpr() const
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)
Complex values, per C99 6.2.5p11.
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
bool isAtomicType() const
Represents a 'co_await' expression.
Expr * getReplacement() const
llvm::StringRef getName() const
Return the IR name of the pointer value.
Holds information about the various types of exception specification.
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type, returning the result.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
A use of a default initializer in a constructor or in aggregate initialization.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
RetTy Visit(PTR(Stmt) S, ParamTys... P)
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
LValue - This represents an lvalue references.
void setTBAAInfo(TBAAAccessInfo Info)
CallArgList - Type for representing both the value and type of arguments in a call.
static TBAAAccessInfo getMayAliasInfo()
Represents an implicitly-generated value initialization of an object of a given type.