17#include "mlir/IR/Builders.h"
23#include "llvm/IR/Value.h"
39 if (
const DeclRefExpr *dre = dyn_cast<DeclRefExpr>(e)) {
40 const VarDecl *
var = dyn_cast<VarDecl>(dre->getDecl());
41 return (var &&
var->hasAttr<BlocksAttr>());
50 if (op->isAssignmentOp() || op->isPtrMemOp())
54 if (op->getOpcode() == BO_Comma)
62 dyn_cast<AbstractConditionalOperator>(e)) {
68 if (
const Expr *src = op->getSourceExpr())
75 }
else if (
const CastExpr *
cast = dyn_cast<CastExpr>(e)) {
76 if (
cast->getCastKind() == CK_LValueToRValue)
82 }
else if (
const UnaryOperator *uop = dyn_cast<UnaryOperator>(e)) {
86 }
else if (
const MemberExpr *mem = dyn_cast<MemberExpr>(e)) {
97class AggExprEmitter :
public StmtVisitor<AggExprEmitter> {
108 void withReturnValueSlot(
const Expr *e,
109 llvm::function_ref<RValue(ReturnValueSlot)> fn);
111 AggValueSlot ensureSlot(mlir::Location loc, QualType t) {
112 if (!dest.isIgnored())
114 return cgf.createAggTemp(t, loc,
"agg.tmp.ensured");
117 void ensureDest(mlir::Location loc, QualType ty) {
118 if (!dest.isIgnored())
120 dest = cgf.createAggTemp(ty, loc,
"agg.tmp.ensured");
124 AggExprEmitter(CIRGenFunction &cgf, AggValueSlot dest)
125 : cgf(cgf), dest(dest) {}
130 void emitAggLoadOfLValue(
const Expr *e);
132 void emitArrayInit(Address destPtr, cir::ArrayType arrayTy, QualType arrayQTy,
133 Expr *exprToVisit, ArrayRef<Expr *> args,
136 void emitFinalDestCopy(QualType
type, RValue src);
139 void emitFinalDestCopy(QualType
type,
const LValue &src,
143 void emitCopy(QualType
type,
const AggValueSlot &dest,
144 const AggValueSlot &src);
146 void emitInitializationToLValue(Expr *e, LValue lv);
148 void emitNullInitializationToLValue(mlir::Location loc, LValue lv);
150 void Visit(Expr *e) { StmtVisitor<AggExprEmitter>::Visit(e); }
152 void VisitArraySubscriptExpr(ArraySubscriptExpr *e) {
153 emitAggLoadOfLValue(e);
156 void VisitCallExpr(
const CallExpr *e);
157 void VisitStmtExpr(
const StmtExpr *e) {
158 CIRGenFunction::StmtExprEvaluation eval(cgf);
161 (void)cgf.emitCompoundStmt(*e->
getSubStmt(), &retAlloca, dest);
164 void VisitBinAssign(
const BinaryOperator *e) {
167 assert(cgf.getContext().hasSameUnqualifiedType(e->
getLHS()->
getType(),
169 "Invalid assignment");
174 "block var reference with side effects");
178 LValue lhs = cgf.emitLValue(e->
getLHS());
194 cgf.emitAggExpr(e->
getRHS(), lhsSlot);
197 emitFinalDestCopy(e->
getType(), lhs);
199 if (!dest.isIgnored() && !dest.isExternallyDestructed() &&
205 void VisitDeclRefExpr(DeclRefExpr *e) { emitAggLoadOfLValue(e); }
207 void VisitInitListExpr(InitListExpr *e);
208 void VisitCXXConstructExpr(
const CXXConstructExpr *e);
210 void visitCXXParenListOrInitListExpr(Expr *e, ArrayRef<Expr *> args,
211 FieldDecl *initializedFieldInUnion,
213 void VisitCXXDefaultInitExpr(CXXDefaultInitExpr *die) {
214 CIRGenFunction::CXXDefaultInitExprScope Scope(cgf, die);
217 void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *e) {
220 bool wasExternallyDestructed = dest.isExternallyDestructed();
224 dest.setExternallyDestructed();
229 if (!wasExternallyDestructed)
233 void VisitExprWithCleanups(ExprWithCleanups *e);
238 case CK_LValueToRValueBitCast: {
239 if (dest.isIgnored()) {
245 LValue sourceLV = cgf.emitLValue(e->
getSubExpr());
247 sourceLV.getAddress().withElementType(cgf.getBuilder(), cgf.voidTy);
249 dest.getAddress().withElementType(cgf.getBuilder(), cgf.voidTy);
251 mlir::Location loc = cgf.getLoc(e->
getExprLoc());
253 mlir::Value sizeVal = cgf.getBuilder().getConstInt(
255 cgf.getContext().getTypeSizeInChars(e->
getType()).getQuantity());
256 cgf.getBuilder().createMemCpy(loc, destAddress.
getPointer(),
261 case CK_LValueToRValue:
266 "AggExprEmitter: volatile lvalue-to-rvalue cast");
269 case CK_UserDefinedConversion:
270 case CK_ConstructorConversion:
273 "Implicit cast types must be compatible");
277 if (dest.isIgnored()) {
283 Address castPtr = dest.getAddress().withElementType(cgf.getBuilder(),
284 cgf.convertType(ty));
286 cgf.makeAddrLValue(castPtr, ty));
291 std::string(
"AggExprEmitter: VisitCastExpr: ") +
296 void VisitStmt(Stmt *
s) {
297 cgf.cgm.errorNYI(
s->getSourceRange(),
298 std::string(
"AggExprEmitter::VisitStmt: ") +
299 s->getStmtClassName());
301 void VisitParenExpr(ParenExpr *pe) { Visit(pe->
getSubExpr()); }
302 void VisitGenericSelectionExpr(GenericSelectionExpr *ge) {
305 void VisitCoawaitExpr(CoawaitExpr *e) {
306 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCoawaitExpr");
308 void VisitCoyieldExpr(CoyieldExpr *e) {
309 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitCoyieldExpr");
311 void VisitUnaryCoawait(UnaryOperator *e) {
312 cgf.cgm.errorNYI(e->
getSourceRange(),
"AggExprEmitter: VisitUnaryCoawait");
314 void VisitUnaryExtension(UnaryOperator *e) { Visit(e->
getSubExpr()); }
315 void VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *e) {
317 "AggExprEmitter: VisitSubstNonTypeTemplateParmExpr");
319 void VisitConstantExpr(ConstantExpr *e) {
322 if (mlir::Attribute result = ConstantEmitter(cgf).tryEmitConstantExpr(e)) {
323 mlir::Value resultVal = cgf.getBuilder().getConstant(
324 cgf.getLoc(e->
getSourceRange()), mlir::cast<mlir::TypedAttr>(result));
325 LValue destLVal = cgf.makeAddrLValue(dest.getAddress(), e->
getType());
326 cgf.emitStoreThroughLValue(
RValue::get(resultVal), destLVal);
334 void VisitMemberExpr(MemberExpr *e) { emitAggLoadOfLValue(e); }
335 void VisitUnaryDeref(UnaryOperator *e) { emitAggLoadOfLValue(e); }
336 void VisitStringLiteral(StringLiteral *e) { emitAggLoadOfLValue(e); }
337 void VisitCompoundLiteralExpr(CompoundLiteralExpr *e);
339 void VisitPredefinedExpr(
const PredefinedExpr *e) {
341 "AggExprEmitter: VisitPredefinedExpr");
343 void VisitBinaryOperator(
const BinaryOperator *e) {
345 "AggExprEmitter: VisitBinaryOperator");
347 void VisitPointerToDataMemberBinaryOperator(
const BinaryOperator *e) {
349 "AggExprEmitter: VisitPointerToDataMemberBinaryOperator");
351 void VisitBinComma(
const BinaryOperator *e) {
352 cgf.emitIgnoredExpr(e->
getLHS());
355 void VisitBinCmp(
const BinaryOperator *e) {
358 const ComparisonCategoryInfo &cmpInfo =
359 cgf.getContext().CompCategories.getInfoForType(e->
getType());
361 "cannot copy non-trivially copyable aggregate");
368 cgf.cgm.errorNYI(e->
getBeginLoc(),
"aggregate three-way comparison");
371 CIRGenBuilderTy builder = cgf.getBuilder();
374 cgf.cgm.errorNYI(e->
getBeginLoc(),
"VisitBinCmp: complex type");
377 cgf.cgm.errorNYI(e->
getBeginLoc(),
"VisitBinCmp: aggregate type");
379 mlir::Value lhs = cgf.emitAnyExpr(e->
getLHS()).getValue();
380 mlir::Value rhs = cgf.emitAnyExpr(e->
getRHS()).getValue();
382 mlir::Value resultScalar;
391 cir::CmpOrdering ordering = cmpInfo.
isStrong()
392 ? cir::CmpOrdering::Strong
393 : cir::CmpOrdering::Weak;
395 loc, lhs, rhs, ltRes, eqRes, gtRes, ordering);
400 loc, lhs, rhs, ltRes, eqRes, gtRes, unorderedRes);
406 LValue destLVal = cgf.makeAddrLValue(dest.getAddress(), e->
getType());
411 LValue fieldLVal = cgf.emitLValueForFieldInitialization(
412 destLVal, resultField, resultField->
getName());
413 cgf.emitStoreThroughLValue(
RValue::get(resultScalar), fieldLVal);
418 void VisitCXXRewrittenBinaryOperator(CXXRewrittenBinaryOperator *e) {
420 "AggExprEmitter: VisitCXXRewrittenBinaryOperator");
422 void VisitObjCMessageExpr(ObjCMessageExpr *e) {
424 "AggExprEmitter: VisitObjCMessageExpr");
426 void VisitObjCIVarRefExpr(ObjCIvarRefExpr *e) {
428 "AggExprEmitter: VisitObjCIVarRefExpr");
431 void VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *e) {
433 LValue destLV = cgf.makeAddrLValue(dest.getAddress(), e->
getType());
434 emitInitializationToLValue(e->
getBase(), destLV);
437 void VisitAbstractConditionalOperator(
const AbstractConditionalOperator *e) {
440 CIRGenFunction::OpaqueValueMapping binding(cgf, e);
441 CIRGenFunction::ConditionalEvaluation eval(cgf);
444 bool isExternallyDestructed = dest.isExternallyDestructed();
445 bool destructNonTrivialCStruct =
446 !isExternallyDestructed &&
448 isExternallyDestructed |= destructNonTrivialCStruct;
450 cgf.emitIfOnBoolExpr(
453 [&](mlir::OpBuilder &
b, mlir::Location loc) {
454 eval.beginEvaluation();
456 CIRGenFunction::LexicalScope lexScope{cgf, loc,
457 b.getInsertionBlock()};
458 cgf.curLexScope->setAsTernary();
459 dest.setExternallyDestructed(isExternallyDestructed);
460 assert(!cir::MissingFeatures::incrementProfileCounter());
461 Visit(e->getTrueExpr());
462 cir::YieldOp::create(b, loc);
464 eval.endEvaluation();
468 [&](mlir::OpBuilder &
b, mlir::Location loc) {
469 eval.beginEvaluation();
471 CIRGenFunction::LexicalScope lexScope{cgf, loc,
472 b.getInsertionBlock()};
473 cgf.curLexScope->setAsTernary();
479 dest.setExternallyDestructed(isExternallyDestructed);
482 cir::YieldOp::create(
b, loc);
484 eval.endEvaluation();
488 if (destructNonTrivialCStruct)
491 "Abstract conditional aggregate: destructNonTrivialCStruct");
502 uint64_t numElements = e->
getArraySize().getZExtValue();
511 "VisitArrayInitLoopExpr: Non-constant array");
516 emitArrayInit(dest, arrayTy, e->
getType(),
522 "AggExprEmitter: VisitImplicitValueInitExpr");
547 assert(array.isSimple() &&
"initializer_list array not a simple lvalue");
548 Address arrayPtr = array.getAddress();
552 assert(
arrayType &&
"std::initializer_list constructed from non-array");
555 assert(record->getNumFields() == 2 &&
556 "Expected std::initializer_list to only have two fields");
559 assert(field != record->field_end() &&
560 ctx.
hasSameType(field->getType()->getPointeeType(),
562 "Expected std::initializer_list first field to be const E *");
573 assert(field != record->field_end() &&
574 "Expected std::initializer_list to have two fields");
584 assert(field->getType()->isPointerType() &&
585 ctx.
hasSameType(field->getType()->getPointeeType(),
587 "Expected std::initializer_list second field to be const E *");
595 "AggExprEmitter: VisitCXXScalarValueInitExpr");
597 void VisitCXXTypeidExpr(
CXXTypeidExpr *e) { emitAggLoadOfLValue(e); }
603 "AggExprEmitter: VisitOpaqueValueExpr");
608 "AggExprEmitter: VisitPseudoObjectExpr");
614 mlir::Value vaArgValue = cgf.
emitVAArg(e);
627 emitFinalDestCopy(e->
getType(), tmpLValue);
635 emitFinalDestCopy(e->
getType(), result);
648 if (
auto *ile = dyn_cast<InitListExpr>(e)) {
649 if (ile->getNumInits())
654 if (
const auto *cons = dyn_cast_or_null<CXXConstructExpr>(e))
655 return cons->getConstructor()->isDefaultConstructor() &&
656 cons->getConstructor()->isTrivial();
663void AggExprEmitter::emitAggLoadOfLValue(
const Expr *e) {
669 emitFinalDestCopy(e->
getType(), lv);
672void AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *e) {
676 emitAggLoadOfLValue(e);
697void AggExprEmitter::emitArrayInit(Address destPtr, cir::ArrayType arrayTy,
698 QualType arrayQTy, Expr *e,
699 ArrayRef<Expr *> args, Expr *arrayFiller) {
703 const uint64_t numInitElements = args.size();
707 const QualType elementType =
712 const mlir::Type cirElementType = cgf.
convertType(elementType);
713 const cir::PointerType cirElementPtrType =
716 auto begin = cir::CastOp::create(builder, loc, cirElementPtrType,
717 cir::CastKind::array_to_ptrdecay,
720 const CharUnits elementSize =
722 const CharUnits elementAlign =
733 loc,
"arrayinit.endOfInit");
746 mlir::Value element = begin;
753 for (uint64_t i = 0; i != numInitElements; ++i) {
764 const Address address =
Address(element, cirElementType, elementAlign);
765 const LValue elementLV = cgf.
makeAddrLValue(address, elementType);
766 emitInitializationToLValue(args[i], elementLV);
769 const uint64_t numArrayElements = arrayTy.getSize();
777 if (numInitElements != numArrayElements &&
778 !(dest.
isZeroed() && hasTrivialFiller &&
781 if (numInitElements) {
783 element = cir::PtrStrideOp::create(builder, loc, cirElementPtrType,
798 cir::ConstantOp numArrayElementsConst = builder.
getConstInt(
799 loc, mlir::cast<cir::IntType>(cgf.
ptrDiffTy), numArrayElements);
800 mlir::Value end = cir::PtrStrideOp::create(builder, loc, cirElementPtrType,
801 begin, numArrayElementsConst);
806 [&](mlir::OpBuilder &
b, mlir::Location loc) {
807 cir::LoadOp currentElement = builder.
createLoad(loc, tmpAddr);
808 cir::CmpOp cmp = cir::CmpOp::create(builder, loc, cir::CmpOpKind::ne,
809 currentElement, end);
813 [&](mlir::OpBuilder &
b, mlir::Location loc) {
814 cir::LoadOp currentElement = builder.
createLoad(loc, tmpAddr);
818 Address(currentElement, cirElementType, elementAlign),
822 if (setArrayInitLoopExprScope)
823 idx = cir::PtrDiffOp::create(
b, loc, cgf.
ptrDiffTy, currentElement,
826 CIRGenFunction::ArrayInitLoopExprScope loopExprScope(
827 cgf, setArrayInitLoopExprScope, idx);
830 emitInitializationToLValue(arrayFiller, elementLV);
832 emitNullInitializationToLValue(loc, elementLV);
836 loc, mlir::cast<cir::IntType>(cgf.
ptrDiffTy), 1);
837 auto nextElement = cir::PtrStrideOp::create(
838 builder, loc, cirElementPtrType, currentElement, one);
852void AggExprEmitter::emitFinalDestCopy(QualType
type, RValue src) {
853 assert(src.
isAggregate() &&
"value must be aggregate value!");
859void AggExprEmitter::emitFinalDestCopy(
860 QualType
type,
const LValue &src,
871 cgf.
cgm.
errorNYI(
"emitFinalDestCopy: EVK_RValue & PCK_Struct");
875 cgf.
cgm.
errorNYI(
"emitFinalDestCopy: !EVK_RValue & PCK_Struct");
886 emitCopy(
type, dest, srcAgg);
893void AggExprEmitter::emitCopy(QualType
type,
const AggValueSlot &dest,
894 const AggValueSlot &src) {
907void AggExprEmitter::emitInitializationToLValue(Expr *e, LValue lv) {
908 const QualType
type = lv.getType();
914 return emitNullInitializationToLValue(loc, lv);
920 if (
type->isReferenceType()) {
945void AggExprEmitter::VisitCXXConstructExpr(
const CXXConstructExpr *e) {
950void AggExprEmitter::emitNullInitializationToLValue(mlir::Location loc,
952 const QualType
type = lv.getType();
977void AggExprEmitter::VisitLambdaExpr(
LambdaExpr *e) {
984 CIRGenFunction::CleanupDeactivationScope deactivationScope(cgf);
986 for (
auto [curField, capture, captureInit] : llvm::zip(
989 llvm::StringRef fieldName = curField->getName();
990 if (capture.capturesVariable()) {
991 assert(!curField->isBitField() &&
"lambdas don't have bitfield members!");
992 ValueDecl *v = capture.getCapturedVar();
995 }
else if (capture.capturesThis()) {
1005 if (curField->hasCapturedVLAType())
1008 emitInitializationToLValue(captureInit, lv);
1012 curField->getType().isDestructedType()) {
1013 assert(lv.isSimple());
1015 curField->getType(),
1021void AggExprEmitter::VisitExprWithCleanups(ExprWithCleanups *e) {
1022 CIRGenFunction::FullExprCleanupScope fullExprScope(cgf, e->
getSubExpr());
1026void AggExprEmitter::VisitCallExpr(
const CallExpr *e) {
1032 withReturnValueSlot(
1033 e, [&](ReturnValueSlot slot) {
return cgf.
emitCallExpr(e, slot); });
1036void AggExprEmitter::withReturnValueSlot(
1037 const Expr *e, llvm::function_ref<RValue(ReturnValueSlot)> fn) {
1038 QualType retTy = e->
getType();
1041 bool requiresDestruction =
1043 if (requiresDestruction)
1046 "withReturnValueSlot: return value requiring destruction is NYI");
1061 fn(ReturnValueSlot(retAddr));
1064void AggExprEmitter::VisitInitListExpr(InitListExpr *e) {
1066 llvm_unreachable(
"GNU array range designator extension");
1071 visitCXXParenListOrInitListExpr(
1075void AggExprEmitter::visitCXXParenListOrInitListExpr(
1076 Expr *e, ArrayRef<Expr *> args, FieldDecl *initializedFieldInUnion,
1077 Expr *arrayFiller) {
1080 const AggValueSlot dest = ensureSlot(loc, e->
getType());
1083 cir::ArrayType arrayTy =
1090 "visitCXXParenListOrInitListExpr variable array type");
1096 "visitCXXParenListOrInitListExpr array type");
1106 unsigned numInitElements = args.size();
1111 CIRGenFunction::CleanupDeactivationScope deactivateCleanups(cgf);
1113 unsigned curInitIndex = 0;
1116 if (
auto *cxxrd = dyn_cast<CXXRecordDecl>(record)) {
1117 assert(numInitElements >= cxxrd->getNumBases() &&
1118 "missing initializer for base class");
1119 for (
auto &base : cxxrd->bases()) {
1120 assert(!base.isVirtual() &&
"should not see vbases here");
1121 CXXRecordDecl *baseRD = base.getType()->getAsCXXRecordDecl();
1131 if (base.getType().isDestructedType()) {
1133 "push deferred deactivation cleanup");
1140 CIRGenFunction::FieldConstructionScope fcScope(cgf, dest.
getAddress());
1144 if (record->isUnion()) {
1147 if (!initializedFieldInUnion) {
1152 assert(llvm::all_of(record->fields(),
1153 [](
const FieldDecl *f) {
1154 return f->isUnnamedBitField() ||
1155 f->isAnonymousStructOrUnion();
1157 "Only unnamed bitfields or anonymous class allowed");
1162 FieldDecl *initedField = initializedFieldInUnion;
1165 destLV, initedField, initedField->
getName());
1167 if (numInitElements) {
1169 emitInitializationToLValue(args[0], fieldLV);
1172 emitNullInitializationToLValue(loc, fieldLV);
1179 for (
const FieldDecl *field : record->fields()) {
1181 if (field->getType()->isIncompleteArrayType())
1185 if (field->isUnnamedBitField())
1191 if (curInitIndex == numInitElements && dest.
isZeroed() &&
1199 if (curInitIndex < numInitElements) {
1201 CIRGenFunction::SourceLocRAIIObject loc{
1202 cgf, cgf.
getLoc(record->getSourceRange())};
1203 emitInitializationToLValue(args[curInitIndex++], lv);
1213 field->getType().isDestructedType()) {
1214 assert(lv.isSimple());
1240 getContext().getASTRecordLayout(baseRD).getSize() <=
1249 AggExprEmitter(*
this, slot).Visit(
const_cast<Expr *
>(e));
1264 assert((record->hasTrivialCopyConstructor() ||
1265 record->hasTrivialCopyAssignment() ||
1266 record->hasTrivialMoveConstructor() ||
1267 record->hasTrivialMoveAssignment() ||
1268 record->hasAttr<TrivialABIAttr>() || record->isUnion()) &&
1269 "Trying to aggregate-copy a type without a trivial copy/move "
1270 "constructor or assignment operator");
1272 if (record->isEmpty())
1295 typeInfo =
getContext().getTypeInfoDataSizeInChars(ty);
1297 typeInfo =
getContext().getTypeInfoInChars(ty);
1303 cgm.errorNYI(
"emitAggregateCopy: GC");
1309 bool skipTailPadding =
1310 mayOverlap && dataSize !=
getContext().getTypeSizeInChars(ty);
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.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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...
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Expr * getSubExpr() const
Get the initializer to use for each array element.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
QualType getElementType() const
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getBeginLoc() const LLVM_READONLY
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::CmpThreeWayOp createThreeWayCmpTotalOrdering(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, const llvm::APSInt <Res, const llvm::APSInt &eqRes, const llvm::APSInt >Res, cir::CmpOrdering ordering)
cir::CmpThreeWayOp createThreeWayCmpPartialOrdering(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, const llvm::APSInt <Res, const llvm::APSInt &eqRes, const llvm::APSInt >Res, const llvm::APSInt &unorderedRes)
cir::StoreOp createStore(mlir::Location loc, mlir::Value val, Address dst, bool isVolatile=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})
cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)
cir::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false)
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
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.
void pushIrregularPartialArrayCleanup(mlir::Value arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlign, Destroyer *destroyer)
Push an EH cleanup to destroy already-constructed elements of the given array.
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
void emitAggregateStore(mlir::Value value, Address dest)
RValue emitAtomicExpr(AtomicExpr *e)
void emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
void pushDestroyAndDeferDeactivation(QualType::DestructionKind dtorKind, Address addr, QualType type)
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.
Destroyer * getDestroyer(clang::QualType::DestructionKind kind)
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 emitInheritedCXXConstructorCall(const CXXConstructorDecl *d, bool forVirtualBase, Address thisAddr, bool inheritedFromVBase, const CXXInheritedCtorInitExpr *e)
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)
mlir::Value emitVAArg(VAArgExpr *ve)
Generate code to get an argument from the passed in pointer and update it accordingly.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
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
This trivial value class is used to represent the result of an expression that is evaluated.
Address getAggregateAddress() const
Return the value of the address of the aggregate.
static RValue get(mlir::Value v)
CXXTemporary * getTemporary()
const Expr * getSubExpr() const
A default argument (C++ [dcl.fct.default]).
Expr * getExpr()
Get the initialization expression that will be used.
Represents a call to an inherited base class constructor from an inheriting constructor.
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Represents a list-initialization with parenthesis.
MutableArrayRef< Expr * > getInitExprs()
FieldDecl * getInitializedFieldInUnion()
Represents a C++ struct/union/class.
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
SourceRange getSourceRange() const LLVM_READONLY
An expression "T()" which creates an rvalue of a non-class type T.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
A C++ throw-expression (C++ [except.throw]).
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
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 - This is an opaque type for sizes expressed in character units.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
bool isPartial() const
True iff the comparison is not totally ordered.
const ValueInfo * getLess() const
const ValueInfo * getUnordered() const
const CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
bool isStrong() const
True iff the comparison is "strong".
const ValueInfo * getGreater() const
const ValueInfo * getEqualOrEquiv() const
const Expr * getInitializer() const
Represents the canonical version of C arrays with a specified constant size.
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.
Represents an implicitly-generated value initialization of an object of a given type.
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.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
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.
Represents a place-holder for an object not to be initialized by anything.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
const Expr * getSubExpr() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
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 isPointerType() const
bool isReferenceType() const
bool isVariableArrayType() const
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
RecordDecl * castAsRecordDecl() const
bool isAnyComplexType() const
bool isMemberPointerType() const
bool isRealFloatingType() const
Floating point categories.
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
Represents a call to the builtin function __builtin_va_arg.
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.
@ Address
A pointer to a ValueDecl.
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 cleanupDeactivationScope()
static bool aggValueSlotVolatile()
static bool atomicTypes()
static bool cudaSupport()
static bool incrementProfileCounter()
clang::CharUnits getPointerAlign() const
llvm::APSInt getIntValue() const
Get the constant integer value used by this variable to represent the comparison category result type...