ClangIR CodeGen code uses both `mlir::MLIRContext` and `clang::ASTContext` objects extensively. Refering to either of those as just "context" can be confusing. Change the names of all variables, parameters, and fields in `clang/lib/CIR/CodeGen` that refer to `MLIRContext` or an `ASTContext` to be either `mlirContext` or `astContext`. This change is only the renaming of variables/parameters/fields. There are no behavior changes. So there are no new tests or changes to existing tests. This change mimics a recent change in the ClangIR incubator repository.
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
//===--- CIRGenerator.cpp - Emit CIR from ASTs ----------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This builds an AST and converts it to CIR.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "CIRGenModule.h"
|
|
|
|
#include "mlir/IR/MLIRContext.h"
|
|
|
|
#include "clang/AST/DeclGroup.h"
|
|
#include "clang/CIR/CIRGenerator.h"
|
|
#include "clang/CIR/Dialect/IR/CIRDialect.h"
|
|
|
|
using namespace cir;
|
|
using namespace clang;
|
|
|
|
void CIRGenerator::anchor() {}
|
|
|
|
CIRGenerator::CIRGenerator(clang::DiagnosticsEngine &diags,
|
|
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs,
|
|
const CodeGenOptions &cgo)
|
|
: diags(diags), fs(std::move(vfs)), codeGenOpts{cgo} {}
|
|
CIRGenerator::~CIRGenerator() = default;
|
|
|
|
void CIRGenerator::Initialize(ASTContext &astContext) {
|
|
using namespace llvm;
|
|
|
|
this->astContext = &astContext;
|
|
|
|
mlirContext = std::make_unique<mlir::MLIRContext>();
|
|
mlirContext->loadDialect<cir::CIRDialect>();
|
|
cgm = std::make_unique<clang::CIRGen::CIRGenModule>(
|
|
*mlirContext.get(), astContext, codeGenOpts, diags);
|
|
}
|
|
|
|
mlir::ModuleOp CIRGenerator::getModule() const { return cgm->getModule(); }
|
|
|
|
bool CIRGenerator::HandleTopLevelDecl(DeclGroupRef group) {
|
|
|
|
for (Decl *decl : group)
|
|
cgm->emitTopLevelDecl(decl);
|
|
|
|
return true;
|
|
}
|