18#include "mlir/IR/Location.h"
28 bool suppressNewContext)
39 switch (
type->getTypeClass()) {
40#define TYPE(name, parent)
41#define ABSTRACT_TYPE(name, parent)
42#define NON_CANONICAL_TYPE(name, parent) case Type::name:
43#define DEPENDENT_TYPE(name, parent) case Type::name:
44#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(name, parent) case Type::name:
45#include "clang/AST/TypeNodes.inc"
46 llvm_unreachable(
"non-canonical or dependent type in IR-generation");
49 case Type::DeducedTemplateSpecialization:
50 llvm_unreachable(
"undeduced type in IR-generation");
55 case Type::BlockPointer:
56 case Type::LValueReference:
57 case Type::RValueReference:
58 case Type::MemberPointer:
61 case Type::ConstantMatrix:
62 case Type::FunctionProto:
63 case Type::FunctionNoProto:
65 case Type::ObjCObjectPointer:
68 case Type::HLSLAttributedResource:
69 case Type::HLSLInlineSpirv:
77 case Type::ConstantArray:
78 case Type::IncompleteArray:
79 case Type::VariableArray:
81 case Type::ObjCObject:
82 case Type::ObjCInterface:
83 case Type::ArrayParameter:
88 type = cast<AtomicType>(
type)->getValueType();
91 llvm_unreachable(
"unknown type kind!");
110 return mlir::FileLineColLoc::get(builder.getStringAttr(filename),
114 assert(
currSrcLoc &&
"expected to inherit some source location");
125 mlir::Attribute metadata;
132 return builder.getUnknownLoc();
137 mlir::Attribute metadata;
151 if (isa<LabelStmt>(
s))
156 if (isa<SwitchCase>(
s) && !ignoreCaseStmts)
163 if (isa<SwitchStmt>(
s))
164 ignoreCaseStmts =
true;
167 return std::any_of(
s->child_begin(),
s->child_end(),
168 [=](
const Stmt *subStmt) {
169 return containsLabel(subStmt, ignoreCaseStmts);
178 llvm::APSInt resultInt;
182 resultBool = resultInt.getBoolValue();
190 llvm::APSInt &resultInt,
198 llvm::APSInt intValue = result.
Val.
getInt();
202 resultInt = intValue;
206void CIRGenFunction::emitAndUpdateRetAlloca(
QualType type, mlir::Location loc,
208 if (!
type->isVoidType()) {
214void CIRGenFunction::declare(mlir::Value addrVal,
const Decl *var, QualType ty,
215 mlir::Location loc, CharUnits alignment,
217 assert(isa<NamedDecl>(var) &&
"Needs a named decl");
218 assert(!
symbolTable.count(var) &&
"not supposed to be available just yet");
220 auto allocaOp = addrVal.getDefiningOp<cir::AllocaOp>();
221 assert(allocaOp &&
"expected cir::AllocaOp");
225 if (ty->isReferenceType() || ty.isConstQualified())
235 auto applyCleanup = [&]() {
243 if (returnBlock !=
nullptr) {
246 mlir::OpBuilder::InsertionGuard guard(builder);
247 builder.setInsertionPointToEnd(returnBlock);
248 (void)emitReturn(*returnLoc);
251 auto insertCleanupAndLeave = [&](mlir::Block *insPt) {
252 mlir::OpBuilder::InsertionGuard guard(builder);
253 builder.setInsertionPointToEnd(insPt);
265 builder.create<cir::BrOp>(insPt->back().getLoc(), cleanupBlock);
266 if (!cleanupBlock->mightHaveTerminator()) {
267 mlir::OpBuilder::InsertionGuard guard(builder);
268 builder.setInsertionPointToEnd(cleanupBlock);
269 builder.create<cir::YieldOp>(localScope->endLoc);
273 if (localScope->
depth == 0) {
275 if (returnBlock !=
nullptr) {
276 if (returnBlock->getUses().empty()) {
277 returnBlock->erase();
281 for (mlir::BlockOperand &blockUse : returnBlock->getUses()) {
282 cir::BrOp brOp = mlir::cast<cir::BrOp>(blockUse.getOwner());
283 brOp.setSuccessor(cleanupBlock);
287 builder.create<cir::BrOp>(*returnLoc, returnBlock);
291 emitImplicitReturn();
298 if (!localScope->
isTernary() && !insPt->mightHaveTerminator()) {
299 !retVal ? builder.create<cir::YieldOp>(localScope->endLoc)
300 : builder.create<cir::YieldOp>(localScope->endLoc, retVal);
310 insertCleanupAndLeave(cleanupBlock);
315 mlir::Block *curBlock = builder.getBlock();
318 if (curBlock->mightHaveTerminator() && curBlock->getTerminator())
322 bool entryBlock = builder.getInsertionBlock()->isEntryBlock();
323 if (!entryBlock && curBlock->empty()) {
325 if (returnBlock !=
nullptr && returnBlock->getUses().empty())
326 returnBlock->erase();
332 builder.create<cir::BrOp>(curBlock->back().getLoc(), cleanupBlock);
337 insertCleanupAndLeave(curBlock);
340cir::ReturnOp CIRGenFunction::LexicalScope::emitReturn(mlir::Location loc) {
343 if (!cgf.curFn.getFunctionType().hasVoidReturn()) {
345 auto value = builder.create<cir::LoadOp>(
346 loc, cgf.curFn.getFunctionType().getReturnType(), *cgf.fnRetAlloca);
347 return builder.create<cir::ReturnOp>(loc,
350 return builder.create<cir::ReturnOp>(loc);
360 return classDecl->hasTrivialDestructor();
364void CIRGenFunction::LexicalScope::emitImplicitReturn() {
365 CIRGenBuilderTy &builder = cgf.getBuilder();
366 LexicalScope *localScope = cgf.curLexScope;
368 const auto *fd = cast<clang::FunctionDecl>(cgf.curGD.getDecl());
375 if (cgf.getLangOpts().CPlusPlus && !fd->hasImplicitReturnZero() &&
376 !cgf.sawAsmBlock && !fd->getReturnType()->isVoidType() &&
377 builder.getInsertionBlock()) {
378 bool shouldEmitUnreachable =
379 cgf.cgm.getCodeGenOpts().StrictReturn ||
382 if (shouldEmitUnreachable) {
384 if (cgf.cgm.getCodeGenOpts().OptimizationLevel == 0)
385 builder.create<cir::TrapOp>(localScope->endLoc);
387 builder.create<cir::UnreachableOp>(localScope->endLoc);
388 builder.clearInsertionPoint();
393 (void)emitReturn(localScope->endLoc);
397 cir::FuncOp fn, cir::FuncType funcType,
401 "CIRGenFunction can only be used for one function at a time");
406 const auto *fd = dyn_cast_or_null<FunctionDecl>(d);
411 mlir::Block *entryBB = &fn.getBlocks().front();
412 builder.setInsertionPointToStart(entryBB);
416 for (
const auto nameValue : llvm::zip(args, entryBB->getArguments())) {
417 const VarDecl *paramVar = std::get<0>(nameValue);
418 mlir::Value paramVal = std::get<1>(nameValue);
421 paramVal.setLoc(paramLoc);
423 mlir::Value addrVal =
424 emitAlloca(cast<NamedDecl>(paramVar)->getName(),
428 declare(addrVal, paramVar, paramVar->
getType(), paramLoc, alignment,
433 bool isPromoted = isa<ParmVarDecl>(paramVar) &&
434 cast<ParmVarDecl>(paramVar)->isKNRPromoted();
437 cgm.
errorNYI(fd->getSourceRange(),
"Function argument demotion");
441 mlir::Location fnBodyBegin =
getLoc(fd->getBody()->getBeginLoc());
442 builder.CIRBaseBuilderTy::createStore(fnBodyBegin, paramVal, addrVal);
444 assert(builder.getInsertionBlock() &&
"Should be valid");
449 emitAndUpdateRetAlloca(returnType,
getLoc(fd->getBody()->getEndLoc()),
450 getContext().getTypeAlignInChars(returnType));
452 if (isa_and_nonnull<CXXMethodDecl>(d) &&
453 cast<CXXMethodDecl>(d)->isInstance()) {
456 const auto *md = cast<CXXMethodDecl>(d);
457 if (md->getParent()->isLambda() && md->getOverloadedOperator() == OO_Call) {
489 if (
const CompoundStmt *block = dyn_cast<CompoundStmt>(body))
500 for (mlir::Block &block : func.getBlocks()) {
501 if (block.empty() && block.getUses().empty())
502 blocksToDelete.push_back(&block);
504 for (mlir::Block *block : blocksToDelete)
509 cir::FuncType funcType) {
510 const auto funcDecl = cast<FunctionDecl>(gd.
getDecl());
514 Stmt *body = funcDecl->getBody();
519 : builder.getUnknownLoc()};
522 return clangLoc.isValid() ?
getLoc(clangLoc) : builder.getUnknownLoc();
524 const mlir::Location fusedLoc = mlir::FusedLoc::get(
526 {validMLIRLoc(bodyRange.
getBegin()), validMLIRLoc(bodyRange.
getEnd())});
527 mlir::Block *entryBB = fn.addEntryBlock();
539 if (isa<CXXDestructorDecl>(funcDecl)) {
541 }
else if (isa<CXXConstructorDecl>(funcDecl)) {
544 funcDecl->hasAttr<CUDAGlobalAttr>()) {
546 }
else if (isa<CXXMethodDecl>(funcDecl) &&
547 cast<CXXMethodDecl>(funcDecl)->isLambdaStaticInvoker()) {
549 }
else if (funcDecl->isDefaulted() && isa<CXXMethodDecl>(funcDecl) &&
550 (cast<CXXMethodDecl>(funcDecl)->isCopyAssignmentOperator() ||
551 cast<CXXMethodDecl>(funcDecl)->isMoveAssignmentOperator())) {
561 llvm_unreachable(
"no definition for normal function");
564 if (mlir::failed(fn.verifyBody()))
576 const auto *ctor = cast<CXXConstructorDecl>(
curGD.
getDecl());
581 "can only generate complete ctor for this ABI");
590 Stmt *body = ctor->getBody(definition);
591 assert(definition == ctor &&
"emitting wrong constructor body");
593 if (isa_and_nonnull<CXXTryStmt>(body)) {
594 cgm.
errorNYI(ctor->getSourceRange(),
"emitConstructorBody: try body");
609 if (mlir::failed(
emitStmt(body,
true))) {
611 "emitConstructorBody: emit body statement failed.");
645 const bool isTryBody = isa_and_nonnull<CXXTryStmt>(body);
659 llvm_unreachable(
"not expecting a COMDAT");
661 llvm_unreachable(
"already handled deleting case");
664 assert((body ||
getTarget().getCXXABI().isMicrosoft()) &&
665 "can't emit a dtor without a body for non-Microsoft ABIs");
690 assert(dtor->
isImplicit() &&
"bodyless dtor not implicit");
730 const auto *fd = cast<FunctionDecl>(gd.
getDecl());
731 QualType retTy = fd->getReturnType();
733 const auto *md = dyn_cast<CXXMethodDecl>(fd);
734 if (md && md->isInstance()) {
738 cgm.
errorNYI(fd->getSourceRange(),
"most derived return");
742 if (
const auto *cd = dyn_cast<CXXConstructorDecl>(fd))
743 if (cd->getInheritedConstructor())
745 "buildFunctionArgList: inherited constructor");
747 for (
auto *param : fd->parameters())
748 args.push_back(param);
750 if (md && (isa<CXXConstructorDecl>(md) || isa<CXXDestructorDecl>(md)))
764 std::string(
"l-value not implemented for '") +
767 case Expr::ArraySubscriptExprClass:
769 case Expr::UnaryOperatorClass:
771 case Expr::StringLiteralClass:
773 case Expr::MemberExprClass:
775 case Expr::CompoundLiteralExprClass:
777 case Expr::BinaryOperatorClass:
779 case Expr::CompoundAssignOperatorClass: {
783 "CompoundAssignOperator with AtomicType");
791 case Expr::CallExprClass:
792 case Expr::CXXMemberCallExprClass:
793 case Expr::CXXOperatorCallExprClass:
794 case Expr::UserDefinedLiteralClass:
796 case Expr::ParenExprClass:
797 return emitLValue(cast<ParenExpr>(e)->getSubExpr());
798 case Expr::DeclRefExprClass:
800 case Expr::CStyleCastExprClass:
801 case Expr::CXXStaticCastExprClass:
802 case Expr::CXXDynamicCastExprClass:
803 case Expr::ImplicitCastExprClass:
805 case Expr::MaterializeTemporaryExprClass:
812 llvm::raw_svector_ostream
out(buffer);
814 return std::string(
out.str());
834 cgm.
errorNYI(loc,
"Cast the dest ptr to the appropriate i8 pointer type");
841 if (isa<VariableArrayType>(
getContext().getAsArrayType(ty))) {
843 "emitNullInitialization for zero size VariableArrayType");
854 cgm.
errorNYI(loc,
"type is not zero initializable");
861 const mlir::Value zeroValue = builder.getNullValue(
convertType(ty), loc);
862 builder.createStore(loc, zeroValue, destPtr);
869 if (ce->
getCastKind() == CK_UncheckedDerivedToBase)
879 if (ice->isGLValue())
901 uint64_t countFromCLAs = 1;
904 auto cirArrayType = mlir::dyn_cast<cir::ArrayType>(addr.
getElementType());
906 while (cirArrayType) {
907 assert(isa<ConstantArrayType>(
arrayType));
908 countFromCLAs *= cirArrayType.getSize();
912 mlir::dyn_cast<cir::ArrayType>(cirArrayType.getElementType());
916 "CIR and Clang types are out-of-sync");
932 SourceLocation assumptionLoc, int64_t alignment, mlir::Value offsetValue) {
934 return cir::AssumeAlignedOp::create(builder,
getLoc(assumptionLoc), ptrValue,
935 alignment, offsetValue);
940 int64_t alignment, mlir::Value offsetValue) {
950 assert(
type->isVariablyModifiedType() &&
951 "Must pass variably modified type to EmitVLASizes!");
956 assert(
type->isVariablyModifiedType());
960 case Type::CountAttributed:
961 case Type::PackIndexing:
962 case Type::ArrayParameter:
963 case Type::HLSLAttributedResource:
964 case Type::HLSLInlineSpirv:
965 case Type::PredefinedSugar:
966 cgm.
errorNYI(
"CIRGenFunction::emitVariablyModifiedType");
969#define TYPE(Class, Base)
970#define ABSTRACT_TYPE(Class, Base)
971#define NON_CANONICAL_TYPE(Class, Base)
972#define DEPENDENT_TYPE(Class, Base) case Type::Class:
973#define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
974#include "clang/AST/TypeNodes.inc"
976 "dependent type must be resolved before the CIR codegen");
982 case Type::ExtVector:
983 case Type::ConstantMatrix:
987 case Type::TemplateSpecialization:
988 case Type::ObjCTypeParam:
989 case Type::ObjCObject:
990 case Type::ObjCInterface:
991 case Type::ObjCObjectPointer:
993 llvm_unreachable(
"type class is never variably-modified!");
996 type = cast<clang::AdjustedType>(ty)->getAdjustedType();
1000 type = cast<clang::DecayedType>(ty)->getPointeeType();
1004 type = cast<clang::PointerType>(ty)->getPointeeType();
1007 case Type::BlockPointer:
1008 type = cast<clang::BlockPointerType>(ty)->getPointeeType();
1011 case Type::LValueReference:
1012 case Type::RValueReference:
1013 type = cast<clang::ReferenceType>(ty)->getPointeeType();
1016 case Type::MemberPointer:
1017 type = cast<clang::MemberPointerType>(ty)->getPointeeType();
1020 case Type::ConstantArray:
1021 case Type::IncompleteArray:
1023 type = cast<clang::ArrayType>(ty)->getElementType();
1026 case Type::VariableArray: {
1027 cgm.
errorNYI(
"CIRGenFunction::emitVariablyModifiedType VLA");
1031 case Type::FunctionProto:
1032 case Type::FunctionNoProto:
1033 type = cast<clang::FunctionType>(ty)->getReturnType();
1038 case Type::UnaryTransform:
1039 case Type::Attributed:
1040 case Type::BTFTagAttributed:
1041 case Type::SubstTemplateTypeParm:
1042 case Type::MacroQualified:
1048 case Type::Decltype:
1050 case Type::DeducedTemplateSpecialization:
1054 case Type::TypeOfExpr:
1056 emitIgnoredExpr(cast<clang::TypeOfExprType>(ty)->getUnderlyingExpr());
1060 type = cast<clang::AtomicType>(ty)->getValueType();
1064 type = cast<clang::PipeType>(ty)->getElementType();
1067 }
while (
type->isVariablyModifiedType());
1071 if (
getContext().getBuiltinVaListType()->isArrayType())
Defines the clang::Expr interface and subclasses for C++ expressions.
__device__ __2f16 float __ockl_bool s
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.
mlir::Type getElementType() const
virtual void emitInstanceFunctionProlog(SourceLocation loc, CIRGenFunction &cgf)=0
Emit the ABI-specific prolog for the function.
virtual bool hasThisReturn(clang::GlobalDecl gd) const
Returns true if the given constructor or destructor is one of the kinds that the ABI says returns 'th...
virtual bool hasMostDerivedReturn(clang::GlobalDecl gd) const
void buildThisParam(CIRGenFunction &cgf, FunctionArgList ¶ms)
Build a parameter variable suitable for 'this'.
void forceCleanup()
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...
mlir::Type convertType(clang::QualType t)
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 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)
const clang::LangOptions & getLangOpts() const
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...
LValue emitMemberExpr(const MemberExpr *e)
const TargetInfo & getTarget() const
LValue emitLValue(const clang::Expr *e)
Emit code to compute a designator that specifies the location of the expression.
const clang::Decl * curFuncDecl
Address loadCXXThisAddress()
std::string getCounterRefTmpAsString()
LValue makeNaturalAlignAddrLValue(mlir::Value val, QualType ty)
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)
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,...
LValue emitStringLiteralLValue(const StringLiteral *e)
void emitDelegateCXXConstructorCall(const clang::CXXConstructorDecl *ctor, clang::CXXCtorType ctorType, const FunctionArgList &args, clang::SourceLocation loc)
llvm::ScopedHashTableScope< const clang::Decl *, mlir::Value > SymTableScopeTy
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)
EHScopeStack ehStack
Tracks function scope overall cleanup handling.
std::optional< mlir::Value > fnRetAlloca
The compiler-generated variable that holds the return value.
void emitImplicitAssignmentOperatorBody(FunctionArgList &args)
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)
LValue emitCompoundAssignmentLValue(const clang::CompoundAssignOperator *e)
void finishFunction(SourceLocation endLoc)
mlir::LogicalResult emitFunctionBody(const clang::Stmt *body)
std::string getCounterAggTmpAsString()
LValue emitUnaryOpLValue(const clang::UnaryOperator *e)
void emitConstructorBody(FunctionArgList &args)
LValue emitCallExprLValue(const clang::CallExpr *e)
cir::FuncOp curFn
The function for which code is currently being generated.
bool shouldNullCheckClassCastValue(const CastExpr *ce)
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 emitCastLValue(const CastExpr *e)
Casts are never lvalues unless that cast is to a reference type.
bool containsLabel(const clang::Stmt *s, bool ignoreCaseStmts=false)
Return true if the statement contains a label in it.
LValue emitDeclRefLValue(const clang::DeclRefExpr *e)
mlir::Value emitAlignmentAssumption(mlir::Value ptrValue, QualType ty, SourceLocation loc, SourceLocation assumptionLoc, int64_t alignment, mlir::Value offsetValue=nullptr)
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
void emitCXXDestructorCall(const CXXDestructorDecl *dd, CXXDtorType type, bool forVirtualBase, bool delegating, Address thisAddr, QualType thisTy)
LexicalScope * curLexScope
CIRGenFunction(CIRGenModule &cgm, CIRGenBuilderTy &builder, bool suppressNewContext=false)
std::optional< mlir::Location > currSrcLoc
Use to track source locations across nested visitor traversals.
LValue emitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *e)
clang::ASTContext & getContext() const
void setAddrOfLocalVar(const clang::VarDecl *vd, Address addr)
Set the address of a local variable.
mlir::Value cxxabiThisValue
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
void popCleanupBlocks(EHScopeStack::stable_iterator oldCleanupStackDepth)
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
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.
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.
clang::CharUnits getNaturalTypeAlignment(clang::QualType t, LValueBaseInfo *baseInfo)
FIXME: this could likely be a common helper and not necessarily related with codegen.
const clang::TargetInfo & getTarget() const
CIRGenCXXABI & getCXXABI() const
bool isZeroInitializable(clang::QualType ty)
Return whether a type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.
mlir::Type convertType(clang::QualType type)
Convert a Clang type into a mlir::Type.
mlir::Type convertTypeForMem(clang::QualType, bool forBitField=false)
Convert type T into an mlir::Type.
void setCGF(CIRGenFunction *inCGF)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
Type for representing both the decl and type of parameters to a function.
Address getAddress() const
Represents a C++ destructor within a class.
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
CharUnits - This is an opaque type for sizes expressed in character units.
bool isZero() const
isZero - Test whether the quantity equals zero.
CompoundStmt - This represents a group of statements like { stmt stmt }.
Decl - This represents one declaration (or definition), e.g.
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,...
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,...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
CXXDtorType getDtorType() const
const Decl * getDecl() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
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.
A (possibly-)qualified type.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
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.
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const char * getStmtClassName() const
bool hasConstructorVariants() const
Does this ABI have different entrypoints for complete-object and base-subobject constructors?
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isAnyComplexType() const
TypeClass getTypeClass() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents a variable declaration or definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
static std::string getVersionedTmpName(llvm::StringRef name, unsigned cnt)
static bool mayDropFunctionReturn(const ASTContext &astContext, QualType returnType)
static void eraseEmptyAndUnusedBlocks(cir::FuncOp func)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_Complete
Complete object ctor.
CXXDtorType
C++ destructor types.
@ Dtor_Comdat
The COMDAT used for dtors.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
static bool vtableInitialization()
static bool constructABIArgDirectExtend()
static bool cxxabiStructorImplicitParam()
static bool dtorCleanups()
static bool runCleanupsScope()
static bool emitTypeCheck()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
mlir::Block * getCleanupBlock(mlir::OpBuilder &builder)
This structure provides a set of types that are commonly used during IR emission.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.