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");
384 void VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *e) {
385 ASTContext &ctx = cgf.getContext();
386 CIRGenBuilderTy builder = cgf.getBuilder();
387 mlir::Location loc = cgf.getLoc(e->
getExprLoc());
389 LValue array = cgf.emitLValue(e->
getSubExpr());
390 assert(array.isSimple() &&
"initializer_list array not a simple lvalue");
391 Address arrayPtr = array.getAddress();
395 assert(
arrayType &&
"std::initializer_list constructed from non-array");
399 assert(field != record->field_end() &&
400 ctx.
hasSameType(field->getType()->getPointeeType(),
402 "Expected std::initializer_list first field to be const E *");
405 AggValueSlot dest = ensureSlot(loc, e->
getType());
406 LValue destLV = cgf.makeAddrLValue(dest.getAddress(), e->
getType());
408 cgf.emitLValueForFieldInitialization(destLV, *field, field->getName());
411 cgf.emitStoreThroughLValue(
RValue::get(arrayStart), start);
413 assert(field != record->field_end() &&
414 "Expected std::initializer_list to have two fields");
418 cgf.emitLValueForFieldInitialization(destLV, *field, field->getName());
421 cgf.emitStoreThroughLValue(
RValue::get(size), endOrLength);
424 "Aggregate VisitCXXStdInitializerListExpr: field type != sizeTy");
428 assert(++field == record->field_end() &&
429 "Expected std::initializer_list to only have two fields");
432 void VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *e) {
434 "AggExprEmitter: VisitCXXScalarValueInitExpr");
436 void VisitCXXTypeidExpr(CXXTypeidExpr *e) { emitAggLoadOfLValue(e); }
437 void VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *e) {
440 void VisitOpaqueValueExpr(OpaqueValueExpr *e) {
442 "AggExprEmitter: VisitOpaqueValueExpr");
445 void VisitPseudoObjectExpr(PseudoObjectExpr *e) {
447 "AggExprEmitter: VisitPseudoObjectExpr");
450 void VisitVAArgExpr(VAArgExpr *e) {
453 mlir::Value vaArgValue = cgf.emitVAArg(e);
457 Address tmpAddr = cgf.createMemTemp(e->
getType(), loc,
"vaarg.tmp");
460 cgf.emitAggregateStore(vaArgValue, tmpAddr);
463 LValue tmpLValue = cgf.makeAddrLValue(tmpAddr, e->
getType());
466 emitFinalDestCopy(e->
getType(), tmpLValue);
469 void VisitCXXThrowExpr(
const CXXThrowExpr *e) {
470 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCXXThrowExpr");
472 void VisitAtomicExpr(AtomicExpr *e) {
473 RValue result = cgf.emitAtomicExpr(e);
474 emitFinalDestCopy(e->
getType(), result);
487 if (
auto *ile = dyn_cast<InitListExpr>(e)) {
488 if (ile->getNumInits())
493 if (
const auto *cons = dyn_cast_or_null<CXXConstructExpr>(e))
494 return cons->getConstructor()->isDefaultConstructor() &&
495 cons->getConstructor()->isTrivial();
502void AggExprEmitter::emitAggLoadOfLValue(
const Expr *e) {
508 emitFinalDestCopy(e->
getType(), lv);
511void AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *e) {
515 emitAggLoadOfLValue(e);
536void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
537 QualType arrayQTy, Expr *e,
538 ArrayRef<Expr *> args, Expr *arrayFiller) {
542 const uint64_t numInitElements = args.size();
544 const QualType elementType =
548 cgf.
cgm.
errorNYI(loc,
"initialized array requires destruction");
554 const mlir::Type cirElementType = cgf.
convertType(elementType);
555 const cir::PointerType cirElementPtrType =
558 auto begin = cir::CastOp::create(builder, loc, cirElementPtrType,
559 cir::CastKind::array_to_ptrdecay,
562 const CharUnits elementSize =
564 const CharUnits elementAlign =
572 mlir::Value element = begin;
579 for (uint64_t i = 0; i != numInitElements; ++i) {
586 const Address address = Address(element, cirElementType, elementAlign);
587 const LValue elementLV = cgf.
makeAddrLValue(address, elementType);
588 emitInitializationToLValue(args[i], elementLV);
591 const uint64_t numArrayElements = arrayTy.getSize();
599 if (numInitElements != numArrayElements &&
600 !(dest.
isZeroed() && hasTrivialFiller &&
603 if (numInitElements) {
605 element = cir::PtrStrideOp::create(builder, loc, cirElementPtrType,
617 cir::ConstantOp numArrayElementsConst = builder.
getConstInt(
618 loc, mlir::cast<cir::IntType>(cgf.
ptrDiffTy), numArrayElements);
619 mlir::Value end = cir::PtrStrideOp::create(builder, loc, cirElementPtrType,
620 begin, numArrayElementsConst);
625 [&](mlir::OpBuilder &
b, mlir::Location loc) {
626 cir::LoadOp currentElement = builder.
createLoad(loc, tmpAddr);
627 cir::CmpOp cmp = cir::CmpOp::create(builder, loc, cir::CmpOpKind::ne,
628 currentElement, end);
632 [&](mlir::OpBuilder &
b, mlir::Location loc) {
633 cir::LoadOp currentElement = builder.
createLoad(loc, tmpAddr);
639 Address(currentElement, cirElementType, elementAlign),
642 emitInitializationToLValue(arrayFiller, elementLV);
644 emitNullInitializationToLValue(loc, elementLV);
648 cgf.
cgm.
errorNYI(loc,
"update destructed array element for EH");
654 loc, mlir::cast<cir::IntType>(cgf.
ptrDiffTy), 1);
655 auto nextElement = cir::PtrStrideOp::create(
656 builder, loc, cirElementPtrType, currentElement, one);
665void AggExprEmitter::emitFinalDestCopy(QualType
type, RValue src) {
666 assert(src.
isAggregate() &&
"value must be aggregate value!");
672void AggExprEmitter::emitFinalDestCopy(
673 QualType
type,
const LValue &src,
684 cgf.
cgm.
errorNYI(
"emitFinalDestCopy: EVK_RValue & PCK_Struct");
688 cgf.
cgm.
errorNYI(
"emitFinalDestCopy: !EVK_RValue & PCK_Struct");
699 emitCopy(
type, dest, srcAgg);
706void AggExprEmitter::emitCopy(QualType
type,
const AggValueSlot &dest,
707 const AggValueSlot &src) {
720void AggExprEmitter::emitInitializationToLValue(Expr *e, LValue lv) {
721 const QualType
type = lv.getType();
727 return emitNullInitializationToLValue(loc, lv);
733 if (
type->isReferenceType()) {
758void AggExprEmitter::VisitCXXConstructExpr(
const CXXConstructExpr *e) {
763void AggExprEmitter::emitNullInitializationToLValue(mlir::Location loc,
765 const QualType
type = lv.getType();
790void AggExprEmitter::VisitLambdaExpr(
LambdaExpr *e) {
793 [[maybe_unused]] LValue slotLV =
800 for (
auto [curField, capture, captureInit] : llvm::zip(
803 llvm::StringRef fieldName = curField->getName();
804 if (capture.capturesVariable()) {
805 assert(!curField->isBitField() &&
"lambdas don't have bitfield members!");
806 ValueDecl *v = capture.getCapturedVar();
809 }
else if (capture.capturesThis()) {
819 if (curField->hasCapturedVLAType())
822 emitInitializationToLValue(captureInit, lv);
826 curField->getType().isDestructedType())
831void AggExprEmitter::VisitExprWithCleanups(ExprWithCleanups *e) {
832 CIRGenFunction::RunCleanupsScope cleanups(cgf);
835 mlir::OpBuilder::InsertPoint scopeBegin;
843 cir::ScopeOp::create(builder, scopeLoc,
844 [&](mlir::OpBuilder &
b, mlir::Location loc) {
845 scopeBegin =
b.saveInsertionPoint();
849 mlir::OpBuilder::InsertionGuard guard(builder);
850 builder.restoreInsertionPoint(scopeBegin);
851 CIRGenFunction::LexicalScope lexScope{cgf, scopeLoc,
852 builder.getInsertionBlock()};
857void AggExprEmitter::VisitCallExpr(
const CallExpr *e) {
864 e, [&](ReturnValueSlot slot) {
return cgf.
emitCallExpr(e, slot); });
867void AggExprEmitter::withReturnValueSlot(
868 const Expr *e, llvm::function_ref<RValue(ReturnValueSlot)> fn) {
872 bool requiresDestruction =
874 if (requiresDestruction)
877 "withReturnValueSlot: return value requiring destruction is NYI");
892 fn(ReturnValueSlot(retAddr));
895void AggExprEmitter::VisitInitListExpr(InitListExpr *e) {
897 llvm_unreachable(
"GNU array range designator extension");
902 visitCXXParenListOrInitListExpr(
906void AggExprEmitter::visitCXXParenListOrInitListExpr(
907 Expr *e, ArrayRef<Expr *> args, FieldDecl *initializedFieldInUnion,
911 const AggValueSlot dest = ensureSlot(loc, e->
getType());
914 cir::ArrayType arrayTy =
921 "visitCXXParenListOrInitListExpr variable array type");
927 "visitCXXParenListOrInitListExpr array type");
937 unsigned numInitElements = args.size();
944 unsigned curInitIndex = 0;
947 if (
auto *cxxrd = dyn_cast<CXXRecordDecl>(record)) {
948 assert(numInitElements >= cxxrd->getNumBases() &&
949 "missing initializer for base class");
950 for (
auto &base : cxxrd->bases()) {
951 assert(!base.isVirtual() &&
"should not see vbases here");
952 CXXRecordDecl *baseRD = base.getType()->getAsCXXRecordDecl();
962 if (base.getType().isDestructedType()) {
964 "push deferred deactivation cleanup");
971 CIRGenFunction::FieldConstructionScope fcScope(cgf, dest.
getAddress());
975 if (record->isUnion()) {
977 "visitCXXParenListOrInitListExpr union type");
983 for (
const FieldDecl *field : record->fields()) {
985 if (field->getType()->isIncompleteArrayType())
989 if (field->isUnnamedBitField())
995 if (curInitIndex == numInitElements && dest.
isZeroed() &&
1003 if (curInitIndex < numInitElements) {
1005 CIRGenFunction::SourceLocRAIIObject loc{
1006 cgf, cgf.
getLoc(record->getSourceRange())};
1007 emitInitializationToLValue(args[curInitIndex++], lv);
1016 if (field->getType().isDestructedType()) {
1018 "visitCXXParenListOrInitListExpr destructor");
1042 getContext().getASTRecordLayout(baseRD).getSize() <=
1051 AggExprEmitter(*
this, slot).Visit(
const_cast<Expr *
>(e));
1066 assert((record->hasTrivialCopyConstructor() ||
1067 record->hasTrivialCopyAssignment() ||
1068 record->hasTrivialMoveConstructor() ||
1069 record->hasTrivialMoveAssignment() ||
1070 record->hasAttr<TrivialABIAttr>() || record->isUnion()) &&
1071 "Trying to aggregate-copy a type without a trivial copy/move "
1072 "constructor or assignment operator");
1074 if (record->isEmpty())
1097 typeInfo =
getContext().getTypeInfoDataSizeInChars(ty);
1099 typeInfo =
getContext().getTypeInfoInChars(ty);
1109 cgm.errorNYI(
"emitAggregateCopy: GC");
1111 [[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.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
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.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
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
mlir::Value emitRawPointer() const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
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
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
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() 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.
const AstTypeMatcher< ArrayType > arrayType
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