FLANG
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Fortran::lower::CallInterface< T > Class Template Reference

#include <flang/Lower/CallInterface.h>

Classes

struct  FirPlaceHolder
 
struct  PassedEntity
 

Public Types

enum class  PassEntityBy {
  BaseAddress , BoxChar , Box , MutableBox ,
  AddressAndLength , Value , BaseAddressValueAttribute , CharBoxValueAttribute ,
  CharProcTuple , BoxProcRef
}
 Enum the different ways an entity can be passed-by. More...
 
enum class  Property {
  BaseAddress , BoxChar , CharAddress , CharLength ,
  CharProcTuple , Box , MutableBox , Value ,
  BoxProcRef
}
 
using FortranEntity = typename PassedEntityTypes< T >::FortranEntity
 
using FirValue = typename PassedEntityTypes< T >::FirValue
 

Public Member Functions

mlir::func::FuncOp getFuncOp () const
 
std::size_t getNumFIRArguments () const
 Number of MLIR inputs/outputs of the created FuncOp.
 
std::size_t getNumFIRResults () const
 
llvm::SmallVector< mlir::Type > getResultType () const
 Return the MLIR output types.
 
llvm::ArrayRef< PassedEntitygetPassedArguments () const
 
std::optional< PassedEntitygetPassedResult () const
 
mlir::FunctionType genFunctionType ()
 Returns the mlir function type.
 
void determineInterface (bool isImplicit, const Fortran::evaluate::characteristics::Procedure &)
 
bool callerAllocateResult () const
 Does the caller need to allocate storage for the result ?
 
bool mustPassResult () const
 Is the Fortran result passed as an extra MLIR argument ?
 
bool mustSaveResult () const
 Must the MLIR result be saved with a fir.save_result ?
 
bool canBeCalledViaImplicitInterface () const
 Can the associated procedure be called via an implicit interface?
 
fir::FortranProcedureFlagsEnumAttr getProcedureAttrs (mlir::MLIRContext *) const
 

Protected Member Functions

 CallInterface (Fortran::lower::AbstractConverter &c)
 
T & side ()
 CRTP handle.
 
const T & side () const
 
void declare ()
 
void mapPassedEntities ()
 
void mapBackInputToPassedEntity (const FirPlaceHolder &, FirValue)
 

Protected Attributes

llvm::SmallVector< FirPlaceHolderoutputs
 
llvm::SmallVector< FirPlaceHolderinputs
 
mlir::func::FuncOp func
 
llvm::SmallVector< PassedEntitypassedArguments
 
std::optional< PassedEntitypassedResult
 
bool saveResult = false
 
Fortran::lower::AbstractConverterconverter
 
std::optional< Fortran::evaluate::characteristics::Procedurecharacteristic
 

Detailed Description

template<typename T>
class Fortran::lower::CallInterface< T >

CallInterface defines all the logic to determine FIR function interfaces from a characteristic, build the mlir::func::FuncOp and describe back the argument mapping to its user. The logic is shared between the callee and caller sides that it accepts as a curiously recursive template to handle the few things that cannot be shared between both sides (getting characteristics, mangled name, location). It maps FIR arguments to front-end Symbol (callee side) or ActualArgument (caller side) with the same code using the abstract FortranEntity type that can be either a Symbol or an ActualArgument. It works in two passes: a first pass over the characteristics that decides how the interface must be. Then, the funcOp is created for it. Then a simple pass over fir arguments finalize the interface information that must be passed back to the user (and may require having the funcOp). All this passes are driven from the CallInterface constructor.

Member Enumeration Documentation

◆ PassEntityBy

template<typename T >
enum class Fortran::lower::CallInterface::PassEntityBy
strong

Enum the different ways an entity can be passed-by.

Enumerator
Value 

Value means passed by value at the mlir level, it is not necessarily implied by Fortran Value attribute.

BaseAddressValueAttribute 

ValueAttribute means dummy has the Fortran VALUE attribute.

◆ Property

template<typename T >
enum class Fortran::lower::CallInterface::Property
strong

Different properties of an entity that can be passed/returned. One-to-One mapping with PassEntityBy but for PassEntityBy::AddressAndLength that has two properties.

Member Function Documentation

◆ declare()

template<typename T >
void Fortran::lower::CallInterface< T >::declare
protected

Entry point to be called by child ctor to analyze the signature and create/find the mlir::func::FuncOp. Child needs to be initialized first.

Declare drives the different actions to be performed while analyzing the signature and building/finding the mlir::func::FuncOp.

◆ determineInterface()

template<typename T >
void Fortran::lower::CallInterface< T >::determineInterface ( bool  isImplicit,
const Fortran::evaluate::characteristics::Procedure procedure 
)

determineInterface is the entry point of the first pass that defines the interface and is required to get the mlir::func::FuncOp.

◆ getFuncOp()

template<typename T >
mlir::func::FuncOp Fortran::lower::CallInterface< T >::getFuncOp ( ) const
inline

Return the mlir::func::FuncOp. Note that front block is added by this utility if callee side.

◆ getPassedArguments()

template<typename T >
llvm::ArrayRef< PassedEntity > Fortran::lower::CallInterface< T >::getPassedArguments ( ) const
inline

Return a container of Symbol/ActualArgument* and how they must be plugged with the mlir::func::FuncOp.

◆ getPassedResult()

template<typename T >
std::optional< PassedEntity > Fortran::lower::CallInterface< T >::getPassedResult ( ) const
inline

In case the result must be passed by the caller, indicate how. nullopt if the result is not passed by the caller.

◆ getProcedureAttrs()

template<typename T >
fir::FortranProcedureFlagsEnumAttr Fortran::lower::CallInterface< T >::getProcedureAttrs ( mlir::MLIRContext *  mlirContext) const

Translate Fortran procedure attributes into FIR attribute. Return attribute is nullptr if the procedure has no attributes.

◆ mapPassedEntities()

template<typename T >
void Fortran::lower::CallInterface< T >::mapPassedEntities
protected

Second pass entry point, once the mlir::func::FuncOp is created. Nothing is done if it was already called.

Once the signature has been analyzed and the mlir::func::FuncOp was built/found, map the fir inputs to Fortran entities (the symbols or expressions).

Member Data Documentation

◆ characteristic

template<typename T >
std::optional<Fortran::evaluate::characteristics::Procedure> Fortran::lower::CallInterface< T >::characteristic
protected
Initial value:
=
std::nullopt

Store characteristic once created, it is required for further information (e.g. getting the length of character result)


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