17 #include "llvm/ADT/STLExtras.h" 18 #include "llvm/IR/Constants.h" 19 #include "llvm/IR/Instructions.h" 20 #include "llvm/IR/MDBuilder.h" 21 #include "llvm/IR/Metadata.h" 23 using namespace clang;
24 using namespace CodeGen;
35 if (
const ComplexType *comp = dyn_cast<ComplexType>(type)) {
38 return cast<ComplexType>(cast<AtomicType>(
type)->getValueType());
43 class ComplexExprEmitter
44 :
public StmtVisitor<ComplexExprEmitter, ComplexPairTy> {
51 : CGF(cgf), Builder(CGF.Builder), IgnoreReal(ir), IgnoreImag(ii) {
59 bool TestAndClearIgnoreReal() {
64 bool TestAndClearIgnoreImag() {
74 return EmitLoadOfLValue(CGF.EmitLValue(E), E->
getExprLoc());
100 S->
dump(CGF.getContext().getSourceManager());
101 llvm_unreachable(
"Stmt can't have complex result type!");
117 return CGF.EmitCoawaitExpr(*S).getComplexVal();
120 return CGF.EmitCoyieldExpr(*S).getComplexVal();
128 assert(Constant &&
"not a constant");
133 llvm::Constant *pair = Constant.
getValue();
135 pair->getAggregateElement(1U));
141 return emitConstant(Constant, E);
142 return EmitLoadOfLValue(E);
145 return EmitLoadOfLValue(E);
148 return CGF.EmitObjCMessageExpr(E).getComplexVal();
153 CGF.tryEmitAsConstant(ME)) {
154 CGF.EmitIgnoredExpr(ME->
getBase());
155 return emitConstant(Constant, ME);
157 return EmitLoadOfLValue(ME);
161 return EmitLoadOfLValue(CGF.getOrCreateOpaqueLValueMapping(E),
163 return CGF.getOrCreateOpaqueRValueMapping(E).getComplexVal();
167 return CGF.EmitPseudoObjectRValue(E).getComplexVal();
179 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
180 CGF.CGM.EmitExplicitCastExprType(ECE, &CGF);
188 bool isInc,
bool isPre) {
190 return CGF.EmitComplexPrePostIncDec(E, LV, isInc, isPre);
193 return VisitPrePostIncDec(E,
false,
false);
196 return VisitPrePostIncDec(E,
true,
false);
199 return VisitPrePostIncDec(E,
false,
true);
202 return VisitPrePostIncDec(E,
true,
true);
206 TestAndClearIgnoreReal();
207 TestAndClearIgnoreImag();
225 CGF.enterFullExpression(E);
236 llvm::Constant *
Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem));
242 llvm::Constant *
Null =
243 llvm::Constant::getNullValue(CGF.ConvertType(Elem));
260 (
const BinOpInfo &));
268 const BinOpInfo &Op);
271 return EmitBinAdd(EmitBinOps(E));
274 return EmitBinSub(EmitBinOps(E));
277 return EmitBinMul(EmitBinOps(E));
280 return EmitBinDiv(EmitBinOps(E));
289 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd);
292 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub);
295 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul);
298 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv);
319 return EmitLoadOfLValue(E);
325 return CGF.EmitAtomicExpr(E).getComplexVal();
336 return Builder.CreateStructGEP(addr, 0, addr.
getName() +
".realp");
341 return Builder.CreateStructGEP(addr, 1, addr.
getName() +
".imagp");
348 assert(lvalue.
isSimple() &&
"non-simple complex l-value?");
350 return CGF.EmitAtomicLoad(lvalue, loc).getComplexVal();
357 if (!IgnoreReal || isVolatile) {
358 Address RealP = CGF.emitAddrOfRealComponent(SrcPtr, lvalue.
getType());
359 Real = Builder.CreateLoad(RealP, isVolatile, SrcPtr.
getName() +
".real");
362 if (!IgnoreImag || isVolatile) {
363 Address ImagP = CGF.emitAddrOfImagComponent(SrcPtr, lvalue.
getType());
364 Imag = Builder.CreateLoad(ImagP, isVolatile, SrcPtr.
getName() +
".imag");
375 (!isInit && CGF.LValueIsSuitableForInlineAtomic(lvalue)))
379 Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.
getType());
380 Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.
getType());
393 CGF.ErrorUnsupported(E,
"complex expression");
403 return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
409 return EmitLoadOfLValue(E);
411 return CGF.EmitCallExpr(E).getComplexVal();
417 assert(RetAlloca.
isValid() &&
"Expected complex return value");
418 return EmitLoadOfLValue(CGF.MakeAddrLValue(RetAlloca, E->
getType()),
434 Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
435 Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
445 Val = CGF.EmitScalarConversion(Val, SrcType, DestType, Loc);
448 return ComplexPairTy(Val, llvm::Constant::getNullValue(Val->getType()));
454 case CK_Dependent: llvm_unreachable(
"dependent cast kind in IR gen!");
458 case CK_AtomicToNonAtomic:
459 case CK_NonAtomicToAtomic:
461 case CK_LValueToRValue:
462 case CK_UserDefinedConversion:
465 case CK_LValueBitCast: {
466 LValue origLV = CGF.EmitLValue(Op);
468 V = Builder.CreateElementBitCast(V, CGF.ConvertType(DestTy));
469 return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), Op->
getExprLoc());
472 case CK_LValueToRValueBitCast: {
473 LValue SourceLVal = CGF.EmitLValue(Op);
475 CGF.ConvertTypeForMem(DestTy));
476 LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
478 return EmitLoadOfLValue(DestLV, Op->
getExprLoc());
482 case CK_BaseToDerived:
483 case CK_DerivedToBase:
484 case CK_UncheckedDerivedToBase:
487 case CK_ArrayToPointerDecay:
488 case CK_FunctionToPointerDecay:
489 case CK_NullToPointer:
490 case CK_NullToMemberPointer:
491 case CK_BaseToDerivedMemberPointer:
492 case CK_DerivedToBaseMemberPointer:
493 case CK_MemberPointerToBoolean:
494 case CK_ReinterpretMemberPointer:
495 case CK_ConstructorConversion:
496 case CK_IntegralToPointer:
497 case CK_PointerToIntegral:
498 case CK_PointerToBoolean:
501 case CK_IntegralCast:
502 case CK_BooleanToSignedIntegral:
503 case CK_IntegralToBoolean:
504 case CK_IntegralToFloating:
505 case CK_FloatingToIntegral:
506 case CK_FloatingToBoolean:
507 case CK_FloatingCast:
508 case CK_CPointerToObjCPointerCast:
509 case CK_BlockPointerToObjCPointerCast:
510 case CK_AnyPointerToBlockPointerCast:
511 case CK_ObjCObjectLValueCast:
512 case CK_FloatingComplexToReal:
513 case CK_FloatingComplexToBoolean:
514 case CK_IntegralComplexToReal:
515 case CK_IntegralComplexToBoolean:
516 case CK_ARCProduceObject:
517 case CK_ARCConsumeObject:
518 case CK_ARCReclaimReturnedObject:
519 case CK_ARCExtendBlockObject:
520 case CK_CopyAndAutoreleaseBlockObject:
521 case CK_BuiltinFnToFnPtr:
522 case CK_ZeroToOCLOpaqueType:
523 case CK_AddressSpaceConversion:
524 case CK_IntToOCLSampler:
525 case CK_FixedPointCast:
526 case CK_FixedPointToBoolean:
527 case CK_FixedPointToIntegral:
528 case CK_IntegralToFixedPoint:
529 llvm_unreachable(
"invalid cast kind for complex value");
531 case CK_FloatingRealToComplex:
532 case CK_IntegralRealToComplex:
533 return EmitScalarToComplexCast(CGF.EmitScalarExpr(Op), Op->
getType(),
536 case CK_FloatingComplexCast:
537 case CK_FloatingComplexToIntegralComplex:
538 case CK_IntegralComplexCast:
539 case CK_IntegralComplexToFloatingComplex:
540 return EmitComplexToComplexCast(Visit(Op), Op->
getType(), DestTy,
544 llvm_unreachable(
"unknown cast resulting in complex value");
548 TestAndClearIgnoreReal();
549 TestAndClearIgnoreImag();
553 if (Op.first->getType()->isFloatingPointTy()) {
554 ResR = Builder.CreateFNeg(Op.first,
"neg.r");
555 ResI = Builder.CreateFNeg(Op.second,
"neg.i");
557 ResR = Builder.CreateNeg(Op.first,
"neg.r");
558 ResI = Builder.CreateNeg(Op.second,
"neg.i");
564 TestAndClearIgnoreReal();
565 TestAndClearIgnoreImag();
569 if (Op.second->getType()->isFloatingPointTy())
570 ResI = Builder.CreateFNeg(Op.second,
"conj.i");
572 ResI = Builder.CreateNeg(Op.second,
"conj.i");
577 ComplexPairTy ComplexExprEmitter::EmitBinAdd(
const BinOpInfo &Op) {
580 if (Op.LHS.first->getType()->isFloatingPointTy()) {
581 ResR = Builder.CreateFAdd(Op.LHS.first, Op.RHS.first,
"add.r");
582 if (Op.LHS.second && Op.RHS.second)
583 ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second,
"add.i");
585 ResI = Op.LHS.second ? Op.LHS.second : Op.RHS.second;
586 assert(ResI &&
"Only one operand may be real!");
588 ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first,
"add.r");
589 assert(Op.LHS.second && Op.RHS.second &&
590 "Both operands of integer complex operators must be complex!");
591 ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second,
"add.i");
596 ComplexPairTy ComplexExprEmitter::EmitBinSub(
const BinOpInfo &Op) {
598 if (Op.LHS.first->getType()->isFloatingPointTy()) {
599 ResR = Builder.CreateFSub(Op.LHS.first, Op.RHS.first,
"sub.r");
600 if (Op.LHS.second && Op.RHS.second)
601 ResI = Builder.CreateFSub(Op.LHS.second, Op.RHS.second,
"sub.i");
603 ResI = Op.LHS.second ? Op.LHS.second
604 : Builder.CreateFNeg(Op.RHS.second,
"sub.i");
605 assert(ResI &&
"Only one operand may be real!");
607 ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first,
"sub.r");
608 assert(Op.LHS.second && Op.RHS.second &&
609 "Both operands of integer complex operators must be complex!");
610 ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second,
"sub.i");
616 ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
617 const BinOpInfo &Op) {
639 QualType FQTy = CGF.getContext().getFunctionType(Op.Ty, ArgsQTys, EPI);
640 const CGFunctionInfo &FuncInfo = CGF.CGM.getTypes().arrangeFreeFunctionCall(
641 Args, cast<FunctionType>(FQTy.getTypePtr()),
false);
643 llvm::FunctionType *FTy = CGF.CGM.getTypes().GetFunctionType(FuncInfo);
644 llvm::FunctionCallee Func = CGF.CGM.CreateRuntimeFunction(
645 FTy, LibCallName, llvm::AttributeList(),
true);
648 llvm::CallBase *Call;
650 Call->setCallingConv(CGF.CGM.getRuntimeCC());
657 switch (Ty->getTypeID()) {
659 llvm_unreachable(
"Unsupported floating point type!");
660 case llvm::Type::HalfTyID:
662 case llvm::Type::FloatTyID:
664 case llvm::Type::DoubleTyID:
666 case llvm::Type::PPC_FP128TyID:
668 case llvm::Type::X86_FP80TyID:
670 case llvm::Type::FP128TyID:
677 ComplexPairTy ComplexExprEmitter::EmitBinMul(
const BinOpInfo &Op) {
680 llvm::MDBuilder MDHelper(CGF.getLLVMContext());
682 if (Op.LHS.first->getType()->isFloatingPointTy()) {
691 if (Op.LHS.second && Op.RHS.second) {
702 Value *AC = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul_ac");
703 Value *BD = Builder.CreateFMul(Op.LHS.second, Op.RHS.second,
"mul_bd");
704 Value *AD = Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul_ad");
705 Value *BC = Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul_bc");
709 ResR = Builder.CreateFSub(AC, BD,
"mul_r");
710 ResI = Builder.CreateFAdd(AD, BC,
"mul_i");
714 Value *IsRNaN = Builder.CreateFCmpUNO(ResR, ResR,
"isnan_cmp");
715 llvm::BasicBlock *ContBB = CGF.createBasicBlock(
"complex_mul_cont");
716 llvm::BasicBlock *INaNBB = CGF.createBasicBlock(
"complex_mul_imag_nan");
717 llvm::Instruction *Branch = Builder.CreateCondBr(IsRNaN, INaNBB, ContBB);
718 llvm::BasicBlock *OrigBB = Branch->getParent();
722 llvm::MDNode *BrWeight = MDHelper.createBranchWeights(1, (1U << 20) - 1);
723 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
726 CGF.EmitBlock(INaNBB);
727 Value *IsINaN = Builder.CreateFCmpUNO(ResI, ResI,
"isnan_cmp");
728 llvm::BasicBlock *LibCallBB = CGF.createBasicBlock(
"complex_mul_libcall");
729 Branch = Builder.CreateCondBr(IsINaN, LibCallBB, ContBB);
730 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
733 CGF.EmitBlock(LibCallBB);
734 Value *LibCallR, *LibCallI;
735 std::tie(LibCallR, LibCallI) = EmitComplexBinOpLibCall(
737 Builder.CreateBr(ContBB);
741 CGF.EmitBlock(ContBB);
742 llvm::PHINode *RealPHI = Builder.CreatePHI(ResR->getType(), 3,
"real_mul_phi");
743 RealPHI->addIncoming(ResR, OrigBB);
744 RealPHI->addIncoming(ResR, INaNBB);
745 RealPHI->addIncoming(LibCallR, LibCallBB);
746 llvm::PHINode *ImagPHI = Builder.CreatePHI(ResI->getType(), 3,
"imag_mul_phi");
747 ImagPHI->addIncoming(ResI, OrigBB);
748 ImagPHI->addIncoming(ResI, INaNBB);
749 ImagPHI->addIncoming(LibCallI, LibCallBB);
752 assert((Op.LHS.second || Op.RHS.second) &&
753 "At least one operand must be complex!");
758 ResR = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
761 ? Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul.il")
762 : Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
764 assert(Op.LHS.second && Op.RHS.second &&
765 "Both operands of integer complex operators must be complex!");
766 Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
767 Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,
"mul.rr");
768 ResR = Builder.CreateSub(ResRl, ResRr,
"mul.r");
770 Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first,
"mul.il");
771 Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
772 ResI = Builder.CreateAdd(ResIl, ResIr,
"mul.i");
779 ComplexPairTy ComplexExprEmitter::EmitBinDiv(
const BinOpInfo &Op) {
780 llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second;
781 llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second;
784 if (LHSr->getType()->isFloatingPointTy()) {
792 if (RHSi && !CGF.getLangOpts().FastMath) {
793 BinOpInfo LibCallOp = Op;
796 LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType());
798 switch (LHSr->getType()->getTypeID()) {
800 llvm_unreachable(
"Unsupported floating point type!");
801 case llvm::Type::HalfTyID:
802 return EmitComplexBinOpLibCall(
"__divhc3", LibCallOp);
803 case llvm::Type::FloatTyID:
804 return EmitComplexBinOpLibCall(
"__divsc3", LibCallOp);
805 case llvm::Type::DoubleTyID:
806 return EmitComplexBinOpLibCall(
"__divdc3", LibCallOp);
807 case llvm::Type::PPC_FP128TyID:
808 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
809 case llvm::Type::X86_FP80TyID:
810 return EmitComplexBinOpLibCall(
"__divxc3", LibCallOp);
811 case llvm::Type::FP128TyID:
812 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
816 LHSi = llvm::Constant::getNullValue(RHSi->getType());
831 DSTr = Builder.CreateFDiv(ACpBD, CCpDD);
832 DSTi = Builder.CreateFDiv(BCmAD, CCpDD);
834 assert(LHSi &&
"Can have at most one non-complex operand!");
836 DSTr = Builder.CreateFDiv(LHSr, RHSr);
837 DSTi = Builder.CreateFDiv(LHSi, RHSr);
840 assert(Op.LHS.second && Op.RHS.second &&
841 "Both operands of integer complex operators must be complex!");
856 DSTr = Builder.CreateUDiv(Tmp3, Tmp6);
857 DSTi = Builder.CreateUDiv(Tmp9, Tmp6);
859 DSTr = Builder.CreateSDiv(Tmp3, Tmp6);
860 DSTi = Builder.CreateSDiv(Tmp9, Tmp6);
867 ComplexExprEmitter::BinOpInfo
869 TestAndClearIgnoreReal();
870 TestAndClearIgnoreImag();
875 Ops.LHS = Visit(E->
getLHS());
879 Ops.RHS = Visit(E->
getRHS());
886 LValue ComplexExprEmitter::
890 TestAndClearIgnoreReal();
891 TestAndClearIgnoreImag();
894 LHSTy = AT->getValueType();
902 QualType ComplexElementTy = cast<ComplexType>(OpInfo.Ty)->getElementType();
908 .hasSameUnqualifiedType(ComplexElementTy, E->
getRHS()->
getType()));
911 assert(CGF.getContext()
913 OpInfo.RHS = Visit(E->
getRHS());
922 OpInfo.LHS = EmitComplexToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
924 llvm::Value *LHSVal = CGF.EmitLoadOfScalar(LHS, Loc);
928 if (!CGF.getContext().hasSameUnqualifiedType(ComplexElementTy, LHSTy))
929 LHSVal = CGF.EmitScalarConversion(LHSVal, LHSTy, ComplexElementTy, Loc);
932 OpInfo.LHS = EmitScalarToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
942 EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy, Loc);
943 EmitStoreOfComplex(ResVal, LHS,
false);
947 CGF.EmitComplexToScalarConversion(Result, OpInfo.Ty, LHSTy, Loc);
948 CGF.EmitStoreOfScalar(ResVal, LHS,
false);
958 ComplexPairTy (ComplexExprEmitter::*Func)(
const BinOpInfo&)){
960 LValue LV = EmitCompoundAssignLValue(E, Func, Val);
963 if (!CGF.getLangOpts().CPlusPlus)
975 assert(CGF.getContext().hasSameUnqualifiedType(E->
getLHS()->
getType(),
977 "Invalid assignment");
978 TestAndClearIgnoreReal();
979 TestAndClearIgnoreImag();
988 EmitStoreOfComplex(Val, LHS,
false);
995 LValue LV = EmitBinAssignLValue(E, Val);
998 if (!CGF.getLangOpts().CPlusPlus)
1005 return EmitLoadOfLValue(LV, E->
getExprLoc());
1009 CGF.EmitIgnoredExpr(E->
getLHS());
1010 return Visit(E->
getRHS());
1015 TestAndClearIgnoreReal();
1016 TestAndClearIgnoreImag();
1017 llvm::BasicBlock *LHSBlock = CGF.createBasicBlock(
"cond.true");
1018 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock(
"cond.false");
1019 llvm::BasicBlock *ContBlock = CGF.createBasicBlock(
"cond.end");
1026 CGF.EmitBranchOnBoolExpr(E->
getCond(), LHSBlock, RHSBlock,
1027 CGF.getProfileCount(E));
1030 CGF.EmitBlock(LHSBlock);
1031 CGF.incrementProfileCounter(E);
1033 LHSBlock = Builder.GetInsertBlock();
1034 CGF.EmitBranch(ContBlock);
1038 CGF.EmitBlock(RHSBlock);
1040 RHSBlock = Builder.GetInsertBlock();
1041 CGF.EmitBlock(ContBlock);
1045 llvm::PHINode *RealPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.r");
1046 RealPN->addIncoming(LHS.first, LHSBlock);
1047 RealPN->addIncoming(RHS.first, RHSBlock);
1050 llvm::PHINode *ImagPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.i");
1051 ImagPN->addIncoming(LHS.second, LHSBlock);
1052 ImagPN->addIncoming(RHS.second, RHSBlock);
1062 bool Ignore = TestAndClearIgnoreReal();
1064 assert (Ignore ==
false &&
"init list ignored");
1065 Ignore = TestAndClearIgnoreImag();
1067 assert (Ignore ==
false &&
"init list ignored");
1078 assert(E->
getNumInits() == 0 &&
"Unexpected number of inits");
1081 llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy);
1087 Address ArgPtr = CGF.EmitVAArg(E, ArgValue);
1090 CGF.ErrorUnsupported(E,
"complex va_arg expression");
1097 return EmitLoadOfLValue(CGF.MakeAddrLValue(ArgPtr, E->
getType()),
1110 "Invalid complex expression to emit");
1112 return ComplexExprEmitter(*
this, IgnoreReal, IgnoreImag)
1113 .Visit(const_cast<Expr *>(E));
1119 "Invalid complex expression to emit");
1120 ComplexExprEmitter
Emitter(*
this);
1122 Emitter.EmitStoreOfComplex(Val, dest, isInit);
1128 ComplexExprEmitter(*this).EmitStoreOfComplex(V, dest, isInit);
1134 return ComplexExprEmitter(*this).EmitLoadOfLValue(src, loc);
1140 LValue LVal = ComplexExprEmitter(*this).EmitBinAssignLValue(E, Val);
1141 if (getLangOpts().OpenMP)
1142 CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(*
this,
1148 const ComplexExprEmitter::BinOpInfo &);
1152 case BO_MulAssign:
return &ComplexExprEmitter::EmitBinMul;
1153 case BO_DivAssign:
return &ComplexExprEmitter::EmitBinDiv;
1154 case BO_SubAssign:
return &ComplexExprEmitter::EmitBinSub;
1155 case BO_AddAssign:
return &ComplexExprEmitter::EmitBinAdd;
1157 llvm_unreachable(
"unexpected complex compound assignment");
1165 return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1173 LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1174 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.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
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.
bool GE(InterpState &S, CodePtr OpPC)
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.
Address getAddress(CodeGenFunction &CGF) const
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
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
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 rewritten comparison expression that was originally written using operator syntax.
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
bool Null(InterpState &S, CodePtr OpPC)
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.