clang 24.0.0git
CIRGenAction.h
Go to the documentation of this file.
1//===---- CIRGenAction.h - CIR Code Generation Frontend Action -*- C++ -*--===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_CIR_CIRGENACTION_H
10#define LLVM_CLANG_CIR_CIRGENACTION_H
11
14#include "llvm/ADT/SmallVector.h"
15
16#include "mlir/IR/BuiltinOps.h"
17#include "mlir/IR/OwningOpRef.h"
18
19namespace llvm {
20class LLVMContext;
21} // namespace llvm
22
23namespace mlir {
24class MLIRContext;
25class ModuleOp;
26} // namespace mlir
27
28namespace cir {
29class CIRGenConsumer;
30
32public:
41
42private:
43 friend class CIRGenConsumer;
44
45 mlir::OwningOpRef<mlir::ModuleOp> MLIRMod;
46
47 mlir::MLIRContext *MLIRCtx;
48
49 std::unique_ptr<llvm::LLVMContext> Ctx;
51
52protected:
53 CIRGenAction(OutputType Action, mlir::MLIRContext *MLIRCtx = nullptr);
54
56
57 bool hasCIRSupport() const override { return true; }
58
59 void ExecuteAction() override;
60
61 std::unique_ptr<clang::ASTConsumer>
63 llvm::StringRef InFile) override;
64
65public:
66 ~CIRGenAction() override;
67
69};
70
72 virtual void anchor();
73
74public:
75 EmitCIRAction(mlir::MLIRContext *MLIRCtx = nullptr);
76};
77
79 virtual void anchor();
80
81public:
82 EmitCIRBCAction(mlir::MLIRContext *MLIRCtx = nullptr);
83};
84
86 virtual void anchor();
87
88public:
89 EmitLLVMAction(mlir::MLIRContext *MLIRCtx = nullptr);
90};
91
92class EmitBCAction : public CIRGenAction {
93 virtual void anchor();
94
95public:
96 EmitBCAction(mlir::MLIRContext *MLIRCtx = nullptr);
97};
98
100 virtual void anchor();
101
102public:
103 EmitAssemblyAction(mlir::MLIRContext *MLIRCtx = nullptr);
104};
105
107 virtual void anchor();
108
109public:
110 EmitObjAction(mlir::MLIRContext *MLIRCtx = nullptr);
111};
112
113} // namespace cir
114
115#endif
Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...
CIRGenAction(OutputType Action, mlir::MLIRContext *MLIRCtx=nullptr)
bool hasCIRSupport() const override
Does this action support use with CIR files?
OutputType Action
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
bool BeginSourceFileAction(clang::CompilerInstance &CI) override
Callback at the start of processing a single input.
~CIRGenAction() override
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &CI, llvm::StringRef InFile) override
friend class CIRGenConsumer
EmitAssemblyAction(mlir::MLIRContext *MLIRCtx=nullptr)
EmitBCAction(mlir::MLIRContext *MLIRCtx=nullptr)
EmitCIRAction(mlir::MLIRContext *MLIRCtx=nullptr)
EmitCIRBCAction(mlir::MLIRContext *MLIRCtx=nullptr)
EmitLLVMAction(mlir::MLIRContext *MLIRCtx=nullptr)
EmitObjAction(mlir::MLIRContext *MLIRCtx=nullptr)
Abstract base class to use for AST consumer-based frontend actions.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30