clang 22.0.0git
LowerModule.h
Go to the documentation of this file.
1//===--- LowerModule.h - Abstracts CIR's module lowering --------*- 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// This file partially mimics clang/lib/CodeGen/CodeGenModule.h. The queries are
10// adapted to operate on the CIR dialect, however.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERMODULE_H
15#define CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERMODULE_H
16
17#include "CIRCXXABI.h"
18#include "mlir/IR/BuiltinOps.h"
24#include <memory>
25
26namespace cir {
27
29 mlir::ModuleOp module;
30 const std::unique_ptr<clang::TargetInfo> target;
31 std::unique_ptr<CIRCXXABI> abi;
32 [[maybe_unused]] mlir::PatternRewriter &rewriter;
33
34public:
36 mlir::ModuleOp &module, std::unique_ptr<clang::TargetInfo> target,
37 mlir::PatternRewriter &rewriter);
38 ~LowerModule() = default;
39
42 return target->getCXXABI().getKind();
43 }
44
45 CIRCXXABI &getCXXABI() const { return *abi; }
46 const clang::TargetInfo &getTarget() const { return *target; }
47 mlir::MLIRContext *getMLIRContext() { return module.getContext(); }
48};
49
50std::unique_ptr<LowerModule> createLowerModule(mlir::ModuleOp module,
51 mlir::PatternRewriter &rewriter);
52
53} // namespace cir
54
55#endif // CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_LOWERMODULE_H
Defines the clang::LangOptions interface.
mlir::MLIRContext * getMLIRContext()
Definition LowerModule.h:47
CIRCXXABI & getCXXABI() const
Definition LowerModule.h:45
clang::TargetCXXABI::Kind getCXXABIKind() const
Definition LowerModule.h:40
LowerModule(clang::LangOptions langOpts, clang::CodeGenOptions codeGenOpts, mlir::ModuleOp &module, std::unique_ptr< clang::TargetInfo > target, mlir::PatternRewriter &rewriter)
const clang::TargetInfo & getTarget() const
Definition LowerModule.h:46
~LowerModule()=default
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Kind
The basic C++ ABI kind.
Exposes information about the current target.
Definition TargetInfo.h:226
Defines the clang::TargetInfo interface.
std::unique_ptr< LowerModule > createLowerModule(mlir::ModuleOp module, mlir::PatternRewriter &rewriter)
static bool lowerModuleLangOpts()