13#ifndef FORTRAN_OPTIMIZER_SUPPORT_KINDMAPPING_H
14#define FORTRAN_OPTIMIZER_SUPPORT_KINDMAPPING_H
16#include "mlir/IR/OpDefinition.h"
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/IR/Type.h"
50 using KindTy = unsigned;
51 using Bitsize = unsigned;
52 using LLVMTypeID = llvm::Type::TypeID;
53 using MatchResult = mlir::ParseResult;
68 explicit KindMapping(mlir::MLIRContext *context, llvm::StringRef map,
70 explicit KindMapping(mlir::MLIRContext *context, llvm::StringRef map,
92 mlir::MLIRContext *getContext()
const {
return context; }
107 KindTy defaultCharacterKind()
const;
108 KindTy defaultComplexKind()
const;
109 KindTy defaultDoubleKind()
const;
110 KindTy defaultIntegerKind()
const;
111 KindTy defaultLogicalKind()
const;
112 KindTy defaultRealKind()
const;
125 MatchResult badMapString(
const llvm::Twine &ptr);
126 MatchResult parse(llvm::StringRef kindMap);
129 mlir::MLIRContext *context;
130 llvm::DenseMap<std::pair<char, KindTy>, Bitsize> intMap;
131 llvm::DenseMap<std::pair<char, KindTy>, LLVMTypeID> floatMap;
132 llvm::DenseMap<char, KindTy> defaultMap;
Definition: KindMapping.h:48
std::string defaultsToString() const
Convert the current default kinds to a string.
Definition: KindMapping.cpp:380
static constexpr const char * getDefaultMap()
Get the default kind map as a string.
Definition: KindMapping.h:98
Bitsize getIntegerBitsize(KindTy kind) const
Get the size in bits of !fir.int<kind>
Definition: KindMapping.cpp:282
static constexpr const char * getDefaultKinds()
Get the default kinds as a string.
Definition: KindMapping.h:115
const llvm::fltSemantics & getFloatSemantics(KindTy kind) const
Get the float semantics of !fir.real<kind>
Definition: KindMapping.cpp:305
std::string mapToString() const
Convert the current kind map to a string.
Definition: KindMapping.cpp:309
Bitsize getLogicalBitsize(KindTy kind) const
Get the size in bits of !fir.logical<kind>
Definition: KindMapping.cpp:286
static std::vector< KindTy > toDefaultKinds(llvm::StringRef defs)
Definition: KindMapping.cpp:409
Bitsize getCharacterBitsize(KindTy kind) const
Get the size in bits of !fir.char<kind>
Definition: KindMapping.cpp:278
Bitsize getRealBitsize(KindTy kind) const
Get the size in bits of !fir.real<kind>
Definition: KindMapping.cpp:298
LLVMTypeID getRealTypeID(KindTy kind) const
Get the LLVM Type::TypeID of !fir.real<kind>
Definition: KindMapping.cpp:290
LLVMTypeID getComplexTypeID(KindTy kind) const
Get the LLVM Type::TypeID of !fir.complex<kind>
Definition: KindMapping.cpp:294
Definition: AbstractConverter.h:31