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.
SPIRVReader: Add OpCopyMemory support
Add support for translating `OpCopyMemory` into `llvm.memcpy`. Fixes KhronosGroup#2769
- Loading branch information
Showing
2 changed files
with
71 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; Check SPIRVReader support for OpCopyMemory. | ||
|
||
; 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 -o - | FileCheck %s | ||
|
||
OpCapability Addresses | ||
OpCapability Int16 | ||
OpCapability Kernel | ||
OpMemoryModel Physical64 OpenCL | ||
OpEntryPoint Kernel %kernel "copymemory" | ||
OpName %pShort "pShort" | ||
OpName %dstShort "dstShort" | ||
OpName %pInt "pInt" | ||
OpName %dstInt "dstInt" | ||
%ushort = OpTypeInt 16 0 | ||
%uint = OpTypeInt 32 0 | ||
%void = OpTypeVoid | ||
%gptr_short = OpTypePointer CrossWorkgroup %ushort | ||
%pptr_short = OpTypePointer Function %ushort | ||
%gptr_int = OpTypePointer CrossWorkgroup %uint | ||
%pptr_int = OpTypePointer Function %uint | ||
%kernel_sig = OpTypeFunction %void %gptr_short %gptr_int | ||
%ushort_42 = OpConstant %ushort 42 | ||
%uint_4242 = OpConstant %uint 4242 | ||
%kernel = OpFunction %void None %kernel_sig | ||
%dstShort = OpFunctionParameter %gptr_short | ||
%dstInt = OpFunctionParameter %gptr_int | ||
%entry = OpLabel | ||
%pShort = OpVariable %pptr_short Function %ushort_42 | ||
%pInt = OpVariable %pptr_int Function %uint_4242 | ||
OpCopyMemory %dstShort %pShort | ||
OpCopyMemory %dstInt %pInt | ||
OpReturn | ||
OpFunctionEnd | ||
|
||
; CHECK-LABEL: define spir_kernel void @copymemory(ptr addrspace(1) %dstShort, ptr addrspace(1) %dstInt) | ||
; CHECK: call void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) %dstShort, ptr @pShort, i64 ptrtoint (ptr getelementptr (i16, ptr null, i32 1) to i64), i1 false) | ||
; CHECK: call void @llvm.memcpy.p1.p0.i64(ptr addrspace(1) %dstInt, ptr @pInt, i64 ptrtoint (ptr getelementptr (i32, ptr null, i32 1) to i64), i1 false) |