16#include "mlir/IR/Builders.h"
37 if (
const DeclRefExpr *dre = dyn_cast<DeclRefExpr>(e)) {
38 const VarDecl *
var = dyn_cast<VarDecl>(dre->getDecl());
39 return (var &&
var->hasAttr<BlocksAttr>());
48 if (op->isAssignmentOp() || op->isPtrMemOp())
52 if (op->getOpcode() == BO_Comma)
60 dyn_cast<AbstractConditionalOperator>(e)) {
66 if (
const Expr *src = op->getSourceExpr())
73 }
else if (
const CastExpr *
cast = dyn_cast<CastExpr>(e)) {
74 if (
cast->getCastKind() == CK_LValueToRValue)
80 }
else if (
const UnaryOperator *uop = dyn_cast<UnaryOperator>(e)) {
84 }
else if (
const MemberExpr *mem = dyn_cast<MemberExpr>(e)) {
95class AggExprEmitter :
public StmtVisitor<AggExprEmitter> {
106 void withReturnValueSlot(
const Expr *e,
107 llvm::function_ref<RValue(ReturnValueSlot)> fn);
109 AggValueSlot ensureSlot(mlir::Location loc, QualType t) {
110 if (!dest.isIgnored())
112 return cgf.createAggTemp(t, loc,
"agg.tmp.ensured");
115 void ensureDest(mlir::Location loc, QualType ty) {
116 if (!dest.isIgnored())
118 dest = cgf.createAggTemp(ty, loc,
"agg.tmp.ensured");
122 AggExprEmitter(CIRGenFunction &cgf, AggValueSlot dest)
123 : cgf(cgf), dest(dest) {}
128 void emitAggLoadOfLValue(
const Expr *e);
130 void emitArrayInit(Address destPtr, cir::ArrayType arrayTy, QualType arrayQTy,
131 Expr *exprToVisit, ArrayRef<Expr *> args,
134 void emitFinalDestCopy(QualType
type, RValue src);
137 void emitFinalDestCopy(QualType
type,
const LValue &src,
141 void emitCopy(QualType
type,
const AggValueSlot &dest,
142 const AggValueSlot &src);
144 void emitInitializationToLValue(Expr *e, LValue lv);
146 void emitNullInitializationToLValue(mlir::Location loc, LValue lv);
148 void Visit(Expr *e) { StmtVisitor<AggExprEmitter>::Visit(e); }
150 void VisitArraySubscriptExpr(ArraySubscriptExpr *e) {
151 emitAggLoadOfLValue(e);
154 void VisitCallExpr(
const CallExpr *e);
155 void VisitStmtExpr(
const StmtExpr *e) {
156 CIRGenFunction::StmtExprEvaluation eval(cgf);
159 (void)cgf.emitCompoundStmt(*e->
getSubStmt(), &retAlloca, dest);
162 void VisitBinAssign(
const BinaryOperator *e) {
165 assert(cgf.getContext().hasSameUnqualifiedType(e->
getLHS()->
getType(),
167 "Invalid assignment");
172 "block var reference with side effects");
176 LValue lhs = cgf.emitLValue(e->
getLHS());
192 cgf.emitAggExpr(e->
getRHS(), lhsSlot);
195 emitFinalDestCopy(e->
getType(), lhs);
197 if (!dest.isIgnored() && !dest.isExternallyDestructed() &&
203 void VisitDeclRefExpr(DeclRefExpr *e) { emitAggLoadOfLValue(e); }
205 void VisitInitListExpr(InitListExpr *e);
206 void VisitCXXConstructExpr(
const CXXConstructExpr *e);
208 void visitCXXParenListOrInitListExpr(Expr *e, ArrayRef<Expr *> args,
209 FieldDecl *initializedFieldInUnion,
211 void VisitCXXDefaultInitExpr(CXXDefaultInitExpr *die) {
212 CIRGenFunction::CXXDefaultInitExprScope Scope(cgf, die);
215 void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *e) {
218 bool wasExternallyDestructed = dest.isExternallyDestructed();
222 dest.setExternallyDestructed();
227 if (!wasExternallyDestructed)
231 void VisitExprWithCleanups(ExprWithCleanups *e);
236 case CK_LValueToRValueBitCast: {
237 if (dest.isIgnored()) {
243 LValue sourceLV = cgf.emitLValue(e->
getSubExpr());
244 Address sourceAddress =
245 sourceLV.getAddress().withElementType(cgf.getBuilder(), cgf.voidTy);
246 Address destAddress =
247 dest.getAddress().withElementType(cgf.getBuilder(), cgf.voidTy);
249 mlir::Location loc = cgf.getLoc(e->
getExprLoc());
251 mlir::Value sizeVal = cgf.getBuilder().getConstInt(
253 cgf.getContext().getTypeSizeInChars(e->
getType()).getQuantity());
254 cgf.getBuilder().createMemCpy(loc, destAddress.
getPointer(),
259 case CK_LValueToRValue:
264 "AggExprEmitter: volatile lvalue-to-rvalue cast");
267 case CK_UserDefinedConversion:
268 case CK_ConstructorConversion:
271 "Implicit cast types must be compatible");
276 std::string(
"AggExprEmitter: VisitCastExpr: ") +
281 void VisitStmt(Stmt *
s) {
282 cgf.cgm.errorNYI(
s->getSourceRange(),
283 std::string(
"AggExprEmitter::VisitStmt: ") +
284 s->getStmtClassName());
286 void VisitParenExpr(ParenExpr *pe) { Visit(pe->
getSubExpr()); }
287 void VisitGenericSelectionExpr(GenericSelectionExpr *ge) {
290 void VisitCoawaitExpr(CoawaitExpr *e) {
291 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCoawaitExpr");
293 void VisitCoyieldExpr(CoyieldExpr *e) {
294 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCoyieldExpr");
296 void VisitUnaryCoawait(UnaryOperator *e) {
297 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitUnaryCoawait");
299 void VisitUnaryExtension(UnaryOperator *e) { Visit(e->
getSubExpr()); }
300 void VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *e) {
302 "AggExprEmitter: VisitSubstNonTypeTemplateParmExpr");
304 void VisitConstantExpr(ConstantExpr *e) {
305 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitConstantExpr");
307 void VisitMemberExpr(MemberExpr *e) { emitAggLoadOfLValue(e); }
308 void VisitUnaryDeref(UnaryOperator *e) { emitAggLoadOfLValue(e); }
309 void VisitStringLiteral(StringLiteral *e) { emitAggLoadOfLValue(e); }
310 void VisitCompoundLiteralExpr(CompoundLiteralExpr *e);
312 void VisitPredefinedExpr(
const PredefinedExpr *e) {
314 "AggExprEmitter: VisitPredefinedExpr");
316 void VisitBinaryOperator(
const BinaryOperator *e) {
318 "AggExprEmitter: VisitBinaryOperator");
320 void VisitPointerToDataMemberBinaryOperator(
const BinaryOperator *e) {
322 "AggExprEmitter: VisitPointerToDataMemberBinaryOperator");
324 void VisitBinComma(
const BinaryOperator *e) {
325 cgf.emitIgnoredExpr(e->
getLHS());
328 void VisitBinCmp(
const BinaryOperator *e) {
329 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitBinCmp");
331 void VisitCXXRewrittenBinaryOperator(CXXRewrittenBinaryOperator *e) {
333 "AggExprEmitter: VisitCXXRewrittenBinaryOperator");
335 void VisitObjCMessageExpr(ObjCMessageExpr *e) {
337 "AggExprEmitter: VisitObjCMessageExpr");
339 void VisitObjCIVarRefExpr(ObjCIvarRefExpr *e) {
341 "AggExprEmitter: VisitObjCIVarRefExpr");
344 void VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *e) {
346 LValue destLV = cgf.makeAddrLValue(dest.getAddress(), e->
getType());
347 emitInitializationToLValue(e->
getBase(), destLV);
350 void VisitAbstractConditionalOperator(
const AbstractConditionalOperator *e) {
352 "AggExprEmitter: VisitAbstractConditionalOperator");
355 void VisitCXXParenListInitExpr(CXXParenListInitExpr *e) {
361 void VisitArrayInitLoopExpr(
const ArrayInitLoopExpr *e,
362 llvm::Value *outerBegin =
nullptr) {
364 "AggExprEmitter: VisitArrayInitLoopExpr");
366 void VisitImplicitValueInitExpr(ImplicitValueInitExpr *e) {
368 "AggExprEmitter: VisitImplicitValueInitExpr");
370 void VisitNoInitExpr(NoInitExpr *e) {
371 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitNoInitExpr");
373 void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *dae) {
374 CIRGenFunction::CXXDefaultArgExprScope scope(cgf, dae);
377 void VisitCXXInheritedCtorInitExpr(
const CXXInheritedCtorInitExpr *e) {
379 "AggExprEmitter: VisitCXXInheritedCtorInitExpr");
381 void VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *e) {
383 "AggExprEmitter: VisitCXXStdInitializerListExpr");
385 void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *e) {
387 "AggExprEmitter: VisitCXXScalarValueInitExpr");
389 void VisitCXXTypeidExpr(CXXTypeidExpr *e) {
390 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCXXTypeidExpr");
392 void VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *e) {
395 void VisitOpaqueValueExpr(OpaqueValueExpr *e) {
397 "AggExprEmitter: VisitOpaqueValueExpr");
400 void VisitPseudoObjectExpr(PseudoObjectExpr *e) {
402 "AggExprEmitter: VisitPseudoObjectExpr");
405 void VisitVAArgExpr(VAArgExpr *e) {
408 mlir::Value vaArgValue = cgf.emitVAArg(e);
412 Address tmpAddr = cgf.createMemTemp(e->
getType(), loc,
"vaarg.tmp");
415 cgf.emitAggregateStore(vaArgValue, tmpAddr);
418 LValue tmpLValue = cgf.makeAddrLValue(tmpAddr, e->
getType());
421 emitFinalDestCopy(e->
getType(), tmpLValue);
424 void VisitCXXThrowExpr(
const CXXThrowExpr *e) {
425 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCXXThrowExpr");
427 void VisitAtomicExpr(AtomicExpr *e) {
428 RValue result = cgf.emitAtomicExpr(e);
429 emitFinalDestCopy(e->
getType(), result);
442 if (
auto *ile = dyn_cast<InitListExpr>(e)) {
443 if (ile->getNumInits())
448 if (
const auto *cons = dyn_cast_or_null<CXXConstructExpr>(e))
449 return cons->getConstructor()->isDefaultConstructor() &&
450 cons->getConstructor()->isTrivial();
457void AggExprEmitter::emitAggLoadOfLValue(
const Expr *e) {
463 emitFinalDestCopy(e->
getType(), lv);
466void AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *e) {
470 emitAggLoadOfLValue(e);
491void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
492 QualType arrayQTy, Expr *e,
493 ArrayRef<Expr *> args, Expr *arrayFiller) {
497 const uint64_t numInitElements = args.size();
499 const QualType elementType =
503 cgf.
cgm.
errorNYI(loc,
"initialized array requires destruction");
509 const mlir::Type cirElementType = cgf.
convertType(elementType);
510 const cir::PointerType cirElementPtrType =
513 auto begin = cir::CastOp::create(builder, loc, cirElementPtrType,
514 cir::CastKind::array_to_ptrdecay,
517 const CharUnits elementSize =
519 const CharUnits elementAlign =
527 mlir::Value element = begin;
534 for (uint64_t i = 0; i != numInitElements; ++i) {
541 const Address address = Address(element, cirElementType, elementAlign);
542 const LValue elementLV = cgf.
makeAddrLValue(address, elementType);
543 emitInitializationToLValue(args[i], elementLV);
546 const uint64_t numArrayElements = arrayTy.getSize();
554 if (numInitElements != numArrayElements &&
555 !(dest.
isZeroed() && hasTrivialFiller &&
558 if (numInitElements) {
560 element = cir::PtrStrideOp::create(builder, loc, cirElementPtrType,
572 cir::ConstantOp numArrayElementsConst = builder.
getConstInt(
573 loc, mlir::cast<cir::IntType>(cgf.
ptrDiffTy), numArrayElements);
574 mlir::Value end = cir::PtrStrideOp::create(builder, loc, cirElementPtrType,
575 begin, numArrayElementsConst);
580 [&](mlir::OpBuilder &
b, mlir::Location loc) {
581 cir::LoadOp currentElement = builder.
createLoad(loc, tmpAddr);
582 cir::CmpOp cmp = cir::CmpOp::create(builder, loc, cir::CmpOpKind::ne,
583 currentElement, end);
587 [&](mlir::OpBuilder &
b, mlir::Location loc) {
588 cir::LoadOp currentElement = builder.
createLoad(loc, tmpAddr);
594 Address(currentElement, cirElementType, elementAlign),
597 emitInitializationToLValue(arrayFiller, elementLV);
599 emitNullInitializationToLValue(loc, elementLV);
603 cgf.
cgm.
errorNYI(loc,
"update destructed array element for EH");
609 loc, mlir::cast<cir::IntType>(cgf.
ptrDiffTy), 1);
610 auto nextElement = cir::PtrStrideOp::create(
611 builder, loc, cirElementPtrType, currentElement, one);
620void AggExprEmitter::emitFinalDestCopy(QualType
type, RValue src) {
621 assert(src.
isAggregate() &&
"value must be aggregate value!");
627void AggExprEmitter::emitFinalDestCopy(
628 QualType
type,
const LValue &src,
639 cgf.
cgm.
errorNYI(
"emitFinalDestCopy: EVK_RValue & PCK_Struct");
643 cgf.
cgm.
errorNYI(
"emitFinalDestCopy: !EVK_RValue & PCK_Struct");
654 emitCopy(
type, dest, srcAgg);
661void AggExprEmitter::emitCopy(QualType
type,
const AggValueSlot &dest,
662 const AggValueSlot &src) {
675void AggExprEmitter::emitInitializationToLValue(Expr *e, LValue lv) {
676 const QualType
type = lv.getType();
682 return emitNullInitializationToLValue(loc, lv);
688 if (
type->isReferenceType()) {
713void AggExprEmitter::VisitCXXConstructExpr(
const CXXConstructExpr *e) {
718void AggExprEmitter::emitNullInitializationToLValue(mlir::Location loc,
720 const QualType
type = lv.getType();
745void AggExprEmitter::VisitLambdaExpr(
LambdaExpr *e) {
748 [[maybe_unused]] LValue slotLV =
755 for (
auto [curField, capture, captureInit] : llvm::zip(
758 llvm::StringRef fieldName = curField->getName();
759 if (capture.capturesVariable()) {
760 assert(!curField->isBitField() &&
"lambdas don't have bitfield members!");
761 ValueDecl *v = capture.getCapturedVar();
764 }
else if (capture.capturesThis()) {
774 if (curField->hasCapturedVLAType())
777 emitInitializationToLValue(captureInit, lv);
781 curField->getType().isDestructedType())
786void AggExprEmitter::VisitExprWithCleanups(ExprWithCleanups *e) {
787 CIRGenFunction::RunCleanupsScope cleanups(cgf);
790 mlir::OpBuilder::InsertPoint scopeBegin;
798 cir::ScopeOp::create(builder, scopeLoc,
799 [&](mlir::OpBuilder &
b, mlir::Location loc) {
800 scopeBegin =
b.saveInsertionPoint();
804 mlir::OpBuilder::InsertionGuard guard(builder);
805 builder.restoreInsertionPoint(scopeBegin);
806 CIRGenFunction::LexicalScope lexScope{cgf, scopeLoc,
807 builder.getInsertionBlock()};
812void AggExprEmitter::VisitCallExpr(
const CallExpr *e) {
819 e, [&](ReturnValueSlot slot) {
return cgf.
emitCallExpr(e, slot); });
822void AggExprEmitter::withReturnValueSlot(
823 const Expr *e, llvm::function_ref<RValue(ReturnValueSlot)> fn) {
827 bool requiresDestruction =
829 if (requiresDestruction)
832 "withReturnValueSlot: return value requiring destruction is NYI");
847 fn(ReturnValueSlot(retAddr));
850void AggExprEmitter::VisitInitListExpr(InitListExpr *e) {
852 llvm_unreachable(
"GNU array range designator extension");
857 visitCXXParenListOrInitListExpr(
861void AggExprEmitter::visitCXXParenListOrInitListExpr(
862 Expr *e, ArrayRef<Expr *> args, FieldDecl *initializedFieldInUnion,
866 const AggValueSlot dest = ensureSlot(loc, e->
getType());
869 cir::ArrayType arrayTy =
876 "visitCXXParenListOrInitListExpr variable array type");
882 "visitCXXParenListOrInitListExpr array type");
892 unsigned numInitElements = args.size();
899 unsigned curInitIndex = 0;
902 if (
auto *cxxrd = dyn_cast<CXXRecordDecl>(record)) {
903 assert(numInitElements >= cxxrd->getNumBases() &&
904 "missing initializer for base class");
905 for (
auto &base : cxxrd->bases()) {
906 assert(!base.isVirtual() &&
"should not see vbases here");
907 CXXRecordDecl *baseRD = base.getType()->getAsCXXRecordDecl();
917 if (base.getType().isDestructedType()) {
919 "push deferred deactivation cleanup");
926 CIRGenFunction::FieldConstructionScope fcScope(cgf, dest.
getAddress());
930 if (record->isUnion()) {
932 "visitCXXParenListOrInitListExpr union type");
938 for (
const FieldDecl *field : record->fields()) {
940 if (field->getType()->isIncompleteArrayType())
944 if (field->isUnnamedBitField())
950 if (curInitIndex == numInitElements && dest.
isZeroed() &&
958 if (curInitIndex < numInitElements) {
960 CIRGenFunction::SourceLocRAIIObject loc{
961 cgf, cgf.
getLoc(record->getSourceRange())};
962 emitInitializationToLValue(args[curInitIndex++], lv);
971 if (field->getType().isDestructedType()) {
973 "visitCXXParenListOrInitListExpr destructor");
997 getContext().getASTRecordLayout(baseRD).getSize() <=
1006 AggExprEmitter(*
this, slot).Visit(
const_cast<Expr *
>(e));
1021 assert((record->hasTrivialCopyConstructor() ||
1022 record->hasTrivialCopyAssignment() ||
1023 record->hasTrivialMoveConstructor() ||
1024 record->hasTrivialMoveAssignment() ||
1025 record->hasAttr<TrivialABIAttr>() || record->isUnion()) &&
1026 "Trying to aggregate-copy a type without a trivial copy/move "
1027 "constructor or assignment operator");
1029 if (record->isEmpty())
1052 typeInfo =
getContext().getTypeInfoDataSizeInChars(ty);
1054 typeInfo =
getContext().getTypeInfoInChars(ty);
1064 cgm.errorNYI(
"emitAggregateCopy: GC");
1066 [[maybe_unused]] cir::CopyOp copyOp =
static bool isBlockVarRef(const Expr *E)
Is the value of the given expression possibly a reference to or into a __block variable?
static bool isTrivialFiller(Expr *e)
__device__ __2f16 float __ockl_bool s
cir::ConditionOp createCondition(mlir::Value condition)
Create a loop condition.
cir::PtrStrideOp createPtrStride(mlir::Location loc, mlir::Value base, mlir::Value stride)
cir::PointerType getPointerTo(mlir::Type ty)
cir::DoWhileOp createDoWhile(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder)
Create a do-while operation.
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, int64_t value)
cir::YieldOp createYield(mlir::Location loc, mlir::ValueRange value={})
Create a yield operation.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
QualType getElementType() const
A builtin binary operation expression such as "x + y" or "x <= y".
mlir::Value getPointer() const
mlir::Type getElementType() const
clang::CharUnits getAlignment() const
IsZeroed_t isZeroed() const
Overlap_t mayOverlap() const
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
IsDestructed_t isExternallyDestructed() const
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Address getAddress() const
void setExternallyDestructed(bool destructed=true)
static AggValueSlot ignored()
Returns an aggregate value slot indicating that the aggregate value is being ignored.
IsAliased_t isPotentiallyAliased() const
void setVolatile(bool flag)
cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)
cir::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false)
static bool hasScalarEvaluationKind(clang::QualType type)
mlir::Type convertType(clang::QualType t)
static cir::TypeEvaluationKind getEvaluationKind(clang::QualType type)
Return the cir::TypeEvaluationKind of QualType type.
CIRGenTypes & getTypes() const
const clang::LangOptions & getLangOpts() const
cir::AllocaOp createTempAlloca(mlir::Type ty, mlir::Location loc, const Twine &name="tmp", mlir::Value arraySize=nullptr, bool insertIntoFnEntryBlock=false)
This creates an alloca and inserts it into the entry block if ArraySize is nullptr,...
RValue emitCallExpr(const clang::CallExpr *e, ReturnValueSlot returnValue=ReturnValueSlot())
LValue emitLValue(const clang::Expr *e)
Emit code to compute a designator that specifies the location of the expression.
void emitAggregateCopy(LValue dest, LValue src, QualType eltTy, AggValueSlot::Overlap_t mayOverlap, bool isVolatile=false)
Emit an aggregate copy.
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
void emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
AggValueSlot::Overlap_t getOverlapForFieldInit(const FieldDecl *fd)
void emitCXXConstructExpr(const clang::CXXConstructExpr *e, AggValueSlot dest)
LValue emitAggExprToLValue(const Expr *e)
void emitStoreOfScalar(mlir::Value value, Address addr, bool isVolatile, clang::QualType ty, LValueBaseInfo baseInfo, bool isInit=false, bool isNontemporal=false)
static bool hasAggregateEvaluationKind(clang::QualType type)
void emitScalarInit(const clang::Expr *init, mlir::Location loc, LValue lvalue, bool capturedByInit=false)
LValue emitLValueForFieldInitialization(LValue base, const clang::FieldDecl *field, llvm::StringRef fieldName)
Like emitLValueForField, excpet that if the Field is a reference, this will return the address of the...
mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)
Emit the computation of the specified expression of scalar type.
Address getAddressOfDirectBaseInCompleteClass(mlir::Location loc, Address value, const CXXRecordDecl *derived, const CXXRecordDecl *base, bool baseIsVirtual)
Convert the given pointer to a complete class to the given direct base.
CIRGenBuilderTy & getBuilder()
AggValueSlot::Overlap_t getOverlapForBaseInit(const CXXRecordDecl *rd, const CXXRecordDecl *baseRD, bool isVirtual)
Determine whether a base class initialization may overlap some other object.
void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
mlir::Value emitStoreThroughBitfieldLValue(RValue src, LValue dstresult)
std::optional< mlir::Location > currSrcLoc
Use to track source locations across nested visitor traversals.
clang::ASTContext & getContext() const
void emitStoreThroughLValue(RValue src, LValue dst, bool isInit=false)
Store the specified rvalue into the specified lvalue, where both are guaranteed to the have the same ...
Address createMemTemp(QualType t, mlir::Location loc, const Twine &name="tmp", Address *alloca=nullptr, mlir::OpBuilder::InsertPoint ip={})
Create a temporary memory object of the given type, with appropriate alignmen and cast it to the defa...
void emitAggExpr(const clang::Expr *e, AggValueSlot slot)
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
const clang::LangOptions & getLangOpts() const
mlir::Value emitNullConstant(QualType t, mlir::Location loc)
Return the result of value-initializing the given type, i.e.
llvm::DenseMap< const clang::FieldDecl *, llvm::StringRef > lambdaFieldToName
Keep a map between lambda fields and names, this needs to be per module since lambdas might get gener...
bool isZeroInitializable(clang::QualType ty)
Return whether a type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.
Address getAddress() const
Address getAggregateAddress() const
Return the value of the address of the aggregate.
static RValue get(mlir::Value v)
CXXTemporary * getTemporary()
const Expr * getSubExpr() const
Expr * getExpr()
Get the initialization expression that will be used.
MutableArrayRef< Expr * > getInitExprs()
FieldDecl * getInitializedFieldInUnion()
Represents a C++ struct/union/class.
SourceRange getSourceRange() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range of the expression.
SourceRange getSourceRange() const LLVM_READONLY
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
static const char * getCastKindName(CastKind CK)
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
const Expr * getInitializer() const
A reference to a declared variable, function, enum, etc.
InitListExpr * getUpdater() const
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
const Expr * getSubExpr() const
Expr * getResultExpr()
Return the result expression of this controlling expression.
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool hadArrayRangeDesignator() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
const Expr * getInit(unsigned Init) const
ArrayRef< Expr * > inits()
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
capture_range captures() const
Retrieve this lambda's captures.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
const Expr * getSubExpr() const
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
Represents a struct/union/class.
field_range fields() const
CompoundStmt * getSubStmt()
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool isReferenceType() const
bool isVariableArrayType() const
RecordDecl * castAsRecordDecl() const
bool isAnyComplexType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
Represents a variable declaration or definition.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
constexpr Variable var(Literal L)
Returns the variable of L.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)
static bool emitLifetimeMarkers()
static bool aggValueSlotDestructedFlag()
static bool aggValueSlotGC()
static bool aggValueSlotAlias()
static bool opLoadStoreAtomic()
static bool aggEmitFinalDestCopyRValue()
static bool aggValueSlotVolatile()
static bool opScopeCleanupRegion()
static bool atomicTypes()
static bool cudaSupport()
static bool requiresCleanups()
clang::CharUnits getPointerAlign() const