16#include "mlir/IR/Builders.h"
17#include "mlir/IR/Location.h"
18#include "mlir/Support/LLVM.h"
30 const Stmt *exprResult,
39 if (
const auto *ls = dyn_cast<LabelStmt>(exprResult)) {
40 if (cgf.
emitLabel(*ls->getDecl()).failed())
41 return mlir::failure();
42 exprResult = ls->getSubStmt();
43 }
else if (
const auto *as = dyn_cast<AttributedStmt>(exprResult)) {
46 exprResult = as->getSubStmt();
48 llvm_unreachable(
"Unknown value statement");
64 return mlir::success();
69 mlir::LogicalResult result = mlir::success();
71 assert((!lastValue || (lastValue && exprResult)) &&
72 "If lastValue is not null then the CompoundStmt must have a "
75 for (
const Stmt *curStmt : s.
body()) {
76 const bool saveResult = lastValue && exprResult == curStmt;
79 result = mlir::failure();
81 if (
emitStmt(curStmt,
false).failed())
82 result = mlir::failure();
91 switch (
attr->getKind()) {
96 case attr::AlwaysInline:
97 case attr::NoConvergent:
100 case attr::HLSLControlFlowHint:
102 "Unimplemented statement attribute: ",
attr->getKind());
104 case attr::CXXAssume: {
106 if (
getLangOpts().CXXAssumptions && builder.getInsertionBlock() &&
110 assumptionValue, cir::AssumeBundleKind::None,
126 mlir::OpBuilder::InsertPoint scopeInsPt;
127 cir::ScopeOp::create(
129 [&](mlir::OpBuilder &b, mlir::Type &
type, mlir::Location loc) {
130 scopeInsPt = b.saveInsertionPoint();
132 mlir::OpBuilder::InsertionGuard guard(builder);
133 builder.restoreInsertionPoint(scopeInsPt);
134 LexicalScope lexScope(*
this, scopeLoc, builder.getInsertionBlock());
145 bool useCurrentScope,
148 return mlir::success();
152 case Stmt::CXXCatchStmtClass:
153 case Stmt::SEHExceptStmtClass:
154 case Stmt::SEHFinallyStmtClass:
155 case Stmt::MSDependentExistsStmtClass:
156 case Stmt::UnresolvedSYCLKernelCallStmtClass:
157 llvm_unreachable(
"invalid statement class to emit generically");
158 case Stmt::BreakStmtClass:
159 case Stmt::NullStmtClass:
160 case Stmt::CompoundStmtClass:
161 case Stmt::ContinueStmtClass:
162 case Stmt::DeclStmtClass:
163 case Stmt::ReturnStmtClass:
164 llvm_unreachable(
"should have emitted these statements as simple");
166#define STMT(Type, Base)
167#define ABSTRACT_STMT(Op)
168#define EXPR(Type, Base) case Stmt::Type##Class:
169#include "clang/AST/StmtNodes.inc"
171 assert(builder.getInsertionBlock() &&
172 "expression emission must have an insertion point");
180 return mlir::success();
182 case Stmt::IfStmtClass:
184 case Stmt::SwitchStmtClass:
186 case Stmt::ForStmtClass:
188 case Stmt::WhileStmtClass:
190 case Stmt::DoStmtClass:
192 case Stmt::CXXTryStmtClass:
194 case Stmt::CXXForRangeStmtClass:
196 case Stmt::CoroutineBodyStmtClass:
198 case Stmt::IndirectGotoStmtClass:
200 case Stmt::CoreturnStmtClass:
202 case Stmt::OpenACCComputeConstructClass:
204 case Stmt::OpenACCLoopConstructClass:
206 case Stmt::OpenACCCombinedConstructClass:
208 case Stmt::OpenACCDataConstructClass:
210 case Stmt::OpenACCEnterDataConstructClass:
212 case Stmt::OpenACCExitDataConstructClass:
214 case Stmt::OpenACCHostDataConstructClass:
216 case Stmt::OpenACCWaitConstructClass:
218 case Stmt::OpenACCInitConstructClass:
220 case Stmt::OpenACCShutdownConstructClass:
222 case Stmt::OpenACCSetConstructClass:
224 case Stmt::OpenACCUpdateConstructClass:
226 case Stmt::OpenACCCacheConstructClass:
228 case Stmt::OpenACCAtomicConstructClass:
230 case Stmt::GCCAsmStmtClass:
231 case Stmt::MSAsmStmtClass:
233 case Stmt::OMPScopeDirectiveClass:
235 case Stmt::OMPErrorDirectiveClass:
237 case Stmt::OMPParallelDirectiveClass:
239 case Stmt::OMPTaskwaitDirectiveClass:
241 case Stmt::OMPTaskyieldDirectiveClass:
243 case Stmt::OMPBarrierDirectiveClass:
245 case Stmt::OMPMetaDirectiveClass:
247 case Stmt::OMPCanonicalLoopClass:
249 case Stmt::OMPSimdDirectiveClass:
251 case Stmt::OMPTileDirectiveClass:
253 case Stmt::OMPUnrollDirectiveClass:
255 case Stmt::OMPFuseDirectiveClass:
257 case Stmt::OMPForDirectiveClass:
259 case Stmt::OMPForSimdDirectiveClass:
261 case Stmt::OMPSectionsDirectiveClass:
263 case Stmt::OMPSectionDirectiveClass:
265 case Stmt::OMPSingleDirectiveClass:
267 case Stmt::OMPMasterDirectiveClass:
269 case Stmt::OMPCriticalDirectiveClass:
271 case Stmt::OMPParallelForDirectiveClass:
273 case Stmt::OMPParallelForSimdDirectiveClass:
276 case Stmt::OMPParallelMasterDirectiveClass:
278 case Stmt::OMPParallelSectionsDirectiveClass:
281 case Stmt::OMPTaskDirectiveClass:
283 case Stmt::OMPTaskgroupDirectiveClass:
285 case Stmt::OMPFlushDirectiveClass:
287 case Stmt::OMPDepobjDirectiveClass:
289 case Stmt::OMPScanDirectiveClass:
291 case Stmt::OMPOrderedDirectiveClass:
293 case Stmt::OMPAtomicDirectiveClass:
295 case Stmt::OMPTargetDirectiveClass:
297 case Stmt::OMPTeamsDirectiveClass:
299 case Stmt::OMPCancellationPointDirectiveClass:
302 case Stmt::OMPCancelDirectiveClass:
304 case Stmt::OMPTargetDataDirectiveClass:
306 case Stmt::OMPTargetEnterDataDirectiveClass:
309 case Stmt::OMPTargetExitDataDirectiveClass:
311 case Stmt::OMPTargetParallelDirectiveClass:
313 case Stmt::OMPTargetParallelForDirectiveClass:
316 case Stmt::OMPTaskLoopDirectiveClass:
318 case Stmt::OMPTaskLoopSimdDirectiveClass:
320 case Stmt::OMPMaskedTaskLoopDirectiveClass:
322 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
325 case Stmt::OMPMasterTaskLoopDirectiveClass:
327 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
330 case Stmt::OMPParallelGenericLoopDirectiveClass:
333 case Stmt::OMPParallelMaskedDirectiveClass:
335 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
338 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
341 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
344 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
347 case Stmt::OMPDistributeDirectiveClass:
349 case Stmt::OMPDistributeParallelForDirectiveClass:
352 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
355 case Stmt::OMPDistributeSimdDirectiveClass:
357 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
360 case Stmt::OMPTargetParallelForSimdDirectiveClass:
363 case Stmt::OMPTargetSimdDirectiveClass:
365 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
368 case Stmt::OMPTargetUpdateDirectiveClass:
370 case Stmt::OMPTeamsDistributeDirectiveClass:
373 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
376 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
379 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
382 case Stmt::OMPTeamsGenericLoopDirectiveClass:
385 case Stmt::OMPTargetTeamsDirectiveClass:
387 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
390 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
393 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
396 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
399 case Stmt::OMPInteropDirectiveClass:
401 case Stmt::OMPDispatchDirectiveClass:
403 case Stmt::OMPGenericLoopDirectiveClass:
405 case Stmt::OMPReverseDirectiveClass:
407 case Stmt::OMPSplitDirectiveClass:
409 case Stmt::OMPInterchangeDirectiveClass:
411 case Stmt::OMPAssumeDirectiveClass:
413 case Stmt::OMPMaskedDirectiveClass:
415 case Stmt::OMPStripeDirectiveClass:
417 case Stmt::LabelStmtClass:
418 case Stmt::AttributedStmtClass:
419 case Stmt::GotoStmtClass:
420 case Stmt::DefaultStmtClass:
421 case Stmt::CaseStmtClass:
422 case Stmt::SEHLeaveStmtClass:
423 case Stmt::SYCLKernelCallStmtClass:
424 case Stmt::ObjCAtTryStmtClass:
425 case Stmt::ObjCAtThrowStmtClass:
426 case Stmt::ObjCAtSynchronizedStmtClass:
427 case Stmt::ObjCForCollectionStmtClass:
428 case Stmt::ObjCAutoreleasePoolStmtClass:
429 case Stmt::SEHTryStmtClass:
430 case Stmt::ObjCAtCatchStmtClass:
431 case Stmt::ObjCAtFinallyStmtClass:
432 case Stmt::DeferStmtClass:
433 case Stmt::CXXExpansionStmtPatternClass:
434 case Stmt::CXXExpansionStmtInstantiationClass:
437 return mlir::failure();
438 case Stmt::CapturedStmtClass:
439 llvm_unreachable(
"CapturedStmt must be handled by the parent directive");
442 llvm_unreachable(
"Unexpected statement class");
446 bool useCurrentScope) {
449 return mlir::failure();
450 case Stmt::DeclStmtClass:
452 case Stmt::CompoundStmtClass:
456 case Stmt::GotoStmtClass:
458 case Stmt::ContinueStmtClass:
462 case Stmt::NullStmtClass:
465 case Stmt::LabelStmtClass:
467 case Stmt::CaseStmtClass:
468 case Stmt::DefaultStmtClass:
474 case Stmt::BreakStmtClass:
476 case Stmt::ReturnStmtClass:
478 case Stmt::AttributedStmtClass:
482 return mlir::success();
488 return mlir::failure();
498 mlir::Location loc) {
503 unsigned numBlocks = r.getBlocks().size();
504 for (
auto &block : r.getBlocks()) {
507 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
508 block.hasNoSuccessors())
509 eraseBlocks.push_back(&block);
512 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
513 mlir::OpBuilder::InsertionGuard guardCase(builder);
514 builder.setInsertionPointToEnd(&block);
515 builder.createYield(loc);
519 for (
auto *b : eraseBlocks)
524 mlir::LogicalResult res = mlir::success();
527 const Stmt *constevalExecuted;
530 if (!constevalExecuted) {
538 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
540 return emitStmt(constevalExecuted,
true);
544 return mlir::failure();
562 return mlir::success();
575 cir::ScopeOp::create(builder, scopeLoc,
576 [&](mlir::OpBuilder &b, mlir::Location loc) {
578 builder.getInsertionBlock()};
579 res = ifStmtBuilder();
586 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
591 return mlir::success();
599 bool createNewScope =
false;
600 if (
const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
601 rv = ewc->getSubExpr();
602 createNewScope =
true;
605 auto handleReturnVal = [&]() {
616 builder.createFlagStore(loc,
true, nrvoFlag);
627 ->isReferenceType()) {
631 builder.CIRBaseBuilderTy::createStore(loc, result.
getValue(),
634 mlir::Value value =
nullptr;
639 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
658 if (!createNewScope) {
674 cir::AllocaOp retAlloca =
675 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
676 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
679 cir::ReturnOp::create(builder, loc, {value});
681 cir::ReturnOp::create(builder, loc);
687 builder.createBlock(builder.getBlock()->getParent());
688 return mlir::success();
704 builder.createBlock(builder.getBlock()->getParent());
706 return mlir::success();
718 builder.createBlock(builder.getBlock()->getParent());
719 return mlir::success();
727 builder.createBlock(builder.getBlock()->getParent());
729 return mlir::success();
736 mlir::Block *currBlock = builder.getBlock();
737 mlir::Block *labelBlock = currBlock;
739 if (!currBlock->empty() || currBlock->isEntryBlock()) {
741 mlir::OpBuilder::InsertionGuard guard(builder);
742 labelBlock = builder.createBlock(builder.getBlock()->getParent());
747 builder.setInsertionPointToEnd(labelBlock);
750 builder.setInsertionPointToEnd(labelBlock);
752 cgm.mapBlockAddress(cir::BlockAddrInfoAttr::get(builder.getContext(),
759 return mlir::success();
766 builder.createBlock(builder.getBlock()->getParent());
768 return mlir::success();
774 mlir::ArrayAttr value, CaseOpKind
kind,
775 bool buildingTopLevelCase) {
778 "only case or default stmt go here");
780 mlir::LogicalResult result = mlir::success();
782 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
785 SubStmtKind subStmtKind = SubStmtKind::Other;
786 const Stmt *sub =
stmt->getSubStmt();
788 mlir::OpBuilder::InsertPoint insertPoint;
789 CaseOp::create(builder, loc, value,
kind, insertPoint);
792 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
793 builder.restoreInsertionPoint(insertPoint);
796 subStmtKind = SubStmtKind::Default;
797 builder.createYield(loc);
799 subStmtKind = SubStmtKind::Case;
800 builder.createYield(loc);
805 insertPoint = builder.saveInsertionPoint();
840 if (subStmtKind == SubStmtKind::Case) {
842 }
else if (subStmtKind == SubStmtKind::Default) {
844 buildingTopLevelCase);
845 }
else if (buildingTopLevelCase) {
849 builder.restoreInsertionPoint(insertPoint);
857 bool buildingTopLevelCase) {
858 cir::CaseOpKind
kind;
859 mlir::ArrayAttr value;
866 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
867 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
868 cir::IntAttr::get(condType, endVal)});
869 kind = cir::CaseOpKind::Range;
871 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
872 kind = cir::CaseOpKind::Equal;
876 buildingTopLevelCase);
881 bool buildingTopLevelCase) {
883 cir::CaseOpKind::Default, buildingTopLevelCase);
887 bool buildingTopLevelCase) {
889 "build switch case without specifying the type of the condition");
893 buildingTopLevelCase);
897 buildingTopLevelCase);
899 llvm_unreachable(
"expect case or default stmt");
908 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
909 mlir::LogicalResult loopRes = mlir::success();
913 return mlir::failure();
915 return mlir::failure();
917 return mlir::failure();
919 return mlir::failure();
923 forOp = builder.createFor(
926 [&](mlir::OpBuilder &b, mlir::Location loc) {
927 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
928 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
929 mlir::Value condVal = evaluateExprAsBool(s.getCond());
930 builder.createCondition(condVal);
933 [&](mlir::OpBuilder &b, mlir::Location loc) {
937 RunCleanupsScope bodyScope(*this);
938 bool useCurrentScope = true;
939 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
940 loopRes = mlir::failure();
941 if (emitStmt(s.getBody(), useCurrentScope).failed())
942 loopRes = mlir::failure();
946 [&](mlir::OpBuilder &b, mlir::Location loc) {
948 if (emitStmt(s.getInc(), true).failed())
949 loopRes = mlir::failure();
950 builder.createYield(loc);
955 mlir::LogicalResult res = mlir::success();
957 cir::ScopeOp::create(builder, scopeLoc,
958 [&](mlir::OpBuilder &b, mlir::Location loc) {
964 builder.getInsertionBlock()};
965 res = forStmtBuilder();
972 return mlir::success();
979 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
980 mlir::LogicalResult loopRes = mlir::success();
984 return mlir::failure();
992 bool needsCondCleanup =
998 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1001 mlir::Value condVal;
1011 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
1013 builder.createCondition(condVal);
1015 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1020 loopRes = mlir::failure();
1023 auto stepBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1026 loopRes = mlir::failure();
1027 builder.createYield(loc);
1030 if (needsCondCleanup) {
1031 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1032 ? cir::CleanupKind::All
1033 : cir::CleanupKind::Normal;
1034 forOp = builder.createFor(
1037 [&](mlir::OpBuilder &b, mlir::Location loc) {
1038 loopCondScope.emitIntoLoopCleanupRegion(loc);
1039 builder.createYield(loc);
1044 bodyBuilder, stepBuilder);
1049 auto res = mlir::success();
1051 cir::ScopeOp::create(builder, scopeLoc,
1052 [&](mlir::OpBuilder &b, mlir::Location loc) {
1054 builder.getInsertionBlock()};
1055 res = forStmtBuilder();
1062 return mlir::success();
1066 cir::DoWhileOp doWhileOp;
1069 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
1070 mlir::LogicalResult loopRes = mlir::success();
1073 doWhileOp = builder.createDoWhile(
1076 [&](mlir::OpBuilder &b, mlir::Location loc) {
1077 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1078 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1082 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1083 builder.createCondition(condVal);
1086 [&](mlir::OpBuilder &b, mlir::Location loc) {
1088 RunCleanupsScope bodyScope(*this);
1089 if (emitStmt(s.getBody(), false).failed())
1090 loopRes = mlir::failure();
1096 mlir::LogicalResult res = mlir::success();
1098 cir::ScopeOp::create(builder, scopeLoc,
1099 [&](mlir::OpBuilder &b, mlir::Location loc) {
1101 builder.getInsertionBlock()};
1102 res = doStmtBuilder();
1109 return mlir::success();
1113 cir::WhileOp whileOp;
1116 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
1117 mlir::LogicalResult loopRes = mlir::success();
1124 bool needsCondCleanup =
1130 auto condBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1140 builder.createCondition(condVal);
1142 auto bodyBuilder = [&](mlir::OpBuilder &b, mlir::Location loc) {
1146 loopRes = mlir::failure();
1150 if (needsCondCleanup) {
1151 cir::CleanupKind cleanupKind =
getLangOpts().Exceptions
1152 ? cir::CleanupKind::All
1153 : cir::CleanupKind::Normal;
1154 whileOp = builder.createWhile(
1157 [&](mlir::OpBuilder &b, mlir::Location loc) {
1158 loopCondScope.emitIntoLoopCleanupRegion(loc);
1159 builder.createYield(loc);
1169 mlir::LogicalResult res = mlir::success();
1171 cir::ScopeOp::create(builder, scopeLoc,
1172 [&](mlir::OpBuilder &b, mlir::Location loc) {
1174 builder.getInsertionBlock()};
1175 res = whileStmtBuilder();
1182 return mlir::success();
1202 mlir::Block *switchBlock = builder.getBlock();
1208 builder.setInsertionPointToEnd(switchBlock);
1215 auto *c = body.front();
1218 return mlir::failure();
1220 body = body.drop_front();
1226 mlir::Block *lastBlock = builder.getBlock();
1227 switchBlock = builder.createBlock(switchBlock->getParent());
1228 builder.setInsertionPointToEnd(lastBlock);
1232 for (
auto *c : body) {
1233 if (
auto *
switchCase = dyn_cast<SwitchCase>(c)) {
1234 builder.setInsertionPointToEnd(switchBlock);
1240 return mlir::failure();
1247 return mlir::failure();
1250 return mlir::success();
1261 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1264 return mlir::failure();
1277 mlir::LogicalResult res = mlir::success();
1278 swop = SwitchOp::create(
1281 [&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
1282 curLexScope->setAsSwitch();
1284 condTypeStack.push_back(condV.getType());
1286 res = emitSwitchBody(s.getBody());
1288 condTypeStack.pop_back();
1296 mlir::LogicalResult res = mlir::success();
1297 cir::ScopeOp::create(builder, scopeLoc,
1298 [&](mlir::OpBuilder &b, mlir::Location loc) {
1300 builder.getInsertionBlock()};
1301 res = switchStmtBuilder();
1305 swop.collectCases(cases);
1306 for (
auto caseOp : cases)
1331 cgm.errorNYI(loc,
"emitReturnOfRValue: complex return type");
1340 cir::AllocaOp retAlloca =
1341 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
1342 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
1345 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.
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)
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::Block * indirectGotoBlock
IndirectBranch - The first time an indirect goto is seen we create a block reserved for the indirect ...
mlir::Operation * curFn
The current function or global initializer that is generated code for.
mlir::LogicalResult emitAsmStmt(const clang::AsmStmt &s)
mlir::LogicalResult emitOMPParallelForSimdDirective(const OMPParallelForSimdDirective &s)
mlir::LogicalResult emitOMPDistributeParallelForDirective(const OMPDistributeParallelForDirective &s)
mlir::LogicalResult emitOpenACCComputeConstruct(const OpenACCComputeConstruct &s)
mlir::LogicalResult emitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &s)
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 emitOMPOrderedDirective(const OMPOrderedDirective &s)
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)
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 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)
void instantiateIndirectGotoBlock()
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)
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)
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.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
DeclStmt * getBeginStmt()
DeclStmt * getRangeStmt()
SourceLocation getEndLoc() const LLVM_READONLY
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.
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.
The JSON file list parser is used to communicate input to InstallAPI.
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...