FLANG
CodeGen.h
1//===-- Optimizer/CodeGen/CodeGen.h -- code generation ----------*- 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#ifndef FORTRAN_OPTIMIZER_CODEGEN_CODEGEN_H
10#define FORTRAN_OPTIMIZER_CODEGEN_CODEGEN_H
11
12#include "flang/Frontend/CodeGenOptions.h"
13#include "mlir/IR/BuiltinOps.h"
14#include "mlir/Pass/Pass.h"
15#include "mlir/Pass/PassRegistry.h"
16#include "llvm/IR/Module.h"
17#include "llvm/Support/raw_ostream.h"
18#include <memory>
19
20namespace fir {
21
23
24struct NameUniquer;
25
26#define GEN_PASS_DECL_FIRTOLLVMLOWERING
27#define GEN_PASS_DECL_CODEGENREWRITE
28#define GEN_PASS_DECL_REMATERIALIZEFIRBOXOPSPASS
29#define GEN_PASS_DECL_TARGETREWRITEPASS
30#define GEN_PASS_DECL_BOXEDPROCEDUREPASS
31#define GEN_PASS_DECL_LOWERREPACKARRAYSPASS
32#include "flang/Optimizer/CodeGen/CGPasses.h.inc"
33
36 // Do not fail when type descriptors are not found when translating
37 // operations that use them at the LLVM level like fir.embox. Instead,
38 // just use a null pointer.
39 // This is useful to test translating programs manually written where a
40 // frontend did not generate type descriptor data structures. However, note
41 // that such programs would crash at runtime if the derived type descriptors
42 // are required by the runtime, so this is only an option to help debugging.
43 bool ignoreMissingTypeDescriptors = false;
44 // Similar to ignoreMissingTypeDescriptors, but generate external declaration
45 // for the missing type descriptor globals instead.
46 bool skipExternalRttiDefinition = false;
47
48 // Generate TBAA information for FIR types and memory accessing operations.
49 bool applyTBAA = false;
50
51 // Force the usage of a unified tbaa tree in TBAABuilder.
52 bool forceUnifiedTBAATree = false;
53
54 // If set to true, then the global variables created
55 // for the derived types have been renamed to avoid usage
56 // of special symbols that may not be supported by all targets.
57 // The renaming is done by the CompilerGeneratedNamesConversion pass.
58 // If it is true, FIR-to-LLVM pass has to use
59 // fir::NameUniquer::getTypeDescriptorAssemblyName() to take
60 // the name of the global variable corresponding to a derived
61 // type's descriptor.
62 bool typeDescriptorsRenamedForAssembly = false;
63
64 // Specify the calculation method for complex number division used by the
65 // Conversion pass of the MLIR complex dialect.
68};
69
71std::unique_ptr<mlir::Pass> createFIRToLLVMPass();
72
74std::unique_ptr<mlir::Pass> createFIRToLLVMPass(FIRToLLVMPassOptions options);
75
76using LLVMIRLoweringPrinter =
77 std::function<void(llvm::Module &, llvm::raw_ostream &)>;
78
80std::unique_ptr<mlir::Pass> createLLVMDialectToLLVMPass(
81 llvm::raw_ostream &output,
82 LLVMIRLoweringPrinter printer =
83 [](llvm::Module &m, llvm::raw_ostream &out) { m.print(out, nullptr); });
84
87 const fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns,
89
91void populatePreCGRewritePatterns(mlir::RewritePatternSet &patterns,
92 bool preserveDeclare);
93
94// declarative passes
95#define GEN_PASS_REGISTRATION
96#include "flang/Optimizer/CodeGen/CGPasses.h.inc"
97
98} // namespace fir
99
100#endif // FORTRAN_OPTIMIZER_CODEGEN_CODEGEN_H
ComplexRangeKind
Controls the various implementations for complex division.
Definition CodeGenOptions.h:212
@ CX_Full
Definition CodeGenOptions.h:216
Definition TypeConverter.h:50
Definition AbstractConverter.h:37
std::unique_ptr< mlir::Pass > createFIRToLLVMPass()
Convert FIR to the LLVM IR dialect with default options.
Definition CodeGen.cpp:4841
void populatePreCGRewritePatterns(mlir::RewritePatternSet &patterns, bool preserveDeclare)
Populate the pattern set with the PreCGRewrite patterns.
Definition PreCGRewrite.cpp:474
std::unique_ptr< mlir::Pass > createLLVMDialectToLLVMPass(llvm::raw_ostream &output, LLVMIRLoweringPrinter printer=[](llvm::Module &m, llvm::raw_ostream &out) { m.print(out, nullptr);})
Convert the LLVM IR dialect to LLVM-IR proper.
Definition CodeGen.cpp:4851
void populateFIRToLLVMConversionPatterns(const fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns, fir::FIRToLLVMPassOptions &options)
Populate the given list with patterns that convert from FIR to LLVM.
Definition CodeGen.cpp:4856
FIR to LLVM translation pass options.
Definition CodeGen.h:35
Definition InternalNames.h:45