[clang] [CIR][NFC] Organize emit functions in CIRGenFunction.h (PR #133017)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 26 03:36:22 PDT 2025
================
@@ -488,6 +364,143 @@ class CIRGenFunction : public CIRGenTypeCache {
LexicalScope *curLexScope = nullptr;
+ /// ----------------------
+ /// CIR emit functions
+ /// ----------------------
+private:
+ void emitAndUpdateRetAlloca(clang::QualType type, mlir::Location loc,
+ clang::CharUnits alignment);
+
+public:
+ mlir::Value emitAlloca(llvm::StringRef name, mlir::Type ty,
+ mlir::Location loc, clang::CharUnits alignment,
+ bool insertIntoFnEntryBlock,
+ mlir::Value arraySize = nullptr);
+ mlir::Value emitAlloca(llvm::StringRef name, mlir::Type ty,
+ mlir::Location loc, clang::CharUnits alignment,
+ mlir::OpBuilder::InsertPoint ip,
+ mlir::Value arraySize = nullptr);
+
+ /// Emit code to compute the specified expression which can have any type. The
+ /// result is returned as an RValue struct. If this is an aggregate
+ /// expression, the aggloc/agglocvolatile arguments indicate where the result
+ /// should be returned.
+ RValue emitAnyExpr(const clang::Expr *e);
+
+ AutoVarEmission emitAutoVarAlloca(const clang::VarDecl &d);
+
+ /// Emit code and set up symbol table for a variable declaration with auto,
+ /// register, or no storage class specifier. These turn into simple stack
+ /// objects, globals depending on target.
+ void emitAutoVarDecl(const clang::VarDecl &d);
+
+ void emitAutoVarCleanups(const AutoVarEmission &emission);
+ void emitAutoVarInit(const AutoVarEmission &emission);
+
+ LValue emitBinaryOperatorLValue(const BinaryOperator *e);
+
+ /// Emit an expression as an initializer for an object (variable, field, etc.)
+ /// at the given location. The expression is not necessarily the normal
+ /// initializer for the object, and the address is not necessarily
+ /// its normal location.
+ ///
+ /// \param init the initializing expression
+ /// \param d the object to act as if we're initializing
+ /// \param lvalue the lvalue to initialize
+ /// \param capturedByInit true if \p d is a __block variable whose address is
+ /// potentially changed by the initializer
+ void emitExprAsInit(const clang::Expr *init, const clang::ValueDecl *d,
+ LValue lvalue, bool capturedByInit = false);
+
+ mlir::LogicalResult emitFunctionBody(const clang::Stmt *body);
+
+ mlir::Value emitPromotedScalarExpr(const Expr *e, QualType promotionType);
+
+ /// Emit the computation of the specified expression of scalar type.
+ mlir::Value emitScalarExpr(const clang::Expr *e);
+
+ mlir::Value emitScalarPrePostIncDec(const UnaryOperator *e, LValue lv,
+ bool isInc, bool isPre);
+
+ /// Build a debug stoppoint if we are emitting debug info.
+ void emitStopPoint(const Stmt *s);
+
+ // Build CIR for a statement. useCurrentScope should be true if no
+ // new scopes need be created when finding a compound statement.
+ mlir::LogicalResult
+ emitStmt(const clang::Stmt *s, bool useCurrentScope,
+ llvm::ArrayRef<const Attr *> attrs = std::nullopt);
+
+ mlir::LogicalResult emitSimpleStmt(const clang::Stmt *s,
+ bool useCurrentScope);
+
+ mlir::LogicalResult emitForStmt(const clang::ForStmt &S);
----------------
xlauko wrote:
```suggestion
mlir::LogicalResult emitForStmt(const clang::ForStmt &s);
```
https://github.com/llvm/llvm-project/pull/133017
More information about the cfe-commits
mailing list