[clang] [llvm] [HLSL] Implement `WaveReadLaneAt` intrinsic (PR #111010)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 13:06:59 PDT 2024
================
@@ -18835,6 +18835,24 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic();
return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID));
}
+ case Builtin::BI__builtin_hlsl_wave_read_lane_at: {
+ // Due to the use of variadic arguments we must explicitly retreive them and
+ // create our function type.
+ Value *OpExpr = EmitScalarExpr(E->getArg(0));
+ Value *OpIndex = EmitScalarExpr(E->getArg(1));
+ llvm::FunctionType *FT = llvm::FunctionType::get(
+ OpExpr->getType(), ArrayRef{OpExpr->getType(), OpIndex->getType()},
+ false);
+
+ // Get overloaded name
+ std::string name =
+ Intrinsic::getName(CGM.getHLSLRuntime().getWaveReadLaneAtIntrinsic(),
+ ArrayRef{OpExpr->getType()}, &CGM.getModule());
+ return EmitRuntimeCall(CGM.CreateRuntimeFunction(FT, name, {},
----------------
farzonl wrote:
It will we need to modify https://github.com/llvm/llvm-project/blob/848cb21ddca5dc4d8c52e487264936be8f1bfe8d/llvm/lib/Transforms/Scalar/Scalarizer.cpp#L748
to become:
```c++
if (isVectorIntrinsicWithScalarOpAtArg(ID, J) || TTI->isTargetIntrinsicWithScalarOpAtArg(ID, J))
```
by adding a new `TargetTransformInfo` api
https://github.com/llvm/llvm-project/pull/111010
More information about the cfe-commits
mailing list