FLANG

Public Types | Public Member Functions | Public Attributes | List of all members
IntrinsicLibrary Struct Reference

## Public Types
using | RuntimeCallGenerator = std::function< mlir::Value(Fortran::lower::FirOpBuilder &, mlir::Location, llvm::ArrayRef< mlir::Value >)>
using | ElementalGenerator = decltype(&IntrinsicLibrary::genAbs)
using | ExtendedGenerator = decltype(&IntrinsicLibrary::genLenTrim)
using | Generator = std::variant< ElementalGenerator, ExtendedGenerator >

## Public Member Functions
| IntrinsicLibrary (Fortran::lower::FirOpBuilder &builder, mlir::Location loc)
| IntrinsicLibrary (const IntrinsicLibrary &)=delete
fir::ExtendedValue | genIntrinsicCall (llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< fir::ExtendedValue > arg)
mlir::Value | genRuntimeCall (llvm::StringRef name, mlir::Type, llvm::ArrayRef< mlir::Value >)
RuntimeCallGenerator | getRuntimeCallGenerator (llvm::StringRef name, mlir::FunctionType soughtFuncType)
mlir::Value | genAbs (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genAimag (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genAint (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genAnint (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genCeiling (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genConjg (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genDim (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genDprod (mlir::Type, llvm::ArrayRef< mlir::Value >)
template<Extremum , ExtremumBehavior >
mlir::Value | genExtremum (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genFloor (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genIAnd (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genIchar (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genIEOr (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genIOr (mlir::Type, llvm::ArrayRef< mlir::Value >)
fir::ExtendedValue | genLen (mlir::Type, llvm::ArrayRef< fir::ExtendedValue >)
fir::ExtendedValue | genLenTrim (mlir::Type, llvm::ArrayRef< fir::ExtendedValue >)
mlir::Value | genMerge (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genMod (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genNint (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genSign (mlir::Type, llvm::ArrayRef< mlir::Value >)
mlir::Value | genConversion (mlir::Type, llvm::ArrayRef< mlir::Value >)
template<typename GeneratorType >
mlir::Value | outlineInWrapper (GeneratorType, llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< mlir::Value > args)
fir::ExtendedValue | outlineInWrapper (ExtendedGenerator, llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< fir::ExtendedValue > args)
template<typename GeneratorType >
mlir::FuncOp | getWrapper (GeneratorType, llvm::StringRef name, mlir::FunctionType, bool loadRefArguments=false)
template<typename GeneratorType >
fir::ExtendedValue | genElementalCall (GeneratorType, llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< fir::ExtendedValue > args, bool outline)
| Generate calls to ElementalGenerator, handling the elemental aspects.
mlir::Value | invokeGenerator (ElementalGenerator generator, mlir::Type resultType, llvm::ArrayRef< mlir::Value > args)
| Helper to invoke code generator for the intrinsics given arguments.
mlir::Value | invokeGenerator (RuntimeCallGenerator generator, mlir::Type resultType, llvm::ArrayRef< mlir::Value > args)
mlir::Value | invokeGenerator (ExtendedGenerator generator, mlir::Type resultType, llvm::ArrayRef< mlir::Value > args)
mlir::SymbolRefAttr | getUnrestrictedIntrinsicSymbolRefAttr (llvm::StringRef name, mlir::FunctionType signature)

## Public Attributes
Fortran::lower::FirOpBuilder & | builder
mlir::Location | loc

## Member Typedef Documentation

## ◆ ElementalGenerator

using IntrinsicLibrary::ElementalGenerator = decltype(&IntrinsicLibrary::genAbs)

Define the different FIR generators that can be mapped to intrinsic to generate the related code.

## Member Function Documentation

## ◆ genConversion()

mlir::Value IntrinsicLibrary::genConversion | ( | mlir::Type | resultType,
|  | llvm::ArrayRef< mlir::Value > | args
| ) |  |

Implement all conversion functions like DBLE, the first argument is the value to convert. There may be an additional KIND arguments that is ignored because this is already reflected in the result type.

## ◆ genIntrinsicCall()

fir::ExtendedValue IntrinsicLibrary::genIntrinsicCall | ( | llvm::StringRef | name,
|  | mlir::Type | resultType,
|  | llvm::ArrayRef< fir::ExtendedValue > | arg
| ) |  |

Generate FIR for call to Fortran intrinsic `name` with arguments `arg` and expected result type `resultType`.

## ◆ genRuntimeCall()

mlir::Value IntrinsicLibrary::genRuntimeCall | ( | llvm::StringRef | name,
|  | mlir::Type | resultType,
|  | llvm::ArrayRef< mlir::Value > | args
| ) |  |

Search a runtime function that is associated to the generic intrinsic name and whose signature matches the intrinsic arguments and result types. If no such runtime function is found but a runtime function associated with the Fortran generic exists and has the same number of arguments, conversions will be inserted before and/or after the call. This is to mainly to allow 16 bits float support even-though little or no math runtime is currently available for it.

## ◆ getUnrestrictedIntrinsicSymbolRefAttr()

mlir::SymbolRefAttr IntrinsicLibrary::getUnrestrictedIntrinsicSymbolRefAttr | ( | llvm::StringRef | name,
|  | mlir::FunctionType | signature
| ) |  |

Get pointer to unrestricted intrinsic. Generate the related unrestricted intrinsic if it is not defined yet.

## ◆ outlineInWrapper()

template<typename GeneratorType >

mlir::Value IntrinsicLibrary::outlineInWrapper | ( | GeneratorType | generator,
|  | llvm::StringRef | name,
|  | mlir::Type | resultType,
|  | llvm::ArrayRef< mlir::Value > | args
| ) |  |

All generators can be outlined. This will build a function named "fir."+ <generic name> + "." + <result type code> and generate the intrinsic implementation inside instead of at the intrinsic call sites. This can be used to keep the FIR more readable. Only one function will be generated for all the similar calls in a program. If the Generator is nullptr, the wrapper uses genRuntimeCall.

The documentation for this struct was generated from the following file:

- lib/Lower/IntrinsicCall.cpp