1// RUN: %clang_cc1 -emit-llvm -o - -triple x86_64-darwin-apple %s | FileCheck %s
2
3#pragma OPENCL EXTENSION cl_khr_fp16 : enable
4
5// CHECK-LABEL: define{{.*}} void @test_half_builtins
6void test_half_builtins(half h0, half h1, half h2) {
7  volatile half res;
8
9  // CHECK: call half @llvm.copysign.f16(half %h0, half %h1)
10  res = __builtin_copysignf16(h0, h1);
11
12  // CHECK: call half @llvm.fabs.f16(half %h0)
13  res = __builtin_fabsf16(h0);
14
15  // CHECK: call half @llvm.ceil.f16(half %h0)
16  res = __builtin_ceilf16(h0);
17
18  // CHECK: call half @llvm.cos.f16(half %h0)
19  res = __builtin_cosf16(h0);
20
21  // CHECK: call half @llvm.exp.f16(half %h0)
22  res = __builtin_expf16(h0);
23
24  // CHECK: call half @llvm.exp2.f16(half %h0)
25  res = __builtin_exp2f16(h0);
26
27  // CHECK: call half @llvm.floor.f16(half %h0)
28  res = __builtin_floorf16(h0);
29
30  // CHECK: call half @llvm.fma.f16(half %h0, half %h1, half %h2)
31  res = __builtin_fmaf16(h0, h1 ,h2);
32
33  // CHECK: call half @llvm.maxnum.f16(half %h0, half %h1)
34  res = __builtin_fmaxf16(h0, h1);
35
36  // CHECK: call half @llvm.minnum.f16(half %h0, half %h1)
37  res = __builtin_fminf16(h0, h1);
38
39  // CHECK: frem half %h0, %h1
40  res = __builtin_fmodf16(h0, h1);
41
42  // CHECK: call half @llvm.pow.f16(half %h0, half %h1)
43  res = __builtin_powf16(h0, h1);
44
45  // CHECK: call half @llvm.log10.f16(half %h0)
46  res = __builtin_log10f16(h0);
47
48  // CHECK: call half @llvm.log2.f16(half %h0)
49  res = __builtin_log2f16(h0);
50
51  // CHECK: call half @llvm.log.f16(half %h0)
52  res = __builtin_logf16(h0);
53
54  // CHECK: call half @llvm.rint.f16(half %h0)
55  res = __builtin_rintf16(h0);
56
57  // CHECK: call half @llvm.round.f16(half %h0)
58  res = __builtin_roundf16(h0);
59
60  // CHECK: call half @llvm.sin.f16(half %h0)
61  res = __builtin_sinf16(h0);
62
63  // CHECK: call half @llvm.sqrt.f16(half %h0)
64  res = __builtin_sqrtf16(h0);
65
66  // CHECK: call half @llvm.trunc.f16(half %h0)
67  res = __builtin_truncf16(h0);
68
69  // CHECK: call half @llvm.canonicalize.f16(half %h0)
70  res = __builtin_canonicalizef16(h0);
71}
72