[clang] [CIR] Build out AST consumer patterns to reach the entry point into CIRGen (PR #91007)

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Fri May 3 16:14:14 PDT 2024


================
@@ -0,0 +1,61 @@
+//===---- CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_CIR_CIRGENACTION_H
+#define LLVM_CLANG_CIR_CIRGENACTION_H
+
+#include "clang/Frontend/FrontendAction.h"
+
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/OwningOpRef.h"
+
+namespace mlir {
+class MLIRContext;
+class ModuleOp;
+} // namespace mlir
+
+namespace cir {
+class CIRGenConsumer;
+
+class CIRGenAction : public clang::ASTFrontendAction {
+public:
+  enum class OutputType {
+    EmitCIR,
----------------
bcardosolopes wrote:

This is a bit more complicated that it looks. The rationale is that we need to duplicate all actions in order to use clangir transparently in all the pipeline, see the current code here: https://github.com/llvm/clangir/blob/main/clang/lib/CIR/FrontendAction/CIRGenAction.cpp

So we antecipate all existing available ones: https://github.com/llvm/clangir/blob/f52e99e0bd566a4a3bfe73d1991d1ae692407d61/clang/include/clang/CIRFrontendAction/CIRGenAction.h#L33

If you have better ideas we're happy to abide.

https://github.com/llvm/llvm-project/pull/91007


More information about the cfe-commits mailing list