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::OMPAssumeDirectiveClass:
446 case Stmt::OMPMaskedDirectiveClass:
448 case Stmt::OMPStripeDirectiveClass:
450 case Stmt::LabelStmtClass:
451 case Stmt::AttributedStmtClass:
452 case Stmt::GotoStmtClass:
453 case Stmt::DefaultStmtClass:
454 case Stmt::CaseStmtClass:
455 case Stmt::SEHLeaveStmtClass:
456 case Stmt::ObjCAtTryStmtClass:
457 case Stmt::ObjCAtThrowStmtClass:
458 case Stmt::ObjCAtSynchronizedStmtClass:
459 case Stmt::ObjCForCollectionStmtClass:
460 case Stmt::ObjCAutoreleasePoolStmtClass:
461 case Stmt::SEHTryStmtClass:
462 case Stmt::ObjCAtCatchStmtClass:
463 case Stmt::ObjCAtFinallyStmtClass:
464 case Stmt::DeferStmtClass:
465 case Stmt::CXXExpansionStmtPatternClass:
466 case Stmt::CXXExpansionStmtInstantiationClass:
469 return mlir::failure();
470 case Stmt::CapturedStmtClass:
471 llvm_unreachable(
"CapturedStmt must be handled by the parent directive");
474 llvm_unreachable(
"Unexpected statement class");
478 bool useCurrentScope) {
481 return mlir::failure();
482 case Stmt::DeclStmtClass:
484 case Stmt::CompoundStmtClass:
488 case Stmt::GotoStmtClass:
490 case Stmt::ContinueStmtClass:
494 case Stmt::NullStmtClass:
497 case Stmt::LabelStmtClass:
499 case Stmt::CaseStmtClass:
500 case Stmt::DefaultStmtClass:
506 case Stmt::BreakStmtClass:
508 case Stmt::ReturnStmtClass:
510 case Stmt::AttributedStmtClass:
514 return mlir::success();
520 return mlir::failure();
530 mlir::Location loc) {
535 unsigned numBlocks = r.getBlocks().size();
536 for (
auto &block : r.getBlocks()) {
539 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
540 block.hasNoSuccessors())
541 eraseBlocks.push_back(&block);
544 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
545 mlir::OpBuilder::InsertionGuard guardCase(builder);
546 builder.setInsertionPointToEnd(&block);
547 builder.createYield(loc);
551 for (
auto *b : eraseBlocks)
556 mlir::LogicalResult res = mlir::success();
559 const Stmt *constevalExecuted;
562 if (!constevalExecuted) {
570 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
572 return emitStmt(constevalExecuted,
true);
576 return mlir::failure();
594 return mlir::success();
607 cir::ScopeOp::create(builder, scopeLoc,
608 [&](mlir::OpBuilder &b, mlir::Location loc) {
610 builder.getInsertionBlock()};
611 res = ifStmtBuilder();
618 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
623 return mlir::success();
631 bool createNewScope =
false;
632 if (
const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
633 rv = ewc->getSubExpr();
634 createNewScope =
true;
637 auto handleReturnVal = [&]() {
648 builder.createFlagStore(loc,
true, nrvoFlag);
659 ->isReferenceType()) {
663 builder.CIRBaseBuilderTy::createStore(loc, result.
getValue(),
666 mlir::Value value =
nullptr;
671 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
690 if (!createNewScope) {
706 cir::AllocaOp retAlloca =
707 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
708 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
711 cir::ReturnOp::create(builder, loc, {value});
713 cir::ReturnOp::create(builder, loc);
719 builder.createBlock(builder.getBlock()->getParent());
720 return mlir::success();
736 builder.createBlock(builder.getBlock()->getParent());
738 return mlir::success();
747 return mlir::success();
757 builder.createBlock(builder.getBlock()->getParent());
758 return mlir::success();
766 builder.createBlock(builder.getBlock()->getParent());
768 return mlir::success();
775 mlir::Block *currBlock = builder.getBlock();
776 mlir::Block *labelBlock = currBlock;
778 if (!currBlock->empty() || currBlock->isEntryBlock()) {
780 mlir::OpBuilder::InsertionGuard guard(builder);
781 labelBlock = builder.createBlock(builder.getBlock()->getParent());
786 builder.setInsertionPointToEnd(labelBlock);
791 return mlir::success();
798 builder.createBlock(builder.getBlock()->getParent());
800 return mlir::success();
806 mlir::ArrayAttr value, CaseOpKind
kind,
807 bool buildingTopLevelCase) {
810 "only case or default stmt go here");
812 mlir::LogicalResult result = mlir::success();
814 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
817 SubStmtKind subStmtKind = SubStmtKind::Other;
818 const Stmt *sub =
stmt->getSubStmt();
820 mlir::OpBuilder::InsertPoint insertPoint;
821 CaseOp::create(builder, loc, value,
kind, insertPoint);
824 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
825 builder.restoreInsertionPoint(insertPoint);
828 subStmtKind = SubStmtKind::Default;
829 builder.createYield(loc);
831 subStmtKind = SubStmtKind::Case;
832 builder.createYield(loc);
837 insertPoint = builder.saveInsertionPoint();
872 if (subStmtKind == SubStmtKind::Case) {
874 }
else if (subStmtKind == SubStmtKind::Default) {
876 buildingTopLevelCase);
877 }
else if (buildingTopLevelCase) {
881 builder.restoreInsertionPoint(insertPoint);
889 bool buildingTopLevelCase) {
890 cir::CaseOpKind
kind;
891 mlir::ArrayAttr value;
897 condType = builder.getUIntNTy(1);
903 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
904 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
905 cir::IntAttr::get(condType, endVal)});
906 kind = cir::CaseOpKind::Range;
908 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
909 kind = cir::CaseOpKind::Equal;
913 buildingTopLevelCase);
918 bool buildingTopLevelCase) {
920 cir::CaseOpKind::Default, buildingTopLevelCase);
924 bool buildingTopLevelCase) {
926 "build switch case without specifying the type of the condition");
930 buildingTopLevelCase);
934 buildingTopLevelCase);
936 llvm_unreachable(
"expect case or default stmt");
945 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
946 mlir::LogicalResult loopRes = mlir::success();
950 return mlir::failure();
952 return mlir::failure();
954 return mlir::failure();
956 return mlir::failure();
960 forOp = builder.createFor(
963 [&](mlir::OpBuilder &b, mlir::Location loc) {
964 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
965 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
966 mlir::Value condVal = evaluateExprAsBool(s.getCond());
967 builder.createCondition(condVal);
970 [&](mlir::OpBuilder &b, mlir::Location loc) {
974 RunCleanupsScope bodyScope(*this);
975 bool useCurrentScope = true;
976 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
977 loopRes = mlir::failure();
978 if (emitStmt(s.getBody(), useCurrentScope).failed())
979 loopRes = mlir::failure();
983 [&](mlir::OpBuilder &b, mlir::Location loc) {
985 if (emitStmt(s.getInc(), true).failed())
986 loopRes = mlir::failure();
987 builder.createYield(loc);
992 mlir::LogicalResult res = mlir::success();
994 cir::ScopeOp::create(builder, scopeLoc,
995 [&](mlir::OpBuilder &b, mlir::Location loc) {
1001 builder.getInsertionBlock()};
1002 res = forStmtBuilder();
1009 return mlir::success();
1016 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
1017 mlir::LogicalResult loopRes = mlir::success();
1021 return mlir::failure();
1029 bool needsCondCleanup =
1035 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1038 mlir::Value condVal;
1048 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
1050 builder.createCondition(condVal);
1052 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1057 loopRes = mlir::failure();
1060 auto stepBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1063 loopRes = mlir::failure();
1064 builder.createYield(loc);
1067 if (needsCondCleanup) {
1068 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1069 ? cir::CleanupKind::All
1070 : cir::CleanupKind::Normal;
1071 forOp = builder.createFor(
1074 [&](mlir::OpBuilder &b, mlir::Location loc) {
1075 loopCondScope.emitIntoLoopCleanupRegion(loc);
1076 builder.createYield(loc);
1081 bodyBuilder, stepBuilder);
1086 auto res = mlir::success();
1088 cir::ScopeOp::create(builder, scopeLoc,
1089 [&](mlir::OpBuilder &b, mlir::Location loc) {
1091 builder.getInsertionBlock()};
1092 res = forStmtBuilder();
1099 return mlir::success();
1103 cir::DoWhileOp doWhileOp;
1106 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
1107 mlir::LogicalResult loopRes = mlir::success();
1110 doWhileOp = builder.createDoWhile(
1113 [&](mlir::OpBuilder &b, mlir::Location loc) {
1114 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1115 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1119 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1120 builder.createCondition(condVal);
1123 [&](mlir::OpBuilder &b, mlir::Location loc) {
1125 RunCleanupsScope bodyScope(*this);
1126 if (emitStmt(s.getBody(), false).failed())
1127 loopRes = mlir::failure();
1133 mlir::LogicalResult res = mlir::success();
1135 cir::ScopeOp::create(builder, scopeLoc,
1136 [&](mlir::OpBuilder &b, mlir::Location loc) {
1138 builder.getInsertionBlock()};
1139 res = doStmtBuilder();
1146 return mlir::success();
1150 cir::WhileOp whileOp;
1153 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
1154 mlir::LogicalResult loopRes = mlir::success();
1161 bool needsCondCleanup =
1167 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1177 builder.createCondition(condVal);
1179 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1183 loopRes = mlir::failure();
1187 if (needsCondCleanup) {
1188 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1189 ? cir::CleanupKind::All
1190 : cir::CleanupKind::Normal;
1191 whileOp = builder.createWhile(
1194 [&](mlir::OpBuilder &b, mlir::Location loc) {
1195 loopCondScope.emitIntoLoopCleanupRegion(loc);
1196 builder.createYield(loc);
1206 mlir::LogicalResult res = mlir::success();
1208 cir::ScopeOp::create(builder, scopeLoc,
1209 [&](mlir::OpBuilder &b, mlir::Location loc) {
1211 builder.getInsertionBlock()};
1212 res = whileStmtBuilder();
1219 return mlir::success();
1239 mlir::Block *switchBlock = builder.getBlock();
1245 builder.setInsertionPointToEnd(switchBlock);
1252 auto *c = body.front();
1255 return mlir::failure();
1257 body = body.drop_front();
1263 mlir::Block *lastBlock = builder.getBlock();
1264 switchBlock = builder.createBlock(switchBlock->getParent());
1265 builder.setInsertionPointToEnd(lastBlock);
1269 for (
auto *c : body) {
1270 if (
auto *
switchCase = dyn_cast<SwitchCase>(c)) {
1271 builder.setInsertionPointToEnd(switchBlock);
1277 return mlir::failure();
1284 return mlir::failure();
1287 return mlir::success();
1298 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1301 return mlir::failure();
1313 condV = builder.createBoolToInt(condV, builder.getUIntNTy(1));
1321 mlir::LogicalResult res = mlir::success();
1322 swop = SwitchOp::create(
1325 [&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
1326 curLexScope->setAsSwitch();
1328 condTypeStack.push_back(condV.getType());
1330 res = emitSwitchBody(s.getBody());
1332 condTypeStack.pop_back();
1340 mlir::LogicalResult res = mlir::success();
1341 cir::ScopeOp::create(builder, scopeLoc,
1342 [&](mlir::OpBuilder &b, mlir::Location loc) {
1344 builder.getInsertionBlock()};
1345 res = switchStmtBuilder();
1349 swop.collectCases(cases);
1350 for (
auto caseOp : cases)
1375 assert(rv.
isComplex() &&
"Unknown rvalue kind?");
1385 cir::AllocaOp retAlloca =
1386 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
1387 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
1390 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 the destructor cleanup for a loop's condition variable so that it can be emitted into the lo...
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 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 emitLifetimeMarkers()
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...