13#ifndef FORTRAN_OPTIMIZER_CODEGEN_TYPECONVERTER_H
14#define FORTRAN_OPTIMIZER_CODEGEN_TYPECONVERTER_H
16#include "flang/Optimizer/Builder/Todo.h"
17#include "flang/Optimizer/CodeGen/TBAABuilder.h"
18#include "flang/Optimizer/CodeGen/Target.h"
19#include "flang/Optimizer/Dialect/FIRType.h"
20#include "flang/Optimizer/Dialect/Support/FIRContext.h"
21#include "flang/Optimizer/Dialect/Support/KindMapping.h"
22#include "mlir/Conversion/LLVMCommon/TypeConverter.h"
23#include "llvm/Support/Debug.h"
26static constexpr unsigned kAddrPosInBox = 0;
27static constexpr unsigned kElemLenPosInBox = 1;
28static constexpr unsigned kVersionPosInBox = 2;
29static constexpr unsigned kRankPosInBox = 3;
30static constexpr unsigned kTypePosInBox = 4;
31static constexpr unsigned kAttributePosInBox = 5;
32static constexpr unsigned kExtraPosInBox = 6;
33static constexpr unsigned kDimsPosInBox = 7;
34static constexpr unsigned kOptTypePtrPosInBox = 8;
35static constexpr unsigned kOptRowTypePosInBox = 9;
38static constexpr unsigned kDimLowerBoundPos = 0;
39static constexpr unsigned kDimExtentPos = 1;
40static constexpr unsigned kDimStridePos = 2;
53 bool forceUnifiedTBAATree,
const mlir::DataLayout &);
57 mlir::Type offsetType()
const;
60 mlir::Type indexType()
const;
63 std::optional<llvm::LogicalResult>
64 convertRecordType(fir::RecordType derived,
65 llvm::SmallVectorImpl<mlir::Type> &results,
bool isPacked);
69 bool requiresExtendedDesc(mlir::Type boxElementType)
const;
73 static constexpr int unknownRank() {
return -1; }
84 mlir::Type convertBoxProcType(BoxProcType boxproc)
const;
86 unsigned characterBitsize(fir::CharacterType charTy)
const;
90 mlir::Type convertCharType(fir::CharacterType charTy)
const;
92 template <
typename A> mlir::Type convertPointerLike(A &ty)
const {
93 return mlir::LLVM::LLVMPointerType::get(ty.getContext());
97 mlir::Type convertSequenceType(SequenceType seq)
const;
102 mlir::Type convertTypeDescType(mlir::MLIRContext *ctx)
const;
104 const KindMapping &getKindMap()
const {
return kindMapping; }
107 void attachTBAATag(mlir::LLVM::AliasAnalysisOpInterface op,
108 mlir::Type baseFIRType, mlir::Type accessFIRType,
109 mlir::LLVM::GEPOp gep)
const;
111 const mlir::DataLayout &getDataLayout()
const {
112 assert(dataLayout &&
"must be set in ctor");
118 std::unique_ptr<CodeGenSpecifics> specifics;
119 std::unique_ptr<TBAABuilder> tbaaBuilder;
120 const mlir::DataLayout *dataLayout;
This class provides a shared interface for box and class types.
Definition: FIRType.h:40
Definition: KindMapping.h:48
Definition: TypeConverter.h:50
mlir::Type convertBoxType(BaseBoxType box, int rank=unknownRank()) const
Definition: TypeConverter.cpp:250
mlir::Type convertBoxTypeAsStruct(BaseBoxType box, int=unknownRank()) const
Definition: TypeConverter.cpp:176
Definition: AbstractConverter.h:31
Definition: AbstractConverter.h:27