| 1 |
; REQUIRES: spirv-as |
| 2 |
; RUN: spirv-as --target-env spv1.0 -o %t.spv %s |
| 3 |
; RUN: spirv-val %t.spv |
| 4 |
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 5 |
; RUN: llvm-dis %t.rev.bc |
| 6 |
; RUN: FileCheck < %t.rev.ll %s |
| 7 |
|
| 8 |
; CHECK: define spir_func [4 x i8] @non_constant_array_elements(i8 %[[#ARG0:]], i8 %[[#ARG1:]]) |
| 9 |
; CHECK: %[[#ArrayPtr:]] = alloca [4 x i8] |
| 10 |
; CHECK: %[[GEP:[0-9a-z.]+]] = getelementptr inbounds [4 x i8], ptr %[[#ArrayPtr]], i32 0, i32 0 |
| 11 |
; CHECK: store i8 %[[#ARG1]], ptr %[[GEP]] |
| 12 |
; CHECK: %[[GEP1:[0-9a-z.]+]] = getelementptr inbounds [4 x i8], ptr %[[#ArrayPtr]], i32 0, i32 1 |
| 13 |
; CHECK: store i8 %[[#ARG0]], ptr %[[GEP1]] |
| 14 |
; CHECK: %[[GEP2:[0-9a-z.]+]] = getelementptr inbounds [4 x i8], ptr %[[#ArrayPtr]], i32 0, i32 2 |
| 15 |
; CHECK: store i8 0, ptr %[[GEP2]] |
| 16 |
; CHECK: %[[GEP3:[0-9a-z.]+]] = getelementptr inbounds [4 x i8], ptr %[[#ArrayPtr]], i32 0, i32 3 |
| 17 |
; CHECK: store i8 10, ptr %[[GEP3]] |
| 18 |
|
| 19 |
; CHECK: %[[LoadArr:[0-9a-z.]+]] = load [4 x i8], ptr %[[#ArrayPtr]] |
| 20 |
; CHECK: ret [4 x i8] %[[LoadArr]] |
| 21 |
|
| 22 |
; SPIR-V |
| 23 |
; Version: 1.0 |
| 24 |
; Generator: Khronos LLVM/SPIR-V Translator; 14 |
| 25 |
; Bound: 23 |
| 26 |
; Schema: 0 |
| 27 |
OpCapability Addresses |
| 28 |
OpCapability Linkage |
| 29 |
OpCapability Kernel |
| 30 |
OpCapability Int8 |
| 31 |
%1 = OpExtInstImport "OpenCL.std" |
| 32 |
OpMemoryModel Physical64 OpenCL |
| 33 |
OpSource Unknown 0 |
| 34 |
OpName %_arr_uchar_uint_4 "arrtype" |
| 35 |
OpName %non_constant_array_elements "non_constant_array_elements" |
| 36 |
OpDecorate %non_constant_array_elements LinkageAttributes "non_constant_array_elements" Export |
| 37 |
%uchar = OpTypeInt 8 0 |
| 38 |
%uint = OpTypeInt 32 0 |
| 39 |
%uchar_10 = OpConstant %uchar 10 |
| 40 |
%uchar_0 = OpConstant %uchar 0 |
| 41 |
%uint_0 = OpConstant %uint 0 |
| 42 |
%uint_1 = OpConstant %uint 1 |
| 43 |
%uint_4 = OpConstant %uint 4 |
| 44 |
%_arr_uchar_uint_4 = OpTypeArray %uchar %uint_4 |
| 45 |
%5 = OpTypeFunction %_arr_uchar_uint_4 %uchar %uchar |
| 46 |
%_ptr_Function_uint = OpTypePointer Function %uint |
| 47 |
%non_constant_array_elements = OpFunction %_arr_uchar_uint_4 None %5 |
| 48 |
%484 = OpFunctionParameter %uchar |
| 49 |
%485 = OpFunctionParameter %uchar |
| 50 |
%7 = OpLabel |
| 51 |
%14 = OpCompositeConstruct %_arr_uchar_uint_4 %485 %484 %uchar_0 %uchar_10 |
| 52 |
OpReturnValue %14 |
| 53 |
OpFunctionEnd |