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:
435 return mlir::failure();
436 case Stmt::CapturedStmtClass:
437 llvm_unreachable(
"CapturedStmt must be handled by the parent directive");
440 llvm_unreachable(
"Unexpected statement class");
444 bool useCurrentScope) {
447 return mlir::failure();
448 case Stmt::DeclStmtClass:
450 case Stmt::CompoundStmtClass:
454 case Stmt::GotoStmtClass:
456 case Stmt::ContinueStmtClass:
460 case Stmt::NullStmtClass:
463 case Stmt::LabelStmtClass:
465 case Stmt::CaseStmtClass:
466 case Stmt::DefaultStmtClass:
472 case Stmt::BreakStmtClass:
474 case Stmt::ReturnStmtClass:
476 case Stmt::AttributedStmtClass:
480 return mlir::success();
486 return mlir::failure();
496 mlir::Location loc) {
501 unsigned numBlocks = r.getBlocks().size();
502 for (
auto &block : r.getBlocks()) {
505 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
506 block.hasNoSuccessors())
507 eraseBlocks.push_back(&block);
510 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
511 mlir::OpBuilder::InsertionGuard guardCase(builder);
512 builder.setInsertionPointToEnd(&block);
513 builder.createYield(loc);
517 for (
auto *b : eraseBlocks)
522 mlir::LogicalResult res = mlir::success();
525 const Stmt *constevalExecuted;
528 if (!constevalExecuted) {
536 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
538 return emitStmt(constevalExecuted,
true);
542 return mlir::failure();
560 return mlir::success();
573 cir::ScopeOp::create(builder, scopeLoc,
574 [&](mlir::OpBuilder &b, mlir::Location loc) {
576 builder.getInsertionBlock()};
577 res = ifStmtBuilder();
584 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
589 return mlir::success();
597 bool createNewScope =
false;
598 if (
const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
599 rv = ewc->getSubExpr();
600 createNewScope =
true;
603 auto handleReturnVal = [&]() {
614 builder.createFlagStore(loc,
true, nrvoFlag);
625 ->isReferenceType()) {
629 builder.CIRBaseBuilderTy::createStore(loc, result.
getValue(),
632 mlir::Value value =
nullptr;
637 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
656 if (!createNewScope) {
672 cir::AllocaOp retAlloca =
673 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
674 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
677 cir::ReturnOp::create(builder, loc, {value});
679 cir::ReturnOp::create(builder, loc);
685 builder.createBlock(builder.getBlock()->getParent());
686 return mlir::success();
702 builder.createBlock(builder.getBlock()->getParent());
704 return mlir::success();
716 builder.createBlock(builder.getBlock()->getParent());
717 return mlir::success();
725 builder.createBlock(builder.getBlock()->getParent());
727 return mlir::success();
734 mlir::Block *currBlock = builder.getBlock();
735 mlir::Block *labelBlock = currBlock;
737 if (!currBlock->empty() || currBlock->isEntryBlock()) {
739 mlir::OpBuilder::InsertionGuard guard(builder);
740 labelBlock = builder.createBlock(builder.getBlock()->getParent());
745 builder.setInsertionPointToEnd(labelBlock);
748 builder.setInsertionPointToEnd(labelBlock);
750 cgm.mapBlockAddress(cir::BlockAddrInfoAttr::get(builder.getContext(),
757 return mlir::success();
764 builder.createBlock(builder.getBlock()->getParent());
766 return mlir::success();
772 mlir::ArrayAttr value, CaseOpKind
kind,
773 bool buildingTopLevelCase) {
776 "only case or default stmt go here");
778 mlir::LogicalResult result = mlir::success();
780 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
783 SubStmtKind subStmtKind = SubStmtKind::Other;
784 const Stmt *sub =
stmt->getSubStmt();
786 mlir::OpBuilder::InsertPoint insertPoint;
787 CaseOp::create(builder, loc, value,
kind, insertPoint);
790 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
791 builder.restoreInsertionPoint(insertPoint);
794 subStmtKind = SubStmtKind::Default;
795 builder.createYield(loc);
797 subStmtKind = SubStmtKind::Case;
798 builder.createYield(loc);
803 insertPoint = builder.saveInsertionPoint();
838 if (subStmtKind == SubStmtKind::Case) {
840 }
else if (subStmtKind == SubStmtKind::Default) {
842 buildingTopLevelCase);
843 }
else if (buildingTopLevelCase) {
847 builder.restoreInsertionPoint(insertPoint);
855 bool buildingTopLevelCase) {
856 cir::CaseOpKind
kind;
857 mlir::ArrayAttr value;
864 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
865 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
866 cir::IntAttr::get(condType, endVal)});
867 kind = cir::CaseOpKind::Range;
869 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
870 kind = cir::CaseOpKind::Equal;
874 buildingTopLevelCase);
879 bool buildingTopLevelCase) {
881 cir::CaseOpKind::Default, buildingTopLevelCase);
885 bool buildingTopLevelCase) {
887 "build switch case without specifying the type of the condition");
891 buildingTopLevelCase);
895 buildingTopLevelCase);
897 llvm_unreachable(
"expect case or default stmt");
906 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
907 mlir::LogicalResult loopRes = mlir::success();
911 return mlir::failure();
913 return mlir::failure();
915 return mlir::failure();
917 return mlir::failure();
921 forOp = builder.createFor(
924 [&](mlir::OpBuilder &b, mlir::Location loc) {
925 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
926 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
927 mlir::Value condVal = evaluateExprAsBool(s.getCond());
928 builder.createCondition(condVal);
931 [&](mlir::OpBuilder &b, mlir::Location loc) {
935 RunCleanupsScope bodyScope(*this);
936 bool useCurrentScope = true;
937 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
938 loopRes = mlir::failure();
939 if (emitStmt(s.getBody(), useCurrentScope).failed())
940 loopRes = mlir::failure();
944 [&](mlir::OpBuilder &b, mlir::Location loc) {
946 if (emitStmt(s.getInc(), true).failed())
947 loopRes = mlir::failure();
948 builder.createYield(loc);
953 mlir::LogicalResult res = mlir::success();
955 cir::ScopeOp::create(builder, scopeLoc,
956 [&](mlir::OpBuilder &b, mlir::Location loc) {
962 builder.getInsertionBlock()};
963 res = forStmtBuilder();
970 return mlir::success();
977 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
978 mlir::LogicalResult loopRes = mlir::success();
982 return mlir::failure();
985 forOp = builder.createFor(
988 [&](mlir::OpBuilder &b, mlir::Location loc) {
989 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
990 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
995 if (s.getConditionVariable())
996 emitDecl(*s.getConditionVariable());
1000 condVal = evaluateExprAsBool(s.getCond());
1002 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
1004 builder.createCondition(condVal);
1007 [&](mlir::OpBuilder &b, mlir::Location loc) {
1012 loopRes = mlir::failure();
1016 [&](mlir::OpBuilder &b, mlir::Location loc) {
1019 loopRes = mlir::failure();
1020 builder.createYield(loc);
1025 auto res = mlir::success();
1026 auto scopeLoc = getLoc(s.getSourceRange());
1027 cir::ScopeOp::create(builder, scopeLoc,
1028 [&](mlir::OpBuilder &b, mlir::Location loc) {
1029 LexicalScope lexScope{*
this, loc,
1030 builder.getInsertionBlock()};
1031 res = forStmtBuilder();
1037 terminateStructuredRegionBody(forOp.getBody(), getLoc(s.getEndLoc()));
1038 return mlir::success();
1042 cir::DoWhileOp doWhileOp;
1045 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
1046 mlir::LogicalResult loopRes = mlir::success();
1049 doWhileOp = builder.createDoWhile(
1052 [&](mlir::OpBuilder &b, mlir::Location loc) {
1053 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1054 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1058 mlir::Value condVal = evaluateExprAsBool(s.getCond());
1059 builder.createCondition(condVal);
1062 [&](mlir::OpBuilder &b, mlir::Location loc) {
1064 RunCleanupsScope bodyScope(*this);
1065 if (emitStmt(s.getBody(), false).failed())
1066 loopRes = mlir::failure();
1072 mlir::LogicalResult res = mlir::success();
1074 cir::ScopeOp::create(builder, scopeLoc,
1075 [&](mlir::OpBuilder &b, mlir::Location loc) {
1077 builder.getInsertionBlock()};
1078 res = doStmtBuilder();
1085 return mlir::success();
1089 cir::WhileOp whileOp;
1092 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
1093 mlir::LogicalResult loopRes = mlir::success();
1096 whileOp = builder.createWhile(
1099 [&](mlir::OpBuilder &b, mlir::Location loc) {
1100 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
1101 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
1102 mlir::Value condVal;
1105 if (s.getConditionVariable())
1106 emitDecl(*s.getConditionVariable());
1110 condVal = evaluateExprAsBool(s.getCond());
1111 builder.createCondition(condVal);
1114 [&](mlir::OpBuilder &b, mlir::Location loc) {
1116 RunCleanupsScope bodyScope(*this);
1117 if (emitStmt(s.getBody(), false).failed())
1118 loopRes = mlir::failure();
1124 mlir::LogicalResult res = mlir::success();
1126 cir::ScopeOp::create(builder, scopeLoc,
1127 [&](mlir::OpBuilder &b, mlir::Location loc) {
1129 builder.getInsertionBlock()};
1130 res = whileStmtBuilder();
1137 return mlir::success();
1157 mlir::Block *switchBlock = builder.getBlock();
1163 builder.setInsertionPointToEnd(switchBlock);
1170 auto *c = body.front();
1173 return mlir::failure();
1175 body = body.drop_front();
1181 mlir::Block *lastBlock = builder.getBlock();
1182 switchBlock = builder.createBlock(switchBlock->getParent());
1183 builder.setInsertionPointToEnd(lastBlock);
1187 for (
auto *c : body) {
1188 if (
auto *
switchCase = dyn_cast<SwitchCase>(c)) {
1189 builder.setInsertionPointToEnd(switchBlock);
1195 return mlir::failure();
1202 return mlir::failure();
1205 return mlir::success();
1216 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1219 return mlir::failure();
1232 mlir::LogicalResult res = mlir::success();
1233 swop = SwitchOp::create(
1236 [&](mlir::OpBuilder &b, mlir::Location loc, mlir::OperationState &os) {
1237 curLexScope->setAsSwitch();
1239 condTypeStack.push_back(condV.getType());
1241 res = emitSwitchBody(s.getBody());
1243 condTypeStack.pop_back();
1251 mlir::LogicalResult res = mlir::success();
1252 cir::ScopeOp::create(builder, scopeLoc,
1253 [&](mlir::OpBuilder &b, mlir::Location loc) {
1255 builder.getInsertionBlock()};
1256 res = switchStmtBuilder();
1260 swop.collectCases(cases);
1261 for (
auto caseOp : cases)
1286 cgm.errorNYI(loc,
"emitReturnOfRValue: complex return type");
1295 cir::AllocaOp retAlloca =
1296 mlir::cast<cir::AllocaOp>(
fnRetAlloca->getDefiningOp());
1297 auto value = cir::LoadOp::create(builder, loc, retAlloca.getAllocaType(),
1300 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)
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)
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,...
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.
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
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO).
WhileStmt - This represents a 'while' stmt.
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.
U cast(CodeGen::Address addr)
@ Other
Other implicit parameter.
static bool aggValueSlotGC()
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...