| 1 |
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc |
| 2 |
// RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 3 |
// RUN: llvm-spirv %t.bc -o %t.spv |
| 4 |
// RUN: spirv-val %t.spv |
| 5 |
// RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc |
| 6 |
// RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 7 |
// RUN: llvm-spirv -r -emit-opaque-pointers --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc |
| 8 |
// RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR |
| 9 |
|
| 10 |
// CHECK-SPIRV: SatConvertSToU |
| 11 |
|
| 12 |
// CHECK-LLVM-LABEL: @testSToU |
| 13 |
// CHECK-LLVM: call spir_func <2 x i8> @_Z18convert_uchar2_satDv2_i( |
| 14 |
|
| 15 |
// CHECK-SPV-IR-LABEL: @testSToU |
| 16 |
// CHECK-SPV-IR: call spir_func <2 x i8> @_Z30__spirv_SatConvertSToU_Ruchar2Dv2_i( |
| 17 |
|
| 18 |
kernel void testSToU(global int2 *a, global uchar2 *res) { |
| 19 |
res[0] = convert_uchar2_sat(*a); |
| 20 |
} |
| 21 |
|
| 22 |
// CHECK-SPIRV: SatConvertUToS |
| 23 |
|
| 24 |
// CHECK-LLVM-LABEL: @testUToS |
| 25 |
// CHECK-LLVM: call spir_func <2 x i8> @_Z17convert_char2_satDv2_j( |
| 26 |
|
| 27 |
// CHECK-SPV-IR-LABEL: @testUToS |
| 28 |
// CHECK-SPV-IR: call spir_func <2 x i8> @_Z29__spirv_SatConvertUToS_Rchar2Dv2_j( |
| 29 |
kernel void testUToS(global uint2 *a, global char2 *res) { |
| 30 |
res[0] = convert_char2_sat(*a); |
| 31 |
} |
| 32 |
|
| 33 |
// CHECK-SPIRV: ConvertUToF |
| 34 |
|
| 35 |
// CHECK-LLVM-LABEL: @testUToF |
| 36 |
// CHECK-LLVM: call spir_func <2 x float> @_Z18convert_float2_rtzDv2_j( |
| 37 |
|
| 38 |
// CHECK-SPV-IR-LABEL: @testUToF |
| 39 |
// CHECK-SPV-IR: call spir_func <2 x float> @_Z31__spirv_ConvertUToF_Rfloat2_rtzDv2_j( |
| 40 |
kernel void testUToF(global uint2 *a, global float2 *res) { |
| 41 |
res[0] = convert_float2_rtz(*a); |
| 42 |
} |
| 43 |
|
| 44 |
// CHECK-SPIRV: ConvertFToU |
| 45 |
|
| 46 |
// CHECK-LLVM-LABEL: @testFToUSat |
| 47 |
// CHECK-LLVM: call spir_func <2 x i32> @_Z21convert_uint2_sat_rtnDv2_f( |
| 48 |
|
| 49 |
// CHECK-SPV-IR-LABEL: @testFToUSat |
| 50 |
// CHECK-SPV-IR: call spir_func <2 x i32> @_Z34__spirv_ConvertFToU_Ruint2_sat_rtnDv2_f( |
| 51 |
kernel void testFToUSat(global float2 *a, global uint2 *res) { |
| 52 |
res[0] = convert_uint2_sat_rtn(*a); |
| 53 |
} |
| 54 |
|
| 55 |
// CHECK-SPIRV: UConvert |
| 56 |
|
| 57 |
// CHECK-LLVM-LABEL: @testUToUSat |
| 58 |
// CHECK-LLVM: call spir_func i32 @_Z16convert_uint_sath( |
| 59 |
|
| 60 |
// CHECK-SPV-IR-LABEL: @testUToUSat |
| 61 |
// CHECK-SPV-IR: call spir_func i32 @_Z26__spirv_UConvert_Ruint_sath( |
| 62 |
kernel void testUToUSat(global uchar *a, global uint *res) { |
| 63 |
res[0] = convert_uint_sat(*a); |
| 64 |
} |
| 65 |
|
| 66 |
// CHECK-SPIRV: UConvert |
| 67 |
|
| 68 |
// CHECK-LLVM-LABEL: @testUToUSat1 |
| 69 |
// CHECK-LLVM: call spir_func i8 @_Z17convert_uchar_satj( |
| 70 |
|
| 71 |
// CHECK-SPV-IR-LABEL: @testUToUSat1 |
| 72 |
// CHECK-SPV-IR: call spir_func i8 @_Z27__spirv_UConvert_Ruchar_satj( |
| 73 |
kernel void testUToUSat1(global uint *a, global uchar *res) { |
| 74 |
res[0] = convert_uchar_sat(*a); |
| 75 |
} |
| 76 |
|
| 77 |
// CHECK-SPIRV: ConvertFToU |
| 78 |
|
| 79 |
// CHECK-LLVM-LABEL: @testFToU |
| 80 |
// CHECK-LLVM: call spir_func <3 x i32> @_Z17convert_uint3_rtpDv3_f( |
| 81 |
|
| 82 |
// CHECK-SPV-IR-LABEL: @testFToU |
| 83 |
// CHECK-SPV-IR: call spir_func <3 x i32> @_Z30__spirv_ConvertFToU_Ruint3_rtpDv3_f( |
| 84 |
kernel void testFToU(global float3 *a, global uint3 *res) { |
| 85 |
res[0] = convert_uint3_rtp(*a); |
| 86 |
} |