-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SPIRV] Porting 4 tests from Translator #151678
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 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0b48528
Porting 4 tests from Translator that checks:
EbinJose2002 23f9283
Update llvm/test/CodeGen/SPIRV/GlobalVarAddrspace.ll
EbinJose2002 ea3b941
Update llvm/test/CodeGen/SPIRV/align-duplicate.ll
EbinJose2002 3fd969a
Update llvm/test/CodeGen/SPIRV/duplicate-types.ll
EbinJose2002 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| ; This test case checks that LLVM -> SPIR-V translation produces valid | ||
| ; SPIR-V module, where a global variable, defined with non-default | ||
| ; address space, have correct non-function storage class. | ||
| ; | ||
| ; No additional checks are needed in addition to simple translation | ||
| ; to SPIR-V. In case of an error newly produced SPIR-V module validation | ||
| ; would fail due to spirv-val that detects problematic SPIR-V code from | ||
| ; translator and reports it as the following error: | ||
| ; | ||
| ; "Variables can not have a function[7] storage class outside of a function". | ||
| ; | ||
| ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK: %[[#Ptr:]] = OpTypePointer CrossWorkgroup %[[#]] | ||
| ; CHECK: %[[#]] = OpVariable %[[#Ptr]] CrossWorkgroup %[[#]] | ||
|
|
||
| @G = addrspace(1) global i1 true | ||
|
|
||
| define spir_func i1 @f(i1 %0) { | ||
| store i1 %0, ptr addrspace(1) @G, align 1 | ||
| ret i1 %0 | ||
| } | ||
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,37 @@ | ||
| ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s | ||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ;CHECK: OpEntryPoint Kernel %[[#KernelId:]] | ||
| ;CHECK: %[[#image2d_t:]] = OpTypeImage | ||
| ;CHECK: %[[#sampler_t:]] = OpTypeSampler | ||
| ;CHECK: %[[#sampled_image_t:]] = OpTypeSampledImage | ||
|
|
||
| define spir_func float @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp) { | ||
| ;CHECK-NOT: %[[#KernelId]] = OpFunction %[[#]] | ||
| ;CHECK: OpFunction | ||
| ;CHECK: %[[#image:]] = OpFunctionParameter %[[#image2d_t]] | ||
| ;CHECK: %[[#sampler:]] = OpFunctionParameter %[[#sampler_t]] | ||
| entry: | ||
| %call = call spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp, <2 x i32> zeroinitializer) | ||
| ;CHECK: %[[#sampled_image:]] = OpSampledImage %[[#sampled_image_t]] %[[#image]] %[[#sampler]] | ||
| ;CHECK: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#sampled_image]] %[[#]] Lod %[[#]] | ||
|
|
||
| %0 = extractelement <4 x i32> %call, i32 0 | ||
| %conv = sitofp i32 %0 to float | ||
| ret float %conv | ||
| } | ||
|
|
||
| declare spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), i32, <2 x i32>) | ||
|
|
||
| define spir_kernel void @test2(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp, ptr addrspace(1) %result) { | ||
| ;CHECK: %[[#KernelId]] = OpFunction %[[#]] | ||
| entry: | ||
| %call = call spir_func float @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, target("spirv.Sampler") %Smp) | ||
| %0 = load float, ptr addrspace(1) %result, align 4 | ||
| %add = fadd float %0, %call | ||
| store float %add, ptr addrspace(1) %result, align 4 | ||
| ret void | ||
| } |
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,16 @@ | ||
| ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | ||
EbinJose2002 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; Test that duplicate align information does not result in SPIR-V validation | ||
| ; errors due to duplicate Alignment Decorations. | ||
|
|
||
| ;CHECK: OpDecorate %[[#Var:]] Alignment | ||
| ;CHECK: %[[#Var]] = OpVariable %[[#]] | ||
|
|
||
| define spir_func void @f() { | ||
| %res = alloca i16, align 2, !spirv.Decorations !1 | ||
| ret void | ||
| } | ||
|
|
||
| !1 = !{!2} | ||
| !2 = !{i32 44, i32 2} | ||
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,16 @@ | ||
| ; Check that we don't end up with duplicated array types in TypeMap. | ||
| ; No FileCheck needed, we only want to check the absence of errors. | ||
| ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | ||
EbinJose2002 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK: %[[#]] = OpTypeArray %[[#]] %[[#]] | ||
| ; CHECK-NOT: OpTypeArray | ||
|
|
||
| %duplicate = type { [2 x ptr addrspace(4)] } | ||
|
|
||
| define spir_kernel void @foo() { | ||
| entry: | ||
| alloca [2 x ptr addrspace(4)], align 8 | ||
| alloca %duplicate, align 8 | ||
| ret void | ||
| } | ||
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.