File: ConvertPtr.cl

package info (click to toggle)
spirv-llvm-translator-14 14.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,640 kB
  • sloc: cpp: 47,664; lisp: 3,704; sh: 153; python: 43; makefile: 33
file content (27 lines) | stat: -rw-r--r-- 931 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc
// RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
// RUN: llvm-spirv %t.bc -o %t.spv
// RUN: spirv-val %t.spv
// RUN: llvm-spirv -r %t.spv -o %t.rev.bc
// RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM

kernel void testConvertPtrToU(global int *a, global unsigned long *res) {
  res[0] = (unsigned long)&a[0];
}

// CHECK-SPIRV: 4 ConvertPtrToU

// CHECK-LLVM-LABEL: @testConvertPtrToU
// CHECK-LLVM: %0 = ptrtoint i32 addrspace(1)* %a to i32
// CHECK-LLVM: zext i32 %0 to i64

kernel void testConvertUToPtr(unsigned long a) {
  global unsigned int *res = (global unsigned int *)a;
  res[0] = 0;
}

// CHECK-SPIRV: 4 ConvertUToPtr

// CHECK-LLVM-LABEL: @testConvertUToPtr
// CHECK-LLVM: %[[Conv:[a-z]+]] = trunc i64 %a to i32
// CHECK-LLVM: inttoptr i32 %[[Conv]] to i32 addrspace(1)*