14#ifndef MLIR_DIALECT_OPENACC_OPENACCRUNTIMEUTILS_H
15#define MLIR_DIALECT_OPENACC_OPENACCRUNTIMEUTILS_H
23#include "llvm/ADT/ArrayRef.h"
24#include "llvm/ADT/DenseMap.h"
25#include "llvm/ADT/StringRef.h"
36#define ACC_RTL(Enum, ...) Enum,
37#include "mlir/Dialect/OpenACC/OpenACCRuntimeFunctions.def"
57#define ACC_DESC_BEGIN(Enum, ...) Enum,
58#include "mlir/Dialect/OpenACC/OpenACCRuntimeDescriptors.def"
62#define ACC_DESC_BEGIN(Enum, ...) enum class Enum##Field : int64_t {
63#define ACC_DESC_FIELD(Enum, Field, TypeToken) Field,
64#define ACC_DESC_END(Enum) \
67#include "mlir/Dialect/OpenACC/OpenACCRuntimeDescriptors.def"
70template <
typename FieldEnum>
72 return static_cast<int64_t>(field);
78#define ACC_KERNEL_ARG_FIELD(Field, TypeToken) Field,
79#include "mlir/Dialect/OpenACC/OpenACCRuntimeKernelArgs.def"
84 return static_cast<int64_t>(field);
139 std::function<MapFlags(
Operation *mapOp, MapFlags flags)>;
180 int64_t asyncSyncRuntimeValue = -1;
181 int64_t asyncNoValueRuntimeValue = -4;
201 Region &globalSymbolRegion,
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Configuration for OpenACC to LLVM runtime lowering.
int64_t getAsyncNoValueRuntimeValue() const
StringRef getName(RuntimeFunction fn) const
std::string formatMapFlags(MapFlags flags) const
Renders flags for a diagnostic as the names of the set bits and the decimal and hexadecimal encoding ...
std::string getFunctionDisplayName(StringRef mangledOrSymbol) const
std::function< Value(Location, OpBuilder &)> KernelBinaryDescriptorFn
Materialize the target-specific binary descriptor passed to __tgt_acc_kernel.
void setKernelBinaryDescriptorFn(KernelBinaryDescriptorFn fn)
int64_t getAsyncSyncRuntimeValue() const
void setName(RuntimeFunction fn, StringRef name)
Value createDeclareBinaryDescriptor(Location loc, OpBuilder &builder) const
void setAsyncSyncRuntimeValue(int64_t runtimeValue)
Runtime encoding of acc_async_sync, used when an operation carries no async clause.
void setDeviceTypeRuntimeValue(DeviceType type, int64_t runtimeValue)
Map an OpenACC dialect DeviceType to the integer encoding expected by the target runtime.
void setMapFlagRuntimeValue(MapFlags flag, int64_t runtimeValue)
Map a single OpenACC dialect MapFlags bit to the bit the target runtime gives the same meaning.
int64_t getDeviceTypeRuntimeValue(DeviceType type) const
std::function< MapFlags(Operation *mapOp, MapFlags flags)> MapFlagsPostProcessFn
Adjust the flags of a mapping before they are encoded.
void setFunctionDisplayNameFn(FunctionDisplayNameFn fn)
std::function< std::string(StringRef)> FunctionDisplayNameFn
int64_t getMapFlagsRuntimeValue(MapFlags flags) const
std::function< Value(Location, OpBuilder &)> DeclareBinaryDescriptorFn
Materialize the target-specific binary descriptor passed to __tgt_acc_declare.
MapFlags postProcessMapFlags(Operation *mapOp, MapFlags flags) const
void setMapFlagsPostProcessFn(MapFlagsPostProcessFn fn)
Value createKernelBinaryDescriptor(Location loc, OpBuilder &builder) const
void setDeclareBinaryDescriptorFn(DeclareBinaryDescriptorFn fn)
void setAsyncNoValueRuntimeValue(int64_t runtimeValue)
Runtime encoding of acc_async_noval, used for an async clause without an argument.
LLVM::LLVMFunctionType getRuntimeFunctionType(MLIRContext *ctx, RuntimeFunction fn)
Builds the LLVM function type for fn in ctx.
void populateDialectIdentityDeviceTypeMapping(ACCRuntimeCallConfig &config)
Install a device-type mapping that uses OpenACC dialect enum ordinals as the runtime encoding.
StringRef getRuntimeFunctionName(RuntimeFunction fn)
Returns the default runtime symbol name for fn.
int64_t getKernelArgumentFieldIndex(KernelArgumentField field)
The index an insert of field addresses.
LLVM::LLVMStructType getDataDescriptorType(MLIRContext *ctx, DataDescriptor desc, Type baseType={})
Builds the LLVM type of desc in ctx.
DataDescKind getDataDescriptorKind(DataDescriptor desc)
Returns the descriptor kind the runtime reads from the version field of desc.
LLVM::LLVMStructType getKernelArgumentType(MLIRContext *ctx)
The LLVM type of the argument struct passed to __tgt_acc_kernel.
StringRef getDataDescriptorName(DataDescriptor desc)
Returns the name of the runtime type desc materializes.
DataDescriptor
IDs for the argument descriptors of the OpenACC data entry points, declared in OpenACCRuntimeDescript...
RuntimeResult
Status returned by the runtime entry points that report whether they completed.
RuntimeFunction
IDs for OpenACC compiler-to-runtime entry points (__tgt_acc_*).
void populateDialectIdentityMapFlagsMapping(ACCRuntimeCallConfig &config)
Install a map-flag mapping that uses the OpenACC dialect bit positions as the runtime encoding,...
int64_t getDataDescriptorFieldIndex(FieldEnum field)
The index an insert or extract of field addresses.
KernelArgumentField
Fields of the argument struct passed to __tgt_acc_kernel, in declaration order.
FailureOr< LLVM::CallOp > createRuntimeCall(Location loc, OpBuilder &builder, Region &globalSymbolRegion, SymbolTable &symbolTable, RuntimeFunction fn, const ACCRuntimeCallConfig &config, ArrayRef< Value > arguments)
Declares (if needed) and returns a call to the runtime function identified by fn using the name from ...
Include the generated interface declarations.
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap