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;
36struct SpecificIntrinsic;
37} // namespace evaluate
38
39namespace lower {
40
47 AbstractConverter &converter);
48
51using OperandPrepare = std::function<void(const Fortran::lower::SomeExpr &)>;
52using OperandPrepareAs = std::function<void(const Fortran::lower::SomeExpr &,
54
59using OperandPresent = std::function<std::optional<mlir::Value>(std::size_t)>;
60
69using OperandGetter = std::function<fir::ExtendedValue(std::size_t, bool)>;
70
83 std::optional<mlir::Type> retTy,
84 const OperandPrepare &prepareOptionalArgument,
85 const OperandPrepareAs &prepareOtherArgument, AbstractConverter &converter);
86
95lowerCustomIntrinsic(fir::FirOpBuilder &builder, mlir::Location loc,
96 llvm::StringRef name, std::optional<mlir::Type> retTy,
97 const OperandPresent &isPresentCheck,
98 const OperandGetter &getOperand, std::size_t numOperands,
100
107genIntrinsicCall(fir::FirOpBuilder &builder, mlir::Location loc,
108 llvm::StringRef name, std::optional<mlir::Type> resultType,
110 StatementContext &stmtCtx,
111 Fortran::lower::AbstractConverter *converter = nullptr);
112
113} // namespace lower
114} // namespace Fortran
115
116#endif // FORTRAN_LOWER_CUSTOMINTRINSICCALL_H
Definition: call.h:232
Definition: AbstractConverter.h:82
Definition: StatementContext.h:46
Definition: BoxValue.h:478
Definition: FIRBuilder.h:55
Definition: FIRType.h:77
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:329
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:92
std::function< fir::ExtendedValue(std::size_t, bool)> OperandGetter
Definition: CustomIntrinsicCall.h:69
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:307
std::function< std::optional< mlir::Value >(std::size_t)> OperandPresent
Definition: CustomIntrinsicCall.h:59
std::function< void(const Fortran::lower::SomeExpr &)> OperandPrepare
Definition: CustomIntrinsicCall.h:51
bool intrinsicRequiresCustomOptionalHandling(const Fortran::evaluate::ProcedureRef &procRef, const Fortran::evaluate::SpecificIntrinsic &intrinsic, AbstractConverter &converter)
Definition: CustomIntrinsicCall.cpp:78
Definition: bit-population-count.h:20
LowerIntrinsicArgAs
Definition: IntrinsicCall.h:96