[RISCV][VLOPT] Clear DemandedVLs for each invocation of runOnMachineFunction
[llvm-project.git] / clang / lib / CIR / CodeGen / CIRGenerator.cpp
blob91070eda7d45ad77caefa8616cb18184c8e6f782
1 //===--- CIRGenerator.cpp - Emit CIR from ASTs ----------------------------===//
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 // This builds an AST and converts it to CIR.
11 //===----------------------------------------------------------------------===//
13 #include "CIRGenModule.h"
15 #include "mlir/IR/MLIRContext.h"
17 #include "clang/AST/DeclGroup.h"
18 #include "clang/CIR/CIRGenerator.h"
19 #include "clang/CIR/Dialect/IR/CIRDialect.h"
21 using namespace cir;
22 using namespace clang;
24 void CIRGenerator::anchor() {}
26 CIRGenerator::CIRGenerator(clang::DiagnosticsEngine &diags,
27 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
28 const CodeGenOptions &cgo)
29 : diags(diags), fs(std::move(vfs)), codeGenOpts{cgo} {}
30 CIRGenerator::~CIRGenerator() = default;
32 void CIRGenerator::Initialize(ASTContext &astContext) {
33 using namespace llvm;
35 this->astContext = &astContext;
37 mlirContext = std::make_unique<mlir::MLIRContext>();
38 mlirContext->loadDialect<cir::CIRDialect>();
39 cgm = std::make_unique<clang::CIRGen::CIRGenModule>(
40 *mlirContext.get(), astContext, codeGenOpts, diags);
43 mlir::ModuleOp CIRGenerator::getModule() const { return cgm->getModule(); }
45 bool CIRGenerator::HandleTopLevelDecl(DeclGroupRef group) {
47 for (Decl *decl : group)
48 cgm->emitTopLevelDecl(decl);
50 return true;