16#include "mlir/IR/Builders.h"
17#include "mlir/IR/Location.h"
18#include "mlir/Support/LLVM.h"
25#include "llvm/Support/SaveAndRestore.h"
32 const Stmt *exprResult,
41 if (
const auto *ls = dyn_cast<LabelStmt>(exprResult)) {
42 if (cgf.
emitLabel(*ls->getDecl()).failed())
43 return mlir::failure();
44 exprResult = ls->getSubStmt();
45 }
else if (
const auto *as = dyn_cast<AttributedStmt>(exprResult)) {
48 exprResult = as->getSubStmt();
50 llvm_unreachable(
"Unknown value statement");
66 return mlir::success();
71 mlir::LogicalResult result = mlir::success();
73 assert((!lastValue || (lastValue && exprResult)) &&
74 "If lastValue is not null then the CompoundStmt must have a "
77 for (
const Stmt *curStmt : s.
body()) {
78 const bool saveResult = lastValue && exprResult == curStmt;
81 result = mlir::failure();
83 if (
emitStmt(curStmt,
false).failed())
84 result = mlir::failure();
98 switch (
attr->getKind()) {
102 case attr::NoConvergent:
104 case attr::AMDGPUAvailableVisible:
105 case attr::HLSLControlFlowHint:
107 "Unimplemented statement attribute: ",
attr->getKind());
111 alwaysinline =
false;
113 case attr::AlwaysInline:
117 case attr::MustTail: {
123 case attr::CXXAssume: {
125 if (
getLangOpts().CXXAssumptions && builder.getInsertionBlock() &&
129 assumptionValue, cir::AssumeBundleKind::None,
136 assert(!(alwaysinline && noinline) &&
137 "alwaysinline and noinline are mutually exclusive");
153 mlir::OpBuilder::InsertPoint scopeInsPt;
154 cir::ScopeOp::create(
156 [&](mlir::OpBuilder &b, mlir::Type &
type, mlir::Location loc) {
157 scopeInsPt = b.saveInsertionPoint();
159 mlir::OpBuilder::InsertionGuard guard(builder);
160 builder.restoreInsertionPoint(scopeInsPt);
161 LexicalScope lexScope(*
this, scopeLoc, builder.getInsertionBlock());
172 bool useCurrentScope,
175 return mlir::success();
179 case Stmt::CXXCatchStmtClass:
180 case Stmt::SEHExceptStmtClass:
181 case Stmt::SEHFinallyStmtClass:
182 case Stmt::MSDependentExistsStmtClass:
183 case Stmt::UnresolvedSYCLKernelCallStmtClass:
184 llvm_unreachable(
"invalid statement class to emit generically");
185 case Stmt::BreakStmtClass:
186 case Stmt::NullStmtClass:
187 case Stmt::CompoundStmtClass:
188 case Stmt::ContinueStmtClass:
189 case Stmt::DeclStmtClass:
190 case Stmt::ReturnStmtClass:
191 llvm_unreachable(
"should have emitted these statements as simple");
193#define STMT(Type, Base)
194#define ABSTRACT_STMT(Op)
195#define EXPR(Type, Base) case Stmt::Type##Class:
196#include "clang/AST/StmtNodes.inc"
198 assert(builder.getInsertionBlock() &&
199 "expression emission must have an insertion point");
207 return mlir::success();
209 case Stmt::IfStmtClass:
211 case Stmt::SwitchStmtClass:
213 case Stmt::ForStmtClass:
215 case Stmt::WhileStmtClass:
217 case Stmt::DoStmtClass:
219 case Stmt::CXXTryStmtClass:
221 case Stmt::CXXForRangeStmtClass:
223 case Stmt::CoroutineBodyStmtClass:
225 case Stmt::IndirectGotoStmtClass:
227 case Stmt::CoreturnStmtClass:
229 case Stmt::SYCLKernelCallStmtClass:
231 case Stmt::OpenACCComputeConstructClass:
233 case Stmt::OpenACCLoopConstructClass:
235 case Stmt::OpenACCCombinedConstructClass:
237 case Stmt::OpenACCDataConstructClass:
239 case Stmt::OpenACCEnterDataConstructClass:
241 case Stmt::OpenACCExitDataConstructClass:
243 case Stmt::OpenACCHostDataConstructClass:
245 case Stmt::OpenACCWaitConstructClass:
247 case Stmt::OpenACCInitConstructClass:
249 case Stmt::OpenACCShutdownConstructClass:
251 case Stmt::OpenACCSetConstructClass:
253 case Stmt::OpenACCUpdateConstructClass:
255 case Stmt::OpenACCCacheConstructClass:
257 case Stmt::OpenACCAtomicConstructClass:
259 case Stmt::GCCAsmStmtClass:
260 case Stmt::MSAsmStmtClass:
262 case Stmt::OMPScopeDirectiveClass:
264 case Stmt::OMPErrorDirectiveClass:
266 case Stmt::OMPParallelDirectiveClass:
268 case Stmt::OMPTaskwaitDirectiveClass:
270 case Stmt::OMPTaskyieldDirectiveClass:
272 case Stmt::OMPBarrierDirectiveClass:
274 case Stmt::OMPMetaDirectiveClass:
276 case Stmt::OMPCanonicalLoopClass:
278 case Stmt::OMPSimdDirectiveClass:
280 case Stmt::OMPTileDirectiveClass:
282 case Stmt::OMPUnrollDirectiveClass:
284 case Stmt::OMPFuseDirectiveClass:
286 case Stmt::OMPForDirectiveClass:
288 case Stmt::OMPForSimdDirectiveClass:
290 case Stmt::OMPSectionsDirectiveClass:
292 case Stmt::OMPSectionDirectiveClass:
294 case Stmt::OMPSingleDirectiveClass:
296 case Stmt::OMPMasterDirectiveClass:
298 case Stmt::OMPCriticalDirectiveClass:
300 case Stmt::OMPParallelForDirectiveClass:
302 case Stmt::OMPParallelForSimdDirectiveClass:
305 case Stmt::OMPParallelMasterDirectiveClass:
307 case Stmt::OMPParallelSectionsDirectiveClass:
310 case Stmt::OMPTaskDirectiveClass:
312 case Stmt::OMPTaskgroupDirectiveClass:
314 case Stmt::OMPFlushDirectiveClass:
316 case Stmt::OMPDepobjDirectiveClass:
318 case Stmt::OMPScanDirectiveClass:
320 case Stmt::OMPOrderedStandaloneDirectiveClass:
323 case Stmt::OMPOrderedBlockAssocDirectiveClass:
326 case Stmt::OMPAtomicDirectiveClass:
328 case Stmt::OMPTargetDirectiveClass:
330 case Stmt::OMPTeamsDirectiveClass:
332 case Stmt::OMPCancellationPointDirectiveClass:
335 case Stmt::OMPCancelDirectiveClass:
337 case Stmt::OMPTargetDataDirectiveClass:
339 case Stmt::OMPTargetEnterDataDirectiveClass:
342 case Stmt::OMPTargetExitDataDirectiveClass:
344 case Stmt::OMPTargetParallelDirectiveClass:
346 case Stmt::OMPTargetParallelForDirectiveClass:
349 case Stmt::OMPTaskLoopDirectiveClass:
351 case Stmt::OMPTaskLoopSimdDirectiveClass:
353 case Stmt::OMPMaskedTaskLoopDirectiveClass:
355 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
358 case Stmt::OMPMasterTaskLoopDirectiveClass:
360 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
363 case Stmt::OMPParallelGenericLoopDirectiveClass:
366 case Stmt::OMPParallelMaskedDirectiveClass:
368 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
371 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
374 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
377 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
380 case Stmt::OMPDistributeDirectiveClass:
382 case Stmt::OMPDistributeParallelForDirectiveClass:
385 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
388 case Stmt::OMPDistributeSimdDirectiveClass:
390 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
393 case Stmt::OMPTargetParallelForSimdDirectiveClass:
396 case Stmt::OMPTargetSimdDirectiveClass:
398 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
401 case Stmt::OMPTargetUpdateDirectiveClass:
403 case Stmt::OMPTeamsDistributeDirectiveClass:
406 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
409 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
412 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
415 case Stmt::OMPTeamsGenericLoopDirectiveClass:
418 case Stmt::OMPTargetTeamsDirectiveClass:
420 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
423 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
426 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
429 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
432 case Stmt::OMPInteropDirectiveClass:
434 case Stmt::OMPDispatchDirectiveClass:
436 case Stmt::OMPGenericLoopDirectiveClass:
438 case Stmt::OMPReverseDirectiveClass:
440 case Stmt::OMPSplitDirectiveClass:
442 case Stmt::OMPInterchangeDirectiveClass:
444 case Stmt::OMPFlattenDirectiveClass:
446 case Stmt::OMPAssumeDirectiveClass:
448 case Stmt::OMPMaskedDirectiveClass:
450 case Stmt::OMPStripeDirectiveClass:
452 case Stmt::LabelStmtClass:
453 case Stmt::AttributedStmtClass:
454 case Stmt::GotoStmtClass:
455 case Stmt::DefaultStmtClass:
456 case Stmt::CaseStmtClass:
457 case Stmt::SEHLeaveStmtClass:
458 case Stmt::ObjCAtTryStmtClass:
459 case Stmt::ObjCAtThrowStmtClass:
460 case Stmt::ObjCAtSynchronizedStmtClass:
461 case Stmt::ObjCForCollectionStmtClass:
462 case Stmt::ObjCAutoreleasePoolStmtClass:
463 case Stmt::SEHTryStmtClass:
464 case Stmt::ObjCAtCatchStmtClass:
465 case Stmt::ObjCAtFinallyStmtClass:
466 case Stmt::DeferStmtClass:
467 case Stmt::CXXExpansionStmtPatternClass:
468 case Stmt::CXXExpansionStmtInstantiationClass:
471 return mlir::failure();
472 case Stmt::CapturedStmtClass:
473 llvm_unreachable(
"CapturedStmt must be handled by the parent directive");
476 llvm_unreachable(
"Unexpected statement class");
480 bool useCurrentScope) {
483 return mlir::failure();
484 case Stmt::DeclStmtClass:
486 case Stmt::CompoundStmtClass:
490 case Stmt::GotoStmtClass:
492 case Stmt::ContinueStmtClass:
496 case Stmt::NullStmtClass:
499 case Stmt::LabelStmtClass:
501 case Stmt::CaseStmtClass:
502 case Stmt::DefaultStmtClass:
508 case Stmt::BreakStmtClass:
510 case Stmt::ReturnStmtClass:
512 case Stmt::AttributedStmtClass:
516 return mlir::success();
522 return mlir::failure();
532 mlir::Location loc) {
537 unsigned numBlocks = r.getBlocks().size();
538 for (
auto &block : r.getBlocks()) {
541 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
542 block.hasNoSuccessors())
543 eraseBlocks.push_back(&block);
546 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
547 mlir::OpBuilder::InsertionGuard guardCase(builder);
548 builder.setInsertionPointToEnd(&block);
549 builder.createYield(loc);
553 for (
auto *b : eraseBlocks)
558 mlir::LogicalResult res = mlir::success();
561 const Stmt *constevalExecuted;
564 if (!constevalExecuted) {
572 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
574 return emitStmt(constevalExecuted,
true);
578 return mlir::failure();
596 return mlir::success();
609 cir::ScopeOp::create(builder, scopeLoc,
610 [&](mlir::OpBuilder &b, mlir::Location loc) {
612 builder.getInsertionBlock()};
613 res = ifStmtBuilder();
620 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
625 return mlir::success();
633 bool createNewScope =
false;
634 if (
const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
635 rv = ewc->getSubExpr();
636 createNewScope =
true;
639 auto handleReturnVal = [&]() {
650 builder.createFlagStore(loc,
true, nrvoFlag);
661 ->isReferenceType()) {
665 builder.CIRBaseBuilderTy::createStore(loc, result.
getValue(),
668 mlir::Value value =
nullptr;
673 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
692 if (!createNewScope) {
708 cir::AllocaOp retAlloca =
709 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
710 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
713 cir::ReturnOp::create(builder, loc, {value});
715 cir::ReturnOp::create(builder, loc);
721 builder.createBlock(builder.getBlock()->getParent());
722 return mlir::success();
738 builder.createBlock(builder.getBlock()->getParent());
740 return mlir::success();
749 return mlir::success();
759 builder.createBlock(builder.getBlock()->getParent());
760 return mlir::success();
768 builder.createBlock(builder.getBlock()->getParent());
770 return mlir::success();
777 mlir::Block *currBlock = builder.getBlock();
778 mlir::Block *labelBlock = currBlock;
780 if (!currBlock->empty() || currBlock->isEntryBlock()) {
782 mlir::OpBuilder::InsertionGuard guard(builder);
783 labelBlock = builder.createBlock(builder.getBlock()->getParent());
788 builder.setInsertionPointToEnd(labelBlock);
793 return mlir::success();
800 builder.createBlock(builder.getBlock()->getParent());
802 return mlir::success();
808 mlir::ArrayAttr value, CaseOpKind
kind,
809 bool buildingTopLevelCase) {
812 "only case or default stmt go here");
814 mlir::LogicalResult result = mlir::success();
816 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
819 SubStmtKind subStmtKind = SubStmtKind::Other;
820 const Stmt *sub =
stmt->getSubStmt();
822 mlir::OpBuilder::InsertPoint insertPoint;
823 CaseOp::create(builder, loc, value,
kind, insertPoint);
826 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
827 builder.restoreInsertionPoint(insertPoint);
830 subStmtKind = SubStmtKind::Default;
831 builder.createYield(loc);
833 subStmtKind = SubStmtKind::Case;
834 builder.createYield(loc);
839 insertPoint = builder.saveInsertionPoint();
874 if (subStmtKind == SubStmtKind::Case) {
876 }
else if (subStmtKind == SubStmtKind::Default) {
878 buildingTopLevelCase);
879 }
else if (buildingTopLevelCase) {
883 builder.restoreInsertionPoint(insertPoint);
891 bool buildingTopLevelCase) {
892 cir::CaseOpKind
kind;
893 mlir::ArrayAttr value;
899 condType = builder.getUIntNTy(1);
905 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
906 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
907 cir::IntAttr::get(condType, endVal)});
908 kind = cir::CaseOpKind::Range;
910 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
911 kind = cir::CaseOpKind::Equal;
915 buildingTopLevelCase);
920 bool buildingTopLevelCase) {
922 cir::CaseOpKind::Default, buildingTopLevelCase);
926 bool buildingTopLevelCase) {
928 "build switch case without specifying the type of the condition");
932 buildingTopLevelCase);
936 buildingTopLevelCase);
938 llvm_unreachable(
"expect case or default stmt");
947 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
948 mlir::LogicalResult loopRes = mlir::success();
952 return mlir::failure();
954 return mlir::failure();
956 return mlir::failure();
958 return mlir::failure();
962 forOp = builder.createFor(
965 [&](mlir::OpBuilder &b, mlir::Location loc) {
966 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
967 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
968 mlir::Value condVal = evaluateExprAsBool(s.getCond());
969 builder.createCondition(condVal);
972 [&](mlir::OpBuilder &b, mlir::Location loc) {
976 RunCleanupsScope bodyScope(*this);
977 bool useCurrentScope = true;
978 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
979 loopRes = mlir::failure();
980 if (emitStmt(s.getBody(), useCurrentScope).failed())
981 loopRes = mlir::failure();
985 [&](mlir::OpBuilder &b, mlir::Location loc) {
987 if (emitStmt(s.getInc(), true).failed())
988 loopRes = mlir::failure();
989 builder.createYield(loc);
994 mlir::LogicalResult res = mlir::success();
996 cir::ScopeOp::create(builder, scopeLoc,
997 [&](mlir::OpBuilder &b, mlir::Location loc) {
1003 builder.getInsertionBlock()};
1004 res = forStmtBuilder();
1011 return mlir::success();
1018 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
1019 mlir::LogicalResult loopRes = mlir::success();
1023 return mlir::failure();
1031 bool needsCondCleanup =
1034 shouldEmitLifetimeMarkersForAutoVar());
1037 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1040 mlir::Value condVal;
1050 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
1052 builder.createCondition(condVal);
1054 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1059 loopRes = mlir::failure();
1062 auto stepBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1065 loopRes = mlir::failure();
1066 builder.createYield(loc);
1069 if (needsCondCleanup) {
1070 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1071 ? cir::CleanupKind::All
1072 : cir::CleanupKind::Normal;
1073 forOp = builder.createFor(
1076 [&](mlir::OpBuilder &b, mlir::Location loc) {
1077 loopCondScope.emitIntoLoopCleanupRegion(loc);
1078 builder.createYield(loc);
1083 bodyBuilder, stepBuilder);
1088 auto res = mlir::success();
1090 cir::ScopeOp::create(builder, scopeLoc,
1091 [&](mlir::OpBuilder &b, mlir::Location loc) {
1093 builder.getInsertionBlock()};
1094 res = forStmtBuilder();
1101 return mlir::success();
1105 cir::DoWhileOp doWhileOp;
1108 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
1109 mlir::LogicalResult loopRes = mlir::success();
1112 doWhileOp = builder.createDoWhile(
1115 [&](mlir::OpBuilder &b, mlir::Location loc) {
1116 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1117 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1121 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1122 builder.createCondition(condVal);
1125 [&](mlir::OpBuilder &b, mlir::Location loc) {
1127 RunCleanupsScope bodyScope(*this);
1128 if (emitStmt(s.getBody(), false).failed())
1129 loopRes = mlir::failure();
1135 mlir::LogicalResult res = mlir::success();
1137 cir::ScopeOp::create(builder, scopeLoc,
1138 [&](mlir::OpBuilder &b, mlir::Location loc) {
1140 builder.getInsertionBlock()};
1141 res = doStmtBuilder();
1148 return mlir::success();
1152 cir::WhileOp whileOp;
1155 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
1156 mlir::LogicalResult loopRes = mlir::success();
1163 bool needsCondCleanup =
1166 shouldEmitLifetimeMarkersForAutoVar());
1169 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1179 builder.createCondition(condVal);
1181 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1185 loopRes = mlir::failure();
1189 if (needsCondCleanup) {
1190 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1191 ? cir::CleanupKind::All
1192 : cir::CleanupKind::Normal;
1193 whileOp = builder.createWhile(
1196 [&](mlir::OpBuilder &b, mlir::Location loc) {
1197 loopCondScope.emitIntoLoopCleanupRegion(loc);
1198 builder.createYield(loc);
1208 mlir::LogicalResult res = mlir::success();
1210 cir::ScopeOp::create(builder, scopeLoc,
1211 [&](mlir::OpBuilder &b, mlir::Location loc) {
1213 builder.getInsertionBlock()};
1214 res = whileStmtBuilder();
1221 return mlir::success();
1241 mlir::Block *switchBlock = builder.getBlock();
1247 builder.setInsertionPointToEnd(switchBlock);
1254 auto *c = body.front();
1257 return mlir::failure();
1259 body = body.drop_front();
1265 mlir::Block *lastBlock = builder.getBlock();
1266 switchBlock = builder.createBlock(switchBlock->getParent());
1267 builder.setInsertionPointToEnd(lastBlock);
1271 for (
auto *c : body) {
1272 if (
auto *
switchCase = dyn_cast<SwitchCase>(c)) {
1273 builder.setInsertionPointToEnd(switchBlock);
1279 return mlir::failure();
1286 return mlir::failure();
1289 return mlir::success();
1300 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1303 return mlir::failure();
1315 condV = builder.createBoolToInt(condV, builder.getUIntNTy(1));
1323 mlir::LogicalResult res = mlir::success();
1324 swop = SwitchOp::create(
1327 [&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
1328 curLexScope->setAsSwitch();
1330 condTypeStack.push_back(condV.getType());
1332 res = emitSwitchBody(s.getBody());
1334 condTypeStack.pop_back();
1342 mlir::LogicalResult res = mlir::success();
1343 cir::ScopeOp::create(builder, scopeLoc,
1344 [&](mlir::OpBuilder &b, mlir::Location loc) {
1346 builder.getInsertionBlock()};
1347 res = switchStmtBuilder();
1351 swop.collectCases(cases);
1352 for (
auto caseOp : cases)
1377 assert(rv.
isComplex() &&
"Unknown rvalue kind?");
1387 cir::AllocaOp retAlloca =
1388 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
1389 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
1392 cir::ReturnOp::create(builder, loc, {value});
static mlir::LogicalResult emitStmtWithResult(CIRGenFunction &cgf, const Stmt *exprResult, AggValueSlot slot, Address *lastValue)
Defines the clang::Expr interface and subclasses for C++ expressions.
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
Attr - This represents one attribute.
Represents an attribute applied to a statement.
ArrayRef< const Attr * > getAttrs() const
BreakStmt - This represents a break.
mlir::Value getPointer() const
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Captures cleanups for a loop's condition variable so that they can be emitted into the loop op's per-...
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
void forceCleanup(ArrayRef< mlir::Value * > valuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
mlir::LogicalResult emitOMPTargetParallelForDirective(const OMPTargetParallelForDirective &s)
mlir::LogicalResult emitOMPParallelMasterTaskLoopSimdDirective(const OMPParallelMasterTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPSimdDirective(const OMPSimdDirective &s)
mlir::Value emitCheckedArgForAssume(const Expr *e)
Emits an argument for a call to a __builtin_assume.
mlir::LogicalResult emitDoStmt(const clang::DoStmt &s)
mlir::LogicalResult emitOMPCriticalDirective(const OMPCriticalDirective &s)
static cir::TypeEvaluationKind getEvaluationKind(clang::QualType type)
Return the cir::TypeEvaluationKind of QualType type.
clang::GlobalDecl curGD
The GlobalDecl for the current function being compiled or the global variable currently being initial...
mlir::LogicalResult emitCoreturnStmt(const CoreturnStmt &s)
mlir::LogicalResult emitOpenACCDataConstruct(const OpenACCDataConstruct &s)
EHScopeStack::stable_iterator prologueCleanupDepth
The cleanup depth enclosing all the cleanups associated with the parameters.
mlir::LogicalResult emitOpenACCCombinedConstruct(const OpenACCCombinedConstruct &s)
mlir::LogicalResult emitOMPParallelMasterDirective(const OMPParallelMasterDirective &s)
mlir::LogicalResult emitOpenACCWaitConstruct(const OpenACCWaitConstruct &s)
mlir::LogicalResult emitOMPCancellationPointDirective(const OMPCancellationPointDirective &s)
mlir::LogicalResult emitOMPParallelMaskedTaskLoopDirective(const OMPParallelMaskedTaskLoopDirective &s)
mlir::LogicalResult emitOMPReverseDirective(const OMPReverseDirective &s)
const clang::LangOptions & getLangOpts() const
mlir::LogicalResult emitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &s)
mlir::LogicalResult emitOMPTileDirective(const OMPTileDirective &s)
mlir::LogicalResult emitIfOnBoolExpr(const clang::Expr *cond, const clang::Stmt *thenS, const clang::Stmt *elseS)
Emit an if on a boolean condition to the specified blocks.
mlir::LogicalResult emitOMPTargetTeamsDirective(const OMPTargetTeamsDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeParallelForDirective(const OMPTeamsDistributeParallelForDirective &s)
mlir::LogicalResult emitOMPBarrierDirective(const OMPBarrierDirective &s)
mlir::LogicalResult emitOMPTargetParallelDirective(const OMPTargetParallelDirective &s)
mlir::LogicalResult emitOpenACCCacheConstruct(const OpenACCCacheConstruct &s)
mlir::LogicalResult emitOMPTargetDirective(const OMPTargetDirective &s)
mlir::LogicalResult emitCXXForRangeStmt(const CXXForRangeStmt &s, llvm::ArrayRef< const Attr * > attrs)
mlir::Value evaluateExprAsBool(const clang::Expr *e)
Perform the usual unary conversions on the specified expression and compare the result against zero,...
void emitAggregateCopy(LValue dest, LValue src, QualType eltTy, AggValueSlot::Overlap_t mayOverlap, bool isVolatile=false)
Emit an aggregate copy.
mlir::LogicalResult emitOMPScopeDirective(const OMPScopeDirective &s)
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
mlir::LogicalResult emitOMPDepobjDirective(const OMPDepobjDirective &s)
bool constantFoldsToBool(const clang::Expr *cond, bool &resultBool, bool allowLabels=false)
If the specified expression does not fold to a constant, or if it does but contains a label,...
void emitLoopConditionVariable(const clang::VarDecl &d, DeferredLoopConditionCleanup &condCleanup)
Emit a loop's condition-variable declaration.
mlir::LogicalResult emitReturnStmt(const clang::ReturnStmt &s)
mlir::LogicalResult emitOpenACCInitConstruct(const OpenACCInitConstruct &s)
void emitAnyExprToMem(const Expr *e, Address location, Qualifiers quals, bool isInitializer)
Emits the code necessary to evaluate an arbitrary expression into the given memory location.
mlir::LogicalResult emitOMPDistributeParallelForSimdDirective(const OMPDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPUnrollDirective(const OMPUnrollDirective &s)
mlir::LogicalResult emitOMPTaskDirective(const OMPTaskDirective &s)
mlir::LogicalResult emitOpenACCSetConstruct(const OpenACCSetConstruct &s)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
mlir::LogicalResult emitOMPTeamsGenericLoopDirective(const OMPTeamsGenericLoopDirective &s)
mlir::LogicalResult emitOMPCanonicalLoop(const OMPCanonicalLoop &s)
mlir::LogicalResult emitSwitchStmt(const clang::SwitchStmt &s)
mlir::LogicalResult emitOMPTeamsDirective(const OMPTeamsDirective &s)
mlir::LogicalResult emitCaseStmt(const clang::CaseStmt &s, mlir::Type condType, bool buildingTopLevelCase)
llvm::ScopedHashTableScope< const clang::Decl *, mlir::Value > SymTableScopeTy
mlir::LogicalResult emitOMPMaskedTaskLoopDirective(const OMPMaskedTaskLoopDirective &s)
mlir::LogicalResult emitOMPFuseDirective(const OMPFuseDirective &s)
mlir::LogicalResult emitSimpleStmt(const clang::Stmt *s, bool useCurrentScope)
mlir::LogicalResult emitOMPSectionDirective(const OMPSectionDirective &s)
mlir::LogicalResult emitAsmStmt(const clang::AsmStmt &s)
mlir::LogicalResult emitOMPFlattenDirective(const OMPFlattenDirective &s)
mlir::LogicalResult emitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &s)
mlir::LogicalResult emitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &s)
mlir::LogicalResult emitOMPOrderedStandaloneDirective(const OMPOrderedStandaloneDirective &s)
mlir::LogicalResult emitOpenACCComputeConstruct(const OpenACCComputeConstruct &s)
mlir::LogicalResult emitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &s)
EHScopeStack ehStack
Tracks function scope overall cleanup handling.
mlir::LogicalResult emitSwitchBody(const clang::Stmt *s)
mlir::LogicalResult emitForStmt(const clang::ForStmt &s)
mlir::LogicalResult emitOMPTaskwaitDirective(const OMPTaskwaitDirective &s)
mlir::LogicalResult emitOMPFlushDirective(const OMPFlushDirective &s)
mlir::LogicalResult emitOMPGenericLoopDirective(const OMPGenericLoopDirective &s)
mlir::LogicalResult emitOMPTargetUpdateDirective(const OMPTargetUpdateDirective &s)
std::optional< mlir::Value > fnRetAlloca
The compiler-generated variable that holds the return value.
mlir::LogicalResult emitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &s)
mlir::LogicalResult emitOMPInterchangeDirective(const OMPInterchangeDirective &s)
mlir::LogicalResult emitOMPDispatchDirective(const OMPDispatchDirective &s)
mlir::LogicalResult emitCXXTryStmt(const clang::CXXTryStmt &s, cxxTryBodyEmitter &bodyCallback)
mlir::LogicalResult emitOMPParallelDirective(const OMPParallelDirective &s)
mlir::LogicalResult emitAttributedStmt(const AttributedStmt &s)
mlir::LogicalResult emitOMPForSimdDirective(const OMPForSimdDirective &s)
mlir::LogicalResult emitOMPTaskLoopDirective(const OMPTaskLoopDirective &s)
Address returnValue
The temporary alloca to hold the return value.
mlir::LogicalResult emitOMPTargetDataDirective(const OMPTargetDataDirective &s)
mlir::LogicalResult emitLabel(const clang::LabelDecl &d)
mlir::LogicalResult emitOMPTargetParallelGenericLoopDirective(const OMPTargetParallelGenericLoopDirective &s)
static bool hasAggregateEvaluationKind(clang::QualType type)
mlir::LogicalResult emitOMPParallelMaskedDirective(const OMPParallelMaskedDirective &s)
mlir::LogicalResult emitOMPMaskedTaskLoopSimdDirective(const OMPMaskedTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPAtomicDirective(const OMPAtomicDirective &s)
mlir::LogicalResult emitOpenACCShutdownConstruct(const OpenACCShutdownConstruct &s)
mlir::LogicalResult emitBreakStmt(const clang::BreakStmt &s)
mlir::LogicalResult emitIndirectGotoStmt(const IndirectGotoStmt &s)
const CallExpr * mustTailCall
mlir::LogicalResult emitOMPTeamsDistributeParallelForSimdDirective(const OMPTeamsDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPTaskgroupDirective(const OMPTaskgroupDirective &s)
mlir::LogicalResult emitOMPParallelMaskedTaskLoopSimdDirective(const OMPParallelMaskedTaskLoopSimdDirective &s)
mlir::LogicalResult emitOMPTeamsDistributeDirective(const OMPTeamsDistributeDirective &s)
void emitReturnOfRValue(mlir::Location loc, RValue rv, QualType ty)
mlir::LogicalResult emitOMPInteropDirective(const OMPInteropDirective &s)
mlir::LogicalResult emitOMPErrorDirective(const OMPErrorDirective &s)
mlir::LogicalResult emitOMPSingleDirective(const OMPSingleDirective &s)
mlir::LogicalResult emitContinueStmt(const clang::ContinueStmt &s)
mlir::LogicalResult emitOMPTaskyieldDirective(const OMPTaskyieldDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeSimdDirective(const OMPTargetTeamsDistributeSimdDirective &s)
mlir::LogicalResult emitOMPScanDirective(const OMPScanDirective &s)
llvm::SmallVector< mlir::Type, 2 > condTypeStack
The type of the condition for the emitting switch statement.
mlir::LogicalResult emitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective &s)
void emitStopPoint(const Stmt *s)
Build a debug stoppoint if we are emitting debug info.
mlir::LogicalResult emitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &s)
mlir::LogicalResult emitOpenACCHostDataConstruct(const OpenACCHostDataConstruct &s)
mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)
Emit the computation of the specified expression of scalar type.
mlir::LogicalResult emitIfStmt(const clang::IfStmt &s)
mlir::LogicalResult emitOMPForDirective(const OMPForDirective &s)
mlir::LogicalResult emitOMPMasterDirective(const OMPMasterDirective &s)
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
mlir::LogicalResult emitSwitchCase(const clang::SwitchCase &s, bool buildingTopLevelCase)
mlir::LogicalResult emitOMPMetaDirective(const OMPMetaDirective &s)
mlir::LogicalResult emitOMPDistributeSimdDirective(const OMPDistributeSimdDirective &s)
void emitDecl(const clang::Decl &d, bool evaluateConditionDecl=false)
mlir::LogicalResult emitOMPParallelGenericLoopDirective(const OMPParallelGenericLoopDirective &s)
mlir::LogicalResult emitOMPMaskedDirective(const OMPMaskedDirective &s)
mlir::LogicalResult emitOMPSplitDirective(const OMPSplitDirective &s)
llvm::DenseMap< const VarDecl *, mlir::Value > nrvoFlags
A mapping from NRVO variables to the flags used to indicate when the NRVO has been applied to this va...
CIRGenModule & getCIRGenModule()
mlir::LogicalResult emitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct &s)
mlir::LogicalResult emitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &s)
mlir::LogicalResult emitOMPOrderedBlockAssocDirective(const OMPOrderedBlockAssocDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeParallelForDirective(const OMPTargetTeamsDistributeParallelForDirective &s)
void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)
mlir::LogicalResult emitOMPParallelForDirective(const OMPParallelForDirective &s)
mlir::LogicalResult emitCaseDefaultCascade(const T *stmt, mlir::Type condType, mlir::ArrayAttr value, cir::CaseOpKind kind, bool buildingTopLevelCase)
mlir::LogicalResult emitOMPSectionsDirective(const OMPSectionsDirective &s)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
mlir::LogicalResult emitOMPDistributeDirective(const OMPDistributeDirective &s)
RValue emitAnyExpr(const clang::Expr *e, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
Emit code to compute the specified expression which can have any type.
mlir::LogicalResult emitOMPTargetTeamsDistributeParallelForSimdDirective(const OMPTargetTeamsDistributeParallelForSimdDirective &s)
mlir::LogicalResult emitOMPTargetTeamsGenericLoopDirective(const OMPTargetTeamsGenericLoopDirective &s)
mlir::LogicalResult emitDeclStmt(const clang::DeclStmt &s)
mlir::LogicalResult emitOMPTeamsDistributeSimdDirective(const OMPTeamsDistributeSimdDirective &s)
mlir::LogicalResult emitDefaultStmt(const clang::DefaultStmt &s, mlir::Type condType, bool buildingTopLevelCase)
mlir::LogicalResult emitWhileStmt(const clang::WhileStmt &s)
mlir::LogicalResult emitLabelStmt(const clang::LabelStmt &s)
mlir::LogicalResult emitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &s)
void terminateStructuredRegionBody(mlir::Region &r, mlir::Location loc)
clang::ASTContext & getContext() const
mlir::LogicalResult emitCoroutineBody(const CoroutineBodyStmt &s)
mlir::LogicalResult emitCompoundStmt(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
mlir::LogicalResult emitGotoStmt(const clang::GotoStmt &s)
bool inAlwaysInlineAttributedStmt
True if the current statement has always_inline attribute.
bool inNoInlineAttributedStmt
True if the current statement has noinline attribute.
mlir::LogicalResult emitOMPParallelMasterTaskLoopDirective(const OMPParallelMasterTaskLoopDirective &s)
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
mlir::LogicalResult emitOMPCancelDirective(const OMPCancelDirective &s)
mlir::LogicalResult emitOMPStripeDirective(const OMPStripeDirective &s)
mlir::LogicalResult emitOMPTargetTeamsDistributeDirective(const OMPTargetTeamsDistributeDirective &s)
mlir::LogicalResult emitCompoundStmtWithoutScope(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
mlir::LogicalResult emitOMPParallelSectionsDirective(const OMPParallelSectionsDirective &s)
mlir::LogicalResult emitOpenACCExitDataConstruct(const OpenACCExitDataConstruct &s)
mlir::LogicalResult emitSYCLKernelCallStmt(const SYCLKernelCallStmt &s)
void emitIgnoredExpr(const clang::Expr *e)
Emit code to compute the specified expression, ignoring the result.
void emitAggExpr(const clang::Expr *e, AggValueSlot slot)
mlir::LogicalResult emitOpenACCAtomicConstruct(const OpenACCAtomicConstruct &s)
mlir::LogicalResult emitOMPTargetSimdDirective(const OMPTargetSimdDirective &s)
mlir::LogicalResult emitOMPAssumeDirective(const OMPAssumeDirective &s)
mlir::LogicalResult emitOpenACCLoopConstruct(const OpenACCLoopConstruct &s)
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
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.
mlir::Value getValue() const
Return the value of this scalar value.
mlir::Value getComplexValue() const
Return the value of this complex value.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
DeclStmt * getBeginStmt()
DeclStmt * getRangeStmt()
SourceLocation getEndLoc() const LLVM_READONLY
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CaseStmt - Represent a case statement.
CompoundStmt - This represents a group of statements like { stmt stmt }.
ContinueStmt - This represents a continue.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
DoStmt - This represents a 'do/while' stmt.
SourceLocation getEndLoc() const
This represents one expression.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
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...
ForStmt - This represents a 'for (init;cond;inc)' stmt.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
SourceLocation getEndLoc() const
GotoStmt - This represents a direct goto.
LabelDecl * getLabel() const
IfStmt - This represents an if/then/else.
bool isNegatedConsteval() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
IndirectGotoStmt - This represents an indirect goto.
Represents the declaration of a label.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
LabelStmt - Represents a label, which has a substatement.
LabelDecl * getDecl() const
SourceLocation getKwLoc() const
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
A (possibly-)qualified type.
The collection of all-type qualifiers we support.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
Stmt - This represents one statement.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
SwitchStmt - This represents a 'switch' stmt.
bool isAllEnumCasesCovered() const
Returns true if the SwitchStmt is a switch of an enum value and all cases have been explicitly covere...
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
SourceLocation getBeginLoc() const
Represents a variable declaration or definition.
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
WhileStmt - This represents a 'while' stmt.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
SourceLocation getEndLoc() const LLVM_READONLY
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > compoundStmt
Matches compound statements.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > switchCase
Matches case and default statements inside switch statements.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
@ Default
Set to the current date and time.
const FunctionProtoType * T
U cast(CodeGen::Address addr)
@ Other
Other implicit parameter.
static bool aggValueSlotGC()
static bool createProfileWeightsForLoop()
static bool loopInfoStack()
static bool emitCondLikelihoodViaExpectIntrinsic()
static bool constantFoldSwitchStatement()
static bool insertBuiltinUnpredictable()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...