blob: fc139d776db6efd8ea63301dc8f259597f06d8a4 [file] [log] [blame]
Matt Arsenaultaf07de42018-12-01 21:56:10 +00001// RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-+cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=FP64,ALL %s
2// RUN: %clang_cc1 -cl-std=CL1.2 -cl-ext=-cl_khr_fp64 -triple spir-unknown-unknown -disable-llvm-passes -emit-llvm -o - %s | FileCheck -check-prefixes=NOFP64,ALL %s
3
4typedef __attribute__((ext_vector_type(2))) float float2;
5typedef __attribute__((ext_vector_type(2))) half half2;
6
7#ifdef cl_khr_fp64
8typedef __attribute__((ext_vector_type(2))) double double2;
9#endif
10
11int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
12
13
14// ALL-LABEL: @test_printf_float2(
Matt Arsenault297afb12019-01-29 20:49:47 +000015// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
Matt Arsenaultaf07de42018-12-01 21:56:10 +000016
Matt Arsenault297afb12019-01-29 20:49:47 +000017
18// NOFP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([7 x i8], [7 x i8] addrspace(2)* @.str, i32 0, i32 0), <2 x float> %0)
Matt Arsenaultaf07de42018-12-01 21:56:10 +000019kernel void test_printf_float2(float2 arg) {
Matt Arsenault297afb12019-01-29 20:49:47 +000020 printf("%v2hlf", arg);
Matt Arsenaultaf07de42018-12-01 21:56:10 +000021}
22
23// ALL-LABEL: @test_printf_half2(
Matt Arsenault297afb12019-01-29 20:49:47 +000024// FP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.1, i32 0, i32 0), <2 x half> %0)
Matt Arsenaultaf07de42018-12-01 21:56:10 +000025
Matt Arsenault297afb12019-01-29 20:49:47 +000026// NOFP64: %call = call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.1, i32 0, i32 0), <2 x half> %0)
Matt Arsenaultaf07de42018-12-01 21:56:10 +000027kernel void test_printf_half2(half2 arg) {
Matt Arsenault297afb12019-01-29 20:49:47 +000028 printf("%v2hf", arg);
Matt Arsenaultaf07de42018-12-01 21:56:10 +000029}
30
31#ifdef cl_khr_fp64
32// FP64-LABEL: @test_printf_double2(
Matt Arsenault297afb12019-01-29 20:49:47 +000033// FP64: call spir_func i32 (i8 addrspace(2)*, ...) @printf(i8 addrspace(2)* getelementptr inbounds ([6 x i8], [6 x i8] addrspace(2)* @.str.2, i32 0, i32 0), <2 x double> %0)
Matt Arsenaultaf07de42018-12-01 21:56:10 +000034kernel void test_printf_double2(double2 arg) {
Matt Arsenault297afb12019-01-29 20:49:47 +000035 printf("%v2lf", arg);
Matt Arsenaultaf07de42018-12-01 21:56:10 +000036}
37#endif