16#include "mlir/IR/Builders.h"
17#include "mlir/IR/Location.h"
18#include "mlir/Support/LLVM.h"
27#include "llvm/Support/SaveAndRestore.h"
37 const AtomicAttr *aa) {
40 for (
auto option : aa->atomicOptions()) {
42 case AtomicAttr::remote_memory:
45 case AtomicAttr::no_remote_memory:
48 case AtomicAttr::fine_grained_memory:
51 case AtomicAttr::no_fine_grained_memory:
54 case AtomicAttr::ignore_denormal_mode:
57 case AtomicAttr::no_ignore_denormal_mode:
66 const Stmt *exprResult,
75 if (
const auto *ls = dyn_cast<LabelStmt>(exprResult)) {
76 if (cgf.
emitLabel(*ls->getDecl()).failed())
77 return mlir::failure();
78 exprResult = ls->getSubStmt();
79 }
else if (
const auto *as = dyn_cast<AttributedStmt>(exprResult)) {
82 exprResult = as->getSubStmt();
84 llvm_unreachable(
"Unknown value statement");
100 return mlir::success();
105 mlir::LogicalResult result = mlir::success();
107 assert((!lastValue || (lastValue && exprResult)) &&
108 "If lastValue is not null then the CompoundStmt must have a "
111 for (
const Stmt *curStmt : s.
body()) {
112 const bool saveResult = lastValue && exprResult == curStmt;
115 result = mlir::failure();
117 if (
emitStmt(curStmt,
false).failed())
118 result = mlir::failure();
130 const AtomicAttr *atomicAttr =
nullptr;
133 switch (
attr->getKind()) {
140 case attr::NoConvergent:
141 case attr::AMDGPUAvailableVisible:
142 case attr::HLSLControlFlowHint:
144 "Unimplemented statement attribute: ",
attr->getKind());
148 alwaysinline =
false;
150 case attr::AlwaysInline:
154 case attr::MustTail: {
160 case attr::CXXAssume: {
162 if (
getLangOpts().CXXAssumptions && builder.getInsertionBlock() &&
166 assumptionValue, cir::AssumeBundleKind::None,
173 assert(!(alwaysinline && noinline) &&
174 "alwaysinline and noinline are mutually exclusive");
186 mlir::LogicalResult result =
189 cgm.setAtomicOpts(savedAtomicOpts);
199 mlir::OpBuilder::InsertPoint scopeInsPt;
200 cir::ScopeOp::create(
202 [&](mlir::OpBuilder &b, mlir::Type &
type, mlir::Location loc) {
203 scopeInsPt = b.saveInsertionPoint();
205 mlir::OpBuilder::InsertionGuard guard(builder);
206 builder.restoreInsertionPoint(scopeInsPt);
207 LexicalScope lexScope(*
this, scopeLoc, builder.getInsertionBlock());
218 bool useCurrentScope,
221 return mlir::success();
225 case Stmt::CXXCatchStmtClass:
226 case Stmt::SEHExceptStmtClass:
227 case Stmt::SEHFinallyStmtClass:
228 case Stmt::MSDependentExistsStmtClass:
229 case Stmt::UnresolvedSYCLKernelCallStmtClass:
230 llvm_unreachable(
"invalid statement class to emit generically");
231 case Stmt::BreakStmtClass:
232 case Stmt::NullStmtClass:
233 case Stmt::CompoundStmtClass:
234 case Stmt::ContinueStmtClass:
235 case Stmt::DeclStmtClass:
236 case Stmt::ReturnStmtClass:
237 llvm_unreachable(
"should have emitted these statements as simple");
239#define STMT(Type, Base)
240#define ABSTRACT_STMT(Op)
241#define EXPR(Type, Base) case Stmt::Type##Class:
242#include "clang/AST/StmtNodes.inc"
244 assert(builder.getInsertionBlock() &&
245 "expression emission must have an insertion point");
253 return mlir::success();
255 case Stmt::IfStmtClass:
257 case Stmt::SwitchStmtClass:
259 case Stmt::ForStmtClass:
261 case Stmt::WhileStmtClass:
263 case Stmt::DoStmtClass:
265 case Stmt::CXXTryStmtClass:
267 case Stmt::CXXForRangeStmtClass:
269 case Stmt::CoroutineBodyStmtClass:
271 case Stmt::IndirectGotoStmtClass:
273 case Stmt::CoreturnStmtClass:
275 case Stmt::SYCLKernelCallStmtClass:
277 case Stmt::OpenACCComputeConstructClass:
279 case Stmt::OpenACCLoopConstructClass:
281 case Stmt::OpenACCCombinedConstructClass:
283 case Stmt::OpenACCDataConstructClass:
285 case Stmt::OpenACCEnterDataConstructClass:
287 case Stmt::OpenACCExitDataConstructClass:
289 case Stmt::OpenACCHostDataConstructClass:
291 case Stmt::OpenACCWaitConstructClass:
293 case Stmt::OpenACCInitConstructClass:
295 case Stmt::OpenACCShutdownConstructClass:
297 case Stmt::OpenACCSetConstructClass:
299 case Stmt::OpenACCUpdateConstructClass:
301 case Stmt::OpenACCCacheConstructClass:
303 case Stmt::OpenACCAtomicConstructClass:
305 case Stmt::GCCAsmStmtClass:
306 case Stmt::MSAsmStmtClass:
308 case Stmt::OMPScopeDirectiveClass:
310 case Stmt::OMPErrorDirectiveClass:
312 case Stmt::OMPParallelDirectiveClass:
314 case Stmt::OMPTaskwaitDirectiveClass:
316 case Stmt::OMPTaskyieldDirectiveClass:
318 case Stmt::OMPBarrierDirectiveClass:
320 case Stmt::OMPMetaDirectiveClass:
322 case Stmt::OMPCanonicalLoopClass:
324 case Stmt::OMPSimdDirectiveClass:
326 case Stmt::OMPTileDirectiveClass:
328 case Stmt::OMPUnrollDirectiveClass:
330 case Stmt::OMPFuseDirectiveClass:
332 case Stmt::OMPForDirectiveClass:
334 case Stmt::OMPForSimdDirectiveClass:
336 case Stmt::OMPSectionsDirectiveClass:
338 case Stmt::OMPSectionDirectiveClass:
340 case Stmt::OMPSingleDirectiveClass:
342 case Stmt::OMPMasterDirectiveClass:
344 case Stmt::OMPCriticalDirectiveClass:
346 case Stmt::OMPParallelForDirectiveClass:
348 case Stmt::OMPParallelForSimdDirectiveClass:
351 case Stmt::OMPParallelMasterDirectiveClass:
353 case Stmt::OMPParallelSectionsDirectiveClass:
356 case Stmt::OMPTaskDirectiveClass:
358 case Stmt::OMPTaskgroupDirectiveClass:
360 case Stmt::OMPFlushDirectiveClass:
362 case Stmt::OMPDepobjDirectiveClass:
364 case Stmt::OMPScanDirectiveClass:
366 case Stmt::OMPOrderedStandaloneDirectiveClass:
369 case Stmt::OMPOrderedBlockAssocDirectiveClass:
372 case Stmt::OMPAtomicDirectiveClass:
374 case Stmt::OMPTargetDirectiveClass:
376 case Stmt::OMPTeamsDirectiveClass:
378 case Stmt::OMPCancellationPointDirectiveClass:
381 case Stmt::OMPCancelDirectiveClass:
383 case Stmt::OMPTargetDataDirectiveClass:
385 case Stmt::OMPTargetEnterDataDirectiveClass:
388 case Stmt::OMPTargetExitDataDirectiveClass:
390 case Stmt::OMPTargetParallelDirectiveClass:
392 case Stmt::OMPTargetParallelForDirectiveClass:
395 case Stmt::OMPTaskLoopDirectiveClass:
397 case Stmt::OMPTaskLoopSimdDirectiveClass:
399 case Stmt::OMPMaskedTaskLoopDirectiveClass:
401 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
404 case Stmt::OMPMasterTaskLoopDirectiveClass:
406 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
409 case Stmt::OMPParallelGenericLoopDirectiveClass:
412 case Stmt::OMPParallelMaskedDirectiveClass:
414 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
417 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
420 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
423 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
426 case Stmt::OMPDistributeDirectiveClass:
428 case Stmt::OMPDistributeParallelForDirectiveClass:
431 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
434 case Stmt::OMPDistributeSimdDirectiveClass:
436 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
439 case Stmt::OMPTargetGenericLoopDirectiveClass:
442 case Stmt::OMPTargetParallelForSimdDirectiveClass:
445 case Stmt::OMPTargetSimdDirectiveClass:
447 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
450 case Stmt::OMPTargetUpdateDirectiveClass:
452 case Stmt::OMPTeamsDistributeDirectiveClass:
455 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
458 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
461 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
464 case Stmt::OMPTeamsGenericLoopDirectiveClass:
467 case Stmt::OMPTargetTeamsDirectiveClass:
469 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
472 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
475 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
478 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
481 case Stmt::OMPInteropDirectiveClass:
483 case Stmt::OMPDispatchDirectiveClass:
485 case Stmt::OMPGenericLoopDirectiveClass:
487 case Stmt::OMPReverseDirectiveClass:
489 case Stmt::OMPSplitDirectiveClass:
491 case Stmt::OMPInterchangeDirectiveClass:
493 case Stmt::OMPFlattenDirectiveClass:
495 case Stmt::OMPAssumeDirectiveClass:
497 case Stmt::OMPMaskedDirectiveClass:
499 case Stmt::OMPStripeDirectiveClass:
501 case Stmt::LabelStmtClass:
502 case Stmt::AttributedStmtClass:
503 case Stmt::GotoStmtClass:
504 case Stmt::DefaultStmtClass:
505 case Stmt::CaseStmtClass:
506 case Stmt::SEHLeaveStmtClass:
507 case Stmt::ObjCAtTryStmtClass:
508 case Stmt::ObjCAtThrowStmtClass:
509 case Stmt::ObjCAtSynchronizedStmtClass:
510 case Stmt::ObjCForCollectionStmtClass:
511 case Stmt::ObjCAutoreleasePoolStmtClass:
512 case Stmt::SEHTryStmtClass:
513 case Stmt::ObjCAtCatchStmtClass:
514 case Stmt::ObjCAtFinallyStmtClass:
515 case Stmt::DeferStmtClass:
516 case Stmt::CXXExpansionStmtPatternClass:
517 case Stmt::CXXExpansionStmtInstantiationClass:
520 return mlir::failure();
521 case Stmt::CapturedStmtClass:
522 llvm_unreachable(
"CapturedStmt must be handled by the parent directive");
525 llvm_unreachable(
"Unexpected statement class");
529 bool useCurrentScope) {
532 return mlir::failure();
533 case Stmt::DeclStmtClass:
535 case Stmt::CompoundStmtClass:
539 case Stmt::GotoStmtClass:
541 case Stmt::ContinueStmtClass:
545 case Stmt::NullStmtClass:
548 case Stmt::LabelStmtClass:
550 case Stmt::CaseStmtClass:
551 case Stmt::DefaultStmtClass:
557 case Stmt::BreakStmtClass:
559 case Stmt::ReturnStmtClass:
561 case Stmt::AttributedStmtClass:
565 return mlir::success();
571 return mlir::failure();
581 mlir::Location loc) {
586 unsigned numBlocks = r.getBlocks().size();
587 for (
auto &block : r.getBlocks()) {
590 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
591 block.hasNoSuccessors())
592 eraseBlocks.push_back(&block);
595 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
596 mlir::OpBuilder::InsertionGuard guardCase(builder);
597 builder.setInsertionPointToEnd(&block);
598 builder.createYield(loc);
602 for (
auto *b : eraseBlocks)
607 mlir::LogicalResult res = mlir::success();
610 const Stmt *constevalExecuted;
613 if (!constevalExecuted) {
621 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
623 return emitStmt(constevalExecuted,
true);
627 return mlir::failure();
640 std::swap(executed, skipped);
649 return mlir::success();
662 cir::ScopeOp::create(builder, scopeLoc,
663 [&](mlir::OpBuilder &b, mlir::Location loc) {
665 builder.getInsertionBlock()};
666 res = ifStmtBuilder();
673 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
678 return mlir::success();
686 bool createNewScope =
false;
687 if (
const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
688 rv = ewc->getSubExpr();
689 createNewScope =
true;
692 auto handleReturnVal = [&]() {
703 builder.createFlagStore(loc,
true, nrvoFlag);
714 ->isReferenceType()) {
718 builder.CIRBaseBuilderTy::createStore(loc, result.
getValue(),
721 mlir::Value value =
nullptr;
726 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
745 if (!createNewScope) {
761 cir::AllocaOp retAlloca =
762 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
763 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
766 cir::ReturnOp::create(builder, loc, {value});
768 cir::ReturnOp::create(builder, loc);
774 builder.createBlock(builder.getBlock()->getParent());
775 return mlir::success();
791 builder.createBlock(builder.getBlock()->getParent());
793 return mlir::success();
802 return mlir::success();
812 builder.createBlock(builder.getBlock()->getParent());
813 return mlir::success();
821 builder.createBlock(builder.getBlock()->getParent());
823 return mlir::success();
830 mlir::Block *currBlock = builder.getBlock();
831 mlir::Block *labelBlock = currBlock;
833 if (!currBlock->empty() || currBlock->isEntryBlock()) {
835 mlir::OpBuilder::InsertionGuard guard(builder);
836 labelBlock = builder.createBlock(builder.getBlock()->getParent());
841 builder.setInsertionPointToEnd(labelBlock);
850 return mlir::success();
857 builder.createBlock(builder.getBlock()->getParent());
859 return mlir::success();
865 mlir::ArrayAttr value, CaseOpKind
kind,
866 bool buildingTopLevelCase) {
869 "only case or default stmt go here");
871 mlir::LogicalResult result = mlir::success();
873 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
876 SubStmtKind subStmtKind = SubStmtKind::Other;
877 const Stmt *sub =
stmt->getSubStmt();
879 mlir::OpBuilder::InsertPoint insertPoint;
880 CaseOp::create(builder, loc, value,
kind, insertPoint);
883 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
884 builder.restoreInsertionPoint(insertPoint);
887 subStmtKind = SubStmtKind::Default;
888 builder.createYield(loc);
890 subStmtKind = SubStmtKind::Case;
891 builder.createYield(loc);
896 insertPoint = builder.saveInsertionPoint();
931 if (subStmtKind == SubStmtKind::Case) {
933 }
else if (subStmtKind == SubStmtKind::Default) {
935 buildingTopLevelCase);
936 }
else if (buildingTopLevelCase) {
940 builder.restoreInsertionPoint(insertPoint);
948 bool buildingTopLevelCase) {
949 cir::CaseOpKind
kind;
950 mlir::ArrayAttr value;
956 condType = builder.getUIntNTy(1);
962 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
963 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
964 cir::IntAttr::get(condType, endVal)});
965 kind = cir::CaseOpKind::Range;
967 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
968 kind = cir::CaseOpKind::Equal;
972 buildingTopLevelCase);
977 bool buildingTopLevelCase) {
979 cir::CaseOpKind::Default, buildingTopLevelCase);
983 bool buildingTopLevelCase) {
985 "build switch case without specifying the type of the condition");
989 buildingTopLevelCase);
993 buildingTopLevelCase);
995 llvm_unreachable(
"expect case or default stmt");
1003 cgm.getCodeGenOpts(), attrs, mustProgress);
1010 auto convertFlag = [&](
bool set) {
1011 return set ? mlir::UnitAttr::get(ctx) : mlir::UnitAttr();
1013 auto convertStateToBool =
1017 return mlir::BoolAttr();
1019 return mlir::BoolAttr::get(ctx,
true);
1021 return mlir::BoolAttr::get(ctx,
false);
1023 llvm_unreachable(
"'full' only applies to unrolling");
1025 llvm_unreachable(
"unknown bool state");
1029 -> std::optional<cir::LoopUnrollMode> {
1032 return std::nullopt;
1034 return cir::LoopUnrollMode::Enable;
1036 return cir::LoopUnrollMode::Disable;
1038 return cir::LoopUnrollMode::Full;
1041 llvm_unreachable(
"unknown unroll state");
1053 auto hints = cir::LoopHintAttr::get(
1066 if (hints.isEmpty())
1072 cir::LoopHintAttr loopHints) {
1075 loopOp.setLoopHintsAttr(loopHints);
1076 loopOp.setLoopIdAttr(
1077 mlir::DistinctAttr::create(mlir::UnitAttr::get(loopOp->getContext())));
1085 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
1086 mlir::LogicalResult loopRes = mlir::success();
1090 return mlir::failure();
1092 return mlir::failure();
1094 return mlir::failure();
1096 return mlir::failure();
1100 cir::LoopHintAttr loopHints =
1103 forOp = builder.createFor(
1106 [&](mlir::OpBuilder &b, mlir::Location loc) {
1107 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1108 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1109 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1110 builder.createCondition(condVal);
1113 [&](mlir::OpBuilder &b, mlir::Location loc) {
1117 RunCleanupsScope bodyScope(*this);
1118 bool useCurrentScope = true;
1119 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
1120 loopRes = mlir::failure();
1121 if (emitStmt(s.getBody(), useCurrentScope).failed())
1122 loopRes = mlir::failure();
1126 [&](mlir::OpBuilder &b, mlir::Location loc) {
1128 if (emitStmt(s.getInc(), true).failed())
1129 loopRes = mlir::failure();
1130 builder.createYield(loc);
1136 mlir::LogicalResult res = mlir::success();
1138 cir::ScopeOp::create(builder, scopeLoc,
1139 [&](mlir::OpBuilder &b, mlir::Location loc) {
1145 builder.getInsertionBlock()};
1146 res = forStmtBuilder();
1153 return mlir::success();
1160 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
1161 mlir::LogicalResult loopRes = mlir::success();
1165 return mlir::failure();
1168 cir::LoopHintAttr loopHints =
getLoopHints(attrs, mustProgress);
1178 condVarExtendedTemporaries =
1180 bool needsCondCleanup =
1183 shouldEmitLifetimeMarkersForAutoVar() ||
1184 !condVarExtendedTemporaries.empty());
1187 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1190 mlir::Value condVal;
1195 condVarExtendedTemporaries);
1201 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
1203 builder.createCondition(condVal);
1205 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1210 loopRes = mlir::failure();
1213 auto stepBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1216 loopRes = mlir::failure();
1217 builder.createYield(loc);
1220 if (needsCondCleanup) {
1221 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1222 ? cir::CleanupKind::All
1223 : cir::CleanupKind::Normal;
1224 forOp = builder.createFor(
1227 [&](mlir::OpBuilder &b, mlir::Location loc) {
1228 loopCondScope.emitIntoCleanupRegion(loc);
1229 builder.createYield(loc);
1234 bodyBuilder, stepBuilder);
1241 auto res = mlir::success();
1243 cir::ScopeOp::create(builder, scopeLoc,
1244 [&](mlir::OpBuilder &b, mlir::Location loc) {
1246 builder.getInsertionBlock()};
1247 res = forStmtBuilder();
1254 return mlir::success();
1259 cir::DoWhileOp doWhileOp;
1261 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
1262 mlir::LogicalResult loopRes = mlir::success();
1265 cir::LoopHintAttr loopHints =
getLoopHints(attrs, mustProgress);
1267 doWhileOp = builder.createDoWhile(
1270 [&](mlir::OpBuilder &b, mlir::Location loc) {
1271 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1272 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1276 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1277 builder.createCondition(condVal);
1280 [&](mlir::OpBuilder &b, mlir::Location loc) {
1282 RunCleanupsScope bodyScope(*this);
1283 if (emitStmt(s.getBody(), false).failed())
1284 loopRes = mlir::failure();
1291 mlir::LogicalResult res = mlir::success();
1293 cir::ScopeOp::create(builder, scopeLoc,
1294 [&](mlir::OpBuilder &b, mlir::Location loc) {
1296 builder.getInsertionBlock()};
1297 res = doStmtBuilder();
1304 return mlir::success();
1310 cir::WhileOp whileOp;
1312 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
1313 mlir::LogicalResult loopRes = mlir::success();
1316 cir::LoopHintAttr loopHints =
getLoopHints(attrs, mustProgress);
1325 condVarExtendedTemporaries =
1327 bool needsCondCleanup =
1330 shouldEmitLifetimeMarkersForAutoVar() ||
1331 !condVarExtendedTemporaries.empty());
1334 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1340 condVarExtendedTemporaries);
1345 builder.createCondition(condVal);
1347 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1351 loopRes = mlir::failure();
1355 if (needsCondCleanup) {
1356 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1357 ? cir::CleanupKind::All
1358 : cir::CleanupKind::Normal;
1359 whileOp = builder.createWhile(
1362 [&](mlir::OpBuilder &b, mlir::Location loc) {
1363 loopCondScope.emitIntoCleanupRegion(loc);
1364 builder.createYield(loc);
1375 mlir::LogicalResult res = mlir::success();
1377 cir::ScopeOp::create(builder, scopeLoc,
1378 [&](mlir::OpBuilder &b, mlir::Location loc) {
1380 builder.getInsertionBlock()};
1381 res = whileStmtBuilder();
1388 return mlir::success();
1408 mlir::Block *switchBlock = builder.getBlock();
1414 builder.setInsertionPointToEnd(switchBlock);
1421 auto *c = body.front();
1424 return mlir::failure();
1426 body = body.drop_front();
1432 mlir::Block *lastBlock = builder.getBlock();
1433 switchBlock = builder.createBlock(switchBlock->getParent());
1434 builder.setInsertionPointToEnd(lastBlock);
1438 for (
auto *c : body) {
1439 if (
auto *
switchCase = dyn_cast<SwitchCase>(c)) {
1440 builder.setInsertionPointToEnd(switchBlock);
1446 return mlir::failure();
1453 return mlir::failure();
1456 return mlir::success();
1467 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1470 return mlir::failure();
1482 condV = builder.createBoolToInt(condV, builder.getUIntNTy(1));
1490 mlir::LogicalResult res = mlir::success();
1491 swop = SwitchOp::create(
1494 [&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
1495 curLexScope->setAsSwitch();
1497 condTypeStack.push_back(condV.getType());
1499 res = emitSwitchBody(s.getBody());
1501 condTypeStack.pop_back();
1509 mlir::LogicalResult res = mlir::success();
1510 cir::ScopeOp::create(builder, scopeLoc,
1511 [&](mlir::OpBuilder &b, mlir::Location loc) {
1513 builder.getInsertionBlock()};
1514 res = switchStmtBuilder();
1518 swop.collectCases(cases);
1519 for (
auto caseOp : cases)
1544 assert(rv.
isComplex() &&
"Unknown rvalue kind?");
1554 cir::AllocaOp retAlloca =
1555 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
1556 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
1559 cir::ReturnOp::create(builder, loc, {value});
static mlir::LogicalResult emitStmtWithResult(CIRGenFunction &cgf, const Stmt *exprResult, AggValueSlot slot, Address *lastValue)
static void setLoopHints(cir::LoopOpInterface loopOp, cir::LoopHintAttr loopHints)
static clang::AtomicOptions getAdjustedAtomicOptions(clang::AtomicOptions ao, const AtomicAttr *aa)
Compute the atomic options that apply for the extent of a clang::atomic attributed statement,...
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 variables whose lifetime ends in a region owned by an enclosing op rather than ...
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 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 emitForStmt(const clang::ForStmt &s, llvm::ArrayRef< const Attr * > attrs={})
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,...
mlir::LogicalResult emitDoStmt(const clang::DoStmt &s, llvm::ArrayRef< const Attr * > attrs={})
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)
void emitLoopConditionVariable(const clang::VarDecl &d, CapturedCleanups &condCleanup, llvm::ArrayRef< QualType > extendedTemporaries)
Emit a loop's condition-variable declaration.
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 emitWhileStmt(const clang::WhileStmt &s, llvm::ArrayRef< const Attr * > attrs={})
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 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 emitOMPTargetGenericLoopDirective(const OMPTargetGenericLoopDirective &s)
mlir::LogicalResult emitOMPTargetParallelForSimdDirective(const OMPTargetParallelForSimdDirective &s)
mlir::LogicalResult emitOMPInterchangeDirective(const OMPInterchangeDirective &s)
mlir::LogicalResult emitOMPDispatchDirective(const OMPDispatchDirective &s)
mlir::LogicalResult emitOMPParallelDirective(const OMPParallelDirective &s)
mlir::LogicalResult emitCXXTryStmt(const clang::CXXTryStmt &s, cxxTryBodyEmitter &bodyCallback, bool isFnTryBlock=false)
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)
bool checkIfLoopMustProgress(const clang::Expr *controllingExpression, bool hasEmptyBody)
cir::LoopHintAttr getLoopHints(llvm::ArrayRef< const Attr * > attrs, bool mustProgress)
Build the hints that get attached to a loop, or a null attribute if there is nothing to say about it.
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::MLIRContext & getMLIRContext()
mlir::LogicalResult emitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct &s)
mlir::LogicalResult emitOMPTargetExitDataDirective(const OMPTargetExitDataDirective &s)
bool containsLabel(const clang::Stmt *s, bool ignoreCaseStmts=false)
Return true if the statement contains a label in it.
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 emitLabelStmt(const clang::LabelStmt &s)
mlir::LogicalResult emitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &s)
LexicalScope * curLexScope
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)
static llvm::SmallVector< QualType, 2 > getLifetimeExtendedTemporariesWithDestructor(const clang::VarDecl &d)
The types of the temporaries with a destructor that the initializer of the variable d,...
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.
Encodes a location in the source.
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 ...
void updateLoopAttributes(LoopAttributes &Attrs, ASTContext &Ctx, const CodeGenOptions &CGOpts, llvm::ArrayRef< const Attr * > StmtAttrs, bool MustProgress)
Update Attrs with the loop hints in StmtAttrs (#pragma clang loop, #pragma unroll,...
bool hasEmptyLoopBody(const LoopStmt &S)
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)
static bool aggValueSlotGC()
static bool createProfileWeightsForLoop()
static bool loopInfoStack()
static bool emitCondLikelihoodViaExpectIntrinsic()
static bool constantFoldSwitchStatement()
static bool insertBuiltinUnpredictable()
static bool generateDebugInfo()
static bool incrementProfileCounter()
unsigned fine_grained_memory
unsigned ignore_denormal_mode
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
Attributes that may be specified on loops.
bool LICMDisabled
Value for llvm.licm.disable metadata.
LVEnableState VectorizeEnable
Value for llvm.loop.vectorize.enable metadata.
LVEnableState VectorizeScalable
unsigned UnrollCount
llvm.unroll.
LVEnableState UnrollEnable
Value for llvm.loop.unroll.* metadata (enable, disable, or full).
unsigned PipelineInitiationInterval
Value for llvm.loop.pipeline.iicount metadata.
unsigned UnrollAndJamCount
llvm.unroll.
unsigned CodeAlign
Value for 'llvm.loop.align' metadata.
unsigned VectorizeWidth
Value for llvm.loop.vectorize.width metadata.
LVEnableState UnrollAndJamEnable
Value for llvm.loop.unroll_and_jam.* metadata (enable, disable, or full).
LVEnableState VectorizePredicateEnable
Value for llvm.loop.vectorize.predicate metadata.
bool PipelineDisabled
Value for llvm.loop.pipeline.disable metadata.
bool IsParallel
Generate llvm.loop.parallel metadata for loads and stores.
LVEnableState
State of loop vectorization or unrolling.
bool MustProgress
Value for whether the loop is required to make progress.
LVEnableState DistributeEnable
Value for llvm.loop.distribute.enable metadata.
unsigned InterleaveCount
Value for llvm.loop.interleave.count metadata.