Skip to content

[HLSL] Implement WaveReadLaneAt intrinsics #110739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

inbelic
Copy link
Contributor

@inbelic inbelic commented Oct 1, 2024

- create a clang built-in
- add mapping to dxil opcode
- add lowering to SPIR-V GroupNonUniformShuffle with Scope = 2
  (Group)
- add sema checks
- add related tests

@inbelic inbelic force-pushed the inbelic/wave-read-lane-at branch from fdf04ec to cb3467d Compare October 1, 2024 20:50
    - create a clang built-in
    - add mapping to dxil opcode
    - add lowering to SPIR-V GroupNonUniformShuffle with Scope = 2
      (Group)
    - add sema checks
    - add related tests
@inbelic inbelic force-pushed the inbelic/wave-read-lane-at branch from cb3467d to 0320a5a Compare October 1, 2024 20:54

// Check if the operation supports overload types and OverloadTy is valid
// per the specified types for the operation
if ((ValidTyMask != OverloadKind::UNDEFINED) &&
(ValidTyMask & (uint16_t)Kind) == 0)
(ValidTyMask & (uint16_t)Kind) == 0) {
OverloadTy->print(llvm::errs());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, will remove when I address other comments

Copy link

github-actions bot commented Oct 1, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff f3c408d1726f6a921212faf68085f68bf8533f0c 0320a5acec2565608cb91b271f6cda49fc364bb7 --extensions cpp,h -- clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGHLSLRuntime.h clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/lib/Sema/SemaHLSL.cpp llvm/lib/Target/DirectX/DXILOpBuilder.cpp llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp llvm/utils/TableGen/DXILEmitter.cpp
View the diff from clang-format here.
diff --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index f3707d8076..a7bdc353ae 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -2020,7 +2020,7 @@ __attribute__((convergent)) bool WaveIsFirstLane();
 template <typename T>
 _HLSL_AVAILABILITY(shadermodel, 6.0)
 _HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
-__attribute__((convergent)) T WaveReadLaneAt(T, int32_t);
+    __attribute__((convergent)) T WaveReadLaneAt(T, int32_t);
 
 //===----------------------------------------------------------------------===//
 // sign builtins

.addUse(GR.getSPIRVTypeID(ResType))
.addUse(I.getOperand(2).getReg())
.addUse(I.getOperand(3).getReg())
.addUse(GR.getOrCreateConstInt(2, I, IntTy, TII));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, an HLSL wave corresponds to the SPIR-V workgroup scope, which is denoted as 2.

@inbelic inbelic closed this Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant