Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:51

0001 //===- CIRGenerator.h - CIR Generation from Clang AST ---------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file declares a simple interface to perform CIR generation from Clang
0010 // AST
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_CIR_CIRGENERATOR_H
0015 #define LLVM_CLANG_CIR_CIRGENERATOR_H
0016 
0017 #include "clang/AST/ASTConsumer.h"
0018 #include "clang/Basic/CodeGenOptions.h"
0019 
0020 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0021 #include "llvm/Support/VirtualFileSystem.h"
0022 
0023 #include <memory>
0024 
0025 namespace clang {
0026 class DeclGroupRef;
0027 class DiagnosticsEngine;
0028 namespace CIRGen {
0029 class CIRGenModule;
0030 } // namespace CIRGen
0031 } // namespace clang
0032 
0033 namespace mlir {
0034 class MLIRContext;
0035 } // namespace mlir
0036 namespace cir {
0037 class CIRGenerator : public clang::ASTConsumer {
0038   virtual void anchor();
0039   clang::DiagnosticsEngine &diags;
0040   clang::ASTContext *astContext;
0041   // Only used for debug info.
0042   llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs;
0043 
0044   const clang::CodeGenOptions &codeGenOpts;
0045 
0046 protected:
0047   std::unique_ptr<mlir::MLIRContext> mlirContext;
0048   std::unique_ptr<clang::CIRGen::CIRGenModule> cgm;
0049 
0050 public:
0051   CIRGenerator(clang::DiagnosticsEngine &diags,
0052                llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
0053                const clang::CodeGenOptions &cgo);
0054   ~CIRGenerator() override;
0055   void Initialize(clang::ASTContext &astContext) override;
0056   bool HandleTopLevelDecl(clang::DeclGroupRef group) override;
0057   mlir::ModuleOp getModule() const;
0058 };
0059 
0060 } // namespace cir
0061 
0062 #endif // LLVM_CLANG_CIR_CIRGENERATOR_H