FLANG
Public Types | Public Member Functions | Static Public Member Functions | List of all members
fir::KindMapping Class Reference

#include <flang/Optimizer/Dialect/Support/KindMapping.h>

Public Types

using KindTy = unsigned
 
using Bitsize = unsigned
 
using LLVMTypeID = llvm::Type::TypeID
 
using MatchResult = mlir::ParseResult
 

Public Member Functions

 KindMapping (mlir::MLIRContext *context)
 
 KindMapping (mlir::MLIRContext *context, llvm::ArrayRef< KindTy > defs)
 
 KindMapping (mlir::MLIRContext *context, llvm::StringRef map, llvm::ArrayRef< KindTy > defs=std::nullopt)
 
 KindMapping (mlir::MLIRContext *context, llvm::StringRef map, llvm::StringRef defs)
 
Bitsize getCharacterBitsize (KindTy kind) const
 Get the size in bits of !fir.char<kind>
 
Bitsize getIntegerBitsize (KindTy kind) const
 Get the size in bits of !fir.int<kind>
 
Bitsize getLogicalBitsize (KindTy kind) const
 Get the size in bits of !fir.logical<kind>
 
Bitsize getRealBitsize (KindTy kind) const
 Get the size in bits of !fir.real<kind>
 
LLVMTypeID getRealTypeID (KindTy kind) const
 Get the LLVM Type::TypeID of !fir.real<kind>
 
LLVMTypeID getComplexTypeID (KindTy kind) const
 Get the LLVM Type::TypeID of !fir.complex<kind>
 
mlir::MLIRContext * getContext () const
 
const llvm::fltSemantics & getFloatSemantics (KindTy kind) const
 Get the float semantics of !fir.real<kind>
 
std::string mapToString () const
 Convert the current kind map to a string.
 
KindTy defaultCharacterKind () const
 
KindTy defaultComplexKind () const
 
KindTy defaultDoubleKind () const
 
KindTy defaultIntegerKind () const
 
KindTy defaultLogicalKind () const
 
KindTy defaultRealKind () const
 
std::string defaultsToString () const
 Convert the current default kinds to a string.
 

Static Public Member Functions

static constexpr const char * getDefaultMap ()
 Get the default kind map as a string.
 
static constexpr const char * getDefaultKinds ()
 Get the default kinds as a string.
 
static std::vector< KindTy > toDefaultKinds (llvm::StringRef defs)
 

Detailed Description

The kind mapping is an encoded string that informs FIR how the Fortran KIND values from the front-end should be converted to LLVM IR types. This encoding allows the mapping from front-end KIND values to backend LLVM IR types to be customized by the front-end.

The provided string uses the following syntax.

intrinsic-key : kind-value (, intrinsic-key : kind-value)*

intrinsic-key is a single character for the intrinsic type. 'i' : INTEGER (size in bits) 'l' : LOGICAL (size in bits) 'a' : CHARACTER (size in bits) 'r' : REAL (encoding value) 'c' : COMPLEX (encoding value)

kind-value is either an unsigned integer (for 'i', 'l', and 'a') or one of 'Half', 'BFloat', 'Float', 'Double', 'X86_FP80', or 'FP128' (for 'r' and 'c').

If LLVM adds support for new floating-point types, the final list should be extended.

Constructor & Destructor Documentation

◆ KindMapping() [1/3]

fir::KindMapping::KindMapping ( mlir::MLIRContext *  context)
explicit

KindMapping constructor with both the kind map and default kinds read from command-line options.

◆ KindMapping() [2/3]

fir::KindMapping::KindMapping ( mlir::MLIRContext *  context,
llvm::ArrayRef< KindTy >  defs 
)
explicit

KindMapping constructor taking a defs argument to specify the default kinds for intrinsic types. To set the default kinds, an ArrayRef of 6 KindTy must be passed. The kinds must be the given in the following order: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL. The kind map is read from command-line options, if given.

◆ KindMapping() [3/3]

fir::KindMapping::KindMapping ( mlir::MLIRContext *  context,
llvm::StringRef  map,
llvm::ArrayRef< KindTy >  defs = std::nullopt 
)
explicit

KindMapping constructor taking an optional defs argument to specify the default kinds for intrinsic types. To set the default kinds, an ArrayRef of 6 KindTy must be passed. The kinds must be the given in the following order: CHARACTER, COMPLEX, DOUBLE PRECISION, INTEGER, LOGICAL, and REAL.

Member Function Documentation

◆ toDefaultKinds()

std::vector< KindTy > fir::KindMapping::toDefaultKinds ( llvm::StringRef  defs)
static

Translate a default kinds string into a default kind vector. This vector can be passed to the KindMapping ctor.


The documentation for this class was generated from the following files: