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;
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::OMPFuseDirectiveClass:
220 case Stmt::OMPForDirectiveClass:
221 case Stmt::OMPForSimdDirectiveClass:
222 case Stmt::OMPSectionsDirectiveClass:
223 case Stmt::OMPSectionDirectiveClass:
224 case Stmt::OMPSingleDirectiveClass:
225 case Stmt::OMPMasterDirectiveClass:
226 case Stmt::OMPCriticalDirectiveClass:
227 case Stmt::OMPParallelForDirectiveClass:
228 case Stmt::OMPParallelForSimdDirectiveClass:
229 case Stmt::OMPParallelMasterDirectiveClass:
230 case Stmt::OMPParallelSectionsDirectiveClass:
231 case Stmt::OMPTaskDirectiveClass:
232 case Stmt::OMPTaskgroupDirectiveClass:
233 case Stmt::OMPFlushDirectiveClass:
234 case Stmt::OMPDepobjDirectiveClass:
235 case Stmt::OMPScanDirectiveClass:
236 case Stmt::OMPOrderedDirectiveClass:
237 case Stmt::OMPAtomicDirectiveClass:
238 case Stmt::OMPTargetDirectiveClass:
239 case Stmt::OMPTeamsDirectiveClass:
240 case Stmt::OMPCancellationPointDirectiveClass:
241 case Stmt::OMPCancelDirectiveClass:
242 case Stmt::OMPTargetDataDirectiveClass:
243 case Stmt::OMPTargetEnterDataDirectiveClass:
244 case Stmt::OMPTargetExitDataDirectiveClass:
245 case Stmt::OMPTargetParallelDirectiveClass:
246 case Stmt::OMPTargetParallelForDirectiveClass:
247 case Stmt::OMPTaskLoopDirectiveClass:
248 case Stmt::OMPTaskLoopSimdDirectiveClass:
249 case Stmt::OMPMaskedTaskLoopDirectiveClass:
250 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
251 case Stmt::OMPMasterTaskLoopDirectiveClass:
252 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
253 case Stmt::OMPParallelGenericLoopDirectiveClass:
254 case Stmt::OMPParallelMaskedDirectiveClass:
255 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
256 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
257 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
258 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
259 case Stmt::OMPDistributeDirectiveClass:
260 case Stmt::OMPDistributeParallelForDirectiveClass:
261 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
262 case Stmt::OMPDistributeSimdDirectiveClass:
263 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
264 case Stmt::OMPTargetParallelForSimdDirectiveClass:
265 case Stmt::OMPTargetSimdDirectiveClass:
266 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
267 case Stmt::OMPTargetUpdateDirectiveClass:
268 case Stmt::OMPTeamsDistributeDirectiveClass:
269 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
270 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
271 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
272 case Stmt::OMPTeamsGenericLoopDirectiveClass:
273 case Stmt::OMPTargetTeamsDirectiveClass:
274 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
275 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
276 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
277 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
278 case Stmt::OMPInteropDirectiveClass:
279 case Stmt::OMPDispatchDirectiveClass:
280 case Stmt::OMPGenericLoopDirectiveClass:
281 case Stmt::OMPReverseDirectiveClass:
282 case Stmt::OMPInterchangeDirectiveClass:
283 case Stmt::OMPAssumeDirectiveClass:
284 case Stmt::OMPMaskedDirectiveClass:
285 case Stmt::OMPStripeDirectiveClass:
286 case Stmt::ObjCAtCatchStmtClass:
287 case Stmt::ObjCAtFinallyStmtClass:
288 cgm.errorNYI(
s->getSourceRange(),
289 std::string(
"emitStmt: ") +
s->getStmtClassName());
290 return mlir::failure();
293 llvm_unreachable(
"Unexpected statement class");
297 bool useCurrentScope) {
298 switch (
s->getStmtClass()) {
300 return mlir::failure();
301 case Stmt::DeclStmtClass:
303 case Stmt::CompoundStmtClass:
307 case Stmt::GotoStmtClass:
309 case Stmt::ContinueStmtClass:
313 case Stmt::NullStmtClass:
316 case Stmt::LabelStmtClass:
318 case Stmt::CaseStmtClass:
319 case Stmt::DefaultStmtClass:
325 case Stmt::BreakStmtClass:
327 case Stmt::ReturnStmtClass:
331 return mlir::success();
337 return mlir::failure();
347 mlir::Location loc) {
352 unsigned numBlocks = r.getBlocks().size();
353 for (
auto &block : r.getBlocks()) {
356 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
357 block.hasNoSuccessors())
358 eraseBlocks.push_back(&block);
361 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
362 mlir::OpBuilder::InsertionGuard guardCase(builder);
363 builder.setInsertionPointToEnd(&block);
368 for (
auto *
b : eraseBlocks)
373 mlir::LogicalResult res = mlir::success();
376 const Stmt *constevalExecuted;
377 if (
s.isConsteval()) {
378 constevalExecuted =
s.isNegatedConsteval() ?
s.getThen() :
s.getElse();
379 if (!constevalExecuted) {
387 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
389 return emitStmt(constevalExecuted,
true);
392 if (
emitStmt(
s.getInit(),
true).failed())
393 return mlir::failure();
395 if (
s.getConditionVariable())
402 if (
s.isConstexpr()) {
407 if (
const Stmt *executed = condConstant ?
s.getThen() :
s.getElse())
411 return mlir::success();
423 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
424 builder.create<cir::ScopeOp>(
426 [&](mlir::OpBuilder &
b, mlir::Location loc) {
427 LexicalScope lexScope{*
this, scopeLoc, builder.getInsertionBlock()};
428 res = ifStmtBuilder();
435 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
437 for (
const Decl *i :
s.decls())
440 return mlir::success();
444 mlir::Location loc =
getLoc(
s.getSourceRange());
445 const Expr *rv =
s.getRetValue();
448 s.getNRVOCandidate()->isNRVOVariable()) {
461 ->isReferenceType()) {
467 mlir::Value value =
nullptr;
472 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
477 "complex function return type");
489 auto *retBlock =
curLexScope->getOrCreateRetBlock(*
this, loc);
491 builder.create<cir::BrOp>(loc, retBlock);
494 cgm.errorNYI(
s.getSourceRange(),
"return with cleanup stack");
497 builder.createBlock(builder.getBlock()->getParent());
499 return mlir::success();
509 cir::GotoOp::create(builder,
getLoc(
s.getSourceRange()),
510 s.getLabel()->getName());
515 builder.createBlock(builder.getBlock()->getParent());
517 return mlir::success();
522 builder.createContinue(
getLoc(
s.getKwLoc()));
525 builder.createBlock(builder.getBlock()->getParent());
527 return mlir::success();
534 mlir::Block *currBlock = builder.getBlock();
535 mlir::Block *labelBlock = currBlock;
537 if (!currBlock->empty()) {
539 mlir::OpBuilder::InsertionGuard guard(builder);
540 labelBlock = builder.createBlock(builder.getBlock()->getParent());
545 builder.setInsertionPointToEnd(labelBlock);
547 builder.setInsertionPointToEnd(labelBlock);
553 return mlir::success();
557 builder.createBreak(
getLoc(
s.getKwLoc()));
560 builder.createBlock(builder.getBlock()->getParent());
562 return mlir::success();
568 mlir::ArrayAttr value, CaseOpKind kind,
569 bool buildingTopLevelCase) {
572 "only case or default stmt go here");
574 mlir::LogicalResult result = mlir::success();
576 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
579 SubStmtKind subStmtKind = SubStmtKind::Other;
580 const Stmt *sub =
stmt->getSubStmt();
582 mlir::OpBuilder::InsertPoint insertPoint;
583 builder.create<CaseOp>(loc, value, kind, insertPoint);
586 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
587 builder.restoreInsertionPoint(insertPoint);
590 subStmtKind = SubStmtKind::Default;
591 builder.createYield(loc);
593 subStmtKind = SubStmtKind::Case;
594 builder.createYield(loc);
599 insertPoint = builder.saveInsertionPoint();
634 if (subStmtKind == SubStmtKind::Case) {
636 }
else if (subStmtKind == SubStmtKind::Default) {
638 buildingTopLevelCase);
639 }
else if (buildingTopLevelCase) {
643 builder.restoreInsertionPoint(insertPoint);
651 bool buildingTopLevelCase) {
652 cir::CaseOpKind kind;
653 mlir::ArrayAttr value;
654 llvm::APSInt intVal =
s.getLHS()->EvaluateKnownConstInt(
getContext());
659 if (
const Expr *rhs =
s.getRHS()) {
660 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
661 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
662 cir::IntAttr::get(condType, endVal)});
663 kind = cir::CaseOpKind::Range;
665 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
666 kind = cir::CaseOpKind::Equal;
670 buildingTopLevelCase);
675 bool buildingTopLevelCase) {
677 cir::CaseOpKind::Default, buildingTopLevelCase);
681 bool buildingTopLevelCase) {
683 "build switch case without specifying the type of the condition");
685 if (
s.getStmtClass() == Stmt::CaseStmtClass)
687 buildingTopLevelCase);
689 if (
s.getStmtClass() == Stmt::DefaultStmtClass)
691 buildingTopLevelCase);
693 llvm_unreachable(
"expect case or default stmt");
702 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
703 mlir::LogicalResult loopRes = mlir::success();
706 if (
emitStmt(
s.getInit(),
true).failed())
707 return mlir::failure();
708 if (
emitStmt(
s.getRangeStmt(),
true).failed())
709 return mlir::failure();
710 if (
emitStmt(
s.getBeginStmt(),
true).failed())
711 return mlir::failure();
712 if (
emitStmt(
s.getEndStmt(),
true).failed())
713 return mlir::failure();
722 forOp = builder.createFor(
725 [&](mlir::OpBuilder &
b, mlir::Location loc) {
726 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
727 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
728 mlir::Value condVal = evaluateExprAsBool(s.getCond());
729 builder.createCondition(condVal);
732 [&](mlir::OpBuilder &
b, mlir::Location loc) {
736 bool useCurrentScope = true;
737 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
738 loopRes = mlir::failure();
739 if (emitStmt(s.getBody(), useCurrentScope).failed())
740 loopRes = mlir::failure();
744 [&](mlir::OpBuilder &
b, mlir::Location loc) {
746 if (emitStmt(s.getInc(), true).failed())
747 loopRes = mlir::failure();
748 builder.createYield(loc);
753 mlir::LogicalResult res = mlir::success();
754 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
755 builder.create<cir::ScopeOp>(scopeLoc,
756 [&](mlir::OpBuilder &
b, mlir::Location loc) {
762 *
this, loc, builder.getInsertionBlock()};
763 res = forStmtBuilder();
770 return mlir::success();
777 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
778 mlir::LogicalResult loopRes = mlir::success();
781 if (
emitStmt(
s.getInit(),
true).failed())
782 return mlir::failure();
790 forOp = builder.createFor(
793 [&](mlir::OpBuilder &
b, mlir::Location loc) {
794 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
795 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
800 if (s.getConditionVariable())
801 emitDecl(*s.getConditionVariable());
805 condVal = evaluateExprAsBool(s.getCond());
807 condVal = b.create<cir::ConstantOp>(loc, builder.getTrueAttr());
809 builder.createCondition(condVal);
812 [&](mlir::OpBuilder &
b, mlir::Location loc) {
815 if (
emitStmt(
s.getBody(),
false).failed())
816 loopRes = mlir::failure();
820 [&](mlir::OpBuilder &
b, mlir::Location loc) {
823 loopRes = mlir::failure();
824 builder.createYield(loc);
829 auto res = mlir::success();
830 auto scopeLoc = getLoc(
s.getSourceRange());
831 builder.create<cir::ScopeOp>(scopeLoc,
832 [&](mlir::OpBuilder &
b, mlir::Location loc) {
833 LexicalScope lexScope{
834 *
this, loc, builder.getInsertionBlock()};
835 res = forStmtBuilder();
842 return mlir::success();
846 cir::DoWhileOp doWhileOp;
849 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
850 mlir::LogicalResult loopRes = mlir::success();
858 doWhileOp = builder.createDoWhile(
861 [&](mlir::OpBuilder &
b, mlir::Location loc) {
862 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
863 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
867 mlir::Value condVal = evaluateExprAsBool(s.getCond());
868 builder.createCondition(condVal);
871 [&](mlir::OpBuilder &
b, mlir::Location loc) {
873 if (emitStmt(s.getBody(), false).failed())
874 loopRes = mlir::failure();
880 mlir::LogicalResult res = mlir::success();
881 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
882 builder.create<cir::ScopeOp>(scopeLoc,
883 [&](mlir::OpBuilder &
b, mlir::Location loc) {
885 *
this, loc, builder.getInsertionBlock()};
886 res = doStmtBuilder();
893 return mlir::success();
897 cir::WhileOp whileOp;
900 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
901 mlir::LogicalResult loopRes = mlir::success();
909 whileOp = builder.createWhile(
912 [&](mlir::OpBuilder &
b, mlir::Location loc) {
913 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
914 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
918 if (s.getConditionVariable())
919 emitDecl(*s.getConditionVariable());
923 condVal = evaluateExprAsBool(s.getCond());
924 builder.createCondition(condVal);
927 [&](mlir::OpBuilder &
b, mlir::Location loc) {
929 if (emitStmt(s.getBody(), false).failed())
930 loopRes = mlir::failure();
936 mlir::LogicalResult res = mlir::success();
937 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
938 builder.create<cir::ScopeOp>(scopeLoc,
939 [&](mlir::OpBuilder &
b, mlir::Location loc) {
941 *
this, loc, builder.getInsertionBlock()};
942 res = whileStmtBuilder();
949 return mlir::success();
967 mlir::Block *swtichBlock = builder.getBlock();
970 builder.setInsertionPointToEnd(swtichBlock);
976 return mlir::failure();
983 return mlir::failure();
986 return mlir::success();
997 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
999 if (
emitStmt(
s.getInit(),
true).failed())
1000 return mlir::failure();
1002 if (
s.getConditionVariable())
1003 emitDecl(*
s.getConditionVariable(),
true);
1013 mlir::LogicalResult res = mlir::success();
1014 swop = builder.create<SwitchOp>(
1015 getLoc(
s.getBeginLoc()), condV,
1017 [&](mlir::OpBuilder &
b, mlir::Location loc, mlir::OperationState &os) {
1031 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
1032 mlir::LogicalResult res = mlir::success();
1033 builder.create<cir::ScopeOp>(scopeLoc,
1034 [&](mlir::OpBuilder &
b, mlir::Location loc) {
1036 *
this, loc, builder.getInsertionBlock()};
1037 res = switchStmtBuilder();
1041 swop.collectCases(cases);
1042 for (
auto caseOp : cases)
1043 terminateBody(builder, caseOp.getCaseRegion(), caseOp.getLoc());
1058 cgm.errorNYI(loc,
"emitReturnOfRValue: complex return type");
1060 mlir::Block *retBlock =
curLexScope->getOrCreateRetBlock(*
this, loc);
1062 builder.create<cir::BrOp>(loc, retBlock);
1064 cgm.errorNYI(loc,
"return 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)
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.
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)
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.
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)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::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
void emitAggregateCopy(LValue dest, LValue src, QualType eltTy, AggValueSlot::Overlap_t mayOverlap)
Emit an aggregate copy.
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.
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...