-
Notifications
You must be signed in to change notification settings - Fork 266
handle OpBitcast between pointers and non-pointers #2948
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
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2722a40
handle bitcasts between pointers and scalar integers
bashbaug 2decbf4
handle bitcasts between pointers and vectors of 32-bit integers
bashbaug 145a964
fix formatting
bashbaug 2a725d2
handle more vector types
bashbaug f88150f
remove unused type from OpBitcast_ptr_vector test
bashbaug 91fa4c2
describe the difference between the SPIR-V and LLVM bitcast
bashbaug 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ; Check support of OpBitcast with pointer operands | ||
| ; Converts to scalar integers, which is supported by all SPIR-V versions | ||
|
|
||
| ; REQUIRES: spirv-as | ||
| ; RUN: spirv-as --target-env spv1.0 -o %t.spv %s | ||
| ; RUN: spirv-val %t.spv | ||
| ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc | ||
| ; RUN: llvm-dis %t.rev.bc | ||
| ; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM | ||
| OpCapability Addresses | ||
| OpCapability Kernel | ||
| OpCapability Int64 | ||
| OpMemoryModel Physical64 OpenCL | ||
| OpEntryPoint Kernel %kernel "test" | ||
| %uint = OpTypeInt 32 0 | ||
| %ulong = OpTypeInt 64 0 | ||
| %void = OpTypeVoid | ||
| %pptr_int = OpTypePointer Function %uint | ||
| %kernel_sig = OpTypeFunction %void | ||
| %kernel = OpFunction %void None %kernel_sig | ||
| %entry = OpLabel | ||
| %srcptr = OpVariable %pptr_int Function | ||
| %dstint = OpBitcast %ulong %srcptr | ||
| %dstptr = OpBitcast %pptr_int %dstint | ||
| OpReturn | ||
| OpFunctionEnd | ||
|
|
||
|
|
||
| ; CHECK-LLVM: [[SRCPTR:%[a-z0-9.]+]] = alloca i32, align 4 | ||
| ; CHECK-LLVM: [[DSTINT:%[a-z0-9.]+]] = ptrtoint ptr [[SRCPTR]] to i64 | ||
| ; CHECK-LLVM: [[DSTPTR:%[a-z0-9.]+]] = inttoptr i64 [[DSTINT]] to ptr |
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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| ; Check support of OpBitcast with pointer operands | ||
| ; Converts to vectors of integers, which is supported by SPIR-V 1.5 | ||
|
|
||
| ; REQUIRES: spirv-as | ||
| ; RUN: spirv-as --target-env spv1.5 -o %t.spv %s | ||
| ; RUN: spirv-val %t.spv | ||
| ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc | ||
| ; RUN: llvm-dis %t.rev.bc | ||
| ; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM | ||
| OpCapability Addresses | ||
| OpCapability Kernel | ||
| OpCapability Int64 | ||
| OpMemoryModel Physical64 OpenCL | ||
| OpEntryPoint Kernel %kernel "test" | ||
| %uint = OpTypeInt 32 0 | ||
| %ulong = OpTypeInt 64 0 | ||
|
svenvh marked this conversation as resolved.
Outdated
|
||
| %uint2 = OpTypeVector %uint 2 | ||
| %void = OpTypeVoid | ||
| %pptr_int = OpTypePointer Function %uint | ||
| %kernel_sig = OpTypeFunction %void | ||
| %kernel = OpFunction %void None %kernel_sig | ||
| %entry = OpLabel | ||
| %srcptr = OpVariable %pptr_int Function | ||
| %dstint2 = OpBitcast %uint2 %srcptr | ||
| %dstptr = OpBitcast %pptr_int %dstint2 | ||
| OpReturn | ||
| OpFunctionEnd | ||
|
|
||
|
|
||
| ; CHECK-LLVM: [[SRCPTR:%[a-z0-9.]+]] = alloca i32, align 4 | ||
| ; CHECK-LLVM: [[TMPLONG0:%[a-z0-9.]+]] = ptrtoint ptr [[SRCPTR]] to i64 | ||
| ; CHECK-LLVM: [[DSTINT2:%[a-z0-9.]+]] = bitcast i64 [[TMPLONG0]] to <2 x i32> | ||
| ; CHECK-LLVM: [[TMPLONG1:%[a-z0-9.]+]] = bitcast <2 x i32> [[DSTINT2]] to i64 | ||
| ; CHECK-LLVM: [[DSTPTR:%[a-z0-9.]+]] = inttoptr i64 [[TMPLONG1]] to ptr | ||
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.