19#include "mlir/IR/Location.h"
27#include "llvm/ADT/ScopeExit.h"
28#include "llvm/IR/FPEnv.h"
49 bool suppressNewContext)
61 cir::FastMathFlags flags = cir::FastMathFlags::none;
62 if (fpFeatures.getAllowFPReassociate())
63 flags = flags | cir::FastMathFlags::reassoc;
64 if (fpFeatures.getNoHonorNaNs())
65 flags = flags | cir::FastMathFlags::nnan;
66 if (fpFeatures.getNoHonorInfs())
67 flags = flags | cir::FastMathFlags::ninf;
68 if (fpFeatures.getNoSignedZero())
69 flags = flags | cir::FastMathFlags::nsz;
70 if (fpFeatures.getAllowReciprocal())
71 flags = flags | cir::FastMathFlags::arcp;
72 if (fpFeatures.getAllowApproxFunc())
73 flags = flags | cir::FastMathFlags::afn;
75 flags = flags | cir::FastMathFlags::contract;
76 builder.setFastMathFlags(flags);
83 switch (
type->getTypeClass()) {
84#define TYPE(name, parent)
85#define ABSTRACT_TYPE(name, parent)
86#define NON_CANONICAL_TYPE(name, parent) case Type::name:
87#define DEPENDENT_TYPE(name, parent) case Type::name:
88#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(name, parent) case Type::name:
89#include "clang/AST/TypeNodes.inc"
90 llvm_unreachable(
"non-canonical or dependent type in IR-generation");
93 case Type::DeducedTemplateSpecialization:
94 llvm_unreachable(
"undeduced type in IR-generation");
99 case Type::BlockPointer:
100 case Type::LValueReference:
101 case Type::RValueReference:
102 case Type::MemberPointer:
104 case Type::ExtVector:
105 case Type::ConstantMatrix:
106 case Type::FunctionProto:
107 case Type::FunctionNoProto:
109 case Type::ObjCObjectPointer:
112 case Type::OverflowBehavior:
113 case Type::HLSLAttributedResource:
114 case Type::HLSLInlineSpirv:
122 case Type::ConstantArray:
123 case Type::IncompleteArray:
124 case Type::VariableArray:
126 case Type::ObjCObject:
127 case Type::ObjCInterface:
128 case Type::ArrayParameter:
136 llvm_unreachable(
"unknown type kind!");
141 return cgm.getTypes().convertTypeForMem(t);
145 return cgm.getTypes().convertType(t);
155 return mlir::FileLineColLoc::get(builder.getStringAttr(filename),
164 return builder.getUnknownLoc();
189 return builder.getUnknownLoc();
194 mlir::Attribute metadata;
221 ignoreCaseStmts =
true;
225 [=](
const Stmt *subStmt) {
226 return containsLabel(subStmt, ignoreCaseStmts);
235 llvm::APSInt resultInt;
239 resultBool = resultInt.getBoolValue();
247 llvm::APSInt &resultInt,
255 llvm::APSInt intValue = result.
Val.
getInt();
259 resultInt = intValue;
263void CIRGenFunction::emitAndUpdateRetAlloca(
QualType type, mlir::Location loc,
265 if (!
type->isVoidType()) {
268 mlir::cast<cir::AllocaOp>(allocaAddr.
getDefiningOp()).setReturnSlot(
true);
273void CIRGenFunction::declare(mlir::Value addrVal,
const Decl *var, QualType ty,
274 mlir::Location loc, CharUnits alignment,
277 assert(!
symbolTable.count(var) &&
"not supposed to be available just yet");
279 Address addr(addrVal, alignment);
280 cir::AllocaOp allocaOp = addr.getUnderlyingAllocaOp();
281 assert(allocaOp &&
"expected cir::AllocaOp");
285 if (ty->isReferenceType() || ty.isConstQualified())
292 assert(d->
hasAttr<AnnotateAttr>() &&
"no annotate attribute");
300 assert(field->
hasAttr<AnnotateAttr>() &&
"no annotate attribute");
304 ptr,
cgm.emitAnnotateAttr(
attr));
318 for (mlir::Block *retBlock : localScope->
getRetBlocks()) {
319 mlir::OpBuilder::InsertionGuard guard(builder);
320 builder.setInsertionPointToEnd(retBlock);
321 retBlocks.push_back(retBlock);
322 mlir::Location retLoc = localScope->
getRetLoc(retBlock);
334 mlir::Block *curBlock = builder.getBlock();
337 if (curBlock->mightHaveTerminator() && curBlock->getTerminator())
343 bool isEntryBlock = builder.getInsertionBlock()->isEntryBlock();
344 if (!isEntryBlock && curBlock->empty()) {
346 for (mlir::Block *retBlock : retBlocks) {
347 if (retBlock->getUses().empty())
353 if (localScope->
depth == 0) {
357 mlir::Location retLoc = localScope->
getRetLoc(retBlock);
358 if (retBlock->getUses().empty()) {
361 cir::BrOp::create(builder, retLoc, retBlock);
365 emitImplicitReturn();
372 if (!localScope->
isTernary() && !curBlock->mightHaveTerminator()) {
373 !retVal ? cir::YieldOp::create(builder, localScope->endLoc)
374 : cir::YieldOp::create(builder, localScope->endLoc, retVal);
378cir::ReturnOp CIRGenFunction::LexicalScope::emitReturn(mlir::Location loc) {
381 auto fn = dyn_cast<cir::FuncOp>(cgf.curFn);
382 assert(fn &&
"emitReturn from non-function");
384 if (!fn.getFunctionType().hasVoidReturn()) {
386 auto value = cir::LoadOp::create(
387 builder, loc, fn.getFunctionType().getReturnType(), *cgf.fnRetAlloca);
388 return cir::ReturnOp::create(builder, loc,
391 return cir::ReturnOp::create(builder, loc);
401 return classDecl->hasTrivialDestructor();
408 mlir::Operation *op = &block->back();
409 auto cleanupScopeOp = mlir::dyn_cast<cir::CleanupScopeOp>(op);
417 for (mlir::Block &bodyBlock : cleanupScopeOp.getBodyRegion()) {
418 if (bodyBlock.mightHaveTerminator()) {
419 if (mlir::isa<cir::YieldOp>(bodyBlock.getTerminator()))
421 assert(!mlir::isa<cir::BreakOp>(bodyBlock.getTerminator()) &&
422 !mlir::isa<cir::ContinueOp>(bodyBlock.getTerminator()) &&
423 !mlir::isa<cir::ResumeOp>(bodyBlock.getTerminator()));
429void CIRGenFunction::LexicalScope::emitImplicitReturn() {
430 CIRGenBuilderTy &builder = cgf.getBuilder();
431 LexicalScope *localScope = cgf.curLexScope;
436 const auto *fd = dyn_cast_or_null<clang::FunctionDecl>(cgf.curGD.getDecl());
443 if (fd && cgf.getLangOpts().CPlusPlus && !fd->hasImplicitReturnZero() &&
444 !cgf.sawAsmBlock && !fd->getReturnType()->isVoidType() &&
445 builder.getInsertionBlock() &&
447 bool shouldEmitUnreachable =
448 cgf.cgm.getCodeGenOpts().StrictReturn ||
451 if (shouldEmitUnreachable) {
453 if (cgf.cgm.getCodeGenOpts().OptimizationLevel == 0)
454 cir::TrapOp::create(builder, localScope->endLoc,
true);
456 cir::UnreachableOp::create(builder, localScope->endLoc,
458 builder.clearInsertionPoint();
463 emitReturn(localScope->endLoc).setImplicit(
true);
471 scope = scope->parentScope;
484 if (value.getType() == ty)
487 assert((mlir::isa<cir::IntType>(ty) || cir::isAnyFloatingPointType(ty)) &&
488 "unexpected promotion type");
490 if (mlir::isa<cir::IntType>(ty))
491 return cgf.
getBuilder().CIRBaseBuilderTy::createIntCast(value, ty);
497 mlir::Block *entryBB,
501 if (fd && fd->
hasAttr<NakedAttr>()) {
502 cgm.errorNYI(bodyBeginLoc,
"naked function decl");
508 mlir::Location loc =
getLoc(bodyBeginLoc);
509 mlir::Value zero = builder.getNullValue(retTy, loc);
510 builder.CIRBaseBuilderTy::createStore(loc, zero,
returnValue.getPointer());
514 for (
const auto nameValue : llvm::zip(args, entryBB->getArguments())) {
515 const VarDecl *paramVar = std::get<0>(nameValue);
516 mlir::Value paramVal = std::get<1>(nameValue);
519 paramVal.setLoc(paramLoc);
521 mlir::Value addrVal =
526 mlir::ptr::MemorySpaceAttrInterface destAddrSpace =
546 mlir::Location fnBodyBegin =
getLoc(bodyBeginLoc);
547 builder.CIRBaseBuilderTy::createStore(fnBodyBegin, paramVal,
550 if (paramVar->
hasAttr<AnnotateAttr>())
553 assert(builder.getInsertionBlock() &&
"Should be valid");
557 cir::FuncOp fn, cir::FuncType funcType,
561 "CIRGenFunction can only be used for one function at a time");
569 const auto *fd = dyn_cast_or_null<FunctionDecl>(d);
578 fn->setAttr(cir::CIRDialect::getNoRecurseAttrName(),
579 mlir::UnitAttr::get(fn.getContext()));
589 builder.setDefaultConstrainedRounding(rm);
590 builder.setDefaultConstrainedExcept(eb);
591 builder.setIsFPConstrained(
false);
592 if ((fd && (fd->UsesFPIntrin() || fd->hasAttr<StrictFPAttr>())) ||
594 rm != llvm::RoundingMode::NearestTiesToEven))) {
595 builder.setIsFPConstrained(
true);
596 fn->setAttr(cir::CIRDialect::getStrictFPAttrName(),
597 mlir::UnitAttr::get(fn.getContext()));
599 mlir::Block *entryBB = &fn.getBlocks().front();
600 builder.setInsertionPointToStart(entryBB);
609 if (
Stmt *body = fd->getBody())
610 bodyEndLoc = body->getEndLoc();
612 bodyEndLoc = fd->getLocation();
614 emitAndUpdateRetAlloca(returnType,
getLoc(bodyEndLoc),
615 getContext().getTypeAlignInChars(returnType));
629 if (
Stmt *body = fd->getBody())
630 bodyBeginLoc = body->getBeginLoc();
632 bodyBeginLoc = fd->getLocation();
637 if (
const auto *md = dyn_cast_if_present<CXXMethodDecl>(d);
638 md && !md->isStatic()) {
640 md->getParent()->isLambda() && md->getOverloadedOperator() == OO_Call;
642 if (md->isImplicitObjectMemberFunction())
643 cgm.getCXXABI().emitInstanceFunctionProlog(loc, *
this);
672 for (
auto *fd : md->getParent()->fields()) {
673 if (fd->hasCapturedVLAType()) {
674 mlir::Value exprArg =
681 }
else if (md->isImplicitObjectMemberFunction()) {
695 if (!fd || !fd->hasAttr<NakedAttr>()) {
696 for (
const VarDecl *vd : args) {
701 if (
const auto *pvd = dyn_cast<ParmVarDecl>(vd))
702 ty = pvd->getOriginalType();
725 "deferred conditional cleanups were not consumed by a "
726 "FullExprCleanupScope");
735 if (
const CompoundStmt *block = dyn_cast<CompoundStmt>(body))
746 for (mlir::Block &block : func.getBlocks()) {
747 if (block.empty() && block.getUses().empty())
748 blocksToDelete.push_back(&block);
750 for (mlir::Block *block : blocksToDelete)
755 cir::FuncType funcType) {
759 if (funcDecl->isInlineBuiltinDeclaration()) {
763 std::string fdInlineName = (
cgm.getMangledName(funcDecl) +
".inline").str();
765 mlir::cast_or_null<cir::FuncOp>(
cgm.getGlobalValue(fdInlineName));
767 mlir::OpBuilder::InsertionGuard guard(builder);
768 builder.setInsertionPoint(fn);
769 clone = cir::FuncOp::create(builder, fn.getLoc(), fdInlineName,
770 fn.getFunctionType());
771 cgm.insertGlobalSymbol(clone);
772 clone.setLinkage(cir::GlobalLinkageKind::InternalLinkage);
773 clone.setSymVisibility(
"private");
774 clone.setInlineKind(cir::InlineKind::AlwaysInline);
776 fn.setLinkage(cir::GlobalLinkageKind::ExternalLinkage);
777 fn.setSymVisibility(
"private");
785 if (LLVM_UNLIKELY(pd->isInlineBuiltinDeclaration())) {
786 std::string inlineName = funcDecl->getName().str() +
".inline";
787 if (
auto inlineFn = mlir::cast_or_null<cir::FuncOp>(
788 cgm.getGlobalValue(inlineName))) {
793 .replaceAllSymbolUses(fn.getSymNameAttr(),
cgm.getModule())
795 llvm_unreachable(
"Failed to replace inline builtin symbol uses");
796 cgm.eraseGlobalSymbol(inlineFn);
805 Stmt *body = funcDecl->getBody();
812 return clangLoc.isValid() ?
getLoc(clangLoc) : builder.getUnknownLoc();
814 const mlir::Location fusedLoc = mlir::FusedLoc::get(
816 {validMLIRLoc(bodyRange.
getBegin()), validMLIRLoc(bodyRange.
getEnd())});
817 mlir::Block *entryBB = fn.addEntryBlock();
831 if (body && isa_and_nonnull<CoroutineBodyStmt>(body))
832 llvm::append_range(
fnArgs, funcDecl->parameters());
835 fn->setAttr(cir::CIRDialect::getMustProgressAttrName(),
838 if (shouldEmitLifetimeMarkers)
846 funcDecl->hasAttr<CUDAGlobalAttr>()) {
847 cgm.getCUDARuntime().emitDeviceStub(*
this, fn, args);
867 llvm_unreachable(
"no definition for normal function");
874 if (mlir::failed(fn.verifyBody()))
879 cgm.emitOpenCLKernelArgMetadata(fn, funcDecl);
890 assert((
cgm.getTarget().getCXXABI().hasConstructorVariants() ||
892 "can only generate complete ctor for this ABI");
897 cgm.getTarget().getCXXABI().hasConstructorVariants()) {
903 Stmt *body = ctor->getBody(definition);
904 assert(definition == ctor &&
"emitting wrong constructor body");
906 bool isTryBody = isa_and_nonnull<CXXTryStmt>(body);
915 Stmt *emitterBody =
nullptr;
918 : ctor(ctor), ctorType(ctorType), args(args),
920 ~ctorTryBodyEmitter()
override =
default;
930 return cgf.
emitStmt(emitterBody,
true);
934 ctorTryBodyEmitter emitter{ctor, ctorType, args, isTryBody, body};
935 mlir::LogicalResult bodyRes =
942 if (bodyRes.failed())
943 cgm.errorNYI(ctor->getSourceRange(),
944 "emitConstructorBody: emit body statement failed.");
999 const bool isTryBody = isa_and_nonnull<CXXTryStmt>(body);
1015 llvm_unreachable(
"not expecting a unified dtor");
1017 llvm_unreachable(
"not expecting a COMDAT");
1020 llvm_unreachable(
"already handled deleting case");
1023 assert((body ||
getTarget().getCXXABI().isMicrosoft()) &&
1024 "can't emit a dtor without a body for non-Microsoft ABIs");
1042 bool needsVTableInit =
1045 if (needsVTableInit &&
cgm.getCodeGenOpts().StrictVTablePointers &&
1046 cgm.getCodeGenOpts().OptimizationLevel > 0) {
1055 if (needsVTableInit)
1063 assert(dtor->
isImplicit() &&
"bodyless dtor not implicit");
1089 CharUnits align =
cgm.getNaturalTypeAlignment(ty, &baseInfo);
1096 CharUnits alignment =
cgm.getNaturalTypeAlignment(ty, &baseInfo);
1105 QualType retTy = fd->getReturnType();
1110 const auto *md = dyn_cast<CXXMethodDecl>(fd);
1111 if (md && md->isImplicitObjectMemberFunction()) {
1112 if (
cgm.getCXXABI().hasThisReturn(gd))
1113 retTy = md->getThisType();
1114 else if (
cgm.getCXXABI().hasMostDerivedReturn(gd))
1115 cgm.errorNYI(fd->getSourceRange(),
"most derived return");
1116 cgm.getCXXABI().buildThisParam(*
this, args);
1119 bool passedParams =
true;
1120 if (
const auto *cd = dyn_cast<CXXConstructorDecl>(fd))
1121 if (
auto inherited = cd->getInheritedConstructor())
1126 for (
auto *param : fd->parameters()) {
1127 args.push_back(param);
1128 if (!param->hasAttr<PassObjectSizeAttr>())
1132 getContext(), param->getDeclContext(), param->getLocation(),
1135 args.push_back(implicit);
1140 cgm.getCXXABI().addImplicitStructorParams(*
this, retTy, args);
1151 assert(e->
isTransparent() &&
"non-transparent glvalue init list");
1155static std::variant<LValue, RValue>
1160 llvm::scope_exit opaque_cleanup{
1161 [&]() { llvm::for_each(opaques, [&](OVMD &o) { o.unbind(cgf); }); }};
1165 std::variant<LValue, RValue> result;
1170 if (
const auto *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
1173 if (ov->isUnique()) {
1174 assert(ov != resultExpr &&
1175 "A unique OVE cannot be used as the result expression");
1182 if (ov == resultExpr && ov->
isPRValue() && !forLValue &&
1185 "emitPseudoObjectExpr for RValue & aggregate kind");
1187 opaqueData = OVMD::bind(cgf, ov, ov->getSourceExpr());
1190 if (ov == resultExpr) {
1194 "emitPseudoObjectExpr as result");
1199 "emitPseudoObjectExpr as an RValue");
1202 opaques.push_back(opaqueData);
1203 }
else if (semantic == resultExpr) {
1214 "emitPseudoObjectExpr as an ignored value");
1225 return std::get<RValue>(
1242 std::string(
"emitLValue: unsupported l-value class: ") +
1246 case Expr::ObjCPropertyRefExprClass:
1247 llvm_unreachable(
"cannot emit a property reference directly");
1249 case Expr::ObjCSelectorExprClass:
1251 "emitLValue: ObjCSelectorExpr");
1253 case Expr::ObjCIsaExprClass:
1256 case Expr::BinaryOperatorClass:
1258 case Expr::CompoundAssignOperatorClass: {
1261 ty = at->getValueType();
1267 case Expr::CallExprClass:
1268 case Expr::CXXMemberCallExprClass:
1269 case Expr::CXXOperatorCallExprClass:
1270 case Expr::UserDefinedLiteralClass:
1272 case Expr::CXXRewrittenBinaryOperatorClass:
1275 case Expr::VAArgExprClass:
1278 case Expr::DeclRefExprClass:
1280 case Expr::ConstantExprClass: {
1282 if (mlir::Attribute result =
1284 mlir::Value val = builder.getConstant(
1290 case Expr::ParenExprClass:
1292 case Expr::GenericSelectionExprClass:
1294 case Expr::PredefinedExprClass:
1296 case Expr::StringLiteralClass:
1298 case Expr::ObjCEncodeExprClass:
1300 "emitLValue: ObjCEncodeExpr");
1302 case Expr::PseudoObjectExprClass:
1304 case Expr::InitListExprClass:
1306 case Expr::CXXTemporaryObjectExprClass:
1307 case Expr::CXXConstructExprClass:
1309 case Expr::CXXBindTemporaryExprClass:
1311 case Expr::CXXUuidofExprClass:
1313 "emitLValue: CXXUuidofExpr");
1315 case Expr::LambdaExprClass:
1318 case Expr::ExprWithCleanupsClass: {
1335 case Expr::CXXDefaultArgExprClass: {
1340 case Expr::CXXDefaultInitExprClass: {
1345 case Expr::CXXTypeidExprClass:
1347 case Expr::ObjCMessageExprClass:
1349 "emitLValue: ObjCMessageExpr");
1351 case Expr::ObjCIvarRefExprClass:
1353 "emitLValue: ObjCIvarRefExpr");
1355 case Expr::StmtExprClass:
1358 case Expr::UnaryOperatorClass:
1360 case Expr::ArraySubscriptExprClass:
1362 case Expr::MatrixSingleSubscriptExprClass:
1364 "emitLValue: MatrixSingleSubscriptExpr");
1366 case Expr::MatrixSubscriptExprClass:
1368 case Expr::ArraySectionExprClass:
1370 "emitLValue: ArraySectionExpr");
1372 case Expr::ExtVectorElementExprClass:
1374 case Expr::MatrixElementExprClass:
1376 case Expr::CXXThisExprClass:
1378 case Expr::MemberExprClass:
1380 case Expr::CompoundLiteralExprClass:
1382 case Expr::ConditionalOperatorClass:
1384 case Expr::BinaryConditionalOperatorClass:
1386 case Expr::ChooseExprClass:
1388 case Expr::OpaqueValueExprClass:
1390 case Expr::SubstNonTypeTemplateParmExprClass:
1392 case Expr::ImplicitCastExprClass:
1393 case Expr::CStyleCastExprClass:
1394 case Expr::CXXFunctionalCastExprClass:
1395 case Expr::CXXStaticCastExprClass:
1396 case Expr::CXXDynamicCastExprClass:
1397 case Expr::CXXReinterpretCastExprClass:
1398 case Expr::CXXConstCastExprClass:
1400 case Expr::CXXAddrspaceCastExprClass:
1401 case Expr::ObjCBridgedCastExprClass:
1405 "emitLValue: addrspace or ObjC bridged cast");
1407 case Expr::MaterializeTemporaryExprClass:
1409 case Expr::CoawaitExprClass:
1411 case Expr::CoyieldExprClass:
1413 case Expr::PackIndexingExprClass:
1415 case Expr::HLSLOutArgExprClass:
1416 llvm_unreachable(
"cannot emit a HLSL out argument directly");
1422 llvm::raw_svector_ostream
out(buffer);
1424 return std::string(
out.str());
1447 mlir::IntegerAttr sizeVal;
1451 if (isa_and_nonnull<VariableArrayType>(
getContext().getAsArrayType(ty))) {
1453 "emitNullInitialization for zero size VariableArrayType");
1458 sizeVal =
cgm.getSize(size);
1465 if (!
cgm.getTypes().isZeroInitializable(ty)) {
1470 "emitNullInitialization: only pointer-to-data-member (directly or "
1471 "within a record) null initialization is implemented");
1472 mlir::Value nullVal =
cgm.emitNullConstant(ty, loc);
1473 builder.createStore(loc, nullVal, destPtr);
1481 mlir::Value zero = builder.getNullValue(builder.getUInt8Ty(), loc);
1482 mlir::Value sizeValue =
1483 builder.getConstAPInt(loc,
cgm.uInt64Ty, sizeVal.getValue());
1485 builder.createMemSet(loc, destPtr, zero, sizeValue);
1497 ConstructorHelper(fpFeatures);
1500void CIRGenFunction::CIRGenFPOptionsRAII::ConstructorHelper(
1502 oldFPFeatures = cgf.curFPFeatures;
1503 cgf.curFPFeatures = fpFeatures;
1505 oldExcept = cgf.builder.getDefaultConstrainedExcept();
1506 oldRounding = cgf.builder.getDefaultConstrainedRounding();
1508 if (oldFPFeatures == fpFeatures)
1511 oldFastMathFlags = cgf.builder.getFastMathFlags();
1517 cgf.builder.setDefaultConstrainedRounding(newRoundingMode);
1518 cgf.builder.setDefaultConstrainedExcept(newExceptionBehavior);
1520 cgf.setFastMathFlags(fpFeatures);
1522 assert((cgf.curFuncDecl ==
nullptr || cgf.builder.getIsFPConstrained() ||
1526 newRoundingMode == llvm::RoundingMode::NearestTiesToEven)) &&
1527 "FPConstrained should be enabled on entire function");
1534 cgf.curFPFeatures = oldFPFeatures;
1535 cgf.builder.setDefaultConstrainedExcept(oldExcept);
1536 cgf.builder.setDefaultConstrainedRounding(oldRounding);
1537 if (oldFastMathFlags)
1538 cgf.builder.setFastMathFlags(*oldFastMathFlags);
1542 cir::FastMathFlags flags = cir::FastMathFlags::none;
1544 flags |= cir::FastMathFlags::reassoc;
1546 flags |= cir::FastMathFlags::nnan;
1548 flags |= cir::FastMathFlags::ninf;
1550 flags |= cir::FastMathFlags::nsz;
1552 flags |= cir::FastMathFlags::arcp;
1554 flags |= cir::FastMathFlags::afn;
1556 flags |= cir::FastMathFlags::contract;
1561cir::FastMathFlagsAttr
1563 if (fastMathFlags == cir::FastMathFlags::none)
1565 return cir::FastMathFlagsAttr::get(&
getMLIRContext(), fastMathFlags);
1572 if (ce->
getCastKind() == CK_UncheckedDerivedToBase)
1582 if (ice->isGLValue())
1598 mlir::Value numVLAElements =
nullptr;
1610 baseType = elementType;
1611 return numVLAElements;
1627 auto cirArrayType = mlir::dyn_cast<cir::ArrayType>(addr.
getElementType());
1629 while (cirArrayType) {
1631 countFromCLAs *= cirArrayType.getSize();
1635 mlir::dyn_cast<cir::ArrayType>(cirArrayType.getElementType());
1639 "CIR and Clang types are out-of-sync");
1646 cgm.errorNYI(*
currSrcLoc,
"length for non-array underlying types");
1651 mlir::Value numElements =
1657 builder.createMul(numVLAElements.getLoc(), numVLAElements, numElements,
1658 cir::OverflowFlags::NoUnsignedWrap);
1667 mlir::Location assumeLoc =
getLoc(assumptionLoc);
1668 mlir::Value alignValue = builder.getUInt64(alignment, assumeLoc);
1669 mlir::Value cond = builder.getBool(
true, assumeLoc);
1672 bundleArgs.push_back(offsetValue);
1673 cir::AssumeOp::create(builder, assumeLoc, cond, cir::AssumeBundleKind::Align,
1680 int64_t alignment, mlir::Value offsetValue) {
1689 cgm.getASTContext().getAsVariableArrayType(
type);
1690 assert(vla &&
"type was not a variable array type!");
1697 mlir::Value numElements;
1701 elementType =
type->getElementType();
1703 assert(vlaSize &&
"no size for VLA!");
1704 assert(vlaSize.getType() ==
sizeTy);
1707 numElements = vlaSize;
1713 builder.createMul(numElements.getLoc(), numElements, vlaSize,
1714 cir::OverflowFlags::NoUnsignedWrap);
1716 }
while ((
type =
getContext().getAsVariableArrayType(elementType)));
1718 assert(numElements &&
"Undefined elements number");
1719 return {numElements, elementType};
1725 assert(vlaSize &&
"no size for VLA!");
1726 assert(vlaSize.getType() ==
sizeTy);
1733 assert(
type->isVariablyModifiedType() &&
1734 "Must pass variably modified type to EmitVLASizes!");
1739 assert(
type->isVariablyModifiedType());
1741 const Type *ty =
type.getTypePtr();
1743 case Type::CountAttributed:
1744 case Type::PackIndexing:
1745 case Type::ArrayParameter:
1746 case Type::HLSLAttributedResource:
1747 case Type::HLSLInlineSpirv:
1748 case Type::PredefinedSugar:
1749 case Type::LateParsedAttr:
1750 cgm.errorNYI(
"CIRGenFunction::emitVariablyModifiedType");
1753#define TYPE(Class, Base)
1754#define ABSTRACT_TYPE(Class, Base)
1755#define NON_CANONICAL_TYPE(Class, Base)
1756#define DEPENDENT_TYPE(Class, Base) case Type::Class:
1757#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
1758#include "clang/AST/TypeNodes.inc"
1760 "dependent type must be resolved before the CIR codegen");
1766 case Type::ExtVector:
1767 case Type::ConstantMatrix:
1771 case Type::TemplateSpecialization:
1772 case Type::ObjCTypeParam:
1773 case Type::ObjCObject:
1774 case Type::ObjCInterface:
1775 case Type::ObjCObjectPointer:
1777 case Type::OverflowBehavior:
1778 llvm_unreachable(
"type class is never variably-modified!");
1780 case Type::Adjusted:
1792 case Type::BlockPointer:
1796 case Type::LValueReference:
1797 case Type::RValueReference:
1801 case Type::MemberPointer:
1805 case Type::ConstantArray:
1806 case Type::IncompleteArray:
1811 case Type::VariableArray: {
1828 entry = builder.createBoolIntToIntCast(size,
sizeTy);
1835 case Type::FunctionProto:
1836 case Type::FunctionNoProto:
1842 case Type::UnaryTransform:
1843 case Type::Attributed:
1844 case Type::BTFTagAttributed:
1845 case Type::SubstTemplateTypeParm:
1846 case Type::MacroQualified:
1852 case Type::Decltype:
1854 case Type::DeducedTemplateSpecialization:
1858 case Type::TypeOfExpr:
1871 }
while (
type->isVariablyModifiedType());
1875 if (
getContext().getBuiltinVaListType()->isArrayType())
Defines the clang::Expr interface and subclasses for C++ expressions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Address withPointer(mlir::Value newPtr) const
Return address with different pointer, but same element type and alignment.
mlir::Value getPointer() const
mlir::Type getElementType() const
Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const
Return address with different element type, a bitcast pointer, and the same alignment.
mlir::Operation * getDefiningOp() const
Get the operation which defines this address.
static AggValueSlot ignored()
Returns an aggregate value slot indicating that the aggregate value is being ignored.
mlir::Value createFloatingCast(mlir::Value v, mlir::Type destType)
CIRGenFPOptionsRAII(CIRGenFunction &cgf, FPOptions FPFeatures)
The scope of a CXXDefaultInitExpr.
void exit(ArrayRef< mlir::Value * > valuesToReload={})
A non-RAII class containing all the information about a bound opaque value.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
void forceCleanup(ArrayRef< mlir::Value * > valuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
static bool isConstructorDelegationValid(const clang::CXXConstructorDecl *ctor)
Checks whether the given constructor is a valid subject for the complete-to-base constructor delegati...
void emitFunctionProlog(const FunctionArgList &args, mlir::Block *entryBB, const FunctionDecl *fd, SourceLocation bodyBeginLoc)
Emit the function prologue: initialize the return value of an implicit-return-zero function and decla...
mlir::Type convertType(clang::QualType t)
LValue emitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *e)
LValue emitOpaqueValueLValue(const OpaqueValueExpr *e)
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...
EHScopeStack::stable_iterator prologueCleanupDepth
The cleanup depth enclosing all the cleanups associated with the parameters.
cir::FuncOp generateCode(clang::GlobalDecl gd, cir::FuncOp fn, cir::FuncType funcType)
Address emitFieldAnnotations(const clang::FieldDecl *field, Address addr)
Annotate the address of field; accesses must use the result.
CIRGenTypes & getTypes() const
Address emitPointerWithAlignment(const clang::Expr *expr, LValueBaseInfo *baseInfo=nullptr)
Given an expression with a pointer type, emit the value and compute our best estimate of the alignmen...
void emitVariablyModifiedType(QualType ty)
RValue emitLoadOfLValue(LValue lv, SourceLocation loc)
Given an expression that represents a value lvalue, this method emits the address of the lvalue,...
const clang::LangOptions & getLangOpts() const
mlir::Value cxxStructorImplicitParamValue
void emitTrap(mlir::Location loc, bool createNewBlock)
Emit a trap instruction, which is used to abort the program in an abnormal way, usually for debugging...
VlaSizePair getVLASize(const VariableArrayType *type)
Returns an MLIR::Value+QualType pair that corresponds to the size, in non-variably-sized elements,...
mlir::Value loadCXXThis()
Load the value for 'this'.
LValue makeNaturalAlignPointeeAddrLValue(mlir::Value v, clang::QualType t)
Given a value of type T* that may not be to a complete object, construct an l-vlaue withi the natural...
void emitDeleteCall(const FunctionDecl *deleteFD, mlir::Value ptr, QualType deleteTy)
LValue emitMemberExpr(const MemberExpr *e)
const TargetInfo & getTarget() const
LValue emitConditionalOperatorLValue(const AbstractConditionalOperator *expr)
LValue emitLValue(const clang::Expr *e)
Emit code to compute a designator that specifies the location of the expression.
const clang::Decl * curFuncDecl
clang::FPOptions curFPFeatures
Address loadCXXThisAddress()
LValue emitLValueForLambdaField(const FieldDecl *field)
std::string getCounterRefTmpAsString()
LValue makeNaturalAlignAddrLValue(mlir::Value val, QualType ty)
llvm::DenseMap< const Expr *, mlir::Value > vlaSizeMap
bool constantFoldsToSimpleInteger(const clang::Expr *cond, llvm::APSInt &resultInt, bool allowLabels=false)
If the specified expression does not fold to a constant, or if it does fold but contains a label,...
LValue emitComplexCompoundAssignmentLValue(const CompoundAssignOperator *e)
bool checkIfFunctionMustProgress()
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
void initializeVTablePointers(mlir::Location loc, const clang::CXXRecordDecl *rd)
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,...
void emitVarAnnotations(const clang::VarDecl *d, mlir::Value addr)
Annotate the storage of d at addr.
void emitDelegateCXXConstructorCall(const clang::CXXConstructorDecl *ctor, clang::CXXCtorType ctorType, const FunctionArgList &args, clang::SourceLocation loc)
VlaSizePair getVLAElements1D(const VariableArrayType *vla)
Return the number of elements for a single dimension for the given array type.
mlir::Value emitArrayLength(const clang::ArrayType *arrayType, QualType &baseType, Address &addr)
Computes the length of an array in elements, as well as the base element type and a properly-typed fi...
void emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty)
LValue emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e)
llvm::ScopedHashTableScope< const clang::Decl *, mlir::Value > SymTableScopeTy
LValue emitCoawaitLValue(const CoawaitExpr *e)
mlir::Operation * curFn
The current function or global initializer that is generated code for.
EHScopeStack ehStack
Tracks function scope overall cleanup handling.
void enterDtorCleanups(const CXXDestructorDecl *dtor, CXXDtorType type)
Enter the cleanups necessary to complete the given phase of destruction for a destructor.
Address maybeCastStackAddressSpace(Address alloca, mlir::ptr::MemorySpaceAttrInterface destAddrSpace, mlir::Value arraySize=nullptr)
llvm::SmallVector< const ParmVarDecl * > fnArgs
Save Parameter Decl for coroutine.
llvm::SmallVector< PendingCleanupEntry > deferredConditionalCleanupStack
Cleanups for temporaries constructed inside a conditional.
std::optional< mlir::Value > fnRetAlloca
The compiler-generated variable that holds the return value.
void emitImplicitAssignmentOperatorBody(FunctionArgList &args)
cir::FastMathFlagsAttr getFastMathFlagsAttr(cir::FastMathFlags fastMathFlags)
Create a CIR fast-math attribute from the specified flags.
mlir::Type convertTypeForMem(QualType t)
clang::QualType buildFunctionArgList(clang::GlobalDecl gd, FunctionArgList &args)
void emitCtorPrologue(const clang::CXXConstructorDecl *ctor, clang::CXXCtorType ctorType, FunctionArgList &args)
This routine generates necessary code to initialize base classes and non-static data members belongin...
mlir::Value emitAlloca(llvm::StringRef name, mlir::Type ty, mlir::Location loc, clang::CharUnits alignment, bool insertIntoFnEntryBlock, mlir::Value arraySize=nullptr)
mlir::LogicalResult emitCXXTryStmt(const clang::CXXTryStmt &s, cxxTryBodyEmitter &bodyCallback, bool isFnTryBlock=false)
cir::FastMathFlags getCurrentFastMathFlags() const
Convert the active Clang floating-point options to CIR fast-math flags.
LValue emitAggExprToLValue(const Expr *e)
LValue emitCompoundAssignmentLValue(const clang::CompoundAssignOperator *e)
Address returnValue
The temporary alloca to hold the return value.
static bool hasAggregateEvaluationKind(clang::QualType type)
void finishFunction(SourceLocation endLoc)
mlir::LogicalResult emitFunctionBody(const clang::Stmt *body)
std::string getCounterAggTmpAsString()
LValue emitUnaryOpLValue(const clang::UnaryOperator *e)
LValue emitMatrixSubscriptExpr(const MatrixSubscriptExpr *e)
clang::FieldDecl * lambdaThisCaptureField
const clang::Decl * curCodeDecl
This is the inner-most code context, which includes blocks.
void emitConstructorBody(FunctionArgList &args)
LValue emitCallExprLValue(const clang::CallExpr *e)
LValue emitStringLiteralLValue(const StringLiteral *e, llvm::StringRef name=".str")
LValue emitCoyieldLValue(const CoyieldExpr *e)
llvm::SmallDenseMap< const ParmVarDecl *, const ImplicitParamDecl * > sizeArguments
If a ParmVarDecl had the pass_object_size attribute, this will contain a mapping from said ParmVarDec...
mlir::Value loadThisForDtorDelete(const CXXDestructorDecl *dd)
Return the pointer to pass to the operator delete of the given destructor, converted to the type of i...
mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)
Emit the computation of the specified expression of scalar type.
LValue emitPseudoObjectLValue(const PseudoObjectExpr *E)
void popCleanupBlocks(EHScopeStack::stable_iterator oldCleanupStackDepth, ArrayRef< mlir::Value * > valuesToReload={})
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
bool shouldNullCheckClassCastValue(const CastExpr *ce)
CIRGenBuilderTy & getBuilder()
bool didCallStackSave
Whether a cir.stacksave operation has been added.
LValue emitBinaryOperatorLValue(const BinaryOperator *e)
void startFunction(clang::GlobalDecl gd, clang::QualType returnType, cir::FuncOp fn, cir::FuncType funcType, FunctionArgList args, clang::SourceLocation loc, clang::SourceLocation startLoc)
Emit code for the start of a function.
CIRGenModule & getCIRGenModule()
unsigned counterRefTmp
Hold counters for incrementally naming temporaries.
mlir::MLIRContext & getMLIRContext()
void emitDestructorBody(FunctionArgList &args)
Emits the body of the current destructor.
LValue emitInitListLValue(const InitListExpr *e)
std::optional< SourceRange > currSrcLoc
Use to track source locations across nested visitor traversals.
LValue emitCastLValue(const CastExpr *e)
Casts are never lvalues unless that cast is to a reference type.
LValue emitCXXTypeidLValue(const CXXTypeidExpr *e)
bool containsLabel(const clang::Stmt *s, bool ignoreCaseStmts=false)
Return true if the statement contains a label in it.
RValue emitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
LValue emitDeclRefLValue(const clang::DeclRefExpr *e)
static void eraseEmptyAndUnusedBlocks(cir::FuncOp func)
Remove leftover empty and unreachable blocks from an emitted function.
llvm::DenseMap< const clang::ValueDecl *, clang::FieldDecl * > lambdaCaptureFields
mlir::Value emitAlignmentAssumption(mlir::Value ptrValue, QualType ty, SourceLocation loc, SourceLocation assumptionLoc, int64_t alignment, mlir::Value offsetValue=nullptr)
void setFastMathFlags(FPOptions fpFeatures)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
LValue emitMatrixElementExpr(const MatrixElementExpr *e)
LValue emitPredefinedLValue(const PredefinedExpr *e)
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.
void emitCXXDestructorCall(const CXXDestructorDecl *dd, CXXDtorType type, bool forVirtualBase, bool delegating, Address thisAddr, QualType thisTy)
void emitLambdaStaticInvokeBody(const CXXMethodDecl *md)
void emitEndEHSpec(const clang::Decl *d)
Close the cir.try opened by emitStartEHSpec.
CIRGenFunction(CIRGenModule &cgm, CIRGenBuilderTy &builder, bool suppressNewContext=false)
LValue emitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *e)
LValue emitExtVectorElementExpr(const ExtVectorElementExpr *e)
clang::ASTContext & getContext() const
void setAddrOfLocalVar(const clang::VarDecl *vd, Address addr)
Set the address of a local variable.
void emitStartEHSpec(const clang::Decl *d)
Wrap the function body in a cir.try that enforces the exception specification of d: a filter handler ...
mlir::Value cxxabiThisValue
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
Address emitVAListRef(const Expr *e)
Build a "reference" to a va_list; this is either the address or the value of the expression,...
mlir::LogicalResult emitCompoundStmtWithoutScope(const clang::CompoundStmt &s, Address *lastValue=nullptr, AggValueSlot slot=AggValueSlot::ignored())
void emitIgnoredExpr(const clang::Expr *e)
Emit code to compute the specified expression, ignoring the result.
Address createMemTemp(QualType t, mlir::Location loc, const Twine &name="tmp", Address *alloca=nullptr, mlir::OpBuilder::InsertPoint ip={})
Create a temporary memory object of the given type, with appropriate alignmen and cast it to the defa...
LValue emitCXXConstructLValue(const CXXConstructExpr *e)
LValue emitCompoundLiteralLValue(const CompoundLiteralExpr *e)
This class organizes the cross-function state that is used while generating CIR code.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
bool inheritingCtorHasParams(const InheritedConstructor &inherited, CXXCtorType type)
Determine if a C++ inheriting constructor should have parameters matching those of its inherited cons...
mlir::Attribute tryEmitConstantExpr(const ConstantExpr *ce)
Type for representing both the decl and type of parameters to a function.
Address getAddress() const
static LValue makeAddr(Address address, clang::QualType t, LValueBaseInfo baseInfo)
clang::QualType getType() const
mlir::Value getPointer() const
LValueBaseInfo getBaseInfo() const
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.
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
const FunctionDecl * getOperatorDelete() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getFunctionObjectParameterType() const
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
This is an opaque type for sizes expressed in character units.
bool isZero() const
Test whether the quantity equals zero.
CompoundStmt - This represents a group of statements like { stmt stmt }.
An expression that occurs in a constant context and the result of evaluating the expression.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks,...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
SourceLocation getBeginLoc() const LLVM_READONLY
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Returns the set of floating point options that apply to this expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
LangOptions::FPExceptionModeKind getExceptionMode() const
bool allowFPContractAcrossStatement() const
RoundingMode getRoundingMode() const
Represents a member of a struct/union/class.
const Expr * getSubExpr() const
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
QualType getReturnType() const
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
const Decl * getDecl() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Describes an C or C++ initializer list.
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
const Expr * getInit(unsigned Init) const
FPExceptionModeKind
Possible floating point exception behavior.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
FPExceptionModeKind getDefaultExceptionMode() const
RoundingMode getDefaultRoundingMode() const
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
ArrayRef< Expr * > semantics()
A (possibly-)qualified type.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
LangAS getAddressSpace() const
Return the address space of this type.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
child_iterator child_begin()
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
child_iterator child_end()
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isMemberDataPointerType() const
bool isAnyComplexType() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Represents a variable declaration or definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Represents a C array with a specified size that is not an integer-constant-expression.
Expr * getSizeExpr() const
mlir::ptr::MemorySpaceAttrInterface toCIRAddressSpaceAttr(mlir::MLIRContext &ctx, clang::LangAS langAS)
Convert an AST LangAS to the appropriate CIR address space attribute interface.
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
static bool previousOpIsNonYieldingCleanup(mlir::Block *block)
static std::string getVersionedTmpName(llvm::StringRef name, unsigned cnt)
static bool mayDropFunctionReturn(const ASTContext &astContext, QualType returnType)
static mlir::Value emitArgumentDemotion(CIRGenFunction &cgf, const VarDecl *var, mlir::Value value)
An argument came in as a promoted argument; demote it back to its declared type.
static bool functionMightHaveBypass(const Stmt *s)
Does the statement tree rooted at s contain a label, switch, or indirect goto that could bypass a loc...
static std::variant< LValue, RValue > emitPseudoObjectExpr(CIRGenFunction &cgf, const PseudoObjectExpr *e, bool forLValue, AggValueSlot slot)
bool canSkipVTablePointerInitialization(ASTContext &Ctx, const CXXDestructorDecl *Dtor)
Check whether we need to initialize any vtable pointers before calling this destructor.
bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts, const LangOptions &LangOpts)
Decide whether we need to emit the lifetime markers.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_Complete
Complete object ctor.
bool isa(CodeGen::Address addr)
CXXDtorType
C++ destructor types.
@ Dtor_VectorDeleting
Vector deleting dtor.
@ Dtor_Comdat
The COMDAT used for dtors.
@ Dtor_Unified
GCC-style unified dtor.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
U cast(CodeGen::Address addr)
@ Other
Other implicit parameter.
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t int64_t
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 uint64_t
static bool fastMathFuncAttributes()
static bool constructABIArgDirectExtend()
static bool runCleanupsScope()
static bool emitTypeCheck()
static bool addressIsKnownNonNull()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
llvm::ArrayRef< mlir::Block * > getRetBlocks()
LexicalScope(CIRGenFunction &cgf, mlir::Location loc, mlir::Block *eb)
cir::TryOp getClosestTryParent()
mlir::Location getRetLoc(mlir::Block *b)
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.