diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenFunction.h')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenFunction.h | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenFunction.h b/clang/lib/CIR/CodeGen/CIRGenFunction.h index c0ed8b4..dfd9d2c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenFunction.h +++ b/clang/lib/CIR/CodeGen/CIRGenFunction.h @@ -47,6 +47,8 @@ class LoopOp; namespace clang::CIRGen { +struct CGCoroData; + class CIRGenFunction : public CIRGenTypeCache { public: CIRGenModule &cgm; @@ -66,6 +68,18 @@ public: /// The compiler-generated variable that holds the return value. std::optional<mlir::Value> fnRetAlloca; + // Holds coroutine data if the current function is a coroutine. We use a + // wrapper to manage its lifetime, so that we don't have to define CGCoroData + // in this header. + struct CGCoroInfo { + std::unique_ptr<CGCoroData> data; + CGCoroInfo(); + ~CGCoroInfo(); + }; + CGCoroInfo curCoro; + + bool isCoroutine() const { return curCoro.data != nullptr; } + /// The temporary alloca to hold the return value. This is /// invalid iff the function has no return value. Address returnValue = Address::invalid(); @@ -479,55 +493,55 @@ public: ConstantEmission tryEmitAsConstant(const MemberExpr *me); struct AutoVarEmission { - const clang::VarDecl *Variable; + const clang::VarDecl *variable; /// The address of the alloca for languages with explicit address space /// (e.g. OpenCL) or alloca casted to generic pointer for address space /// agnostic languages (e.g. C++). Invalid if the variable was emitted /// as a global constant. - Address Addr; + Address addr; /// True if the variable is of aggregate type and has a constant /// initializer. - bool IsConstantAggregate = false; + bool isConstantAggregate = false; /// True if the variable is a __block variable that is captured by an /// escaping block. - bool IsEscapingByRef = false; + bool isEscapingByRef = false; /// True if the variable was emitted as an offload recipe, and thus doesn't /// have the same sort of alloca initialization. - bool EmittedAsOffload = false; + bool emittedAsOffload = false; - mlir::Value NRVOFlag{}; + mlir::Value nrvoFlag{}; struct Invalid {}; - AutoVarEmission(Invalid) : Variable(nullptr), Addr(Address::invalid()) {} + AutoVarEmission(Invalid) : variable(nullptr), addr(Address::invalid()) {} AutoVarEmission(const clang::VarDecl &variable) - : Variable(&variable), Addr(Address::invalid()) {} + : variable(&variable), addr(Address::invalid()) {} static AutoVarEmission invalid() { return AutoVarEmission(Invalid()); } - bool wasEmittedAsGlobal() const { return !Addr.isValid(); } + bool wasEmittedAsGlobal() const { return !addr.isValid(); } - bool wasEmittedAsOffloadClause() const { return EmittedAsOffload; } + bool wasEmittedAsOffloadClause() const { return emittedAsOffload; } /// Returns the raw, allocated address, which is not necessarily /// the address of the object itself. It is casted to default /// address space for address space agnostic languages. - Address getAllocatedAddress() const { return Addr; } + Address getAllocatedAddress() const { return addr; } // Changes the stored address for the emission. This function should only // be used in extreme cases, and isn't required to model normal AST // initialization/variables. - void setAllocatedAddress(Address A) { Addr = A; } + void setAllocatedAddress(Address a) { addr = a; } /// Returns the address of the object within this declaration. /// Note that this does not chase the forwarding pointer for /// __block decls. Address getObjectAddress(CIRGenFunction &cgf) const { - if (!IsEscapingByRef) - return Addr; + if (!isEscapingByRef) + return addr; assert(!cir::MissingFeatures::opAllocaEscapeByReference()); return Address::invalid(); @@ -1174,6 +1188,10 @@ public: void emitConstructorBody(FunctionArgList &args); + mlir::LogicalResult emitCoroutineBody(const CoroutineBodyStmt &s); + cir::CallOp emitCoroEndBuiltinCall(mlir::Location loc, mlir::Value nullPtr); + cir::CallOp emitCoroIDBuiltinCall(mlir::Location loc, mlir::Value nullPtr); + void emitDestroy(Address addr, QualType type, Destroyer *destroyer); void emitDestructorBody(FunctionArgList &args); @@ -1279,6 +1297,8 @@ public: void emitInitializerForField(clang::FieldDecl *field, LValue lhs, clang::Expr *init); + LValue emitPredefinedLValue(const PredefinedExpr *e); + mlir::Value emitPromotedComplexExpr(const Expr *e, QualType promotionType); mlir::Value emitPromotedScalarExpr(const Expr *e, QualType promotionType); @@ -1473,7 +1493,8 @@ public: mlir::Value emitStoreThroughBitfieldLValue(RValue src, LValue dstresult); - LValue emitStringLiteralLValue(const StringLiteral *e); + LValue emitStringLiteralLValue(const StringLiteral *e, + llvm::StringRef name = ".str"); mlir::LogicalResult emitSwitchBody(const clang::Stmt *s); mlir::LogicalResult emitSwitchCase(const clang::SwitchCase &s, |