FLANG
Classes | Namespaces | Macros | Typedefs | Functions
RTBuilder.h File Reference
#include "flang/Common/Fortran.h"
#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/reduce.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.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)   (I < sizeof(L) / sizeof(*L) ? L[I] : 0)
 
#define FirQuoteKey(X)   #X
 
#define ExpandAndQuoteKey(X)   FirQuoteKey(X)
 
#define FirMacroExpandKey(X)
 
#define FirExpandKey(X)   FirMacroExpandKey(FirQuoteKey(X))
 
#define FirFullSeq(X)   std::integer_sequence<char, FirExpandKey(X)>
 
#define FirAsSequence(X)    decltype(fir::runtime::details::filter(FirFullSeq(X){}))
 
#define FirmkKey(X)
 
#define mkRTKey(X)   FirmkKey(RTNAME(X))
 
#define EXPAND_AND_QUOTE_KEY(S)   ExpandAndQuoteKey(RTNAME(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< 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::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 > ()
 
template<int N, typename A >
void fir::runtime::helper::createArguments (llvm::SmallVectorImpl< mlir::Value > &result, fir::FirOpBuilder &builder, mlir::Location loc, mlir::FunctionType fTy, A arg)
 
template<int N, typename A , typename... As>
void fir::runtime::helper::createArguments (llvm::SmallVectorImpl< mlir::Value > &result, fir::FirOpBuilder &builder, mlir::Location loc, mlir::FunctionType fTy, A arg, As... 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

◆ FirE

#define FirE (   L,
 
)    (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:725
Definition: RTBuilder.h:666

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

◆ 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:746

◆ FirmkKey

#define FirmkKey (   X)
Value:

◆ 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); \
}; \
}