16#include "mlir/IR/Builders.h"
17#include "mlir/IR/Location.h"
18#include "mlir/Support/LLVM.h"
29 const Stmt *exprResult,
37 while (!isa<Expr>(exprResult)) {
38 if (
const auto *ls = dyn_cast<LabelStmt>(exprResult)) {
39 if (cgf.
emitLabel(*ls->getDecl()).failed())
40 return mlir::failure();
41 exprResult = ls->getSubStmt();
42 }
else if (
const auto *as = dyn_cast<AttributedStmt>(exprResult)) {
45 exprResult = as->getSubStmt();
47 llvm_unreachable(
"Unknown value statement");
51 const Expr *e = cast<Expr>(exprResult);
63 return mlir::success();
68 mlir::LogicalResult result = mlir::success();
69 const Stmt *exprResult =
s.getStmtExprResult();
70 assert((!lastValue || (lastValue && exprResult)) &&
71 "If lastValue is not null then the CompoundStmt must have a "
74 for (
const Stmt *curStmt :
s.body()) {
75 const bool saveResult = lastValue && exprResult == curStmt;
78 result = mlir::failure();
80 if (
emitStmt(curStmt,
false).failed())
81 result = mlir::failure();
92 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
93 mlir::OpBuilder::InsertPoint scopeInsPt;
94 builder.create<cir::ScopeOp>(
95 scopeLoc, [&](mlir::OpBuilder &
b, mlir::Type &
type, mlir::Location loc) {
96 scopeInsPt =
b.saveInsertionPoint();
98 mlir::OpBuilder::InsertionGuard guard(builder);
99 builder.restoreInsertionPoint(scopeInsPt);
100 LexicalScope lexScope(*
this, scopeLoc, builder.getInsertionBlock());
111 bool useCurrentScope,
114 return mlir::success();
116 switch (
s->getStmtClass()) {
118 case Stmt::CXXCatchStmtClass:
119 case Stmt::SEHExceptStmtClass:
120 case Stmt::SEHFinallyStmtClass:
121 case Stmt::MSDependentExistsStmtClass:
122 llvm_unreachable(
"invalid statement class to emit generically");
123 case Stmt::BreakStmtClass:
124 case Stmt::NullStmtClass:
125 case Stmt::CompoundStmtClass:
126 case Stmt::ContinueStmtClass:
127 case Stmt::DeclStmtClass:
128 case Stmt::ReturnStmtClass:
129 llvm_unreachable(
"should have emitted these statements as simple");
131#define STMT(Type, Base)
132#define ABSTRACT_STMT(Op)
133#define EXPR(Type, Base) case Stmt::Type##Class:
134#include "clang/AST/StmtNodes.inc"
136 assert(builder.getInsertionBlock() &&
137 "expression emission must have an insertion point");
145 return mlir::success();
147 case Stmt::IfStmtClass:
149 case Stmt::SwitchStmtClass:
151 case Stmt::ForStmtClass:
153 case Stmt::WhileStmtClass:
155 case Stmt::DoStmtClass:
157 case Stmt::CXXForRangeStmtClass:
159 case Stmt::OpenACCComputeConstructClass:
161 case Stmt::OpenACCLoopConstructClass:
163 case Stmt::OpenACCCombinedConstructClass:
165 case Stmt::OpenACCDataConstructClass:
167 case Stmt::OpenACCEnterDataConstructClass:
169 case Stmt::OpenACCExitDataConstructClass:
171 case Stmt::OpenACCHostDataConstructClass:
173 case Stmt::OpenACCWaitConstructClass:
175 case Stmt::OpenACCInitConstructClass:
177 case Stmt::OpenACCShutdownConstructClass:
179 case Stmt::OpenACCSetConstructClass:
181 case Stmt::OpenACCUpdateConstructClass:
183 case Stmt::OpenACCCacheConstructClass:
185 case Stmt::OpenACCAtomicConstructClass:
187 case Stmt::GCCAsmStmtClass:
188 case Stmt::MSAsmStmtClass:
190 case Stmt::OMPScopeDirectiveClass:
191 case Stmt::OMPErrorDirectiveClass:
192 case Stmt::LabelStmtClass:
193 case Stmt::AttributedStmtClass:
194 case Stmt::GotoStmtClass:
195 case Stmt::DefaultStmtClass:
196 case Stmt::CaseStmtClass:
197 case Stmt::SEHLeaveStmtClass:
198 case Stmt::SYCLKernelCallStmtClass:
199 case Stmt::CoroutineBodyStmtClass:
200 case Stmt::CoreturnStmtClass:
201 case Stmt::CXXTryStmtClass:
202 case Stmt::IndirectGotoStmtClass:
203 case Stmt::OMPParallelDirectiveClass:
204 case Stmt::OMPTaskwaitDirectiveClass:
205 case Stmt::OMPTaskyieldDirectiveClass:
206 case Stmt::OMPBarrierDirectiveClass:
207 case Stmt::CapturedStmtClass:
208 case Stmt::ObjCAtTryStmtClass:
209 case Stmt::ObjCAtThrowStmtClass:
210 case Stmt::ObjCAtSynchronizedStmtClass:
211 case Stmt::ObjCForCollectionStmtClass:
212 case Stmt::ObjCAutoreleasePoolStmtClass:
213 case Stmt::SEHTryStmtClass:
214 case Stmt::OMPMetaDirectiveClass:
215 case Stmt::OMPCanonicalLoopClass:
216 case Stmt::OMPSimdDirectiveClass:
217 case Stmt::OMPTileDirectiveClass:
218 case Stmt::OMPUnrollDirectiveClass:
219 case Stmt::OMPForDirectiveClass:
220 case Stmt::OMPForSimdDirectiveClass:
221 case Stmt::OMPSectionsDirectiveClass:
222 case Stmt::OMPSectionDirectiveClass:
223 case Stmt::OMPSingleDirectiveClass:
224 case Stmt::OMPMasterDirectiveClass:
225 case Stmt::OMPCriticalDirectiveClass:
226 case Stmt::OMPParallelForDirectiveClass:
227 case Stmt::OMPParallelForSimdDirectiveClass:
228 case Stmt::OMPParallelMasterDirectiveClass:
229 case Stmt::OMPParallelSectionsDirectiveClass:
230 case Stmt::OMPTaskDirectiveClass:
231 case Stmt::OMPTaskgroupDirectiveClass:
232 case Stmt::OMPFlushDirectiveClass:
233 case Stmt::OMPDepobjDirectiveClass:
234 case Stmt::OMPScanDirectiveClass:
235 case Stmt::OMPOrderedDirectiveClass:
236 case Stmt::OMPAtomicDirectiveClass:
237 case Stmt::OMPTargetDirectiveClass:
238 case Stmt::OMPTeamsDirectiveClass:
239 case Stmt::OMPCancellationPointDirectiveClass:
240 case Stmt::OMPCancelDirectiveClass:
241 case Stmt::OMPTargetDataDirectiveClass:
242 case Stmt::OMPTargetEnterDataDirectiveClass:
243 case Stmt::OMPTargetExitDataDirectiveClass:
244 case Stmt::OMPTargetParallelDirectiveClass:
245 case Stmt::OMPTargetParallelForDirectiveClass:
246 case Stmt::OMPTaskLoopDirectiveClass:
247 case Stmt::OMPTaskLoopSimdDirectiveClass:
248 case Stmt::OMPMaskedTaskLoopDirectiveClass:
249 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
250 case Stmt::OMPMasterTaskLoopDirectiveClass:
251 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
252 case Stmt::OMPParallelGenericLoopDirectiveClass:
253 case Stmt::OMPParallelMaskedDirectiveClass:
254 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
255 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
256 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
257 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
258 case Stmt::OMPDistributeDirectiveClass:
259 case Stmt::OMPDistributeParallelForDirectiveClass:
260 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
261 case Stmt::OMPDistributeSimdDirectiveClass:
262 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
263 case Stmt::OMPTargetParallelForSimdDirectiveClass:
264 case Stmt::OMPTargetSimdDirectiveClass:
265 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
266 case Stmt::OMPTargetUpdateDirectiveClass:
267 case Stmt::OMPTeamsDistributeDirectiveClass:
268 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
269 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
270 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
271 case Stmt::OMPTeamsGenericLoopDirectiveClass:
272 case Stmt::OMPTargetTeamsDirectiveClass:
273 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
274 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
275 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
276 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
277 case Stmt::OMPInteropDirectiveClass:
278 case Stmt::OMPDispatchDirectiveClass:
279 case Stmt::OMPGenericLoopDirectiveClass:
280 case Stmt::OMPReverseDirectiveClass:
281 case Stmt::OMPInterchangeDirectiveClass:
282 case Stmt::OMPAssumeDirectiveClass:
283 case Stmt::OMPMaskedDirectiveClass:
284 case Stmt::OMPStripeDirectiveClass:
285 case Stmt::ObjCAtCatchStmtClass:
286 case Stmt::ObjCAtFinallyStmtClass:
288 std::string(
"emitStmt: ") +
s->getStmtClassName());
289 return mlir::failure();
292 llvm_unreachable(
"Unexpected statement class");
296 bool useCurrentScope) {
297 switch (
s->getStmtClass()) {
299 return mlir::failure();
300 case Stmt::DeclStmtClass:
302 case Stmt::CompoundStmtClass:
306 case Stmt::GotoStmtClass:
308 case Stmt::ContinueStmtClass:
312 case Stmt::NullStmtClass:
315 case Stmt::LabelStmtClass:
317 case Stmt::CaseStmtClass:
318 case Stmt::DefaultStmtClass:
324 case Stmt::BreakStmtClass:
326 case Stmt::ReturnStmtClass:
330 return mlir::success();
336 return mlir::failure();
346 mlir::Location loc) {
351 unsigned numBlocks = r.getBlocks().size();
352 for (
auto &block : r.getBlocks()) {
355 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
356 block.hasNoSuccessors())
357 eraseBlocks.push_back(&block);
360 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
361 mlir::OpBuilder::InsertionGuard guardCase(builder);
362 builder.setInsertionPointToEnd(&block);
367 for (
auto *
b : eraseBlocks)
372 mlir::LogicalResult res = mlir::success();
375 const Stmt *constevalExecuted;
376 if (
s.isConsteval()) {
377 constevalExecuted =
s.isNegatedConsteval() ?
s.getThen() :
s.getElse();
378 if (!constevalExecuted) {
386 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
388 return emitStmt(constevalExecuted,
true);
391 if (
emitStmt(
s.getInit(),
true).failed())
392 return mlir::failure();
394 if (
s.getConditionVariable())
401 if (
s.isConstexpr()) {
406 if (
const Stmt *executed = condConstant ?
s.getThen() :
s.getElse())
410 return mlir::success();
422 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
423 builder.create<cir::ScopeOp>(
425 [&](mlir::OpBuilder &
b, mlir::Location loc) {
426 LexicalScope lexScope{*
this, scopeLoc, builder.getInsertionBlock()};
427 res = ifStmtBuilder();
434 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
436 for (
const Decl *i :
s.decls())
439 return mlir::success();
443 mlir::Location loc =
getLoc(
s.getSourceRange());
444 const Expr *rv =
s.getRetValue();
447 s.getNRVOCandidate()->isNRVOVariable()) {
449 "named return value optimization");
460 ->isReferenceType()) {
466 mlir::Value value =
nullptr;
471 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
476 "non-scalar function return type");
483 builder.create<cir::BrOp>(loc, retBlock);
485 cgm.
errorNYI(
s.getSourceRange(),
"return with cleanup stack");
486 builder.createBlock(builder.getBlock()->getParent());
488 return mlir::success();
498 cir::GotoOp::create(builder,
getLoc(
s.getSourceRange()),
499 s.getLabel()->getName());
504 builder.createBlock(builder.getBlock()->getParent());
506 return mlir::success();
514 builder.createBlock(builder.getBlock()->getParent());
516 return mlir::success();
523 mlir::Block *currBlock = builder.getBlock();
524 mlir::Block *labelBlock = currBlock;
526 if (!currBlock->empty()) {
528 mlir::OpBuilder::InsertionGuard guard(builder);
529 labelBlock = builder.createBlock(builder.getBlock()->getParent());
534 builder.setInsertionPointToEnd(labelBlock);
536 builder.setInsertionPointToEnd(labelBlock);
542 return mlir::success();
549 builder.createBlock(builder.getBlock()->getParent());
551 return mlir::success();
557 mlir::ArrayAttr value, CaseOpKind kind,
558 bool buildingTopLevelCase) {
560 assert((isa<CaseStmt, DefaultStmt>(
stmt)) &&
561 "only case or default stmt go here");
563 mlir::LogicalResult result = mlir::success();
565 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
568 SubStmtKind subStmtKind = SubStmtKind::Other;
569 const Stmt *sub =
stmt->getSubStmt();
571 mlir::OpBuilder::InsertPoint insertPoint;
572 builder.create<CaseOp>(loc, value, kind, insertPoint);
575 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
576 builder.restoreInsertionPoint(insertPoint);
578 if (isa<DefaultStmt>(sub) && isa<CaseStmt>(
stmt)) {
579 subStmtKind = SubStmtKind::Default;
581 }
else if (isa<CaseStmt>(sub) && isa<DefaultStmt, CaseStmt>(
stmt)) {
582 subStmtKind = SubStmtKind::Case;
585 result =
emitStmt(sub, !isa<CompoundStmt>(sub));
588 insertPoint = builder.saveInsertionPoint();
623 if (subStmtKind == SubStmtKind::Case) {
624 result =
emitCaseStmt(*cast<CaseStmt>(sub), condType, buildingTopLevelCase);
625 }
else if (subStmtKind == SubStmtKind::Default) {
627 buildingTopLevelCase);
628 }
else if (buildingTopLevelCase) {
632 builder.restoreInsertionPoint(insertPoint);
640 bool buildingTopLevelCase) {
641 cir::CaseOpKind kind;
642 mlir::ArrayAttr value;
643 llvm::APSInt intVal =
s.getLHS()->EvaluateKnownConstInt(
getContext());
648 if (
const Expr *rhs =
s.getRHS()) {
649 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
650 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
651 cir::IntAttr::get(condType, endVal)});
652 kind = cir::CaseOpKind::Range;
654 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
655 kind = cir::CaseOpKind::Equal;
659 buildingTopLevelCase);
664 bool buildingTopLevelCase) {
666 cir::CaseOpKind::Default, buildingTopLevelCase);
670 bool buildingTopLevelCase) {
672 "build switch case without specifying the type of the condition");
674 if (
s.getStmtClass() == Stmt::CaseStmtClass)
676 buildingTopLevelCase);
678 if (
s.getStmtClass() == Stmt::DefaultStmtClass)
680 buildingTopLevelCase);
682 llvm_unreachable(
"expect case or default stmt");
691 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
692 mlir::LogicalResult loopRes = mlir::success();
695 if (
emitStmt(
s.getInit(),
true).failed())
696 return mlir::failure();
697 if (
emitStmt(
s.getRangeStmt(),
true).failed())
698 return mlir::failure();
699 if (
emitStmt(
s.getBeginStmt(),
true).failed())
700 return mlir::failure();
701 if (
emitStmt(
s.getEndStmt(),
true).failed())
702 return mlir::failure();
714 [&](mlir::OpBuilder &
b, mlir::Location loc) {
715 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
716 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
717 mlir::Value condVal = evaluateExprAsBool(s.getCond());
718 builder.createCondition(condVal);
721 [&](mlir::OpBuilder &
b, mlir::Location loc) {
725 bool useCurrentScope = true;
726 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
727 loopRes = mlir::failure();
728 if (emitStmt(s.getBody(), useCurrentScope).failed())
729 loopRes = mlir::failure();
733 [&](mlir::OpBuilder &
b, mlir::Location loc) {
735 if (emitStmt(s.getInc(), true).failed())
736 loopRes = mlir::failure();
737 builder.createYield(loc);
742 mlir::LogicalResult res = mlir::success();
743 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
744 builder.create<cir::ScopeOp>(scopeLoc,
745 [&](mlir::OpBuilder &
b, mlir::Location loc) {
751 *
this, loc, builder.getInsertionBlock()};
752 res = forStmtBuilder();
759 return mlir::success();
766 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
767 mlir::LogicalResult loopRes = mlir::success();
770 if (
emitStmt(
s.getInit(),
true).failed())
771 return mlir::failure();
782 [&](mlir::OpBuilder &
b, mlir::Location loc) {
783 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
784 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
789 if (s.getConditionVariable())
790 emitDecl(*s.getConditionVariable());
794 condVal = evaluateExprAsBool(s.getCond());
796 condVal = b.create<cir::ConstantOp>(loc, builder.getTrueAttr());
801 [&](mlir::OpBuilder &
b, mlir::Location loc) {
804 if (
emitStmt(
s.getBody(),
false).failed())
805 loopRes = mlir::failure();
809 [&](mlir::OpBuilder &
b, mlir::Location loc) {
812 loopRes = mlir::failure();
818 auto res = mlir::success();
819 auto scopeLoc = getLoc(
s.getSourceRange());
820 builder.create<cir::ScopeOp>(scopeLoc,
821 [&](mlir::OpBuilder &
b, mlir::Location loc) {
822 LexicalScope lexScope{
823 *
this, loc, builder.getInsertionBlock()};
824 res = forStmtBuilder();
831 return mlir::success();
835 cir::DoWhileOp doWhileOp;
838 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
839 mlir::LogicalResult loopRes = mlir::success();
850 [&](mlir::OpBuilder &
b, mlir::Location loc) {
851 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
852 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
856 mlir::Value condVal = evaluateExprAsBool(s.getCond());
857 builder.createCondition(condVal);
860 [&](mlir::OpBuilder &
b, mlir::Location loc) {
862 if (emitStmt(s.getBody(), false).failed())
863 loopRes = mlir::failure();
869 mlir::LogicalResult res = mlir::success();
870 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
871 builder.create<cir::ScopeOp>(scopeLoc,
872 [&](mlir::OpBuilder &
b, mlir::Location loc) {
874 *
this, loc, builder.getInsertionBlock()};
875 res = doStmtBuilder();
882 return mlir::success();
886 cir::WhileOp whileOp;
889 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
890 mlir::LogicalResult loopRes = mlir::success();
901 [&](mlir::OpBuilder &
b, mlir::Location loc) {
902 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
903 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
907 if (s.getConditionVariable())
908 emitDecl(*s.getConditionVariable());
912 condVal = evaluateExprAsBool(s.getCond());
913 builder.createCondition(condVal);
916 [&](mlir::OpBuilder &
b, mlir::Location loc) {
918 if (emitStmt(s.getBody(), false).failed())
919 loopRes = mlir::failure();
925 mlir::LogicalResult res = mlir::success();
926 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
927 builder.create<cir::ScopeOp>(scopeLoc,
928 [&](mlir::OpBuilder &
b, mlir::Location loc) {
930 *
this, loc, builder.getInsertionBlock()};
931 res = whileStmtBuilder();
938 return mlir::success();
951 if (!isa<CompoundStmt>(
s))
956 mlir::Block *swtichBlock = builder.getBlock();
959 builder.setInsertionPointToEnd(swtichBlock);
965 return mlir::failure();
971 if (mlir::failed(
emitStmt(
c, !isa<CompoundStmt>(
c))))
972 return mlir::failure();
975 return mlir::success();
986 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
988 if (
emitStmt(
s.getInit(),
true).failed())
989 return mlir::failure();
991 if (
s.getConditionVariable())
992 emitDecl(*
s.getConditionVariable(),
true);
1002 mlir::LogicalResult res = mlir::success();
1003 swop = builder.create<SwitchOp>(
1004 getLoc(
s.getBeginLoc()), condV,
1006 [&](mlir::OpBuilder &
b, mlir::Location loc, mlir::OperationState &os) {
1020 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
1021 mlir::LogicalResult res = mlir::success();
1022 builder.create<cir::ScopeOp>(scopeLoc,
1023 [&](mlir::OpBuilder &
b, mlir::Location loc) {
1025 *
this, loc, builder.getInsertionBlock()};
1026 res = switchStmtBuilder();
1030 swop.collectCases(cases);
1031 for (
auto caseOp : cases)
1032 terminateBody(builder, caseOp.getCaseRegion(), caseOp.getLoc());
static void terminateBody(CIRGenBuilderTy &builder, mlir::Region &r, mlir::Location loc)
static mlir::LogicalResult emitStmtWithResult(CIRGenFunction &cgf, const Stmt *exprResult, AggValueSlot slot, Address *lastValue)
Defines the clang::Expr interface and subclasses for C++ expressions.
This file defines OpenACC AST classes for statement-level contructs.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
cir::WhileOp createWhile(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder)
Create a while operation.
cir::BreakOp createBreak(mlir::Location loc)
Create a break operation.
cir::ConditionOp createCondition(mlir::Value condition)
Create a loop condition.
cir::ForOp createFor(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> stepBuilder)
Create a for operation.
cir::DoWhileOp createDoWhile(mlir::Location loc, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> condBuilder, llvm::function_ref< void(mlir::OpBuilder &, mlir::Location)> bodyBuilder)
Create a do-while operation.
cir::ContinueOp createContinue(mlir::Location loc)
Create a continue operation.
cir::YieldOp createYield(mlir::Location loc, mlir::ValueRange value={})
Create a yield operation.
BreakStmt - This represents a break.
mlir::LogicalResult emitDoStmt(const clang::DoStmt &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 emitOpenACCDataConstruct(const OpenACCDataConstruct &s)
mlir::LogicalResult emitOpenACCCombinedConstruct(const OpenACCCombinedConstruct &s)
mlir::LogicalResult emitOpenACCWaitConstruct(const OpenACCWaitConstruct &s)
const clang::LangOptions & getLangOpts() const
mlir::LogicalResult emitOpenACCUpdateConstruct(const OpenACCUpdateConstruct &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 emitOpenACCCacheConstruct(const OpenACCCacheConstruct &s)
mlir::LogicalResult emitCXXForRangeStmt(const CXXForRangeStmt &s, llvm::ArrayRef< const Attr * > attrs)
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
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.
llvm::ScopedHashTableScope< const clang::Decl *, mlir::Value > SymTableScopeTy
mlir::LogicalResult emitOpenACCSetConstruct(const OpenACCSetConstruct &s)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
RValue emitAnyExpr(const clang::Expr *e, AggValueSlot aggSlot=AggValueSlot::ignored())
Emit code to compute the specified expression which can have any type.
mlir::LogicalResult emitSwitchStmt(const clang::SwitchStmt &s)
mlir::LogicalResult emitCaseStmt(const clang::CaseStmt &s, mlir::Type condType, bool buildingTopLevelCase)
mlir::LogicalResult emitSimpleStmt(const clang::Stmt *s, bool useCurrentScope)
mlir::LogicalResult emitAsmStmt(const clang::AsmStmt &s)
mlir::LogicalResult emitOpenACCComputeConstruct(const OpenACCComputeConstruct &s)
EHScopeStack ehStack
Tracks function scope overall cleanup handling.
mlir::LogicalResult emitSwitchBody(const clang::Stmt *s)
mlir::LogicalResult emitForStmt(const clang::ForStmt &s)
std::optional< mlir::Value > fnRetAlloca
The compiler-generated variable that holds the return value.
mlir::LogicalResult emitLabel(const clang::LabelDecl &d)
static bool hasAggregateEvaluationKind(clang::QualType type)
mlir::LogicalResult emitOpenACCShutdownConstruct(const OpenACCShutdownConstruct &s)
mlir::LogicalResult emitBreakStmt(const clang::BreakStmt &s)
mlir::LogicalResult emitContinueStmt(const clang::ContinueStmt &s)
llvm::SmallVector< mlir::Type, 2 > condTypeStack
The type of the condition for the emitting switch statement.
mlir::Value emitScalarExpr(const clang::Expr *e)
Emit the computation of the specified expression of scalar type.
void emitStopPoint(const Stmt *s)
Build a debug stoppoint if we are emitting debug info.
mlir::LogicalResult emitOpenACCHostDataConstruct(const OpenACCHostDataConstruct &s)
mlir::LogicalResult emitIfStmt(const clang::IfStmt &s)
mlir::LogicalResult emitSwitchCase(const clang::SwitchCase &s, bool buildingTopLevelCase)
void emitDecl(const clang::Decl &d, bool evaluateConditionDecl=false)
CIRGenModule & getCIRGenModule()
mlir::LogicalResult emitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct &s)
mlir::LogicalResult emitCaseDefaultCascade(const T *stmt, mlir::Type condType, mlir::ArrayAttr value, cir::CaseOpKind kind, bool buildingTopLevelCase)
mlir::LogicalResult emitDeclStmt(const clang::DeclStmt &s)
mlir::LogicalResult emitDefaultStmt(const clang::DefaultStmt &s, mlir::Type condType, bool buildingTopLevelCase)
mlir::LogicalResult emitWhileStmt(const clang::WhileStmt &s)
mlir::LogicalResult emitLabelStmt(const clang::LabelStmt &s)
EHScopeStack::stable_iterator currentCleanupStackDepth
LexicalScope * curLexScope
clang::ASTContext & getContext() const
mlir::LogicalResult emitCompoundStmt(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
mlir::LogicalResult emitGotoStmt(const clang::GotoStmt &s)
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
mlir::LogicalResult emitCompoundStmtWithoutScope(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
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 emitOpenACCLoopConstruct(const OpenACCLoopConstruct &s)
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
This trivial value class is used to represent the result of an expression that is evaluated.
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...
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.
Decl - This represents one declaration (or definition), e.g.
DoStmt - This represents a 'do/while' stmt.
This represents one expression.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
const Decl * getDecl() const
GotoStmt - This represents a direct goto.
IfStmt - This represents an if/then/else.
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.
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;.
Stmt - This represents one statement.
SwitchStmt - This represents a 'switch' stmt.
WhileStmt - This represents a 'while' stmt.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
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.
const FunctionProtoType * T
@ Other
Other implicit parameter.
static bool loopInfoStack()
static bool emitCondLikelihoodViaExpectIntrinsic()
static bool constantFoldSwitchStatement()
static bool insertBuiltinUnpredictable()
static bool ehstackBranches()
static bool requiresCleanups()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
mlir::Block * getOrCreateRetBlock(CIRGenFunction &cgf, mlir::Location loc)