[clang] [CIR] Upstream simple function bodies (PR #127674)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 18 12:00:33 PST 2025
================
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Internal per-function state used for AST-to-ClangIR code gen
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENFUNCTION_H
+#define LLVM_CLANG_LIB_CIR_CODEGEN_CIRGENFUNCTION_H
+
+#include "CIRGenBuilder.h"
+#include "CIRGenModule.h"
+#include "CIRGenTypeCache.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/TypeEvaluationKind.h"
+
+#include "llvm/ADT/ScopedHashTable.h"
+
+namespace clang::CIRGen {
+
+class CIRGenFunction : public CIRGenTypeCache {
+public:
+ CIRGenModule &cgm;
+
+private:
+ /// The builder is a helper class to create IR inside a function. The
+ /// builder is stateful, in particular it keeps an "insertion point": this
+ /// is where the next operations will be introduced.
+ CIRGenBuilderTy &builder;
+
+public:
+ clang::QualType fnRetTy;
+
+ /// This is the current function or global initializer that is generated code
+ /// for.
+ mlir::Operation *curFn = nullptr;
----------------
andykaylor wrote:
I don't understand why a pointer is used here and why this is an `mlir::Operation` rather than a `cir::FuncOp`. At least in this PR, it looks like this is initialized using a non-pointer `cir::FuncOp`. I see a place in the incubator where it is intialized with a cir::GlobalOp, but that confuses me even more.
https://github.com/llvm/llvm-project/pull/127674
More information about the cfe-commits
mailing list