-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[SPIR-V] Map SPIR-V friendly work-item function to built-in variables #148567
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
Merged
wenju-he
merged 4 commits into
llvm:main
from
wenju-he:SPIRVBuiltins.td-__spirv_BuiltIn
Jul 18, 2025
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0d5ae36
[SPIR-V] Map SPIR-V friendly work-item function to built-in variables
wenju-he a4523a5
Variable -> GetQuery
wenju-he a55fd37
align SPIR-V function name in clang/lib/Headers/__clang_spirv_builtins.h
wenju-he 79dd451
check storage class
wenju-he File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,109 @@ | ||
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id:]] BuiltIn GlobalInvocationId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id:]] BuiltIn GlobalLinearId | ||
; CHECK-SPIRV: %[[#Id:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id0:]] BuiltIn GlobalLinearId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id1:]] BuiltIn GlobalInvocationId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id2:]] BuiltIn LocalInvocationIndex | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id3:]] BuiltIn WorkDim | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id4:]] BuiltIn SubgroupSize | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id5:]] BuiltIn SubgroupMaxSize | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id6:]] BuiltIn NumSubgroups | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id7:]] BuiltIn NumEnqueuedSubgroups | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id8:]] BuiltIn SubgroupId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id9:]] BuiltIn SubgroupLocalInvocationId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id10:]] BuiltIn SubgroupEqMask | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id11:]] BuiltIn SubgroupGeMask | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id12:]] BuiltIn SubgroupGtMask | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id13:]] BuiltIn SubgroupLeMask | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id14:]] BuiltIn SubgroupLtMask | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id15:]] BuiltIn LocalInvocationId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id16:]] BuiltIn WorkgroupSize | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id17:]] BuiltIn GlobalSize | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id18:]] BuiltIn WorkgroupId | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id19:]] BuiltIn EnqueuedWorkgroupSize | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id20:]] BuiltIn NumWorkgroups | ||
; CHECK-SPIRV-DAG: OpDecorate %[[#Id21:]] BuiltIn GlobalOffset | ||
|
||
; CHECK-SPIRV: %[[#Id0:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id1:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id2:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id3:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id4:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id5:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id6:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id7:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id8:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id9:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id10:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id11:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id12:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id13:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id14:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id15:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id16:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id17:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id18:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id19:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id20:]] = OpVariable %[[#]] | ||
; CHECK-SPIRV: %[[#Id21:]] = OpVariable %[[#]] | ||
|
||
define spir_kernel void @f() { | ||
entry: | ||
%0 = call spir_func i32 @_Z29__spirv_BuiltInGlobalLinearIdv() | ||
%1 = call spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32 1) | ||
%2 = call spir_func i64 @_Z35__spirv_BuiltInLocalInvocationIndexv() | ||
%3 = call spir_func i32 @_Z22__spirv_BuiltInWorkDimv() | ||
%4 = call spir_func i32 @_Z27__spirv_BuiltInSubgroupSizev() | ||
%5 = call spir_func i32 @_Z30__spirv_BuiltInSubgroupMaxSizev() | ||
%6 = call spir_func i32 @_Z27__spirv_BuiltInNumSubgroupsv() | ||
%7 = call spir_func i32 @_Z35__spirv_BuiltInNumEnqueuedSubgroupsv() | ||
%8 = call spir_func i32 @_Z25__spirv_BuiltInSubgroupIdv() | ||
%9 = call spir_func i32 @_Z40__spirv_BuiltInSubgroupLocalInvocationIdv() | ||
%10 = call spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupEqMaskv() | ||
%11 = call spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupEqMaskKHRv() | ||
%12 = call spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupGeMaskv() | ||
%13 = call spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupGeMaskKHRv() | ||
%14 = call spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupGtMaskv() | ||
%15 = call spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupGtMaskKHRv() | ||
%16 = call spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupLeMaskv() | ||
%17 = call spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupLeMaskKHRv() | ||
%18 = call spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupLtMaskv() | ||
%19 = call spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupLtMaskKHRv() | ||
%20 = call spir_func i64 @_Z32__spirv_BuiltInLocalInvocationIdi(i32 0) | ||
%21 = call spir_func i64 @_Z28__spirv_BuiltInWorkgroupSizei(i32 0) | ||
%22 = call spir_func i64 @_Z25__spirv_BuiltInGlobalSizei(i32 0) | ||
%23 = call spir_func i64 @_Z26__spirv_BuiltInWorkgroupIdi(i32 0) | ||
%24 = call spir_func i64 @_Z36__spirv_BuiltInEnqueuedWorkgroupSizei(i32 0) | ||
%25 = call spir_func i64 @_Z28__spirv_BuiltInNumWorkgroupsi(i32 0) | ||
%26 = call spir_func i64 @_Z27__spirv_BuiltInGlobalOffseti(i32 0) | ||
|
||
ret void | ||
} | ||
|
||
declare spir_func i32 @_Z29__spirv_BuiltInGlobalLinearIdv() | ||
declare spir_func i64 @_Z33__spirv_BuiltInGlobalInvocationIdi(i32) | ||
declare spir_func i64 @_Z35__spirv_BuiltInLocalInvocationIndexv() | ||
declare spir_func i32 @_Z22__spirv_BuiltInWorkDimv() | ||
declare spir_func i32 @_Z27__spirv_BuiltInSubgroupSizev() | ||
declare spir_func i32 @_Z30__spirv_BuiltInSubgroupMaxSizev() | ||
declare spir_func i32 @_Z27__spirv_BuiltInNumSubgroupsv() | ||
declare spir_func i32 @_Z35__spirv_BuiltInNumEnqueuedSubgroupsv() | ||
declare spir_func i32 @_Z25__spirv_BuiltInSubgroupIdv() | ||
declare spir_func i32 @_Z40__spirv_BuiltInSubgroupLocalInvocationIdv() | ||
declare spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupEqMaskv() | ||
declare spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupEqMaskKHRv() | ||
declare spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupGeMaskv() | ||
declare spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupGeMaskKHRv() | ||
declare spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupGtMaskv() | ||
declare spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupGtMaskKHRv() | ||
declare spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupLeMaskv() | ||
declare spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupLeMaskKHRv() | ||
declare spir_func <4 x i32> @_Z29__spirv_BuiltInSubgroupLtMaskv() | ||
declare spir_func <4 x i32> @_Z32__spirv_BuiltInSubgroupLtMaskKHRv() | ||
declare spir_func i64 @_Z32__spirv_BuiltInLocalInvocationIdi(i32) | ||
declare spir_func i64 @_Z28__spirv_BuiltInWorkgroupSizei(i32) | ||
declare spir_func i64 @_Z25__spirv_BuiltInGlobalSizei(i32) | ||
declare spir_func i64 @_Z26__spirv_BuiltInWorkgroupIdi(i32) | ||
declare spir_func i64 @_Z36__spirv_BuiltInEnqueuedWorkgroupSizei(i32) | ||
declare spir_func i64 @_Z28__spirv_BuiltInNumWorkgroupsi(i32) | ||
declare spir_func i64 @_Z27__spirv_BuiltInGlobalOffseti(i32) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.