@@ -2399,6 +2399,7 @@ class OpenMPIRBuilder {
2399
2399
CurInfo.NonContigInfo .Strides .end ());
2400
2400
}
2401
2401
};
2402
+ using MapInfosOrErrorTy = Expected<MapInfosTy &>;
2402
2403
2403
2404
// / Callback function type for functions emitting the host fallback code that
2404
2405
// / is executed when the kernel launch fails. It takes an insertion point as
@@ -2407,6 +2408,11 @@ class OpenMPIRBuilder {
2407
2408
using EmitFallbackCallbackTy =
2408
2409
function_ref<InsertPointOrErrorTy(InsertPointTy)>;
2409
2410
2411
+ // Callback function type for emitting and fetching user defined custom
2412
+ // mappers.
2413
+ using CustomMapperCallbackTy =
2414
+ function_ref<Expected<Function *>(unsigned int )>;
2415
+
2410
2416
// / Generate a target region entry call and host fallback call.
2411
2417
// /
2412
2418
// / \param Loc The location at which the request originated and is fulfilled.
@@ -2473,24 +2479,24 @@ class OpenMPIRBuilder {
2473
2479
// / return nullptr by reference. Accepts a reference to a MapInfosTy object
2474
2480
// / that contains information generated for mappable clauses,
2475
2481
// / including base pointers, pointers, sizes, map types, user-defined mappers.
2476
- void emitOffloadingArrays (
2482
+ Error emitOffloadingArrays (
2477
2483
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
2478
- TargetDataInfo &Info, bool IsNonContiguous = false ,
2479
- function_ref< void ( unsigned int , Value *)> DeviceAddrCB = nullptr ,
2480
- function_ref<Value * (unsigned int )> CustomMapperCB = nullptr);
2484
+ TargetDataInfo &Info, CustomMapperCallbackTy CustomMapperCB ,
2485
+ bool IsNonContiguous = false ,
2486
+ function_ref<void (unsigned int , Value * )> DeviceAddrCB = nullptr);
2481
2487
2482
2488
// / Allocates memory for and populates the arrays required for offloading
2483
2489
// / (offload_{baseptrs|ptrs|mappers|sizes|maptypes|mapnames}). Then, it
2484
2490
// / emits their base addresses as arguments to be passed to the runtime
2485
2491
// / library. In essence, this function is a combination of
2486
2492
// / emitOffloadingArrays and emitOffloadingArraysArgument and should arguably
2487
2493
// / be preferred by clients of OpenMPIRBuilder.
2488
- void emitOffloadingArraysAndArgs (
2494
+ Error emitOffloadingArraysAndArgs (
2489
2495
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, TargetDataInfo &Info,
2490
2496
TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo,
2491
- bool IsNonContiguous = false , bool ForEndCall = false ,
2492
- function_ref< void ( unsigned int , Value *)> DeviceAddrCB = nullptr ,
2493
- function_ref<Value * (unsigned int )> CustomMapperCB = nullptr);
2497
+ CustomMapperCallbackTy CustomMapperCB , bool IsNonContiguous = false ,
2498
+ bool ForEndCall = false ,
2499
+ function_ref<void (unsigned int , Value * )> DeviceAddrCB = nullptr);
2494
2500
2495
2501
// / Creates offloading entry for the provided entry ID \a ID, address \a
2496
2502
// / Addr, size \a Size, and flags \a Flags.
@@ -2950,12 +2956,12 @@ class OpenMPIRBuilder {
2950
2956
// / \param FuncName Optional param to specify mapper function name.
2951
2957
// / \param CustomMapperCB Optional callback to generate code related to
2952
2958
// / custom mappers.
2953
- Function *emitUserDefinedMapper (
2954
- function_ref<MapInfosTy &(InsertPointTy CodeGenIP, llvm::Value *PtrPHI,
2955
- llvm::Value *BeginArg)>
2959
+ Expected< Function *> emitUserDefinedMapper (
2960
+ function_ref<MapInfosOrErrorTy(
2961
+ InsertPointTy CodeGenIP, llvm::Value *PtrPHI, llvm::Value *BeginArg)>
2956
2962
PrivAndGenMapInfoCB,
2957
2963
llvm::Type *ElemTy, StringRef FuncName,
2958
- function_ref<bool( unsigned int , Function **)> CustomMapperCB = nullptr );
2964
+ CustomMapperCallbackTy CustomMapperCB);
2959
2965
2960
2966
// / Generator for '#omp target data'
2961
2967
// /
@@ -2969,21 +2975,21 @@ class OpenMPIRBuilder {
2969
2975
// / \param IfCond Value which corresponds to the if clause condition.
2970
2976
// / \param Info Stores all information realted to the Target Data directive.
2971
2977
// / \param GenMapInfoCB Callback that populates the MapInfos and returns.
2978
+ // / \param CustomMapperCB Callback to generate code related to
2979
+ // / custom mappers.
2972
2980
// / \param BodyGenCB Optional Callback to generate the region code.
2973
2981
// / \param DeviceAddrCB Optional callback to generate code related to
2974
2982
// / use_device_ptr and use_device_addr.
2975
- // / \param CustomMapperCB Optional callback to generate code related to
2976
- // / custom mappers.
2977
2983
InsertPointOrErrorTy createTargetData (
2978
2984
const LocationDescription &Loc, InsertPointTy AllocaIP,
2979
2985
InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
2980
2986
TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
2987
+ CustomMapperCallbackTy CustomMapperCB,
2981
2988
omp::RuntimeFunction *MapperFunc = nullptr ,
2982
2989
function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
2983
2990
BodyGenTy BodyGenType)>
2984
2991
BodyGenCB = nullptr,
2985
2992
function_ref<void(unsigned int , Value *)> DeviceAddrCB = nullptr,
2986
- function_ref<Value *(unsigned int )> CustomMapperCB = nullptr,
2987
2993
Value *SrcLocInfo = nullptr);
2988
2994
2989
2995
using TargetBodyGenCallbackTy = function_ref<InsertPointOrErrorTy(
@@ -2999,6 +3005,7 @@ class OpenMPIRBuilder {
2999
3005
// / \param IsOffloadEntry whether it is an offload entry.
3000
3006
// / \param CodeGenIP The insertion point where the call to the outlined
3001
3007
// / function should be emitted.
3008
+ // / \param Info Stores all information realted to the Target directive.
3002
3009
// / \param EntryInfo The entry information about the function.
3003
3010
// / \param DefaultAttrs Structure containing the default attributes, including
3004
3011
// / numbers of threads and teams to launch the kernel with.
@@ -3010,20 +3017,23 @@ class OpenMPIRBuilder {
3010
3017
// / \param BodyGenCB Callback that will generate the region code.
3011
3018
// / \param ArgAccessorFuncCB Callback that will generate accessors
3012
3019
// / instructions for passed in target arguments where neccessary
3020
+ // / \param CustomMapperCB Callback to generate code related to
3021
+ // / custom mappers.
3013
3022
// / \param Dependencies A vector of DependData objects that carry
3014
3023
// / dependency information as passed in the depend clause
3015
3024
// / \param HasNowait Whether the target construct has a `nowait` clause or
3016
3025
// / not.
3017
3026
InsertPointOrErrorTy createTarget (
3018
3027
const LocationDescription &Loc, bool IsOffloadEntry,
3019
3028
OpenMPIRBuilder::InsertPointTy AllocaIP,
3020
- OpenMPIRBuilder::InsertPointTy CodeGenIP,
3029
+ OpenMPIRBuilder::InsertPointTy CodeGenIP, TargetDataInfo &Info,
3021
3030
TargetRegionEntryInfo &EntryInfo,
3022
3031
const TargetKernelDefaultAttrs &DefaultAttrs,
3023
3032
const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
3024
3033
SmallVectorImpl<Value *> &Inputs, GenMapInfoCallbackTy GenMapInfoCB,
3025
3034
TargetBodyGenCallbackTy BodyGenCB,
3026
3035
TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
3036
+ CustomMapperCallbackTy CustomMapperCB,
3027
3037
SmallVector<DependData> Dependencies = {}, bool HasNowait = false );
3028
3038
3029
3039
// / Returns __kmpc_for_static_init_* runtime function for the specified
0 commit comments