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> {
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!");
114 return CGF.EmitCoawaitExpr(*S).getComplexVal();
117 return CGF.EmitCoyieldExpr(*S).getComplexVal();
127 if (result.isReference())
128 return EmitLoadOfLValue(result.getReferenceLValue(CGF, E),
131 llvm::Constant *pair = result.getValue();
133 pair->getAggregateElement(1U));
135 return EmitLoadOfLValue(E);
138 return EmitLoadOfLValue(E);
141 return CGF.EmitObjCMessageExpr(E).getComplexVal();
147 return EmitLoadOfLValue(CGF.getOpaqueLValueMapping(E), E->
getExprLoc());
148 return CGF.getOpaqueRValueMapping(E).getComplexVal();
152 return CGF.EmitPseudoObjectRValue(E).getComplexVal();
164 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
165 CGF.CGM.EmitExplicitCastExprType(ECE, &CGF);
173 bool isInc,
bool isPre) {
175 return CGF.EmitComplexPrePostIncDec(E, LV, isInc, isPre);
178 return VisitPrePostIncDec(E,
false,
false);
181 return VisitPrePostIncDec(E,
true,
false);
184 return VisitPrePostIncDec(E,
false,
true);
187 return VisitPrePostIncDec(E,
true,
true);
191 TestAndClearIgnoreReal();
192 TestAndClearIgnoreImag();
209 CGF.enterFullExpression(E);
214 Scope.ForceCleanup({&Vals.first, &Vals.second});
220 llvm::Constant *Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem));
226 llvm::Constant *Null =
227 llvm::Constant::getNullValue(CGF.ConvertType(Elem));
244 (
const BinOpInfo &));
252 const BinOpInfo &Op);
255 return EmitBinAdd(EmitBinOps(E));
258 return EmitBinSub(EmitBinOps(E));
261 return EmitBinMul(EmitBinOps(E));
264 return EmitBinDiv(EmitBinOps(E));
269 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinAdd);
272 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinSub);
275 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinMul);
278 return EmitCompoundAssign(E, &ComplexExprEmitter::EmitBinDiv);
299 return EmitLoadOfLValue(E);
305 return CGF.EmitAtomicExpr(E).getComplexVal();
331 assert(lvalue.
isSimple() &&
"non-simple complex l-value?");
333 return CGF.EmitAtomicLoad(lvalue, loc).getComplexVal();
340 if (!IgnoreReal || isVolatile) {
341 Address RealP = CGF.emitAddrOfRealComponent(SrcPtr, lvalue.
getType());
342 Real =
Builder.CreateLoad(RealP, isVolatile, SrcPtr.
getName() +
".real");
345 if (!IgnoreImag || isVolatile) {
346 Address ImagP = CGF.emitAddrOfImagComponent(SrcPtr, lvalue.
getType());
347 Imag =
Builder.CreateLoad(ImagP, isVolatile, SrcPtr.
getName() +
".imag");
358 (!isInit && CGF.LValueIsSuitableForInlineAtomic(lvalue)))
362 Address RealPtr = CGF.emitAddrOfRealComponent(Ptr, lvalue.
getType());
363 Address ImagPtr = CGF.emitAddrOfImagComponent(Ptr, lvalue.
getType());
376 CGF.ErrorUnsupported(E,
"complex expression");
386 return ComplexPairTy(llvm::Constant::getNullValue(Imag->getType()), Imag);
392 return EmitLoadOfLValue(E);
394 return CGF.EmitCallExpr(E).getComplexVal();
400 assert(RetAlloca.
isValid() &&
"Expected complex return value");
401 return EmitLoadOfLValue(CGF.MakeAddrLValue(RetAlloca, E->
getType()),
417 Val.first = CGF.EmitScalarConversion(Val.first, SrcType, DestType, Loc);
418 Val.second = CGF.EmitScalarConversion(Val.second, SrcType, DestType, Loc);
428 Val = CGF.EmitScalarConversion(Val, SrcType, DestType, Loc);
431 return ComplexPairTy(Val, llvm::Constant::getNullValue(Val->getType()));
437 case CK_Dependent: llvm_unreachable(
"dependent cast kind in IR gen!");
441 case CK_AtomicToNonAtomic:
442 case CK_NonAtomicToAtomic:
444 case CK_LValueToRValue:
445 case CK_UserDefinedConversion:
448 case CK_LValueBitCast: {
449 LValue origLV = CGF.EmitLValue(Op);
451 V =
Builder.CreateElementBitCast(V, CGF.ConvertType(DestTy));
452 return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), Op->
getExprLoc());
456 case CK_BaseToDerived:
457 case CK_DerivedToBase:
458 case CK_UncheckedDerivedToBase:
461 case CK_ArrayToPointerDecay:
462 case CK_FunctionToPointerDecay:
463 case CK_NullToPointer:
464 case CK_NullToMemberPointer:
465 case CK_BaseToDerivedMemberPointer:
466 case CK_DerivedToBaseMemberPointer:
467 case CK_MemberPointerToBoolean:
468 case CK_ReinterpretMemberPointer:
469 case CK_ConstructorConversion:
470 case CK_IntegralToPointer:
471 case CK_PointerToIntegral:
472 case CK_PointerToBoolean:
475 case CK_IntegralCast:
476 case CK_BooleanToSignedIntegral:
477 case CK_IntegralToBoolean:
478 case CK_IntegralToFloating:
479 case CK_FloatingToIntegral:
480 case CK_FloatingToBoolean:
481 case CK_FloatingCast:
482 case CK_CPointerToObjCPointerCast:
483 case CK_BlockPointerToObjCPointerCast:
484 case CK_AnyPointerToBlockPointerCast:
485 case CK_ObjCObjectLValueCast:
486 case CK_FloatingComplexToReal:
487 case CK_FloatingComplexToBoolean:
488 case CK_IntegralComplexToReal:
489 case CK_IntegralComplexToBoolean:
490 case CK_ARCProduceObject:
491 case CK_ARCConsumeObject:
492 case CK_ARCReclaimReturnedObject:
493 case CK_ARCExtendBlockObject:
494 case CK_CopyAndAutoreleaseBlockObject:
495 case CK_BuiltinFnToFnPtr:
496 case CK_ZeroToOCLEvent:
497 case CK_ZeroToOCLQueue:
498 case CK_AddressSpaceConversion:
499 case CK_IntToOCLSampler:
500 llvm_unreachable(
"invalid cast kind for complex value");
502 case CK_FloatingRealToComplex:
503 case CK_IntegralRealToComplex:
504 return EmitScalarToComplexCast(CGF.EmitScalarExpr(Op), Op->
getType(),
507 case CK_FloatingComplexCast:
508 case CK_FloatingComplexToIntegralComplex:
509 case CK_IntegralComplexCast:
510 case CK_IntegralComplexToFloatingComplex:
511 return EmitComplexToComplexCast(Visit(Op), Op->
getType(), DestTy,
515 llvm_unreachable(
"unknown cast resulting in complex value");
519 TestAndClearIgnoreReal();
520 TestAndClearIgnoreImag();
524 if (Op.first->getType()->isFloatingPointTy()) {
525 ResR =
Builder.CreateFNeg(Op.first,
"neg.r");
526 ResI =
Builder.CreateFNeg(Op.second,
"neg.i");
528 ResR =
Builder.CreateNeg(Op.first,
"neg.r");
529 ResI =
Builder.CreateNeg(Op.second,
"neg.i");
535 TestAndClearIgnoreReal();
536 TestAndClearIgnoreImag();
540 if (Op.second->getType()->isFloatingPointTy())
541 ResI =
Builder.CreateFNeg(Op.second,
"conj.i");
543 ResI =
Builder.CreateNeg(Op.second,
"conj.i");
548 ComplexPairTy ComplexExprEmitter::EmitBinAdd(
const BinOpInfo &Op) {
551 if (Op.LHS.first->getType()->isFloatingPointTy()) {
552 ResR =
Builder.CreateFAdd(Op.LHS.first, Op.RHS.first,
"add.r");
553 if (Op.LHS.second && Op.RHS.second)
554 ResI =
Builder.CreateFAdd(Op.LHS.second, Op.RHS.second,
"add.i");
556 ResI = Op.LHS.second ? Op.LHS.second : Op.RHS.second;
557 assert(ResI &&
"Only one operand may be real!");
559 ResR =
Builder.CreateAdd(Op.LHS.first, Op.RHS.first,
"add.r");
560 assert(Op.LHS.second && Op.RHS.second &&
561 "Both operands of integer complex operators must be complex!");
562 ResI =
Builder.CreateAdd(Op.LHS.second, Op.RHS.second,
"add.i");
567 ComplexPairTy ComplexExprEmitter::EmitBinSub(
const BinOpInfo &Op) {
569 if (Op.LHS.first->getType()->isFloatingPointTy()) {
570 ResR =
Builder.CreateFSub(Op.LHS.first, Op.RHS.first,
"sub.r");
571 if (Op.LHS.second && Op.RHS.second)
572 ResI =
Builder.CreateFSub(Op.LHS.second, Op.RHS.second,
"sub.i");
574 ResI = Op.LHS.second ? Op.LHS.second
575 :
Builder.CreateFNeg(Op.RHS.second,
"sub.i");
576 assert(ResI &&
"Only one operand may be real!");
578 ResR =
Builder.CreateSub(Op.LHS.first, Op.RHS.first,
"sub.r");
579 assert(Op.LHS.second && Op.RHS.second &&
580 "Both operands of integer complex operators must be complex!");
581 ResI =
Builder.CreateSub(Op.LHS.second, Op.RHS.second,
"sub.i");
587 ComplexPairTy ComplexExprEmitter::EmitComplexBinOpLibCall(StringRef LibCallName,
588 const BinOpInfo &Op) {
610 QualType FQTy = CGF.getContext().getFunctionType(Op.Ty, ArgsQTys, EPI);
611 const CGFunctionInfo &FuncInfo = CGF.CGM.getTypes().arrangeFreeFunctionCall(
612 Args, cast<FunctionType>(FQTy.getTypePtr()),
false);
614 llvm::FunctionType *FTy = CGF.CGM.getTypes().GetFunctionType(FuncInfo);
615 llvm::Constant *Func = CGF.CGM.CreateBuiltinFunction(FTy, LibCallName);
618 llvm::Instruction *
Call;
620 cast<llvm::CallInst>(Call)->setCallingConv(CGF.CGM.getBuiltinCC());
627 switch (Ty->getTypeID()) {
629 llvm_unreachable(
"Unsupported floating point type!");
630 case llvm::Type::HalfTyID:
632 case llvm::Type::FloatTyID:
634 case llvm::Type::DoubleTyID:
636 case llvm::Type::PPC_FP128TyID:
638 case llvm::Type::X86_FP80TyID:
640 case llvm::Type::FP128TyID:
647 ComplexPairTy ComplexExprEmitter::EmitBinMul(
const BinOpInfo &Op) {
650 llvm::MDBuilder MDHelper(CGF.getLLVMContext());
652 if (Op.LHS.first->getType()->isFloatingPointTy()) {
661 if (Op.LHS.second && Op.RHS.second) {
672 Value *AC =
Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul_ac");
673 Value *BD =
Builder.CreateFMul(Op.LHS.second, Op.RHS.second,
"mul_bd");
674 Value *AD =
Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul_ad");
675 Value *BC =
Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul_bc");
679 ResR =
Builder.CreateFSub(AC, BD,
"mul_r");
680 ResI =
Builder.CreateFAdd(AD, BC,
"mul_i");
684 Value *IsRNaN =
Builder.CreateFCmpUNO(ResR, ResR,
"isnan_cmp");
685 llvm::BasicBlock *ContBB = CGF.createBasicBlock(
"complex_mul_cont");
686 llvm::BasicBlock *INaNBB = CGF.createBasicBlock(
"complex_mul_imag_nan");
687 llvm::Instruction *Branch =
Builder.CreateCondBr(IsRNaN, INaNBB, ContBB);
688 llvm::BasicBlock *OrigBB = Branch->getParent();
692 llvm::MDNode *BrWeight = MDHelper.createBranchWeights(1, (1U << 20) - 1);
693 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
696 CGF.EmitBlock(INaNBB);
697 Value *IsINaN =
Builder.CreateFCmpUNO(ResI, ResI,
"isnan_cmp");
698 llvm::BasicBlock *LibCallBB = CGF.createBasicBlock(
"complex_mul_libcall");
699 Branch =
Builder.CreateCondBr(IsINaN, LibCallBB, ContBB);
700 Branch->setMetadata(llvm::LLVMContext::MD_prof, BrWeight);
703 CGF.EmitBlock(LibCallBB);
704 Value *LibCallR, *LibCallI;
705 std::tie(LibCallR, LibCallI) = EmitComplexBinOpLibCall(
711 CGF.EmitBlock(ContBB);
712 llvm::PHINode *RealPHI =
Builder.CreatePHI(ResR->getType(), 3,
"real_mul_phi");
713 RealPHI->addIncoming(ResR, OrigBB);
714 RealPHI->addIncoming(ResR, INaNBB);
715 RealPHI->addIncoming(LibCallR, LibCallBB);
716 llvm::PHINode *ImagPHI =
Builder.CreatePHI(ResI->getType(), 3,
"imag_mul_phi");
717 ImagPHI->addIncoming(ResI, OrigBB);
718 ImagPHI->addIncoming(ResI, INaNBB);
719 ImagPHI->addIncoming(LibCallI, LibCallBB);
722 assert((Op.LHS.second || Op.RHS.second) &&
723 "At least one operand must be complex!");
728 ResR =
Builder.CreateFMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
731 ?
Builder.CreateFMul(Op.LHS.second, Op.RHS.first,
"mul.il")
732 :
Builder.CreateFMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
734 assert(Op.LHS.second && Op.RHS.second &&
735 "Both operands of integer complex operators must be complex!");
736 Value *ResRl =
Builder.CreateMul(Op.LHS.first, Op.RHS.first,
"mul.rl");
737 Value *ResRr =
Builder.CreateMul(Op.LHS.second, Op.RHS.second,
"mul.rr");
738 ResR =
Builder.CreateSub(ResRl, ResRr,
"mul.r");
740 Value *ResIl =
Builder.CreateMul(Op.LHS.second, Op.RHS.first,
"mul.il");
741 Value *ResIr =
Builder.CreateMul(Op.LHS.first, Op.RHS.second,
"mul.ir");
742 ResI =
Builder.CreateAdd(ResIl, ResIr,
"mul.i");
749 ComplexPairTy ComplexExprEmitter::EmitBinDiv(
const BinOpInfo &Op) {
750 llvm::Value *LHSr = Op.LHS.first, *LHSi = Op.LHS.second;
751 llvm::Value *RHSr = Op.RHS.first, *RHSi = Op.RHS.second;
755 if (LHSr->getType()->isFloatingPointTy()) {
762 BinOpInfo LibCallOp = Op;
765 LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType());
767 StringRef LibCallName;
768 switch (LHSr->getType()->getTypeID()) {
770 llvm_unreachable(
"Unsupported floating point type!");
771 case llvm::Type::HalfTyID:
772 return EmitComplexBinOpLibCall(
"__divhc3", LibCallOp);
773 case llvm::Type::FloatTyID:
774 return EmitComplexBinOpLibCall(
"__divsc3", LibCallOp);
775 case llvm::Type::DoubleTyID:
776 return EmitComplexBinOpLibCall(
"__divdc3", LibCallOp);
777 case llvm::Type::PPC_FP128TyID:
778 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
779 case llvm::Type::X86_FP80TyID:
780 return EmitComplexBinOpLibCall(
"__divxc3", LibCallOp);
781 case llvm::Type::FP128TyID:
782 return EmitComplexBinOpLibCall(
"__divtc3", LibCallOp);
785 assert(LHSi &&
"Can have at most one non-complex operand!");
787 DSTr =
Builder.CreateFDiv(LHSr, RHSr);
788 DSTi =
Builder.CreateFDiv(LHSi, RHSr);
790 assert(Op.LHS.second && Op.RHS.second &&
791 "Both operands of integer complex operators must be complex!");
806 DSTr =
Builder.CreateUDiv(Tmp3, Tmp6);
807 DSTi =
Builder.CreateUDiv(Tmp9, Tmp6);
809 DSTr =
Builder.CreateSDiv(Tmp3, Tmp6);
810 DSTi =
Builder.CreateSDiv(Tmp9, Tmp6);
817 ComplexExprEmitter::BinOpInfo
819 TestAndClearIgnoreReal();
820 TestAndClearIgnoreImag();
825 Ops.LHS = Visit(E->
getLHS());
829 Ops.RHS = Visit(E->
getRHS());
836 LValue ComplexExprEmitter::
840 TestAndClearIgnoreReal();
841 TestAndClearIgnoreImag();
844 LHSTy = AT->getValueType();
852 QualType ComplexElementTy = cast<ComplexType>(OpInfo.Ty)->getElementType();
858 .hasSameUnqualifiedType(ComplexElementTy, E->
getRHS()->
getType()));
861 assert(CGF.getContext()
863 OpInfo.RHS = Visit(E->
getRHS());
872 OpInfo.LHS = EmitComplexToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
874 llvm::Value *LHSVal = CGF.EmitLoadOfScalar(LHS, Loc);
878 if (!CGF.getContext().hasSameUnqualifiedType(ComplexElementTy, LHSTy))
879 LHSVal = CGF.EmitScalarConversion(LHSVal, LHSTy, ComplexElementTy, Loc);
882 OpInfo.LHS = EmitScalarToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
892 EmitComplexToComplexCast(Result, OpInfo.Ty, LHSTy, Loc);
893 EmitStoreOfComplex(ResVal, LHS,
false);
897 CGF.EmitComplexToScalarConversion(Result, OpInfo.Ty, LHSTy, Loc);
898 CGF.EmitStoreOfScalar(ResVal, LHS,
false);
908 ComplexPairTy (ComplexExprEmitter::*Func)(
const BinOpInfo&)){
910 LValue LV = EmitCompoundAssignLValue(E, Func, Val);
913 if (!CGF.getLangOpts().CPlusPlus)
925 assert(CGF.getContext().hasSameUnqualifiedType(E->
getLHS()->
getType(),
927 "Invalid assignment");
928 TestAndClearIgnoreReal();
929 TestAndClearIgnoreImag();
938 EmitStoreOfComplex(Val, LHS,
false);
945 LValue LV = EmitBinAssignLValue(E, Val);
948 if (!CGF.getLangOpts().CPlusPlus)
959 CGF.EmitIgnoredExpr(E->
getLHS());
960 return Visit(E->
getRHS());
965 TestAndClearIgnoreReal();
966 TestAndClearIgnoreImag();
967 llvm::BasicBlock *LHSBlock = CGF.createBasicBlock(
"cond.true");
968 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock(
"cond.false");
969 llvm::BasicBlock *ContBlock = CGF.createBasicBlock(
"cond.end");
976 CGF.EmitBranchOnBoolExpr(E->
getCond(), LHSBlock, RHSBlock,
977 CGF.getProfileCount(E));
980 CGF.EmitBlock(LHSBlock);
981 CGF.incrementProfileCounter(E);
983 LHSBlock =
Builder.GetInsertBlock();
984 CGF.EmitBranch(ContBlock);
988 CGF.EmitBlock(RHSBlock);
990 RHSBlock =
Builder.GetInsertBlock();
991 CGF.EmitBlock(ContBlock);
995 llvm::PHINode *RealPN =
Builder.CreatePHI(LHS.first->getType(), 2,
"cond.r");
996 RealPN->addIncoming(LHS.first, LHSBlock);
997 RealPN->addIncoming(RHS.first, RHSBlock);
1000 llvm::PHINode *ImagPN =
Builder.CreatePHI(LHS.first->getType(), 2,
"cond.i");
1001 ImagPN->addIncoming(LHS.second, LHSBlock);
1002 ImagPN->addIncoming(RHS.second, RHSBlock);
1012 bool Ignore = TestAndClearIgnoreReal();
1014 assert (Ignore ==
false &&
"init list ignored");
1015 Ignore = TestAndClearIgnoreImag();
1017 assert (Ignore ==
false &&
"init list ignored");
1028 assert(E->
getNumInits() == 0 &&
"Unexpected number of inits");
1031 llvm::Value* zeroConstant = llvm::Constant::getNullValue(LTy);
1037 Address ArgPtr = CGF.EmitVAArg(E, ArgValue);
1040 CGF.ErrorUnsupported(E,
"complex va_arg expression");
1047 return EmitLoadOfLValue(CGF.MakeAddrLValue(ArgPtr, E->
getType()),
1060 "Invalid complex expression to emit");
1062 return ComplexExprEmitter(*
this, IgnoreReal, IgnoreImag)
1063 .Visit(const_cast<Expr *>(E));
1069 "Invalid complex expression to emit");
1070 ComplexExprEmitter Emitter(*
this);
1072 Emitter.EmitStoreOfComplex(Val, dest, isInit);
1078 ComplexExprEmitter(*this).EmitStoreOfComplex(V, dest, isInit);
1084 return ComplexExprEmitter(*this).EmitLoadOfLValue(src, loc);
1090 return ComplexExprEmitter(*this).EmitBinAssignLValue(E, Val);
1094 const ComplexExprEmitter::BinOpInfo &);
1098 case BO_MulAssign:
return &ComplexExprEmitter::EmitBinMul;
1099 case BO_DivAssign:
return &ComplexExprEmitter::EmitBinDiv;
1100 case BO_SubAssign:
return &ComplexExprEmitter::EmitBinSub;
1101 case BO_AddAssign:
return &ComplexExprEmitter::EmitBinAdd;
1103 llvm_unreachable(
"unexpected complex compound assignment");
1111 return ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1119 LValue Ret = ComplexExprEmitter(*this).EmitCompoundAssignLValue(E, Op, Val);
1120 Result = Val.getScalarVal();
ReturnValueSlot - Contains the address where the return value of a function can be stored...
unsigned getNumInits() const
CastKind getCastKind() const
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
A (possibly-)qualified type.
CompoundStmt * getSubStmt()
Stmt - This represents one statement.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
Address getAddress() const
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.
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.
CompoundLiteralExpr - [C99 6.5.2.5].
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 en...
Address emitAddrOfImagComponent(Address complex, QualType complexType)
An object to manage conditionally-evaluated expressions.
LValue EmitScalarCompoundAssignWithComplex(const CompoundAssignOperator *E, llvm::Value *&Result)
bool isVolatileQualified() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
Describes an C or C++ initializer list.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
Address emitAddrOfRealComponent(Address complex, QualType complexType)
Expr * getTrueExpr() const
CharUnits - This is an opaque type for sizes expressed in character units.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
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...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
detail::InMemoryDirectory::const_iterator I
A default argument (C++ [dcl.fct.default]).
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...
const Expr * getExpr() const
Get the initialization expression that will be used.
Represents a call to the builtin function __builtin_va_arg.
bool isRealFloatingType() const
Floating point categories.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Expr - This represents one expression.
bool isAnyComplexType() const
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
bool isAtomicType() const
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &O)
void add(RValue rvalue, QualType type, bool needscopy=false)
An RAII object to record that we're evaluating a statement expression.
void dump() const
Dumps the specified AST fragment and all subtrees to llvm::errs().
Expr * getSubExpr() const
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.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
QualType getComputationResultType() const
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...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ASTContext & getContext() const
Encodes a location in the source.
QualType getElementType() 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>.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
const T * castAs() const
Member-template castAs<specific type>.
All available information about a concrete callee.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
llvm::StringRef getName() const
Return the IR name of the pointer value.
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.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
Expr * getReplacement() const
CGFunctionInfo - Class to encapsulate the information about a function definition.
SourceLocation getExprLoc() const LLVM_READONLY
static CompoundFunc getComplexOp(BinaryOperatorKind Op)
const Expr * getExpr() const
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
CodeGenFunction::ComplexPairTy ComplexPairTy
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
Represents a 'co_yield' expression.
detail::InMemoryDirectory::const_iterator E
Complex values, per C99 6.2.5p11.
const T * getAs() const
Member-template getAs<specific type>'.
Expr * getFalseExpr() const
QualType getCanonicalType() const
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.
Represents a 'co_await' expression.
const Expr * getSubExpr() const
ComplexPairTy(ComplexExprEmitter::* CompoundFunc)(const ComplexExprEmitter::BinOpInfo &)
SourceLocation getExprLoc() const LLVM_READONLY
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.
const Expr * getSubExpr() const
BoundNodesTreeBuilder *const Builder
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
const Expr * getInit(unsigned Init) const
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.