16#include "mlir/IR/Builders.h"
17#include "mlir/IR/Location.h"
18#include "mlir/Support/LLVM.h"
29 const Stmt *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");
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;
96 [&](mlir::OpBuilder &
b, mlir::Type &
type, mlir::Location loc) {
97 scopeInsPt =
b.saveInsertionPoint();
99 mlir::OpBuilder::InsertionGuard guard(builder);
100 builder.restoreInsertionPoint(scopeInsPt);
101 LexicalScope lexScope(*
this, scopeLoc, builder.getInsertionBlock());
112 bool useCurrentScope,
115 return mlir::success();
117 switch (
s->getStmtClass()) {
119 case Stmt::CXXCatchStmtClass:
120 case Stmt::SEHExceptStmtClass:
121 case Stmt::SEHFinallyStmtClass:
122 case Stmt::MSDependentExistsStmtClass:
123 llvm_unreachable(
"invalid statement class to emit generically");
124 case Stmt::BreakStmtClass:
125 case Stmt::NullStmtClass:
126 case Stmt::CompoundStmtClass:
127 case Stmt::ContinueStmtClass:
128 case Stmt::DeclStmtClass:
129 case Stmt::ReturnStmtClass:
130 llvm_unreachable(
"should have emitted these statements as simple");
132#define STMT(Type, Base)
133#define ABSTRACT_STMT(Op)
134#define EXPR(Type, Base) case Stmt::Type##Class:
135#include "clang/AST/StmtNodes.inc"
137 assert(builder.getInsertionBlock() &&
138 "expression emission must have an insertion point");
146 return mlir::success();
148 case Stmt::IfStmtClass:
150 case Stmt::SwitchStmtClass:
152 case Stmt::ForStmtClass:
154 case Stmt::WhileStmtClass:
156 case Stmt::DoStmtClass:
158 case Stmt::CXXTryStmtClass:
160 case Stmt::CXXForRangeStmtClass:
162 case Stmt::OpenACCComputeConstructClass:
164 case Stmt::OpenACCLoopConstructClass:
166 case Stmt::OpenACCCombinedConstructClass:
168 case Stmt::OpenACCDataConstructClass:
170 case Stmt::OpenACCEnterDataConstructClass:
172 case Stmt::OpenACCExitDataConstructClass:
174 case Stmt::OpenACCHostDataConstructClass:
176 case Stmt::OpenACCWaitConstructClass:
178 case Stmt::OpenACCInitConstructClass:
180 case Stmt::OpenACCShutdownConstructClass:
182 case Stmt::OpenACCSetConstructClass:
184 case Stmt::OpenACCUpdateConstructClass:
186 case Stmt::OpenACCCacheConstructClass:
188 case Stmt::OpenACCAtomicConstructClass:
190 case Stmt::GCCAsmStmtClass:
191 case Stmt::MSAsmStmtClass:
193 case Stmt::OMPScopeDirectiveClass:
194 case Stmt::OMPErrorDirectiveClass:
195 case Stmt::LabelStmtClass:
196 case Stmt::AttributedStmtClass:
197 case Stmt::GotoStmtClass:
198 case Stmt::DefaultStmtClass:
199 case Stmt::CaseStmtClass:
200 case Stmt::SEHLeaveStmtClass:
201 case Stmt::SYCLKernelCallStmtClass:
202 case Stmt::CoroutineBodyStmtClass:
204 case Stmt::CoreturnStmtClass:
205 case Stmt::IndirectGotoStmtClass:
206 case Stmt::OMPParallelDirectiveClass:
207 case Stmt::OMPTaskwaitDirectiveClass:
208 case Stmt::OMPTaskyieldDirectiveClass:
209 case Stmt::OMPBarrierDirectiveClass:
210 case Stmt::CapturedStmtClass:
211 case Stmt::ObjCAtTryStmtClass:
212 case Stmt::ObjCAtThrowStmtClass:
213 case Stmt::ObjCAtSynchronizedStmtClass:
214 case Stmt::ObjCForCollectionStmtClass:
215 case Stmt::ObjCAutoreleasePoolStmtClass:
216 case Stmt::SEHTryStmtClass:
217 case Stmt::OMPMetaDirectiveClass:
218 case Stmt::OMPCanonicalLoopClass:
219 case Stmt::OMPSimdDirectiveClass:
220 case Stmt::OMPTileDirectiveClass:
221 case Stmt::OMPUnrollDirectiveClass:
222 case Stmt::OMPFuseDirectiveClass:
223 case Stmt::OMPForDirectiveClass:
224 case Stmt::OMPForSimdDirectiveClass:
225 case Stmt::OMPSectionsDirectiveClass:
226 case Stmt::OMPSectionDirectiveClass:
227 case Stmt::OMPSingleDirectiveClass:
228 case Stmt::OMPMasterDirectiveClass:
229 case Stmt::OMPCriticalDirectiveClass:
230 case Stmt::OMPParallelForDirectiveClass:
231 case Stmt::OMPParallelForSimdDirectiveClass:
232 case Stmt::OMPParallelMasterDirectiveClass:
233 case Stmt::OMPParallelSectionsDirectiveClass:
234 case Stmt::OMPTaskDirectiveClass:
235 case Stmt::OMPTaskgroupDirectiveClass:
236 case Stmt::OMPFlushDirectiveClass:
237 case Stmt::OMPDepobjDirectiveClass:
238 case Stmt::OMPScanDirectiveClass:
239 case Stmt::OMPOrderedDirectiveClass:
240 case Stmt::OMPAtomicDirectiveClass:
241 case Stmt::OMPTargetDirectiveClass:
242 case Stmt::OMPTeamsDirectiveClass:
243 case Stmt::OMPCancellationPointDirectiveClass:
244 case Stmt::OMPCancelDirectiveClass:
245 case Stmt::OMPTargetDataDirectiveClass:
246 case Stmt::OMPTargetEnterDataDirectiveClass:
247 case Stmt::OMPTargetExitDataDirectiveClass:
248 case Stmt::OMPTargetParallelDirectiveClass:
249 case Stmt::OMPTargetParallelForDirectiveClass:
250 case Stmt::OMPTaskLoopDirectiveClass:
251 case Stmt::OMPTaskLoopSimdDirectiveClass:
252 case Stmt::OMPMaskedTaskLoopDirectiveClass:
253 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
254 case Stmt::OMPMasterTaskLoopDirectiveClass:
255 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
256 case Stmt::OMPParallelGenericLoopDirectiveClass:
257 case Stmt::OMPParallelMaskedDirectiveClass:
258 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
259 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
260 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
261 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
262 case Stmt::OMPDistributeDirectiveClass:
263 case Stmt::OMPDistributeParallelForDirectiveClass:
264 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
265 case Stmt::OMPDistributeSimdDirectiveClass:
266 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
267 case Stmt::OMPTargetParallelForSimdDirectiveClass:
268 case Stmt::OMPTargetSimdDirectiveClass:
269 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
270 case Stmt::OMPTargetUpdateDirectiveClass:
271 case Stmt::OMPTeamsDistributeDirectiveClass:
272 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
273 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
274 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
275 case Stmt::OMPTeamsGenericLoopDirectiveClass:
276 case Stmt::OMPTargetTeamsDirectiveClass:
277 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
278 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
279 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
280 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
281 case Stmt::OMPInteropDirectiveClass:
282 case Stmt::OMPDispatchDirectiveClass:
283 case Stmt::OMPGenericLoopDirectiveClass:
284 case Stmt::OMPReverseDirectiveClass:
285 case Stmt::OMPInterchangeDirectiveClass:
286 case Stmt::OMPAssumeDirectiveClass:
287 case Stmt::OMPMaskedDirectiveClass:
288 case Stmt::OMPStripeDirectiveClass:
289 case Stmt::ObjCAtCatchStmtClass:
290 case Stmt::ObjCAtFinallyStmtClass:
291 cgm.errorNYI(
s->getSourceRange(),
292 std::string(
"emitStmt: ") +
s->getStmtClassName());
293 return mlir::failure();
296 llvm_unreachable(
"Unexpected statement class");
300 bool useCurrentScope) {
301 switch (
s->getStmtClass()) {
303 return mlir::failure();
304 case Stmt::DeclStmtClass:
306 case Stmt::CompoundStmtClass:
310 case Stmt::GotoStmtClass:
312 case Stmt::ContinueStmtClass:
316 case Stmt::NullStmtClass:
319 case Stmt::LabelStmtClass:
321 case Stmt::CaseStmtClass:
322 case Stmt::DefaultStmtClass:
328 case Stmt::BreakStmtClass:
330 case Stmt::ReturnStmtClass:
334 return mlir::success();
340 return mlir::failure();
350 mlir::Location loc) {
355 unsigned numBlocks = r.getBlocks().size();
356 for (
auto &block : r.getBlocks()) {
359 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
360 block.hasNoSuccessors())
361 eraseBlocks.push_back(&block);
364 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
365 mlir::OpBuilder::InsertionGuard guardCase(builder);
366 builder.setInsertionPointToEnd(&block);
371 for (
auto *
b : eraseBlocks)
376 mlir::LogicalResult res = mlir::success();
379 const Stmt *constevalExecuted;
380 if (
s.isConsteval()) {
381 constevalExecuted =
s.isNegatedConsteval() ?
s.getThen() :
s.getElse();
382 if (!constevalExecuted) {
390 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
392 return emitStmt(constevalExecuted,
true);
395 if (
emitStmt(
s.getInit(),
true).failed())
396 return mlir::failure();
398 if (
s.getConditionVariable())
405 if (
s.isConstexpr()) {
410 if (
const Stmt *executed = condConstant ?
s.getThen() :
s.getElse())
414 return mlir::success();
426 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
427 cir::ScopeOp::create(builder, scopeLoc,
428 [&](mlir::OpBuilder &
b, mlir::Location loc) {
430 builder.getInsertionBlock()};
431 res = ifStmtBuilder();
438 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
440 for (
const Decl *i :
s.decls())
443 return mlir::success();
447 mlir::Location loc =
getLoc(
s.getSourceRange());
448 const Expr *rv =
s.getRetValue();
451 bool createNewScope =
false;
452 if (
const auto *ewc = dyn_cast_or_null<ExprWithCleanups>(rv)) {
453 rv = ewc->getSubExpr();
454 createNewScope =
true;
457 auto handleReturnVal = [&]() {
459 s.getNRVOCandidate()->isNRVOVariable()) {
472 ->isReferenceType()) {
476 builder.CIRBaseBuilderTy::createStore(loc, result.
getValue(),
479 mlir::Value value =
nullptr;
484 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
503 if (!createNewScope) {
506 mlir::Location scopeLoc =
511 mlir::OpBuilder::InsertPoint scopeBody;
512 cir::ScopeOp::create(builder, scopeLoc,
513 [&](mlir::OpBuilder &
b, mlir::Location loc) {
514 scopeBody =
b.saveInsertionPoint();
517 mlir::OpBuilder::InsertionGuard guard(builder);
518 builder.restoreInsertionPoint(scopeBody);
520 builder.getInsertionBlock()};
531 auto *retBlock =
curLexScope->getOrCreateRetBlock(*
this, loc);
535 builder.createBlock(builder.getBlock()->getParent());
537 return mlir::success();
547 cir::GotoOp::create(builder,
getLoc(
s.getSourceRange()),
548 s.getLabel()->getName());
553 builder.createBlock(builder.getBlock()->getParent());
555 return mlir::success();
560 builder.createContinue(
getLoc(
s.getKwLoc()));
563 builder.createBlock(builder.getBlock()->getParent());
565 return mlir::success();
572 mlir::Block *currBlock = builder.getBlock();
573 mlir::Block *labelBlock = currBlock;
575 if (!currBlock->empty() || currBlock->isEntryBlock()) {
577 mlir::OpBuilder::InsertionGuard guard(builder);
578 labelBlock = builder.createBlock(builder.getBlock()->getParent());
583 builder.setInsertionPointToEnd(labelBlock);
585 builder.setInsertionPointToEnd(labelBlock);
591 return mlir::success();
595 builder.createBreak(
getLoc(
s.getKwLoc()));
598 builder.createBlock(builder.getBlock()->getParent());
600 return mlir::success();
606 mlir::ArrayAttr value, CaseOpKind kind,
607 bool buildingTopLevelCase) {
610 "only case or default stmt go here");
612 mlir::LogicalResult result = mlir::success();
614 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
617 SubStmtKind subStmtKind = SubStmtKind::Other;
618 const Stmt *sub =
stmt->getSubStmt();
620 mlir::OpBuilder::InsertPoint insertPoint;
621 CaseOp::create(builder, loc, value, kind, insertPoint);
624 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
625 builder.restoreInsertionPoint(insertPoint);
628 subStmtKind = SubStmtKind::Default;
629 builder.createYield(loc);
631 subStmtKind = SubStmtKind::Case;
632 builder.createYield(loc);
637 insertPoint = builder.saveInsertionPoint();
672 if (subStmtKind == SubStmtKind::Case) {
674 }
else if (subStmtKind == SubStmtKind::Default) {
676 buildingTopLevelCase);
677 }
else if (buildingTopLevelCase) {
681 builder.restoreInsertionPoint(insertPoint);
689 bool buildingTopLevelCase) {
690 cir::CaseOpKind kind;
691 mlir::ArrayAttr value;
692 llvm::APSInt intVal =
s.getLHS()->EvaluateKnownConstInt(
getContext());
697 if (
const Expr *rhs =
s.getRHS()) {
698 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
699 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
700 cir::IntAttr::get(condType, endVal)});
701 kind = cir::CaseOpKind::Range;
703 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
704 kind = cir::CaseOpKind::Equal;
708 buildingTopLevelCase);
713 bool buildingTopLevelCase) {
715 cir::CaseOpKind::Default, buildingTopLevelCase);
719 bool buildingTopLevelCase) {
721 "build switch case without specifying the type of the condition");
723 if (
s.getStmtClass() == Stmt::CaseStmtClass)
725 buildingTopLevelCase);
727 if (
s.getStmtClass() == Stmt::DefaultStmtClass)
729 buildingTopLevelCase);
731 llvm_unreachable(
"expect case or default stmt");
740 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
741 mlir::LogicalResult loopRes = mlir::success();
744 if (
emitStmt(
s.getInit(),
true).failed())
745 return mlir::failure();
746 if (
emitStmt(
s.getRangeStmt(),
true).failed())
747 return mlir::failure();
748 if (
emitStmt(
s.getBeginStmt(),
true).failed())
749 return mlir::failure();
750 if (
emitStmt(
s.getEndStmt(),
true).failed())
751 return mlir::failure();
760 forOp = builder.createFor(
763 [&](mlir::OpBuilder &
b, mlir::Location loc) {
764 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
765 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
766 mlir::Value condVal = evaluateExprAsBool(s.getCond());
767 builder.createCondition(condVal);
770 [&](mlir::OpBuilder &
b, mlir::Location loc) {
774 bool useCurrentScope = true;
775 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
776 loopRes = mlir::failure();
777 if (emitStmt(s.getBody(), useCurrentScope).failed())
778 loopRes = mlir::failure();
782 [&](mlir::OpBuilder &
b, mlir::Location loc) {
784 if (emitStmt(s.getInc(), true).failed())
785 loopRes = mlir::failure();
786 builder.createYield(loc);
791 mlir::LogicalResult res = mlir::success();
792 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
793 cir::ScopeOp::create(builder, scopeLoc,
794 [&](mlir::OpBuilder &
b, mlir::Location loc) {
800 builder.getInsertionBlock()};
801 res = forStmtBuilder();
808 return mlir::success();
815 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
816 mlir::LogicalResult loopRes = mlir::success();
819 if (
emitStmt(
s.getInit(),
true).failed())
820 return mlir::failure();
828 forOp = builder.createFor(
831 [&](mlir::OpBuilder &
b, mlir::Location loc) {
832 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
833 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
838 if (s.getConditionVariable())
839 emitDecl(*s.getConditionVariable());
843 condVal = evaluateExprAsBool(s.getCond());
845 condVal = cir::ConstantOp::create(b, loc, builder.getTrueAttr());
847 builder.createCondition(condVal);
850 [&](mlir::OpBuilder &
b, mlir::Location loc) {
853 if (
emitStmt(
s.getBody(),
false).failed())
854 loopRes = mlir::failure();
858 [&](mlir::OpBuilder &
b, mlir::Location loc) {
861 loopRes = mlir::failure();
862 builder.createYield(loc);
867 auto res = mlir::success();
868 auto scopeLoc = getLoc(
s.getSourceRange());
869 cir::ScopeOp::create(builder, scopeLoc,
870 [&](mlir::OpBuilder &
b, mlir::Location loc) {
871 LexicalScope lexScope{*
this, loc,
872 builder.getInsertionBlock()};
873 res = forStmtBuilder();
880 return mlir::success();
884 cir::DoWhileOp doWhileOp;
887 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
888 mlir::LogicalResult loopRes = mlir::success();
896 doWhileOp = builder.createDoWhile(
899 [&](mlir::OpBuilder &
b, mlir::Location loc) {
900 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
901 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
905 mlir::Value condVal = evaluateExprAsBool(s.getCond());
906 builder.createCondition(condVal);
909 [&](mlir::OpBuilder &
b, mlir::Location loc) {
911 if (emitStmt(s.getBody(), false).failed())
912 loopRes = mlir::failure();
918 mlir::LogicalResult res = mlir::success();
919 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
920 cir::ScopeOp::create(builder, scopeLoc,
921 [&](mlir::OpBuilder &
b, mlir::Location loc) {
923 builder.getInsertionBlock()};
924 res = doStmtBuilder();
931 return mlir::success();
935 cir::WhileOp whileOp;
938 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
939 mlir::LogicalResult loopRes = mlir::success();
947 whileOp = builder.createWhile(
950 [&](mlir::OpBuilder &
b, mlir::Location loc) {
951 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
952 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
956 if (s.getConditionVariable())
957 emitDecl(*s.getConditionVariable());
961 condVal = evaluateExprAsBool(s.getCond());
962 builder.createCondition(condVal);
965 [&](mlir::OpBuilder &
b, mlir::Location loc) {
967 if (emitStmt(s.getBody(), false).failed())
968 loopRes = mlir::failure();
974 mlir::LogicalResult res = mlir::success();
975 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
976 cir::ScopeOp::create(builder, scopeLoc,
977 [&](mlir::OpBuilder &
b, mlir::Location loc) {
979 builder.getInsertionBlock()};
980 res = whileStmtBuilder();
987 return mlir::success();
1005 mlir::Block *swtichBlock = builder.getBlock();
1008 builder.setInsertionPointToEnd(swtichBlock);
1014 return mlir::failure();
1021 return mlir::failure();
1024 return mlir::success();
1035 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1037 if (
emitStmt(
s.getInit(),
true).failed())
1038 return mlir::failure();
1040 if (
s.getConditionVariable())
1041 emitDecl(*
s.getConditionVariable(),
true);
1051 mlir::LogicalResult res = mlir::success();
1052 swop = SwitchOp::create(
1053 builder,
getLoc(
s.getBeginLoc()), condV,
1055 [&](mlir::OpBuilder &
b, mlir::Location loc, mlir::OperationState &os) {
1056 curLexScope->setAsSwitch();
1058 condTypeStack.push_back(condV.getType());
1060 res = emitSwitchBody(s.getBody());
1062 condTypeStack.pop_back();
1069 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
1070 mlir::LogicalResult res = mlir::success();
1071 cir::ScopeOp::create(builder, scopeLoc,
1072 [&](mlir::OpBuilder &
b, mlir::Location loc) {
1074 builder.getInsertionBlock()};
1075 res = switchStmtBuilder();
1079 swop.collectCases(cases);
1080 for (
auto caseOp : cases)
1081 terminateBody(builder, caseOp.getCaseRegion(), caseOp.getLoc());
1096 cgm.errorNYI(loc,
"emitReturnOfRValue: complex return type");
1098 mlir::Block *retBlock =
curLexScope->getOrCreateRetBlock(*
this, loc);
1100 cir::BrOp::create(builder, loc, retBlock);
1102 cgm.errorNYI(loc,
"return of r-value with cleanup stack");
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::YieldOp createYield(mlir::Location loc, mlir::ValueRange value={})
Create a yield operation.
BreakStmt - This represents a break.
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()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
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)
void emitAggregateCopy(LValue dest, LValue src, QualType eltTy, AggValueSlot::Overlap_t mayOverlap, bool isVolatile=false)
Emit an aggregate copy.
JumpDest returnBlock(mlir::Block *retBlock)
Unified return block.
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.
mlir::LogicalResult emitOpenACCSetConstruct(const OpenACCSetConstruct &s)
RValue emitReferenceBindingToExpr(const Expr *e)
Emits a reference binding to the passed in expression.
mlir::LogicalResult emitSwitchStmt(const clang::SwitchStmt &s)
mlir::LogicalResult emitCaseStmt(const clang::CaseStmt &s, mlir::Type condType, bool buildingTopLevelCase)
llvm::ScopedHashTableScope< const clang::Decl *, mlir::Value > SymTableScopeTy
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.
Address returnValue
The temporary alloca to hold 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)
void emitReturnOfRValue(mlir::Location loc, RValue rv, QualType ty)
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)
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
cir::BrOp emitBranchThroughCleanup(mlir::Location loc, JumpDest dest)
Build a unconditional branch to the lexical scope cleanup block or with the labeled blocked if alread...
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 emitCXXTryStmt(const clang::CXXTryStmt &s)
void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)
mlir::LogicalResult emitCaseDefaultCascade(const T *stmt, mlir::Type condType, mlir::ArrayAttr value, cir::CaseOpKind kind, bool buildingTopLevelCase)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
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 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 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 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.
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...
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.
This represents one expression.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
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.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SwitchStmt - This represents a 'switch' stmt.
WhileStmt - This represents a 'while' stmt.
@ 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)
const FunctionProtoType * T
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 ehstackBranches()
static bool emitBranchThroughCleanup()
static bool requiresCleanups()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...