FLANG
CustomIntrinsicCall.h
1//===-- Lower/CustomIntrinsicCall.h -----------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
22//===----------------------------------------------------------------------===//
23
24#ifndef FORTRAN_LOWER_CUSTOMINTRINSICCALL_H
25#define FORTRAN_LOWER_CUSTOMINTRINSICCALL_H
26
27#include "flang/Lower/AbstractConverter.h"
28#include "flang/Optimizer/Builder/IntrinsicCall.h"
29#include <functional>
30#include <optional>
31
32namespace Fortran {
33
34namespace evaluate {
35class ProcedureRef;
37} // namespace evaluate
38
39namespace lower {
40
42fir::IntrinsicLoweringOptions getIntrinsicLoweringOptions(AbstractConverter &);
43
48 const Fortran::evaluate::ProcedureRef &procRef,
49 const Fortran::evaluate::SpecificIntrinsic &intrinsic,
50 AbstractConverter &converter);
51
54using OperandPrepare = std::function<void(const Fortran::lower::SomeExpr &)>;
55using OperandPrepareAs = std::function<void(const Fortran::lower::SomeExpr &,
57
62using OperandPresent = std::function<std::optional<mlir::Value>(std::size_t)>;
63
72using OperandGetter = std::function<fir::ExtendedValue(std::size_t, bool)>;
73
86 std::optional<mlir::Type> retTy,
87 const OperandPrepare &prepareOptionalArgument,
88 const OperandPrepareAs &prepareOtherArgument, AbstractConverter &converter);
89
98lowerCustomIntrinsic(fir::FirOpBuilder &builder, mlir::Location loc,
99 llvm::StringRef name, std::optional<mlir::Type> retTy,
100 const OperandPresent &isPresentCheck,
101 const OperandGetter &getOperand, std::size_t numOperands,
103
110genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc,
111 llvm::StringRef name, std::optional<mlir::Type> resultType,
113 StatementContext &stmtCtx,
114 Fortran::lower::AbstractConverter *converter = nullptr);
115
116} // namespace lower
117} // namespace Fortran
118
119#endif // FORTRAN_LOWER_CUSTOMINTRINSICCALL_H
Definition call.h:234
Definition AbstractConverter.h:87
Definition StatementContext.h:46
Definition BoxValue.h:480
Definition FIRBuilder.h:59
Definition FIRType.h:106
Definition call.h:34
Definition ParserActions.h:24
fir::ExtendedValue lowerCustomIntrinsic(fir::FirOpBuilder &builder, mlir::Location loc, llvm::StringRef name, std::optional< mlir::Type > retTy, const OperandPresent &isPresentCheck, const OperandGetter &getOperand, std::size_t numOperands, Fortran::lower::StatementContext &stmtCtx)
Definition CustomIntrinsicCall.cpp:345
fir::ExtendedValue genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc, llvm::StringRef name, std::optional< mlir::Type > resultType, llvm::ArrayRef< fir::ExtendedValue > args, StatementContext &stmtCtx, Fortran::lower::AbstractConverter *converter=nullptr)
Definition CustomIntrinsicCall.cpp:104
void prepareCustomIntrinsicArgument(const Fortran::evaluate::ProcedureRef &procRef, const Fortran::evaluate::SpecificIntrinsic &intrinsic, std::optional< mlir::Type > retTy, const OperandPrepare &prepareOptionalArgument, const OperandPrepareAs &prepareOtherArgument, AbstractConverter &converter)
Definition CustomIntrinsicCall.cpp:323
fir::IntrinsicLoweringOptions getIntrinsicLoweringOptions(AbstractConverter &)
Build intrinsic lowering options from the converter state.
Definition CustomIntrinsicCall.cpp:90
std::function< void(const Fortran::lower::SomeExpr &)> OperandPrepare
Definition CustomIntrinsicCall.h:54
bool intrinsicRequiresCustomOptionalHandling(const Fortran::evaluate::ProcedureRef &procRef, const Fortran::evaluate::SpecificIntrinsic &intrinsic, AbstractConverter &converter)
Definition CustomIntrinsicCall.cpp:79
std::function< fir::ExtendedValue(std::size_t, bool)> OperandGetter
Definition CustomIntrinsicCall.h:72
std::function< std::optional< mlir::Value >(std::size_t)> OperandPresent
Definition CustomIntrinsicCall.h:62
Definition bit-population-count.h:20
LowerIntrinsicArgAs
Definition IntrinsicCall.h:60