Skip to content

Commit

Permalink
New runtime interface for reducer lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
VoxSciurorum committed Oct 16, 2023
1 parent 699892a commit 79459ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5434,13 +5434,15 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
return RValue::get(Builder.CreateCall(FF, {}));
}
case Builtin::BI__hyper_lookup: {
Function *TF = CGM.getIntrinsic(Intrinsic::tapir_frame);
llvm::Value *Frame = Builder.CreateCall(TF, {});
llvm::Value *Size = EmitScalarExpr(E->getArg(1));
Function *F = CGM.getIntrinsic(Intrinsic::hyper_lookup, Size->getType());
llvm::Value *Ptr = EmitScalarExpr(E->getArg(0));
llvm::Value *Identity = EmitScalarExpr(E->getArg(2));
llvm::Value *Reduce = EmitScalarExpr(E->getArg(3));
return RValue::get(Builder.CreateCall(
F, {Ptr, Size, Builder.CreateBitCast(Identity, VoidPtrTy),
F, {Frame, Ptr, Size, Builder.CreateBitCast(Identity, VoidPtrTy),
Builder.CreateBitCast(Reduce, VoidPtrTy)}));
}
}
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,8 @@ def int_tapir_frame
// but that does not work, so rely on the front end to insert bitcasts.
def int_hyper_lookup
: Intrinsic<[llvm_ptr_ty],
[llvm_ptr_ty, llvm_anyint_ty, llvm_ptr_ty, llvm_ptr_ty], [
[llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty,
llvm_ptr_ty, llvm_ptr_ty], [
IntrWillReturn, IntrReadMem, IntrInaccessibleMemOnly,
IntrStrandPure, IntrHyperView, IntrInjective
]>;
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Transforms/Tapir/OpenCilkABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ void OpenCilkABI::prepareModule() {
FunctionType *Grainsize16FnTy = FunctionType::get(Int16Ty, {Int16Ty}, false);
FunctionType *Grainsize32FnTy = FunctionType::get(Int32Ty, {Int32Ty}, false);
FunctionType *Grainsize64FnTy = FunctionType::get(Int64Ty, {Int64Ty}, false);
FunctionType *LookupTy = FunctionType::get(
VoidPtrTy, {VoidPtrTy, Int64Ty, VoidPtrTy, VoidPtrTy}, false);
FunctionType *LookupTy = FunctionType::get(VoidPtrTy,
{StackFramePtrTy, VoidPtrTy, Int64Ty, VoidPtrTy, VoidPtrTy}, false);
FunctionType *UnregTy = FunctionType::get(VoidTy, {VoidPtrTy}, false);
FunctionType *Reg32Ty =
FunctionType::get(VoidTy, {VoidPtrTy, Int32Ty, VoidPtrTy,
Expand Down Expand Up @@ -262,7 +262,7 @@ void OpenCilkABI::prepareModule() {
CilkRTSCilkForGrainsize32},
{"__cilkrts_cilk_for_grainsize_64", Grainsize64FnTy,
CilkRTSCilkForGrainsize64},
{"__cilkrts_reducer_lookup", LookupTy, CilkRTSReducerLookup},
{"__cilkrts_reducer_lookup_in_frame", LookupTy, CilkRTSReducerLookup},
{"__cilkrts_reducer_register_32", Reg32Ty, CilkRTSReducerRegister32},
{"__cilkrts_reducer_register_64", Reg64Ty, CilkRTSReducerRegister64},
{"__cilkrts_reducer_unregister", UnregTy, CilkRTSReducerUnregister},
Expand Down

0 comments on commit 79459ba

Please sign in to comment.