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();
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();
332 return Builder.CreateStructGEP(addr, 0, offset, addr.
getName() +
".realp");
338 CharUnits offset = getContext().getTypeSizeInChars(eltType);
339 return Builder.CreateStructGEP(addr, 1, offset, addr.
getName() +
".imagp");
346 assert(lvalue.
isSimple() &&
"non-simple complex l-value?");
348 return CGF.EmitAtomicLoad(lvalue, loc).getComplexVal();
355 if (!IgnoreReal || isVolatile) {
356 Address RealP = CGF.emitAddrOfRealComponent(SrcPtr, lvalue.
getType());
357 Real = Builder.CreateLoad(RealP, isVolatile, SrcPtr.
getName() +
".real");
360 if (!IgnoreImag || isVolatile) {
361 Address ImagP = CGF.emitAddrOfImagComponent(SrcPtr, lvalue.
getType());
362 Imag = Builder.CreateLoad(ImagP, isVolatile, SrcPtr.
getName() +
".imag");
373 (!isInit && CGF.LValueIsSuitableForInlineAtomic(lvalue)))
377 Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.
getType());
378 Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.
getType());
391 CGF.ErrorUnsupported(E,
"complex expression");
401 return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
407 return EmitLoadOfLValue(E);
409 return CGF.EmitCallExpr(E).getComplexVal();
415 assert(RetAlloca.
isValid() &&
"Expected complex return value");
416 return EmitLoadOfLValue(CGF.MakeAddrLValue(RetAlloca, E->
getType()),
432 Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
433 Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
443 Val = CGF.EmitScalarConversion(Val, SrcType, DestType, Loc);
446 return ComplexPairTy(Val, llvm::Constant::getNullValue(Val->getType()));
452 case CK_Dependent: llvm_unreachable(
"dependent cast kind in IR gen!");
456 case CK_AtomicToNonAtomic:
457 case CK_NonAtomicToAtomic:
459 case CK_LValueToRValue:
460 case CK_UserDefinedConversion:
463 case CK_LValueBitCast: {
464 LValue origLV = CGF.EmitLValue(Op);
466 V = Builder.CreateElementBitCast(V, CGF.ConvertType(DestTy));
467 return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), Op->
getExprLoc());
471 case CK_BaseToDerived:
472 case CK_DerivedToBase:
473 case CK_UncheckedDerivedToBase:
476 case CK_ArrayToPointerDecay:
477 case CK_FunctionToPointerDecay:
478 case CK_NullToPointer:
479 case CK_NullToMemberPointer:
480 case CK_BaseToDerivedMemberPointer:
481 case CK_DerivedToBaseMemberPointer:
482 case CK_MemberPointerToBoolean:
483 case CK_ReinterpretMemberPointer:
484 case CK_ConstructorConversion:
485 case CK_IntegralToPointer:
486 case CK_PointerToIntegral:
487 case CK_PointerToBoolean:
490 case CK_IntegralCast:
491 case CK_BooleanToSignedIntegral:
492 case CK_IntegralToBoolean:
493 case CK_IntegralToFloating:
494 case CK_FloatingToIntegral:
495 case CK_FloatingToBoolean:
496 case CK_FloatingCast:
497 case CK_CPointerToObjCPointerCast:
498 case CK_BlockPointerToObjCPointerCast:
499 case CK_AnyPointerToBlockPointerCast:
500 case CK_ObjCObjectLValueCast:
501 case CK_FloatingComplexToReal:
502 case CK_FloatingComplexToBoolean:
503 case CK_IntegralComplexToReal:
504 case CK_IntegralComplexToBoolean:
505 case CK_ARCProduceObject:
506 case CK_ARCConsumeObject:
507 case CK_ARCReclaimReturnedObject:
508 case CK_ARCExtendBlockObject:
509 case CK_CopyAndAutoreleaseBlockObject:
510 case CK_BuiltinFnToFnPtr:
511 case CK_ZeroToOCLOpaqueType:
512 case CK_AddressSpaceConversion:
513 case CK_IntToOCLSampler:
514 case CK_FixedPointCast:
515 case CK_FixedPointToBoolean:
516 llvm_unreachable(
"invalid cast kind for complex value");
518 case CK_FloatingRealToComplex:
519 case CK_IntegralRealToComplex:
520 return EmitScalarToComplexCast(CGF.EmitScalarExpr(Op), Op->
getType(),
523 case CK_FloatingComplexCast:
524 case CK_FloatingComplexToIntegralComplex:
525 case CK_IntegralComplexCast:
526 case CK_IntegralComplexToFloatingComplex:
527 return EmitComplexToComplexCast(Visit(Op), Op->
getType(), DestTy,
531 llvm_unreachable(
"unknown cast resulting in complex value");
535 TestAndClearIgnoreReal();
536 TestAndClearIgnoreImag();
540 if (Op.first->getType()->isFloatingPointTy()) {
541 ResR = Builder.CreateFNeg(Op.first,
"neg.r");
542 ResI = Builder.CreateFNeg(Op.second,
"neg.i");
544 ResR = Builder.CreateNeg(Op.first,
"neg.r");
545 ResI = Builder.CreateNeg(Op.second,
"neg.i");
551 TestAndClearIgnoreReal();
552 TestAndClearIgnoreImag();
556 if (Op.second->getType()->isFloatingPointTy())
557 ResI = Builder.CreateFNeg(Op.second,
"conj.i");
559 ResI = Builder.CreateNeg(Op.second,
"conj.i");
564 ComplexPairTy ComplexExprEmitter::EmitBinAdd(
const BinOpInfo &Op) {
567 if (Op.LHS.first->getType()->isFloatingPointTy()) {
568 ResR = Builder.CreateFAdd(Op.LHS.first, Op.RHS.first,
"add.r");
569 if (Op.LHS.second && Op.RHS.second)
570 ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second,
"add.i");
572 ResI = Op.LHS.second ? Op.LHS.second : Op.RHS.second;
573 assert(ResI &&
"Only one operand may be real!");
575 ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first,
"add.r");
576 assert(Op.LHS.second && Op.RHS.second &&
577 "Both operands of integer complex operators must be complex!");
578 ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second,
"add.i");
583 ComplexPairTy ComplexExprEmitter::EmitBinSub(
const BinOpInfo &Op) {
585 if (Op.LHS.first->getType()->isFloatingPointTy()) {
586 ResR = Builder.CreateFSub(Op.LHS.first, Op.RHS.first,
"sub.r");
587 if (Op.LHS.second && Op.RHS.second)
588 ResI = Builder.CreateFSub(Op.LHS.second, Op.RHS.second,
"sub.i");
590 ResI = Op.LHS.second ? Op.LHS.second
591 : Builder.CreateFNeg(Op.RHS.second,
"sub.i");
592 assert(ResI &&
"Only one operand may be real!");
594 ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first,
"sub.r");
595 assert(Op.LHS.second && Op.RHS.second &&
596 "Both operands of integer complex operators must be complex!");
597 ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second,
"sub.i");
603 ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
604 const BinOpInfo &Op) {
626 QualType FQTy = CGF.getContext().getFunctionType(Op.Ty, ArgsQTys, EPI);
627 const CGFunctionInfo &FuncInfo = CGF.CGM.getTypes().arrangeFreeFunctionCall(
628 Args, cast<FunctionType>(FQTy.getTypePtr()),
false);
630 llvm::FunctionType *FTy = CGF.CGM.getTypes().GetFunctionType(FuncInfo);
631 llvm::Constant *Func = CGF.CGM.CreateBuiltinFunction(FTy, LibCallName);
634 llvm::Instruction *Call;
636 cast<llvm::CallInst>(Call)->setCallingConv(CGF.CGM.getRuntimeCC());
643 switch (Ty->getTypeID()) {
645 llvm_unreachable(
"Unsupported floating point type!");
646 case llvm::Type::HalfTyID:
648 case llvm::Type::FloatTyID:
650 case llvm::Type::DoubleTyID:
652 case llvm::Type::PPC_FP128TyID:
654 case llvm::Type::X86_FP80TyID:
656 case llvm::Type::FP128TyID:
663 ComplexPairTy ComplexExprEmitter::EmitBinMul(
const BinOpInfo &Op) {
666 llvm::MDBuilder MDHelper(CGF.getLLVMContext());
668 if (Op.LHS.first->getType()->isFloatingPointTy()) {
677 if (Op.LHS.second && Op.RHS.second) {
688 Value *AC = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul_ac");
689 Value *BD = Builder.CreateFMul(Op.LHS.second, Op.RHS.second,
"mul_bd");
690 Value *AD = Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul_ad");
691 Value *BC = Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul_bc");
695 ResR = Builder.CreateFSub(AC, BD,
"mul_r");
696 ResI = Builder.CreateFAdd(AD, BC,
"mul_i");
700 Value *IsRNaN = Builder.CreateFCmpUNO(ResR, ResR,
"isnan_cmp");
701 llvm::BasicBlock *ContBB = CGF.createBasicBlock(
"complex_mul_cont");
702 llvm::BasicBlock *INaNBB = CGF.createBasicBlock(
"complex_mul_imag_nan");
703 llvm::Instruction *Branch = Builder.CreateCondBr(IsRNaN, INaNBB, ContBB);
704 llvm::BasicBlock *OrigBB = Branch->getParent();
708 llvm::MDNode *BrWeight = MDHelper.createBranchWeights(1, (1U << 20) - 1);
709 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
712 CGF.EmitBlock(INaNBB);
713 Value *IsINaN = Builder.CreateFCmpUNO(ResI, ResI,
"isnan_cmp");
714 llvm::BasicBlock *LibCallBB = CGF.createBasicBlock(
"complex_mul_libcall");
715 Branch = Builder.CreateCondBr(IsINaN, LibCallBB, ContBB);
716 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
719 CGF.EmitBlock(LibCallBB);
720 Value *LibCallR, *LibCallI;
721 std::tie(LibCallR, LibCallI) = EmitComplexBinOpLibCall(
723 Builder.CreateBr(ContBB);
727 CGF.EmitBlock(ContBB);
728 llvm::PHINode *RealPHI = Builder.CreatePHI(ResR->getType(), 3,
"real_mul_phi");
729 RealPHI->addIncoming(ResR, OrigBB);
730 RealPHI->addIncoming(ResR, INaNBB);
731 RealPHI->addIncoming(LibCallR, LibCallBB);
732 llvm::PHINode *ImagPHI = Builder.CreatePHI(ResI->getType(), 3,
"imag_mul_phi");
733 ImagPHI->addIncoming(ResI, OrigBB);
734 ImagPHI->addIncoming(ResI, INaNBB);
735 ImagPHI->addIncoming(LibCallI, LibCallBB);
738 assert((Op.LHS.second || Op.RHS.second) &&
739 "At least one operand must be complex!");
744 ResR = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
747 ? Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul.il")
748 : Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
750 assert(Op.LHS.second && Op.RHS.second &&
751 "Both operands of integer complex operators must be complex!");
752 Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
753 Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,
"mul.rr");
754 ResR = Builder.CreateSub(ResRl, ResRr,
"mul.r");
756 Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first,
"mul.il");
757 Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
758 ResI = Builder.CreateAdd(ResIl, ResIr,
"mul.i");
765 ComplexPairTy ComplexExprEmitter::EmitBinDiv(
const BinOpInfo &Op) {
766 llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second;
767 llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second;
770 if (LHSr->getType()->isFloatingPointTy()) {
778 if (RHSi && !CGF.getLangOpts().FastMath) {
779 BinOpInfo LibCallOp = Op;
782 LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType());
784 switch (LHSr->getType()->getTypeID()) {
786 llvm_unreachable(
"Unsupported floating point type!");
787 case llvm::Type::HalfTyID:
788 return EmitComplexBinOpLibCall(
"__divhc3", LibCallOp);
789 case llvm::Type::FloatTyID:
790 return EmitComplexBinOpLibCall(
"__divsc3", LibCallOp);
791 case llvm::Type::DoubleTyID:
792 return EmitComplexBinOpLibCall(
"__divdc3", LibCallOp);
793 case llvm::Type::PPC_FP128TyID:
794 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
795 case llvm::Type::X86_FP80TyID:
796 return EmitComplexBinOpLibCall(
"__divxc3", LibCallOp);
797 case llvm::Type::FP128TyID:
798 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
802 LHSi = llvm::Constant::getNullValue(RHSi->getType());
817 DSTr = Builder.CreateFDiv(ACpBD, CCpDD);
818 DSTi = Builder.CreateFDiv(BCmAD, CCpDD);
820 assert(LHSi &&
"Can have at most one non-complex operand!");
822 DSTr = Builder.CreateFDiv(LHSr, RHSr);
823 DSTi = Builder.CreateFDiv(LHSi, RHSr);
826 assert(Op.LHS.second && Op.RHS.second &&
827 "Both operands of integer complex operators must be complex!");
842 DSTr = Builder.CreateUDiv(Tmp3, Tmp6);
843 DSTi = Builder.CreateUDiv(Tmp9, Tmp6);
845 DSTr = Builder.CreateSDiv(Tmp3, Tmp6);
846 DSTi = Builder.CreateSDiv(Tmp9, Tmp6);
853 ComplexExprEmitter::BinOpInfo
855 TestAndClearIgnoreReal();
856 TestAndClearIgnoreImag();
861 Ops.LHS = Visit(E->
getLHS());
865 Ops.RHS = Visit(E->
getRHS());
872 LValue ComplexExprEmitter::
876 TestAndClearIgnoreReal();
877 TestAndClearIgnoreImag();
880 LHSTy = AT->getValueType();
888 QualType ComplexElementTy = cast<ComplexType>(OpInfo.Ty)->getElementType();
894 .hasSameUnqualifiedType(ComplexElementTy, E->
getRHS()->
getType()));
897 assert(CGF.getContext()
899 OpInfo.RHS = Visit(E->
getRHS());
908 OpInfo.LHS = EmitComplexToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
910 llvm::Value *LHSVal = CGF.EmitLoadOfScalar(LHS, Loc);
914 if (!CGF.getContext().hasSameUnqualifiedType(ComplexElementTy, LHSTy))
915 LHSVal = CGF.EmitScalarConversion(LHSVal, LHSTy, ComplexElementTy, Loc);
918 OpInfo.LHS = EmitScalarToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
928 EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy, Loc);
929 EmitStoreOfComplex(ResVal, LHS,
false);
933 CGF.EmitComplexToScalarConversion(Result, OpInfo.Ty, LHSTy, Loc);
934 CGF.EmitStoreOfScalar(ResVal, LHS,
false);
944 ComplexPairTy (ComplexExprEmitter::*Func)(
const BinOpInfo&)){
946 LValue LV = EmitCompoundAssignLValue(E, Func, Val);
949 if (!CGF.getLangOpts().CPlusPlus)
961 assert(CGF.getContext().hasSameUnqualifiedType(E->
getLHS()->
getType(),
963 "Invalid assignment");
964 TestAndClearIgnoreReal();
965 TestAndClearIgnoreImag();
974 EmitStoreOfComplex(Val, LHS,
false);
981 LValue LV = EmitBinAssignLValue(E, Val);
984 if (!CGF.getLangOpts().CPlusPlus)
995 CGF.EmitIgnoredExpr(E->
getLHS());
996 return Visit(E->
getRHS());
1001 TestAndClearIgnoreReal();
1002 TestAndClearIgnoreImag();
1003 llvm::BasicBlock *LHSBlock = CGF.createBasicBlock(
"cond.true");
1004 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock(
"cond.false");
1005 llvm::BasicBlock *ContBlock = CGF.createBasicBlock(
"cond.end");
1012 CGF.EmitBranchOnBoolExpr(E->
getCond(), LHSBlock, RHSBlock,
1013 CGF.getProfileCount(E));
1016 CGF.EmitBlock(LHSBlock);
1017 CGF.incrementProfileCounter(E);
1019 LHSBlock = Builder.GetInsertBlock();
1020 CGF.EmitBranch(ContBlock);
1024 CGF.EmitBlock(RHSBlock);
1026 RHSBlock = Builder.GetInsertBlock();
1027 CGF.EmitBlock(ContBlock);
1031 llvm::PHINode *RealPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.r");
1032 RealPN->addIncoming(LHS.first, LHSBlock);
1033 RealPN->addIncoming(RHS.first, RHSBlock);
1036 llvm::PHINode *ImagPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.i");
1037 ImagPN->addIncoming(LHS.second, LHSBlock);
1038 ImagPN->addIncoming(RHS.second, RHSBlock);
1048 bool Ignore = TestAndClearIgnoreReal();
1050 assert (Ignore ==
false &&
"init list ignored");
1051 Ignore = TestAndClearIgnoreImag();
1053 assert (Ignore ==
false &&
"init list ignored");
1064 assert(E->
getNumInits() == 0 &&
"Unexpected number of inits");
1067 llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy);
1073 Address ArgPtr = CGF.EmitVAArg(E, ArgValue);
1076 CGF.ErrorUnsupported(E,
"complex va_arg expression");
1083 return EmitLoadOfLValue(CGF.MakeAddrLValue(ArgPtr, E->
getType()),
1096 "Invalid complex expression to emit");
1098 return ComplexExprEmitter(*
this, IgnoreReal, IgnoreImag)
1099 .Visit(const_cast<Expr *>(E));
1105 "Invalid complex expression to emit");
1106 ComplexExprEmitter Emitter(*
this);
1108 Emitter.EmitStoreOfComplex(Val, dest, isInit);
1114 ComplexExprEmitter(*this).EmitStoreOfComplex(V, dest, isInit);
1120 return ComplexExprEmitter(*this).EmitLoadOfLValue(src, loc);
1126 return ComplexExprEmitter(*this).EmitBinAssignLValue(E, Val);
1130 const ComplexExprEmitter::BinOpInfo &);
1134 case BO_MulAssign:
return &ComplexExprEmitter::EmitBinMul;
1135 case BO_DivAssign:
return &ComplexExprEmitter::EmitBinDiv;
1136 case BO_SubAssign:
return &ComplexExprEmitter::EmitBinSub;
1137 case BO_AddAssign:
return &ComplexExprEmitter::EmitBinAdd;
1139 llvm_unreachable(
"unexpected complex compound assignment");
1147 return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1155 LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1156 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
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 * getResultExpr() const
The generic selection's result expression.
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.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
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)
CharUnits - This is an opaque type for sizes expressed in character units.
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.
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.
CallArgList - Type for representing both the value and type of arguments in a call.
Represents an implicitly-generated value initialization of an object of a given type.