forked from KhronosGroup/SPIRV-LLVM-Translator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport to 15] add reverse translation for OpDecorateString and OpM…
…emberDecorateString (KhronosGroup#2677) This PR adds "reverse translation" (from SPIR-V to LLVM IR) support for OpDecorateString and OpMemberDecorateString, see KhronosGroup#2460 and KhronosGroup#2670. These instructions are currently treated as synonyms for OpDecorate and OpMemberDecorate. We'll want to tidy this up at some point, but at least for now we won't crash if we see these instructions. I'll still need to add proper support for decorating variables in the input storage class for KhronosGroup#2670, but I'll do that in a separate PR. (cherry picked from commit f7057b4)
- Loading branch information
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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,33 @@ | ||
; REQUIRES: spirv-as | ||
; RUN: spirv-as --target-env spv1.4 -o %t.spv %s | ||
; RUN: spirv-val %t.spv | ||
; RUN: llvm-spirv -emit-opaque-pointers -r -o - %t.spv | llvm-dis -opaque-pointers | FileCheck %s | ||
|
||
; SPIR-V | ||
; Version: 1.4 | ||
; Generator: Khronos LLVM/SPIR-V Translator; 14 | ||
; Bound: 40 | ||
; Schema: 0 | ||
OpCapability Addresses | ||
OpCapability Linkage | ||
OpCapability Kernel | ||
OpMemoryModel Physical64 OpenCL | ||
OpEntryPoint Kernel %kernel "test" | ||
; Note: this is decorating a variable in the function storage class, which | ||
; is not actually valid according to the SPIR-V spec, but is processed by | ||
; the SPIR-V LLVM Translator and not rejected by spirv-val. | ||
OpDecorateString %temp UserSemantic "foo" | ||
; CHECK: [[STR:@[0-9_.]+]] = {{.*}}foo | ||
; CHECK: call void @llvm.var.annotation(ptr %{{.*}}, ptr [[STR]], ptr undef, i32 undef, ptr undef) | ||
%uint = OpTypeInt 32 0 | ||
%void = OpTypeVoid | ||
%kernel_sig = OpTypeFunction %void %uint | ||
%ptr_uint = OpTypePointer Function %uint | ||
%kernel = OpFunction %void None %kernel_sig | ||
%a = OpFunctionParameter %uint | ||
%entry = OpLabel | ||
%temp = OpVariable %ptr_uint Function | ||
%add = OpIAdd %uint %a %a | ||
OpStore %temp %add Aligned 4 | ||
OpReturn | ||
OpFunctionEnd |
This file contains 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 @@ | ||
; REQUIRES: spirv-as | ||
; RUN: spirv-as --target-env spv1.4 -o %t.spv %s | ||
; RUN: spirv-val %t.spv | ||
; RUN: llvm-spirv -emit-opaque-pointers -r -o - %t.spv | llvm-dis | FileCheck %s | ||
|
||
; SPIR-V | ||
; Version: 1.4 | ||
; Generator: Khronos LLVM/SPIR-V Translator; 14 | ||
; Bound: 44 | ||
; Schema: 0 | ||
OpCapability Addresses | ||
OpCapability Linkage | ||
OpCapability Kernel | ||
OpCapability Int64 | ||
OpMemoryModel Physical64 OpenCL | ||
OpEntryPoint Kernel %kernel "test" | ||
OpMemberDecorateString %struct 0 UserSemantic "foo" | ||
; CHECK: [[STR:@[0-9_.]+]] = {{.*}}foo | ||
; Note: this is checking for an annotation on an instantiation of the structure, | ||
; which is different than an annotation on the structure type. | ||
; CHECK: call ptr @llvm.ptr.annotation.p0(ptr %{{.*}}, ptr [[STR]], ptr undef, i32 undef, ptr undef) | ||
%uint = OpTypeInt 32 0 | ||
%uint_0 = OpConstant %uint 0 | ||
%void = OpTypeVoid | ||
%kernel_sig = OpTypeFunction %void %uint | ||
%struct = OpTypeStruct %uint | ||
%ptr_struct = OpTypePointer Function %struct | ||
%ptr_uint = OpTypePointer Function %uint | ||
%kernel = OpFunction %void None %kernel_sig | ||
%a = OpFunctionParameter %uint | ||
%entry = OpLabel | ||
%s = OpVariable %ptr_struct Function | ||
%add = OpIAdd %uint %a %a | ||
%x = OpInBoundsPtrAccessChain %ptr_uint %s %uint_0 %uint_0 | ||
OpStore %x %add Aligned 4 | ||
OpReturn | ||
OpFunctionEnd |