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::CXXTryStmtClass:
159 case Stmt::CXXForRangeStmtClass:
161 case Stmt::OpenACCComputeConstructClass:
163 case Stmt::OpenACCLoopConstructClass:
165 case Stmt::OpenACCCombinedConstructClass:
167 case Stmt::OpenACCDataConstructClass:
169 case Stmt::OpenACCEnterDataConstructClass:
171 case Stmt::OpenACCExitDataConstructClass:
173 case Stmt::OpenACCHostDataConstructClass:
175 case Stmt::OpenACCWaitConstructClass:
177 case Stmt::OpenACCInitConstructClass:
179 case Stmt::OpenACCShutdownConstructClass:
181 case Stmt::OpenACCSetConstructClass:
183 case Stmt::OpenACCUpdateConstructClass:
185 case Stmt::OpenACCCacheConstructClass:
187 case Stmt::OpenACCAtomicConstructClass:
189 case Stmt::GCCAsmStmtClass:
190 case Stmt::MSAsmStmtClass:
192 case Stmt::OMPScopeDirectiveClass:
193 case Stmt::OMPErrorDirectiveClass:
194 case Stmt::LabelStmtClass:
195 case Stmt::AttributedStmtClass:
196 case Stmt::GotoStmtClass:
197 case Stmt::DefaultStmtClass:
198 case Stmt::CaseStmtClass:
199 case Stmt::SEHLeaveStmtClass:
200 case Stmt::SYCLKernelCallStmtClass:
201 case Stmt::CoroutineBodyStmtClass:
203 case Stmt::CoreturnStmtClass:
204 case Stmt::IndirectGotoStmtClass:
205 case Stmt::OMPParallelDirectiveClass:
206 case Stmt::OMPTaskwaitDirectiveClass:
207 case Stmt::OMPTaskyieldDirectiveClass:
208 case Stmt::OMPBarrierDirectiveClass:
209 case Stmt::CapturedStmtClass:
210 case Stmt::ObjCAtTryStmtClass:
211 case Stmt::ObjCAtThrowStmtClass:
212 case Stmt::ObjCAtSynchronizedStmtClass:
213 case Stmt::ObjCForCollectionStmtClass:
214 case Stmt::ObjCAutoreleasePoolStmtClass:
215 case Stmt::SEHTryStmtClass:
216 case Stmt::OMPMetaDirectiveClass:
217 case Stmt::OMPCanonicalLoopClass:
218 case Stmt::OMPSimdDirectiveClass:
219 case Stmt::OMPTileDirectiveClass:
220 case Stmt::OMPUnrollDirectiveClass:
221 case Stmt::OMPFuseDirectiveClass:
222 case Stmt::OMPForDirectiveClass:
223 case Stmt::OMPForSimdDirectiveClass:
224 case Stmt::OMPSectionsDirectiveClass:
225 case Stmt::OMPSectionDirectiveClass:
226 case Stmt::OMPSingleDirectiveClass:
227 case Stmt::OMPMasterDirectiveClass:
228 case Stmt::OMPCriticalDirectiveClass:
229 case Stmt::OMPParallelForDirectiveClass:
230 case Stmt::OMPParallelForSimdDirectiveClass:
231 case Stmt::OMPParallelMasterDirectiveClass:
232 case Stmt::OMPParallelSectionsDirectiveClass:
233 case Stmt::OMPTaskDirectiveClass:
234 case Stmt::OMPTaskgroupDirectiveClass:
235 case Stmt::OMPFlushDirectiveClass:
236 case Stmt::OMPDepobjDirectiveClass:
237 case Stmt::OMPScanDirectiveClass:
238 case Stmt::OMPOrderedDirectiveClass:
239 case Stmt::OMPAtomicDirectiveClass:
240 case Stmt::OMPTargetDirectiveClass:
241 case Stmt::OMPTeamsDirectiveClass:
242 case Stmt::OMPCancellationPointDirectiveClass:
243 case Stmt::OMPCancelDirectiveClass:
244 case Stmt::OMPTargetDataDirectiveClass:
245 case Stmt::OMPTargetEnterDataDirectiveClass:
246 case Stmt::OMPTargetExitDataDirectiveClass:
247 case Stmt::OMPTargetParallelDirectiveClass:
248 case Stmt::OMPTargetParallelForDirectiveClass:
249 case Stmt::OMPTaskLoopDirectiveClass:
250 case Stmt::OMPTaskLoopSimdDirectiveClass:
251 case Stmt::OMPMaskedTaskLoopDirectiveClass:
252 case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
253 case Stmt::OMPMasterTaskLoopDirectiveClass:
254 case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
255 case Stmt::OMPParallelGenericLoopDirectiveClass:
256 case Stmt::OMPParallelMaskedDirectiveClass:
257 case Stmt::OMPParallelMaskedTaskLoopDirectiveClass:
258 case Stmt::OMPParallelMaskedTaskLoopSimdDirectiveClass:
259 case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
260 case Stmt::OMPParallelMasterTaskLoopSimdDirectiveClass:
261 case Stmt::OMPDistributeDirectiveClass:
262 case Stmt::OMPDistributeParallelForDirectiveClass:
263 case Stmt::OMPDistributeParallelForSimdDirectiveClass:
264 case Stmt::OMPDistributeSimdDirectiveClass:
265 case Stmt::OMPTargetParallelGenericLoopDirectiveClass:
266 case Stmt::OMPTargetParallelForSimdDirectiveClass:
267 case Stmt::OMPTargetSimdDirectiveClass:
268 case Stmt::OMPTargetTeamsGenericLoopDirectiveClass:
269 case Stmt::OMPTargetUpdateDirectiveClass:
270 case Stmt::OMPTeamsDistributeDirectiveClass:
271 case Stmt::OMPTeamsDistributeSimdDirectiveClass:
272 case Stmt::OMPTeamsDistributeParallelForSimdDirectiveClass:
273 case Stmt::OMPTeamsDistributeParallelForDirectiveClass:
274 case Stmt::OMPTeamsGenericLoopDirectiveClass:
275 case Stmt::OMPTargetTeamsDirectiveClass:
276 case Stmt::OMPTargetTeamsDistributeDirectiveClass:
277 case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
278 case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
279 case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
280 case Stmt::OMPInteropDirectiveClass:
281 case Stmt::OMPDispatchDirectiveClass:
282 case Stmt::OMPGenericLoopDirectiveClass:
283 case Stmt::OMPReverseDirectiveClass:
284 case Stmt::OMPInterchangeDirectiveClass:
285 case Stmt::OMPAssumeDirectiveClass:
286 case Stmt::OMPMaskedDirectiveClass:
287 case Stmt::OMPStripeDirectiveClass:
288 case Stmt::ObjCAtCatchStmtClass:
289 case Stmt::ObjCAtFinallyStmtClass:
290 cgm.errorNYI(
s->getSourceRange(),
291 std::string(
"emitStmt: ") +
s->getStmtClassName());
292 return mlir::failure();
295 llvm_unreachable(
"Unexpected statement class");
299 bool useCurrentScope) {
300 switch (
s->getStmtClass()) {
302 return mlir::failure();
303 case Stmt::DeclStmtClass:
305 case Stmt::CompoundStmtClass:
309 case Stmt::GotoStmtClass:
311 case Stmt::ContinueStmtClass:
315 case Stmt::NullStmtClass:
318 case Stmt::LabelStmtClass:
320 case Stmt::CaseStmtClass:
321 case Stmt::DefaultStmtClass:
327 case Stmt::BreakStmtClass:
329 case Stmt::ReturnStmtClass:
333 return mlir::success();
339 return mlir::failure();
349 mlir::Location loc) {
354 unsigned numBlocks = r.getBlocks().size();
355 for (
auto &block : r.getBlocks()) {
358 if (numBlocks != 1 && block.empty() && block.hasNoPredecessors() &&
359 block.hasNoSuccessors())
360 eraseBlocks.push_back(&block);
363 !block.back().hasTrait<mlir::OpTrait::IsTerminator>()) {
364 mlir::OpBuilder::InsertionGuard guardCase(builder);
365 builder.setInsertionPointToEnd(&block);
370 for (
auto *
b : eraseBlocks)
375 mlir::LogicalResult res = mlir::success();
378 const Stmt *constevalExecuted;
379 if (
s.isConsteval()) {
380 constevalExecuted =
s.isNegatedConsteval() ?
s.getThen() :
s.getElse();
381 if (!constevalExecuted) {
389 auto ifStmtBuilder = [&]() -> mlir::LogicalResult {
391 return emitStmt(constevalExecuted,
true);
394 if (
emitStmt(
s.getInit(),
true).failed())
395 return mlir::failure();
397 if (
s.getConditionVariable())
404 if (
s.isConstexpr()) {
409 if (
const Stmt *executed = condConstant ?
s.getThen() :
s.getElse())
413 return mlir::success();
425 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
426 builder.create<cir::ScopeOp>(
428 [&](mlir::OpBuilder &
b, mlir::Location loc) {
429 LexicalScope lexScope{*
this, scopeLoc, builder.getInsertionBlock()};
430 res = ifStmtBuilder();
437 assert(builder.getInsertionBlock() &&
"expected valid insertion point");
439 for (
const Decl *i :
s.decls())
442 return mlir::success();
446 mlir::Location loc =
getLoc(
s.getSourceRange());
447 const Expr *rv =
s.getRetValue();
450 s.getNRVOCandidate()->isNRVOVariable()) {
463 ->isReferenceType()) {
469 mlir::Value value =
nullptr;
474 builder.CIRBaseBuilderTy::createStore(loc, value, *
fnRetAlloca);
479 "complex function return type");
491 auto *retBlock =
curLexScope->getOrCreateRetBlock(*
this, loc);
493 builder.create<cir::BrOp>(loc, retBlock);
496 cgm.errorNYI(
s.getSourceRange(),
"return with cleanup stack");
499 builder.createBlock(builder.getBlock()->getParent());
501 return mlir::success();
511 cir::GotoOp::create(builder,
getLoc(
s.getSourceRange()),
512 s.getLabel()->getName());
517 builder.createBlock(builder.getBlock()->getParent());
519 return mlir::success();
524 builder.createContinue(
getLoc(
s.getKwLoc()));
527 builder.createBlock(builder.getBlock()->getParent());
529 return mlir::success();
536 mlir::Block *currBlock = builder.getBlock();
537 mlir::Block *labelBlock = currBlock;
539 if (!currBlock->empty()) {
541 mlir::OpBuilder::InsertionGuard guard(builder);
542 labelBlock = builder.createBlock(builder.getBlock()->getParent());
547 builder.setInsertionPointToEnd(labelBlock);
549 builder.setInsertionPointToEnd(labelBlock);
555 return mlir::success();
559 builder.createBreak(
getLoc(
s.getKwLoc()));
562 builder.createBlock(builder.getBlock()->getParent());
564 return mlir::success();
570 mlir::ArrayAttr value, CaseOpKind kind,
571 bool buildingTopLevelCase) {
574 "only case or default stmt go here");
576 mlir::LogicalResult result = mlir::success();
578 mlir::Location loc =
getLoc(
stmt->getBeginLoc());
581 SubStmtKind subStmtKind = SubStmtKind::Other;
582 const Stmt *sub =
stmt->getSubStmt();
584 mlir::OpBuilder::InsertPoint insertPoint;
585 builder.create<CaseOp>(loc, value, kind, insertPoint);
588 mlir::OpBuilder::InsertionGuard guardSwitch(builder);
589 builder.restoreInsertionPoint(insertPoint);
592 subStmtKind = SubStmtKind::Default;
593 builder.createYield(loc);
595 subStmtKind = SubStmtKind::Case;
596 builder.createYield(loc);
601 insertPoint = builder.saveInsertionPoint();
636 if (subStmtKind == SubStmtKind::Case) {
638 }
else if (subStmtKind == SubStmtKind::Default) {
640 buildingTopLevelCase);
641 }
else if (buildingTopLevelCase) {
645 builder.restoreInsertionPoint(insertPoint);
653 bool buildingTopLevelCase) {
654 cir::CaseOpKind kind;
655 mlir::ArrayAttr value;
656 llvm::APSInt intVal =
s.getLHS()->EvaluateKnownConstInt(
getContext());
661 if (
const Expr *rhs =
s.getRHS()) {
662 llvm::APSInt endVal = rhs->EvaluateKnownConstInt(
getContext());
663 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal),
664 cir::IntAttr::get(condType, endVal)});
665 kind = cir::CaseOpKind::Range;
667 value = builder.getArrayAttr({cir::IntAttr::get(condType, intVal)});
668 kind = cir::CaseOpKind::Equal;
672 buildingTopLevelCase);
677 bool buildingTopLevelCase) {
679 cir::CaseOpKind::Default, buildingTopLevelCase);
683 bool buildingTopLevelCase) {
685 "build switch case without specifying the type of the condition");
687 if (
s.getStmtClass() == Stmt::CaseStmtClass)
689 buildingTopLevelCase);
691 if (
s.getStmtClass() == Stmt::DefaultStmtClass)
693 buildingTopLevelCase);
695 llvm_unreachable(
"expect case or default stmt");
704 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
705 mlir::LogicalResult loopRes = mlir::success();
708 if (
emitStmt(
s.getInit(),
true).failed())
709 return mlir::failure();
710 if (
emitStmt(
s.getRangeStmt(),
true).failed())
711 return mlir::failure();
712 if (
emitStmt(
s.getBeginStmt(),
true).failed())
713 return mlir::failure();
714 if (
emitStmt(
s.getEndStmt(),
true).failed())
715 return mlir::failure();
724 forOp = builder.createFor(
727 [&](mlir::OpBuilder &
b, mlir::Location loc) {
728 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
729 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
730 mlir::Value condVal = evaluateExprAsBool(s.getCond());
731 builder.createCondition(condVal);
734 [&](mlir::OpBuilder &
b, mlir::Location loc) {
738 bool useCurrentScope = true;
739 if (emitStmt(s.getLoopVarStmt(), useCurrentScope).failed())
740 loopRes = mlir::failure();
741 if (emitStmt(s.getBody(), useCurrentScope).failed())
742 loopRes = mlir::failure();
746 [&](mlir::OpBuilder &
b, mlir::Location loc) {
748 if (emitStmt(s.getInc(), true).failed())
749 loopRes = mlir::failure();
750 builder.createYield(loc);
755 mlir::LogicalResult res = mlir::success();
756 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
757 builder.create<cir::ScopeOp>(scopeLoc,
758 [&](mlir::OpBuilder &
b, mlir::Location loc) {
764 *
this, loc, builder.getInsertionBlock()};
765 res = forStmtBuilder();
772 return mlir::success();
779 auto forStmtBuilder = [&]() -> mlir::LogicalResult {
780 mlir::LogicalResult loopRes = mlir::success();
783 if (
emitStmt(
s.getInit(),
true).failed())
784 return mlir::failure();
792 forOp = builder.createFor(
795 [&](mlir::OpBuilder &
b, mlir::Location loc) {
796 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
797 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
802 if (s.getConditionVariable())
803 emitDecl(*s.getConditionVariable());
807 condVal = evaluateExprAsBool(s.getCond());
809 condVal = b.create<cir::ConstantOp>(loc, builder.getTrueAttr());
811 builder.createCondition(condVal);
814 [&](mlir::OpBuilder &
b, mlir::Location loc) {
817 if (
emitStmt(
s.getBody(),
false).failed())
818 loopRes = mlir::failure();
822 [&](mlir::OpBuilder &
b, mlir::Location loc) {
825 loopRes = mlir::failure();
826 builder.createYield(loc);
831 auto res = mlir::success();
832 auto scopeLoc = getLoc(
s.getSourceRange());
833 builder.create<cir::ScopeOp>(scopeLoc,
834 [&](mlir::OpBuilder &
b, mlir::Location loc) {
835 LexicalScope lexScope{
836 *
this, loc, builder.getInsertionBlock()};
837 res = forStmtBuilder();
844 return mlir::success();
848 cir::DoWhileOp doWhileOp;
851 auto doStmtBuilder = [&]() -> mlir::LogicalResult {
852 mlir::LogicalResult loopRes = mlir::success();
860 doWhileOp = builder.createDoWhile(
863 [&](mlir::OpBuilder &
b, mlir::Location loc) {
864 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
865 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
869 mlir::Value condVal = evaluateExprAsBool(s.getCond());
870 builder.createCondition(condVal);
873 [&](mlir::OpBuilder &
b, mlir::Location loc) {
875 if (emitStmt(s.getBody(), false).failed())
876 loopRes = mlir::failure();
882 mlir::LogicalResult res = mlir::success();
883 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
884 builder.create<cir::ScopeOp>(scopeLoc,
885 [&](mlir::OpBuilder &
b, mlir::Location loc) {
887 *
this, loc, builder.getInsertionBlock()};
888 res = doStmtBuilder();
895 return mlir::success();
899 cir::WhileOp whileOp;
902 auto whileStmtBuilder = [&]() -> mlir::LogicalResult {
903 mlir::LogicalResult loopRes = mlir::success();
911 whileOp = builder.createWhile(
914 [&](mlir::OpBuilder &
b, mlir::Location loc) {
915 assert(!cir::MissingFeatures::createProfileWeightsForLoop());
916 assert(!cir::MissingFeatures::emitCondLikelihoodViaExpectIntrinsic());
920 if (s.getConditionVariable())
921 emitDecl(*s.getConditionVariable());
925 condVal = evaluateExprAsBool(s.getCond());
926 builder.createCondition(condVal);
929 [&](mlir::OpBuilder &
b, mlir::Location loc) {
931 if (emitStmt(s.getBody(), false).failed())
932 loopRes = mlir::failure();
938 mlir::LogicalResult res = mlir::success();
939 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
940 builder.create<cir::ScopeOp>(scopeLoc,
941 [&](mlir::OpBuilder &
b, mlir::Location loc) {
943 *
this, loc, builder.getInsertionBlock()};
944 res = whileStmtBuilder();
951 return mlir::success();
969 mlir::Block *swtichBlock = builder.getBlock();
972 builder.setInsertionPointToEnd(swtichBlock);
978 return mlir::failure();
985 return mlir::failure();
988 return mlir::success();
999 auto switchStmtBuilder = [&]() -> mlir::LogicalResult {
1001 if (
emitStmt(
s.getInit(),
true).failed())
1002 return mlir::failure();
1004 if (
s.getConditionVariable())
1005 emitDecl(*
s.getConditionVariable(),
true);
1015 mlir::LogicalResult res = mlir::success();
1016 swop = builder.create<SwitchOp>(
1017 getLoc(
s.getBeginLoc()), condV,
1019 [&](mlir::OpBuilder &
b, mlir::Location loc, mlir::OperationState &os) {
1033 mlir::Location scopeLoc =
getLoc(
s.getSourceRange());
1034 mlir::LogicalResult res = mlir::success();
1035 builder.create<cir::ScopeOp>(scopeLoc,
1036 [&](mlir::OpBuilder &
b, mlir::Location loc) {
1038 *
this, loc, builder.getInsertionBlock()};
1039 res = switchStmtBuilder();
1043 swop.collectCases(cases);
1044 for (
auto caseOp : cases)
1045 terminateBody(builder, caseOp.getCaseRegion(), caseOp.getLoc());
1060 cgm.errorNYI(loc,
"emitReturnOfRValue: complex return type");
1062 mlir::Block *retBlock =
curLexScope->getOrCreateRetBlock(*
this, loc);
1064 builder.create<cir::BrOp>(loc, retBlock);
1066 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 emitCXXTryStmt(const clang::CXXTryStmt &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 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.
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...