13#include "mlir/IR/MLIRContext.h"
14#include "mlir/IR/OwningOpRef.h"
23 virtual void anchor();
27 std::unique_ptr<raw_pwrite_stream> OutputStream;
31 std::unique_ptr<CIRGenerator> Gen;
42 std::unique_ptr<raw_pwrite_stream> OS)
43 : Action(Action), OutputStream(
std::move(OS)), FS(VFS),
48 assert(!Context &&
"initialized multiple times");
54 Gen->HandleTopLevelDecl(
D);
59 Gen->HandleTranslationUnit(
C);
60 mlir::ModuleOp MlirModule = Gen->getModule();
63 if (OutputStream && MlirModule) {
64 mlir::OpPrintingFlags Flags;
65 Flags.enableDebugInfo(
true,
false);
66 MlirModule->print(*OutputStream, Flags);
74void CIRGenConsumer::anchor() {}
77 : MLIRCtx(MLIRCtx ? MLIRCtx : new
mlir::MLIRContext), Action(Act) {}
81static std::unique_ptr<raw_pwrite_stream>
88 llvm_unreachable(
"Invalid CIRGenAction::OutputType");
91std::unique_ptr<ASTConsumer>
98 auto Result = std::make_unique<cir::CIRGenConsumer>(
106void EmitCIRAction::anchor() {}
static std::unique_ptr< raw_pwrite_stream > getOutputStream(CompilerInstance &CI, StringRef InFile, CIRGenAction::OutputType Action)
CIRGenAction(OutputType Action, mlir::MLIRContext *MLIRCtx=nullptr)
std::unique_ptr< clang::ASTConsumer > CreateASTConsumer(clang::CompilerInstance &CI, llvm::StringRef InFile) override
CIRGenConsumer(CIRGenAction::OutputType Action, DiagnosticsEngine &DiagnosticsEngine, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, const HeaderSearchOptions &HeaderSearchOptions, const CodeGenOptions &CodeGenOptions, const TargetOptions &TargetOptions, const LangOptions &LangOptions, const FrontendOptions &FEOptions, std::unique_ptr< raw_pwrite_stream > OS)
void Initialize(ASTContext &Ctx) override
Initialize - This is called to initialize the consumer, providing the ASTContext.
bool HandleTopLevelDecl(DeclGroupRef D) override
HandleTopLevelDecl - Handle the specified top-level declaration.
void HandleTranslationUnit(ASTContext &C) override
HandleTranslationUnit - This method is called when the ASTs for entire translation unit have been par...
EmitCIRAction(mlir::MLIRContext *MLIRCtx=nullptr)
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
std::unique_ptr< raw_pwrite_stream > createDefaultOutputFile(bool Binary=true, StringRef BaseInput="", StringRef Extension="", bool RemoveFileOnSignal=true, bool CreateMissingDirectories=false, bool ForceUseTemporary=false)
Create the default output file (from the invocation's options) and add it to the list of tracked outp...
TargetOptions & getTargetOpts()
std::unique_ptr< llvm::raw_pwrite_stream > takeOutputStream()
FrontendOptions & getFrontendOpts()
HeaderSearchOptions & getHeaderSearchOpts()
llvm::vfs::FileSystem & getVirtualFileSystem() const
LangOptions & getLangOpts()
CodeGenOptions & getCodeGenOpts()
Concrete class used by the front-end to report problems and issues.
FrontendOptions - Options for controlling the behavior of the frontend.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Options for controlling the target.
The JSON file list parser is used to communicate input to InstallAPI.