FLANG
RTBuilder.h File Reference
#include "flang/Common/uint128.h"
#include "flang/Optimizer/Builder/FIRBuilder.h"
#include "flang/Optimizer/Dialect/FIRDialect.h"
#include "flang/Optimizer/Dialect/FIRType.h"
#include "flang/Runtime/io-api.h"
#include "flang/Runtime/reduce.h"
#include "flang/Support/Fortran.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <cstdint>
#include <functional>

Go to the source code of this file.

Classes

struct  fir::runtime::RuntimeTableKey< RT(ATs...)>
struct  fir::runtime::RuntimeTableEntry< RuntimeTableKey< KT >, RuntimeIdentifier< Cs... > >

Namespaces

namespace  Fortran
namespace  fir

Macros

#define REDUCTION_REF_OPERATION_MODEL(T)
#define REDUCTION_VALUE_OPERATION_MODEL(T)
#define REDUCTION_CHAR_OPERATION_MODEL(T)
#define FirE(L, I)
#define FirQuoteKey(X)
#define ExpandAndQuoteKey(X)
#define FirMacroExpandKey(X)
#define FirExpandKey(X)
#define FirFullSeq(X)
#define FirAsSequence(X)
#define FirmkKey(X)
#define mkRTKey(X)
#define EXPAND_AND_QUOTE_KEY(S)

Typedefs

using fir::runtime::TypeBuilderFunc = mlir::Type (*)(mlir::MLIRContext *)
using fir::runtime::FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *)
template<char... Cs>
using fir::runtime::RuntimeIdentifier = std::integer_sequence<char, Cs...>

Functions

template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned int > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< short int > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< short int * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const short int * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< int > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< int & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< int * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const int * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< char * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const char * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const char16_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const char32_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< char > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< signed char > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< signed char * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const signed char * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< char16_t > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< char16_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< char32_t > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< char32_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned char > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< void * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< void(*)(int)> ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< void ** > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long long > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::common::int128_t > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long long & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const long long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned long > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned long long > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< double > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< double & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< double * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const double * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long double > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< long double * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const long double * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< float > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< float & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< float * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const float * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< bool > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< bool & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< bool * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned short > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned char * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const unsigned char * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned short * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const unsigned short * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const unsigned * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const unsigned long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< unsigned long long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const unsigned long long * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::common::uint128_t > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::common::int128_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::common::uint128_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::common::uint128_t * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< std::complex< float > & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< std::complex< float > * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const std::complex< float > * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< std::complex< double > & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< std::complex< double > * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const std::complex< double > * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< c_float_complex_t > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< c_double_complex_t > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::runtime::Descriptor & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::Descriptor & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::runtime::Descriptor * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::Descriptor * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::common::TypeCategory > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::runtime::typeInfo::DerivedType & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::runtime::typeInfo::DerivedType * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< void > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::io::IoStatementState * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::io::Iostat > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::runtime::io::NamelistGroup & > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< const Fortran::runtime::io::NonTbpDefinedIoTable * > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::ValueReductionOperation< std::complex< float > > > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::ValueReductionOperation< std::complex< double > > > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::ReferenceReductionOperation< std::complex< float > > > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::ReferenceReductionOperation< std::complex< double > > > ()
template<>
constexpr TypeBuilderFunc fir::runtime::getModel< Fortran::runtime::ReductionDerivedTypeOperation > ()
llvm::SmallVector< mlir::Value > fir::runtime::createArguments (fir::FirOpBuilder &builder, mlir::Location loc, mlir::FunctionType fTy, llvm::ArrayRef< mlir::Value > args)
template<typename... As>
llvm::SmallVector< mlir::Value > fir::runtime::createArguments (fir::FirOpBuilder &builder, mlir::Location loc, mlir::FunctionType fTy, As... args)
 Create a SmallVector of arguments for a runtime call.

Detailed Description

This file defines some C++17 template classes that are used to convert the signatures of plain old C functions into a model that can be used to generate MLIR calls to those functions. This can be used to autogenerate tables at compiler compile-time to call runtime support code.

Macro Definition Documentation

◆ EXPAND_AND_QUOTE_KEY

#define EXPAND_AND_QUOTE_KEY ( S)
Value:
ExpandAndQuoteKey(RTNAME(S))

◆ ExpandAndQuoteKey

#define ExpandAndQuoteKey ( X)
Value:
FirQuoteKey(X)

◆ FirAsSequence

#define FirAsSequence ( X)
Value:
decltype(fir::runtime::details::filter(FirFullSeq(X){}))

◆ FirE

#define FirE ( L,
I )
Value:
(I < sizeof(L) / sizeof(*L) ? L[I] : 0)

These macros are used to create the RuntimeTableEntry for runtime function.

For example the runtime function SumReal4 will be expanded as shown below (simplified version)

decltype(_FortranASumReal4)>, "_FortranASumReal4"))>
Definition RTBuilder.h:761
Definition RTBuilder.h:702

These entries are then used to generate the MLIR FunctionType that correspond to the runtime function declaration in C++.

◆ FirExpandKey

#define FirExpandKey ( X)
Value:
FirMacroExpandKey(FirQuoteKey(X))

◆ FirFullSeq

#define FirFullSeq ( X)
Value:
std::integer_sequence<char, FirExpandKey(X)>

◆ FirMacroExpandKey

#define FirMacroExpandKey ( X)
Value:
FirE(X, 0), FirE(X, 1), FirE(X, 2), FirE(X, 3), FirE(X, 4), FirE(X, 5), \
FirE(X, 6), FirE(X, 7), FirE(X, 8), FirE(X, 9), FirE(X, 10), \
FirE(X, 11), FirE(X, 12), FirE(X, 13), FirE(X, 14), FirE(X, 15), \
FirE(X, 16), FirE(X, 17), FirE(X, 18), FirE(X, 19), FirE(X, 20), \
FirE(X, 21), FirE(X, 22), FirE(X, 23), FirE(X, 24), FirE(X, 25), \
FirE(X, 26), FirE(X, 27), FirE(X, 28), FirE(X, 29), FirE(X, 30), \
FirE(X, 31), FirE(X, 32), FirE(X, 33), FirE(X, 34), FirE(X, 35), \
FirE(X, 36), FirE(X, 37), FirE(X, 38), FirE(X, 39), FirE(X, 40), \
FirE(X, 41), FirE(X, 42), FirE(X, 43), FirE(X, 44), FirE(X, 45), \
FirE(X, 46), FirE(X, 47), FirE(X, 48), FirE(X, 49)
#define FirE(L, I)
Definition RTBuilder.h:782

◆ FirmkKey

#define FirmkKey ( X)
Value:

◆ FirQuoteKey

#define FirQuoteKey ( X)
Value:
#X

◆ mkRTKey

#define mkRTKey ( X)
Value:
FirmkKey(RTNAME(X))

◆ REDUCTION_CHAR_OPERATION_MODEL

#define REDUCTION_CHAR_OPERATION_MODEL ( T)
Value:
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ReductionCharOperation<T>>() { \
return [](mlir::MLIRContext *context) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto voidTy = fir::LLVMPointerType::get( \
context, mlir::IntegerType::get(context, 8)); \
auto size_tTy = \
mlir::IntegerType::get(context, 8 * sizeof(std::size_t)); \
auto refTy = fir::ReferenceType::get(f(context)); \
return mlir::FunctionType::get( \
context, {refTy, size_tTy, refTy, refTy, size_tTy, size_tTy}, \
voidTy); \
}; \
}

◆ REDUCTION_REF_OPERATION_MODEL

#define REDUCTION_REF_OPERATION_MODEL ( T)
Value:
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ReferenceReductionOperation<T>>() { \
return [](mlir::MLIRContext *context) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto refTy = fir::ReferenceType::get(f(context)); \
return mlir::FunctionType::get(context, {refTy, refTy}, refTy); \
}; \
}

◆ REDUCTION_VALUE_OPERATION_MODEL

#define REDUCTION_VALUE_OPERATION_MODEL ( T)
Value:
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ValueReductionOperation<T>>() { \
return [](mlir::MLIRContext *context) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto refTy = fir::ReferenceType::get(f(context)); \
return mlir::FunctionType::get(context, {f(context), f(context)}, \
refTy); \
}; \
}