19#include "llvm/IR/Constants.h"
20#include "llvm/IR/Instructions.h"
21#include "llvm/IR/MDBuilder.h"
22#include "llvm/IR/Metadata.h"
43class ComplexExprEmitter
44 :
public StmtVisitor<ComplexExprEmitter, ComplexPairTy> {
49 bool FPHasBeenPromoted;
52 ComplexExprEmitter(CodeGenFunction &cgf,
bool ir =
false,
bool ii =
false)
53 : CGF(cgf), Builder(CGF.Builder), IgnoreReal(ir), IgnoreImag(ii),
54 FPHasBeenPromoted(
false) {}
60 bool TestAndClearIgnoreReal() {
65 bool TestAndClearIgnoreImag() {
78 ComplexPairTy EmitLoadOfLValue(LValue LV, SourceLocation Loc);
82 void EmitStoreOfComplex(
ComplexPairTy Val, LValue LV,
bool isInit);
86 QualType DestType, SourceLocation Loc);
88 ComplexPairTy EmitScalarToComplexCast(llvm::Value *Val, QualType SrcType,
89 QualType DestType, SourceLocation Loc);
96 ApplyDebugLocation DL(CGF, E);
97 return StmtVisitor<ComplexExprEmitter, ComplexPairTy>::Visit(E);
102 llvm_unreachable(
"Stmt can't have complex result type!");
106 if (llvm::Constant *
Result = ConstantEmitter(CGF).tryEmitConstantExpr(E))
108 Result->getAggregateElement(1U));
114 ComplexPairTy VisitGenericSelectionExpr(GenericSelectionExpr *GE) {
115 return Visit(
GE->getResultExpr());
117 ComplexPairTy VisitImaginaryLiteral(
const ImaginaryLiteral *IL);
119 VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *PE) {
134 assert(
Constant &&
"not a constant");
136 return EmitLoadOfLValue(
Constant.getReferenceLValue(CGF, E),
139 llvm::Constant *pair =
Constant.getValue();
141 pair->getAggregateElement(1U));
148 return EmitLoadOfLValue(E);
151 return EmitLoadOfLValue(E);
156 ComplexPairTy VisitArraySubscriptExpr(Expr *E) {
return EmitLoadOfLValue(E); }
158 if (CodeGenFunction::ConstantEmission
Constant =
163 return EmitLoadOfLValue(ME);
183 return EmitLoadOfLValue(E);
187 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
190 return EmitLoadOfLValue(E);
197 ComplexPairTy VisitPrePostIncDec(
const UnaryOperator *E,
bool isInc,
203 return VisitPrePostIncDec(E,
false,
false);
206 return VisitPrePostIncDec(E,
true,
false);
209 return VisitPrePostIncDec(E,
false,
true);
212 return VisitPrePostIncDec(E,
true,
true);
214 ComplexPairTy VisitUnaryDeref(
const Expr *E) {
return EmitLoadOfLValue(E); }
217 QualType PromotionType = QualType());
218 ComplexPairTy VisitPlus(
const UnaryOperator *E, QualType PromotionType);
220 QualType PromotionType = QualType());
221 ComplexPairTy VisitMinus(
const UnaryOperator *E, QualType PromotionType);
227 ComplexPairTy VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
228 CodeGenFunction::CXXDefaultArgExprScope Scope(CGF, DAE);
231 ComplexPairTy VisitCXXDefaultInitExpr(CXXDefaultInitExpr *DIE) {
232 CodeGenFunction::CXXDefaultInitExprScope Scope(CGF, DIE);
236 CodeGenFunction::RunCleanupsScope Scope(CGF);
240 Scope.ForceCleanup({&Vals.first, &Vals.second});
243 ComplexPairTy VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
245 QualType Elem = E->
getType()->
castAs<ComplexType>()->getElementType();
246 llvm::Constant *
Null = llvm::Constant::getNullValue(CGF.
ConvertType(Elem));
249 ComplexPairTy VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
251 QualType Elem = E->
getType()->
castAs<ComplexType>()->getElementType();
252 llvm::Constant *
Null = llvm::Constant::getNullValue(CGF.
ConvertType(Elem));
260 FPOptions FPFeatures;
263 BinOpInfo EmitBinOps(
const BinaryOperator *E,
264 QualType PromotionTy = QualType());
265 ComplexPairTy EmitPromoted(
const Expr *E, QualType PromotionTy);
266 ComplexPairTy EmitPromotedComplexOperand(
const Expr *E, QualType PromotionTy);
267 LValue EmitCompoundAssignLValue(
268 const CompoundAssignOperator *E,
272 const CompoundAssignOperator *E,
279 ComplexPairTy EmitAlgebraicDiv(llvm::Value *A, llvm::Value *B, llvm::Value *
C,
281 ComplexPairTy EmitRangeReductionDiv(llvm::Value *A, llvm::Value *B,
282 llvm::Value *
C, llvm::Value *D);
285 const BinOpInfo &Op);
287 QualType HigherPrecisionTypeForComplexArithmetic(QualType ElementType) {
289 const QualType HigherElementType =
291 const llvm::fltSemantics &ElementTypeSemantics =
293 const llvm::fltSemantics &HigherElementTypeSemantics =
302 if (llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 <=
303 llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) {
308 FPHasBeenPromoted =
true;
317 QualType getPromotionType(FPOptionsOverride Features, QualType Ty,
318 bool IsComplexDivisor) {
319 if (
auto *CT = Ty->
getAs<ComplexType>()) {
320 QualType ElementType = CT->getElementType().getCanonicalType();
321 bool IsFloatingType = ElementType->isFloatingType();
322 bool IsComplexRangePromoted = CGF.
getLangOpts().getComplexRange() ==
323 LangOptions::ComplexRangeKind::CX_Promoted;
324 bool HasNoComplexRangeOverride = !Features.hasComplexRangeOverride();
325 bool HasMatchingComplexRange = Features.hasComplexRangeOverride() &&
326 Features.getComplexRangeOverride() ==
329 if (IsComplexDivisor && IsFloatingType && IsComplexRangePromoted &&
330 (HasNoComplexRangeOverride || HasMatchingComplexRange))
331 return HigherPrecisionTypeForComplexArithmetic(ElementType);
332 if (ElementType.UseExcessPrecision(CGF.
getContext()))
340#define HANDLEBINOP(OP) \
341 ComplexPairTy VisitBin##OP(const BinaryOperator *E) { \
342 QualType promotionTy = \
343 getPromotionType(E->getStoredFPFeaturesOrDefault(), E->getType(), \
344 (E->getOpcode() == BinaryOperatorKind::BO_Div && \
345 E->getRHS()->getType()->isAnyComplexType())); \
346 ComplexPairTy result = EmitBin##OP(EmitBinOps(E, promotionTy)); \
347 if (!promotionTy.isNull()) \
348 result = CGF.EmitUnPromotedValue(result, E->getType()); \
363 ComplexPairTy VisitBinAddAssign(
const CompoundAssignOperator *E) {
365 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd);
367 ComplexPairTy VisitBinSubAssign(
const CompoundAssignOperator *E) {
369 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub);
371 ComplexPairTy VisitBinMulAssign(
const CompoundAssignOperator *E) {
373 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul);
375 ComplexPairTy VisitBinDivAssign(
const CompoundAssignOperator *E) {
377 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv);
385 LValue EmitBinAssignLValue(
const BinaryOperator *E,
ComplexPairTy &Val);
390 VisitAbstractConditionalOperator(
const AbstractConditionalOperator *CO);
395 ComplexPairTy VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
396 return EmitLoadOfLValue(E);
417 return Builder.CreateStructGEP(addr, 0, addr.
getName() +
".realp");
422 return Builder.CreateStructGEP(addr, 1, addr.
getName() +
".imagp");
429 assert(lvalue.
isSimple() &&
"non-simple complex l-value?");
439 llvm::LoadInst *Real =
nullptr, *Imag =
nullptr;
441 if (!IgnoreReal || isVolatile) {
443 Real = Builder.CreateLoad(RealP, isVolatile, SrcPtr.
getName() +
".real");
447 if (!IgnoreImag || isVolatile) {
449 Imag = Builder.CreateLoad(ImagP, isVolatile, SrcPtr.
getName() +
".imag");
460 if (lvalue.getType()->isAtomicType() ||
472 Builder.CreateStore(Val.first, RealPtr, lvalue.isVolatileQualified());
476 Builder.CreateStore(Val.second, ImagPtr, lvalue.isVolatileQualified());
489 llvm::Value *U = llvm::PoisonValue::get(EltTy);
494ComplexExprEmitter::VisitImaginaryLiteral(
const ImaginaryLiteral *IL) {
496 return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
499ComplexPairTy ComplexExprEmitter::VisitCallExpr(
const CallExpr *E) {
501 return EmitLoadOfLValue(E);
506ComplexPairTy ComplexExprEmitter::VisitStmtExpr(
const StmtExpr *E) {
509 assert(RetAlloca.
isValid() &&
"Expected complex return value");
518 SourceLocation Loc) {
537ComplexPairTy ComplexExprEmitter::EmitScalarToComplexCast(llvm::Value *Val,
540 SourceLocation Loc) {
542 DestType = DestType->
castAs<ComplexType>()->getElementType();
546 return ComplexPairTy(Val, llvm::Constant::getNullValue(Val->getType()));
554 llvm_unreachable(
"dependent cast kind in IR gen!");
558 case CK_AtomicToNonAtomic:
559 case CK_NonAtomicToAtomic:
561 case CK_LValueToRValue:
562 case CK_UserDefinedConversion:
565 case CK_LValueBitCast: {
571 case CK_LValueToRValueBitCast: {
577 return EmitLoadOfLValue(DestLV, Op->
getExprLoc());
581 case CK_BaseToDerived:
582 case CK_DerivedToBase:
583 case CK_UncheckedDerivedToBase:
586 case CK_ArrayToPointerDecay:
587 case CK_FunctionToPointerDecay:
588 case CK_NullToPointer:
589 case CK_NullToMemberPointer:
590 case CK_BaseToDerivedMemberPointer:
591 case CK_DerivedToBaseMemberPointer:
592 case CK_MemberPointerToBoolean:
593 case CK_ReinterpretMemberPointer:
594 case CK_ConstructorConversion:
595 case CK_IntegralToPointer:
596 case CK_PointerToIntegral:
597 case CK_PointerToBoolean:
600 case CK_IntegralCast:
601 case CK_BooleanToSignedIntegral:
602 case CK_IntegralToBoolean:
603 case CK_IntegralToFloating:
604 case CK_FloatingToIntegral:
605 case CK_FloatingToBoolean:
606 case CK_FloatingCast:
607 case CK_CPointerToObjCPointerCast:
608 case CK_BlockPointerToObjCPointerCast:
609 case CK_AnyPointerToBlockPointerCast:
610 case CK_ObjCObjectLValueCast:
611 case CK_FloatingComplexToReal:
612 case CK_FloatingComplexToBoolean:
613 case CK_IntegralComplexToReal:
614 case CK_IntegralComplexToBoolean:
615 case CK_ARCProduceObject:
616 case CK_ARCConsumeObject:
617 case CK_ARCReclaimReturnedObject:
618 case CK_ARCExtendBlockObject:
619 case CK_CopyAndAutoreleaseBlockObject:
620 case CK_BuiltinFnToFnPtr:
621 case CK_ZeroToOCLOpaqueType:
622 case CK_AddressSpaceConversion:
623 case CK_IntToOCLSampler:
624 case CK_FloatingToFixedPoint:
625 case CK_FixedPointToFloating:
626 case CK_FixedPointCast:
627 case CK_FixedPointToBoolean:
628 case CK_FixedPointToIntegral:
629 case CK_IntegralToFixedPoint:
631 case CK_HLSLVectorTruncation:
632 case CK_HLSLMatrixTruncation:
633 case CK_HLSLArrayRValue:
634 case CK_HLSLElementwiseCast:
635 case CK_HLSLAggregateSplatCast:
636 llvm_unreachable(
"invalid cast kind for complex value");
638 case CK_FloatingRealToComplex:
639 case CK_IntegralRealToComplex: {
645 case CK_FloatingComplexCast:
646 case CK_FloatingComplexToIntegralComplex:
647 case CK_IntegralComplexCast:
648 case CK_IntegralComplexToFloatingComplex: {
650 return EmitComplexToComplexCast(Visit(Op), Op->
getType(), DestTy,
655 llvm_unreachable(
"unknown cast resulting in complex value");
658ComplexPairTy ComplexExprEmitter::VisitUnaryPlus(
const UnaryOperator *E,
659 QualType PromotionType) {
660 QualType promotionTy =
667 if (!promotionTy.
isNull())
672ComplexPairTy ComplexExprEmitter::VisitPlus(
const UnaryOperator *E,
673 QualType PromotionType) {
674 TestAndClearIgnoreReal();
675 TestAndClearIgnoreImag();
676 if (!PromotionType.
isNull())
681ComplexPairTy ComplexExprEmitter::VisitUnaryMinus(
const UnaryOperator *E,
682 QualType PromotionType) {
683 QualType promotionTy =
690 if (!promotionTy.
isNull())
694ComplexPairTy ComplexExprEmitter::VisitMinus(
const UnaryOperator *E,
695 QualType PromotionType) {
696 TestAndClearIgnoreReal();
697 TestAndClearIgnoreImag();
699 if (!PromotionType.
isNull())
704 llvm::Value *ResR, *ResI;
705 if (Op.first->getType()->isFloatingPointTy()) {
706 ResR = Builder.CreateFNeg(Op.first,
"neg.r");
707 ResI = Builder.CreateFNeg(Op.second,
"neg.i");
709 ResR = Builder.CreateNeg(Op.first,
"neg.r");
710 ResI = Builder.CreateNeg(Op.second,
"neg.i");
715ComplexPairTy ComplexExprEmitter::VisitUnaryNot(
const UnaryOperator *E) {
716 TestAndClearIgnoreReal();
717 TestAndClearIgnoreImag();
721 if (Op.second->getType()->isFloatingPointTy())
722 ResI = Builder.CreateFNeg(Op.second,
"conj.i");
724 ResI = Builder.CreateNeg(Op.second,
"conj.i");
729ComplexPairTy ComplexExprEmitter::EmitBinAdd(
const BinOpInfo &Op) {
730 llvm::Value *ResR, *ResI;
732 if (Op.LHS.first->getType()->isFloatingPointTy()) {
734 ResR = Builder.CreateFAdd(Op.LHS.first, Op.RHS.first,
"add.r");
735 if (Op.LHS.second && Op.RHS.second)
736 ResI = Builder.CreateFAdd(Op.LHS.second, Op.RHS.second,
"add.i");
738 ResI = Op.LHS.second ? Op.LHS.second : Op.RHS.second;
739 assert(ResI &&
"Only one operand may be real!");
741 ResR = Builder.CreateAdd(Op.LHS.first, Op.RHS.first,
"add.r");
742 assert(Op.LHS.second && Op.RHS.second &&
743 "Both operands of integer complex operators must be complex!");
744 ResI = Builder.CreateAdd(Op.LHS.second, Op.RHS.second,
"add.i");
749ComplexPairTy ComplexExprEmitter::EmitBinSub(
const BinOpInfo &Op) {
750 llvm::Value *ResR, *ResI;
751 if (Op.LHS.first->getType()->isFloatingPointTy()) {
753 ResR = Builder.CreateFSub(Op.LHS.first, Op.RHS.first,
"sub.r");
754 if (Op.LHS.second && Op.RHS.second)
755 ResI = Builder.CreateFSub(Op.LHS.second, Op.RHS.second,
"sub.i");
757 ResI = Op.LHS.second ? Op.LHS.second
758 : Builder.CreateFNeg(Op.RHS.second,
"sub.i");
759 assert(ResI &&
"Only one operand may be real!");
761 ResR = Builder.CreateSub(Op.LHS.first, Op.RHS.first,
"sub.r");
762 assert(Op.LHS.second && Op.RHS.second &&
763 "Both operands of integer complex operators must be complex!");
764 ResI = Builder.CreateSub(Op.LHS.second, Op.RHS.second,
"sub.i");
770ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
771 const BinOpInfo &Op) {
774 Op.Ty->castAs<ComplexType>()->getElementType());
776 Op.Ty->castAs<ComplexType>()->getElementType());
778 Op.Ty->castAs<ComplexType>()->getElementType());
780 Op.Ty->castAs<ComplexType>()->getElementType());
788 FunctionProtoType::ExtProtoInfo EPI;
791 SmallVector<QualType, 4> ArgsQTys(
792 4, Op.Ty->castAs<ComplexType>()->getElementType());
800 FTy, LibCallName, llvm::AttributeList(),
true);
803 llvm::CallBase *
Call;
813 switch (Ty->getTypeID()) {
815 llvm_unreachable(
"Unsupported floating point type!");
816 case llvm::Type::HalfTyID:
818 case llvm::Type::FloatTyID:
820 case llvm::Type::DoubleTyID:
822 case llvm::Type::PPC_FP128TyID:
824 case llvm::Type::X86_FP80TyID:
826 case llvm::Type::FP128TyID:
827 return T.isPPC() ?
"__mulkc3" :
"__multc3";
833ComplexPairTy ComplexExprEmitter::EmitBinMul(
const BinOpInfo &Op) {
838 if (Op.LHS.first->getType()->isFloatingPointTy()) {
846 if (Op.LHS.second && Op.RHS.second) {
857 Value *AC = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul_ac");
858 Value *BD = Builder.CreateFMul(Op.LHS.second, Op.RHS.second,
"mul_bd");
859 Value *AD = Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul_ad");
860 Value *BC = Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul_bc");
864 ResR = Builder.CreateFSub(AC, BD,
"mul_r");
865 ResI = Builder.CreateFAdd(AD, BC,
"mul_i");
874 Value *IsRNaN = Builder.CreateFCmpUNO(ResR, ResR,
"isnan_cmp");
877 llvm::Instruction *Branch = Builder.CreateCondBr(IsRNaN, INaNBB, ContBB);
878 llvm::BasicBlock *OrigBB = Branch->getParent();
881 llvm::MDNode *BrWeight = MDHelper.createUnlikelyBranchWeights();
882 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
886 Value *IsINaN = Builder.CreateFCmpUNO(ResI, ResI,
"isnan_cmp");
888 Branch = Builder.CreateCondBr(IsINaN, LibCallBB, ContBB);
889 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
893 Value *LibCallR, *LibCallI;
895 std::tie(LibCallR, LibCallI) = EmitComplexBinOpLibCall(
897 Builder.CreateBr(ContBB);
902 llvm::PHINode *RealPHI =
903 Builder.CreatePHI(ResR->
getType(), 3,
"real_mul_phi");
904 RealPHI->addIncoming(ResR, OrigBB);
905 RealPHI->addIncoming(ResR, INaNBB);
906 RealPHI->addIncoming(LibCallR, LibCallBB);
907 llvm::PHINode *ImagPHI =
908 Builder.CreatePHI(ResI->
getType(), 3,
"imag_mul_phi");
909 ImagPHI->addIncoming(ResI, OrigBB);
910 ImagPHI->addIncoming(ResI, INaNBB);
911 ImagPHI->addIncoming(LibCallI, LibCallBB);
914 assert((Op.LHS.second || Op.RHS.second) &&
915 "At least one operand must be complex!");
920 ResR = Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
923 ? Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul.il")
924 : Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
926 assert(Op.LHS.second && Op.RHS.second &&
927 "Both operands of integer complex operators must be complex!");
928 Value *ResRl = Builder.CreateMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
929 Value *ResRr = Builder.CreateMul(Op.LHS.second, Op.RHS.second,
"mul.rr");
930 ResR = Builder.CreateSub(ResRl, ResRr,
"mul.r");
932 Value *ResIl = Builder.CreateMul(Op.LHS.second, Op.RHS.first,
"mul.il");
933 Value *ResIr = Builder.CreateMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
934 ResI = Builder.CreateAdd(ResIl, ResIr,
"mul.i");
939ComplexPairTy ComplexExprEmitter::EmitAlgebraicDiv(llvm::Value *LHSr,
944 llvm::Value *DSTr, *DSTi;
946 llvm::Value *AC = Builder.CreateFMul(LHSr, RHSr);
947 llvm::Value *BD = Builder.CreateFMul(LHSi, RHSi);
948 llvm::Value *ACpBD = Builder.CreateFAdd(AC, BD);
950 llvm::Value *CC = Builder.CreateFMul(RHSr, RHSr);
951 llvm::Value *DD = Builder.CreateFMul(RHSi, RHSi);
952 llvm::Value *CCpDD = Builder.CreateFAdd(CC, DD);
954 llvm::Value *BC = Builder.CreateFMul(LHSi, RHSr);
955 llvm::Value *AD = Builder.CreateFMul(LHSr, RHSi);
956 llvm::Value *BCmAD = Builder.CreateFSub(BC, AD);
958 DSTr = Builder.CreateFDiv(ACpBD, CCpDD);
959 DSTi = Builder.CreateFDiv(BCmAD, CCpDD);
970ComplexPairTy ComplexExprEmitter::EmitRangeReductionDiv(llvm::Value *LHSr,
981 llvm::Value *IsR = Builder.CreateFCmpUGT(FAbsRHSr, FAbsRHSi,
"abs_cmp");
983 llvm::BasicBlock *TrueBB =
985 llvm::BasicBlock *FalseBB =
988 Builder.CreateCondBr(IsR, TrueBB, FalseBB);
996 llvm::Value *DdC = Builder.CreateFDiv(RHSi, RHSr);
998 llvm::Value *RD = Builder.CreateFMul(DdC, RHSi);
999 llvm::Value *CpRD = Builder.CreateFAdd(RHSr, RD);
1001 llvm::Value *T3 = Builder.CreateFMul(LHSi, DdC);
1002 llvm::Value *T4 = Builder.CreateFAdd(LHSr, T3);
1003 llvm::Value *DSTTr = Builder.CreateFDiv(T4, CpRD);
1005 llvm::Value *T5 = Builder.CreateFMul(LHSr, DdC);
1006 llvm::Value *T6 = Builder.CreateFSub(LHSi, T5);
1007 llvm::Value *DSTTi = Builder.CreateFDiv(T6, CpRD);
1008 Builder.CreateBr(ContBB);
1016 llvm::Value *CdD = Builder.CreateFDiv(RHSr, RHSi);
1018 llvm::Value *RC = Builder.CreateFMul(CdD, RHSr);
1019 llvm::Value *DpRC = Builder.CreateFAdd(RHSi, RC);
1021 llvm::Value *T7 = Builder.CreateFMul(LHSr, CdD);
1022 llvm::Value *T8 = Builder.CreateFAdd(T7, LHSi);
1023 llvm::Value *DSTFr = Builder.CreateFDiv(T8, DpRC);
1025 llvm::Value *T9 = Builder.CreateFMul(LHSi, CdD);
1026 llvm::Value *T10 = Builder.CreateFSub(T9, LHSr);
1027 llvm::Value *DSTFi = Builder.CreateFDiv(T10, DpRC);
1028 Builder.CreateBr(ContBB);
1032 llvm::PHINode *VALr = Builder.CreatePHI(DSTTr->getType(), 2);
1033 VALr->addIncoming(DSTTr, TrueBB);
1034 VALr->addIncoming(DSTFr, FalseBB);
1035 llvm::PHINode *VALi = Builder.CreatePHI(DSTTi->getType(), 2);
1036 VALi->addIncoming(DSTTi, TrueBB);
1037 VALi->addIncoming(DSTFi, FalseBB);
1043ComplexPairTy ComplexExprEmitter::EmitBinDiv(
const BinOpInfo &Op) {
1044 llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second;
1045 llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second;
1046 llvm::Value *DSTr, *DSTi;
1047 if (LHSr->getType()->isFloatingPointTy()) {
1050 assert(LHSi &&
"Can have at most one non-complex operand!");
1052 DSTr = Builder.CreateFDiv(LHSr, RHSr);
1053 DSTi = Builder.CreateFDiv(LHSi, RHSr);
1056 llvm::Value *OrigLHSi = LHSi;
1058 LHSi = llvm::Constant::getNullValue(RHSi->getType());
1061 !FPHasBeenPromoted))
1062 return EmitRangeReductionDiv(LHSr, LHSi, RHSr, RHSi);
1065 return EmitAlgebraicDiv(LHSr, LHSi, RHSr, RHSi);
1074 BinOpInfo LibCallOp = Op;
1077 LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType());
1079 switch (LHSr->getType()->getTypeID()) {
1081 llvm_unreachable(
"Unsupported floating point type!");
1082 case llvm::Type::HalfTyID:
1083 return EmitComplexBinOpLibCall(
"__divhc3", LibCallOp);
1084 case llvm::Type::FloatTyID:
1085 return EmitComplexBinOpLibCall(
"__divsc3", LibCallOp);
1086 case llvm::Type::DoubleTyID:
1087 return EmitComplexBinOpLibCall(
"__divdc3", LibCallOp);
1088 case llvm::Type::PPC_FP128TyID:
1089 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
1090 case llvm::Type::X86_FP80TyID:
1091 return EmitComplexBinOpLibCall(
"__divxc3", LibCallOp);
1092 case llvm::Type::FP128TyID:
1093 return EmitComplexBinOpLibCall(
1098 return EmitAlgebraicDiv(LHSr, LHSi, RHSr, RHSi);
1101 assert(Op.LHS.second && Op.RHS.second &&
1102 "Both operands of integer complex operators must be complex!");
1104 llvm::Value *Tmp1 = Builder.CreateMul(LHSr, RHSr);
1105 llvm::Value *Tmp2 = Builder.CreateMul(LHSi, RHSi);
1106 llvm::Value *Tmp3 = Builder.CreateAdd(Tmp1, Tmp2);
1108 llvm::Value *Tmp4 = Builder.CreateMul(RHSr, RHSr);
1109 llvm::Value *Tmp5 = Builder.CreateMul(RHSi, RHSi);
1110 llvm::Value *Tmp6 = Builder.CreateAdd(Tmp4, Tmp5);
1112 llvm::Value *Tmp7 = Builder.CreateMul(LHSi, RHSr);
1113 llvm::Value *Tmp8 = Builder.CreateMul(LHSr, RHSi);
1114 llvm::Value *Tmp9 = Builder.CreateSub(Tmp7, Tmp8);
1116 if (Op.Ty->castAs<ComplexType>()
1118 ->isUnsignedIntegerType()) {
1119 DSTr = Builder.CreateUDiv(Tmp3, Tmp6);
1120 DSTi = Builder.CreateUDiv(Tmp9, Tmp6);
1122 DSTr = Builder.CreateSDiv(Tmp3, Tmp6);
1123 DSTi = Builder.CreateSDiv(Tmp9, Tmp6);
1132 llvm::Type *ComplexElementTy =
1136 Builder.CreateFPTrunc(result.first, ComplexElementTy,
"unpromotion");
1139 Builder.CreateFPTrunc(result.second, ComplexElementTy,
"unpromotion");
1145 llvm::Type *ComplexElementTy =
1148 result.first =
Builder.CreateFPExt(result.first, ComplexElementTy,
"ext");
1150 result.second =
Builder.CreateFPExt(result.second, ComplexElementTy,
"ext");
1158 if (
auto BO = dyn_cast<BinaryOperator>(E)) {
1159 switch (BO->getOpcode()) {
1160#define HANDLE_BINOP(OP) \
1162 return EmitBin##OP(EmitBinOps(BO, PromotionType));
1171 }
else if (
auto UO = dyn_cast<UnaryOperator>(E)) {
1172 switch (UO->getOpcode()) {
1174 return VisitMinus(UO, PromotionType);
1176 return VisitPlus(UO, PromotionType);
1181 auto result = Visit(
const_cast<Expr *
>(E));
1182 if (!PromotionType.
isNull())
1190 return ComplexExprEmitter(*this).EmitPromoted(E, DstTy);
1194ComplexExprEmitter::EmitPromotedComplexOperand(
const Expr *E,
1197 if (!OverallPromotionType.
isNull())
1200 return Visit(
const_cast<Expr *
>(E));
1202 if (!OverallPromotionType.
isNull()) {
1213ComplexExprEmitter::BinOpInfo
1214ComplexExprEmitter::EmitBinOps(
const BinaryOperator *E,
1215 QualType PromotionType) {
1216 TestAndClearIgnoreReal();
1217 TestAndClearIgnoreImag();
1220 Ops.LHS = EmitPromotedComplexOperand(E->
getLHS(), PromotionType);
1221 Ops.RHS = EmitPromotedComplexOperand(E->
getRHS(), PromotionType);
1222 if (!PromotionType.
isNull())
1223 Ops.Ty = PromotionType;
1230LValue ComplexExprEmitter::EmitCompoundAssignLValue(
1231 const CompoundAssignOperator *E,
1233 TestAndClearIgnoreReal();
1234 TestAndClearIgnoreImag();
1241 const bool IsComplexDivisor = E->
getOpcode() == BO_DivAssign &&
1247 QualType PromotionTypeCR;
1251 if (PromotionTypeCR.
isNull())
1253 OpInfo.Ty = PromotionTypeCR;
1254 QualType ComplexElementTy =
1255 OpInfo.Ty->castAs<ComplexType>()->getElementType();
1256 QualType PromotionTypeRHS =
1262 if (!PromotionTypeRHS.
isNull())
1272 if (!PromotionTypeRHS.
isNull()) {
1278 OpInfo.RHS = Visit(E->
getRHS());
1286 QualType PromotionTypeLHS =
1291 if (!PromotionTypeLHS.
isNull())
1293 EmitComplexToComplexCast(LHSVal, LHSTy, PromotionTypeLHS, Loc);
1295 OpInfo.LHS = EmitComplexToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
1301 QualType PromotedComplexElementTy;
1302 if (!PromotionTypeLHS.
isNull()) {
1303 PromotedComplexElementTy =
1308 PromotedComplexElementTy, Loc);
1316 OpInfo.LHS = EmitScalarToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
1326 EmitComplexToComplexCast(
Result, OpInfo.Ty, LHSTy, Loc);
1327 EmitStoreOfComplex(ResVal, LHS,
false);
1330 llvm::Value *ResVal =
1341 const CompoundAssignOperator *E,
1344 LValue LV = EmitCompoundAssignLValue(E,
Func, Val);
1351 if (!LV.isVolatileQualified())
1354 return EmitLoadOfLValue(LV, E->
getExprLoc());
1357LValue ComplexExprEmitter::EmitBinAssignLValue(
const BinaryOperator *E,
1361 "Invalid assignment");
1362 TestAndClearIgnoreReal();
1363 TestAndClearIgnoreImag();
1366 Val = Visit(E->
getRHS());
1372 EmitStoreOfComplex(Val, LHS,
false);
1377ComplexPairTy ComplexExprEmitter::VisitBinAssign(
const BinaryOperator *E) {
1380 LValue LV = EmitBinAssignLValue(E, Val);
1387 if (!LV.isVolatileQualified())
1390 return EmitLoadOfLValue(LV, E->
getExprLoc());
1393ComplexPairTy ComplexExprEmitter::VisitBinComma(
const BinaryOperator *E) {
1395 return Visit(E->
getRHS());
1398ComplexPairTy ComplexExprEmitter::VisitAbstractConditionalOperator(
1399 const AbstractConditionalOperator *E) {
1400 TestAndClearIgnoreReal();
1401 TestAndClearIgnoreImag();
1417 LHSBlock = Builder.GetInsertBlock();
1425 RHSBlock = Builder.GetInsertBlock();
1430 llvm::PHINode *RealPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.r");
1431 RealPN->addIncoming(LHS.first, LHSBlock);
1432 RealPN->addIncoming(RHS.first, RHSBlock);
1435 llvm::PHINode *ImagPN = Builder.CreatePHI(LHS.first->getType(), 2,
"cond.i");
1436 ImagPN->addIncoming(LHS.second, LHSBlock);
1437 ImagPN->addIncoming(RHS.second, RHSBlock);
1442ComplexPairTy ComplexExprEmitter::VisitChooseExpr(ChooseExpr *E) {
1446ComplexPairTy ComplexExprEmitter::VisitInitListExpr(InitListExpr *E) {
1447 bool Ignore = TestAndClearIgnoreReal();
1449 assert(Ignore ==
false &&
"init list ignored");
1450 Ignore = TestAndClearIgnoreImag();
1452 assert(Ignore ==
false &&
"init list ignored");
1463 assert(E->
getNumInits() == 0 &&
"Unexpected number of inits");
1464 QualType Ty = E->
getType()->
castAs<ComplexType>()->getElementType();
1466 llvm::Value *zeroConstant = llvm::Constant::getNullValue(LTy);
1470ComplexPairTy ComplexExprEmitter::VisitVAArgExpr(VAArgExpr *E) {
1478 llvm::Value *U = llvm::PoisonValue::get(EltTy);
1494 "Invalid complex expression to emit");
1496 return ComplexExprEmitter(*
this, IgnoreReal, IgnoreImag)
1497 .Visit(
const_cast<Expr *
>(E));
1503 "Invalid complex expression to emit");
1504 ComplexExprEmitter
Emitter(*
this);
1506 Emitter.EmitStoreOfComplex(Val, dest, isInit);
1512 ComplexExprEmitter(*this).EmitStoreOfComplex(
V, dest, isInit);
1518 return ComplexExprEmitter(*this).EmitLoadOfLValue(src, loc);
1524 LValue LVal = ComplexExprEmitter(*this).EmitBinAssignLValue(E, Val);
1526 CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(*
this,
1532 const ComplexExprEmitter::BinOpInfo &);
1537 return &ComplexExprEmitter::EmitBinMul;
1539 return &ComplexExprEmitter::EmitBinDiv;
1541 return &ComplexExprEmitter::EmitBinSub;
1543 return &ComplexExprEmitter::EmitBinAdd;
1545 llvm_unreachable(
"unexpected complex compound assignment");
1554 return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1563 LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
static StringRef getComplexMultiplyLibCallName(const llvm::Triple &T, llvm::Type *Ty)
Lookup the libcall name for a given floating point type complex multiply.
static const ComplexType * getComplexType(QualType type)
Return the complex type that we are meant to emit.
CodeGenFunction::ComplexPairTy ComplexPairTy
static llvm::Value * EmitllvmFAbs(CodeGenFunction &CGF, llvm::Value *Value)
static CompoundFunc getComplexOp(BinaryOperatorKind op)
static const ComplexType * getComplexType(QualType type)
Return the complex type that we are meant to emit.
mlir::Value(ComplexExprEmitter::*)(const ComplexExprEmitter::BinOpInfo &) CompoundFunc
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
const QualType GetHigherPrecisionFPType(QualType ElementType) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
const TargetInfo & getTargetInfo() const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
A builtin binary operation expression such as "x + y" or "x <= y".
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
SourceLocation getExprLoc() const
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Get the FP features status of this operator.
Expr * getExpr()
Get the initialization expression that will be used.
A rewritten comparison expression that was originally written using operator syntax.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
CastKind getCastKind() const
bool changesVolatileQualification() const
Return.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::StringRef getName() const
Return the IR name of the pointer value.
A scoped helper to set the current source atom group for CGDebugInfo::addInstToCurrentSourceAtom.
All available information about a concrete callee.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
CGFunctionInfo - Class to encapsulate the information about a function definition.
CallArgList - Type for representing both the value and type of arguments in a call.
void add(RValue rvalue, QualType type)
An object to manage conditionally-evaluated expressions.
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
An RAII object to record that we're evaluating a statement expression.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount, Stmt::Likelihood LH=Stmt::LH_None, const Expr *ConditionalOp=nullptr, const VarDecl *ConditionalDecl=nullptr)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
ComplexPairTy EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
@ UseSkipPath
Skip (false)
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
llvm::Type * ConvertType(QualType T)
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
RValue EmitVAArg(VAArgExpr *VE, Address &VAListAddr, AggValueSlot Slot=AggValueSlot::ignored())
Generate code to get an argument from the passed in pointer and update it accordingly.
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void addInstToCurrentSourceAtom(llvm::Instruction *KeyInstruction, llvm::Value *Backup)
See CGDebugInfo::addInstToCurrentSourceAtom.
llvm::Value * EmitPromotedScalarExpr(const Expr *E, QualType PromotionType)
const LangOptions & getLangOpts() const
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
ComplexPairTy EmitPromotedComplexExpr(const Expr *E, QualType PromotionType)
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
const TargetInfo & getTarget() const
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue=ReturnValueSlot(), llvm::CallBase **CallOrInvoke=nullptr)
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
llvm::Value * EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified complex type to the specified destination type,...
Address emitAddrOfImagComponent(Address complex, QualType complexType)
RValue EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
RValue getOrCreateOpaqueRValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its RValue mapping if it exists, otherwise create one.
RValue EmitAtomicLoad(LValue LV, SourceLocation SL, AggValueSlot Slot=AggValueSlot::ignored())
CGDebugInfo * getDebugInfo()
LValue getOrCreateOpaqueLValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its LValue mapping if it exists, otherwise create one.
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type,...
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **CallOrInvoke, bool IsMustTail, SourceLocation Loc, bool IsVirtualFunctionPointerThunk=false)
EmitCall - Generate a call of the given function, expecting the given result type,...
ASTContext & getContext() const
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
EmitCompoundStmt - Emit a compound statement {..} node.
LValue EmitComplexAssignmentLValue(const BinaryOperator *E)
Emit an l-value for an assignment (simple or compound) of complex type.
llvm::Type * ConvertTypeForMem(QualType T)
RValue EmitAtomicExpr(AtomicExpr *E)
RValue EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block,...
bool LValueIsSuitableForInlineAtomic(LValue Src)
An LValue is a candidate for having its loads and stores be made atomic if we are operating under /vo...
Address emitAddrOfRealComponent(Address complex, QualType complexType)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
const FunctionDecl * getCurrentFunctionDecl() const
ComplexPairTy EmitUnPromotedValue(ComplexPairTy result, QualType PromotionType)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit)
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
ConstantEmission tryEmitAsConstant(const DeclRefExpr *RefExpr)
Try to emit a reference to the given value without producing it as an l-value.
LValue EmitLValue(const Expr *E, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
llvm::LLVMContext & getLLVMContext()
ComplexPairTy EmitPromotedValue(ComplexPairTy result, QualType PromotionType)
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
llvm::Value * EmitScalarConversion(llvm::Value *Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified type to the specified destination type, both of which are LLVM s...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
llvm::FunctionCallee CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false, bool AssumeConvergent=false)
Create or return a runtime function declaration with the specified type and name.
CodeGenTypes & getTypes()
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, TBAAAccessInfo TBAAInfo)
DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType)
getTBAAInfoForSubobject - Get TBAA information for an access with a given base lvalue.
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall, const FunctionDecl *ABIInfoFD)
Figure out the rules for calling a function with the given formal type using the given arguments.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
LValue - This represents an lvalue references.
bool isVolatileQualified() const
Address getAddress() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
static RValue get(llvm::Value *V)
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
Complex values, per C99 6.2.5p11.
QualType getElementType() const
CompoundAssignOperator - For compound assignments (e.g.
QualType getComputationLHSType() const
QualType getComputationResultType() const
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
const Expr * getSubExpr() const
const Expr * getSubExpr() const
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
@ CX_Full
Implementation of complex division and multiplication using a call to runtime library functions(gener...
@ CX_Basic
Implementation of complex division and multiplication using algebraic formulas at source precision.
@ CX_Promoted
Implementation of complex division using algebraic formulas at higher precision.
@ CX_Improved
Implementation of complex division offering an improved handling for overflow in intermediate calcula...
SourceLocation getExprLoc() const LLVM_READONLY
Expr * getSelectedExpr() const
const Expr * getSubExpr() const
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool UseExcessPrecision(const ASTContext &Ctx)
QualType getAtomicUnqualifiedType() const
Remove all qualifiers including _Atomic.
Encodes a location in the source.
CompoundStmt * getSubStmt()
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
Expr * getReplacement() const
virtual bool hasLongDoubleType() const
Determine whether the long double type is supported on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isAnyComplexType() const
bool isAtomicType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAs() const
Member-template getAs<specific type>'.
Expr * getSubExpr() const
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ComplexType > complexType
bool GE(InterpState &S, CodePtr OpPC)
Top level wrappers for InstallAPI frontend operations.
@ Result
The result type of a method or function.
const FunctionProtoType * T
CastKind
CastKind - The kind of operation required for a conversion.
U cast(CodeGen::Address addr)
@ EST_BasicNoexcept
noexcept
llvm::CallingConv::ID getRuntimeCC() const
static TBAAAccessInfo getMayAliasInfo()
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI)