[clang] [CIR] Upstream simple function bodies (PR #127674)
David Olsen via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 18 14:59:25 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;
+
+ clang::ASTContext &getContext() const { return cgm.getASTContext(); }
+
+ CIRGenBuilderTy &getBuilder() { return builder; }
+
+ CIRGenModule &getCIRGenModule() { return cgm; }
+ const CIRGenModule &getCIRGenModule() const { return cgm; }
+
+ mlir::Type convertTypeForMem(QualType T);
----------------
dkolsen-pgi wrote:
This code was copy-pasted from the incubator, where initial-caps is used. When I manually went through and fixed all the capitalization stuff, I missed this declaration and the others you pointed out. I will fix these.
https://github.com/llvm/llvm-project/pull/127674
More information about the cfe-commits
mailing list