[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Headers / openmp-device-functions-bool.c
blobbb010960278497ce7b606350efa69dec73d405ac
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
2 // RUN: %clang_cc1 -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -emit-llvm %s -fopenmp-is-target-device -o - | FileCheck %s --check-prefixes=CHECK,CHECK-C
3 // RUN: %clang_cc1 -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -emit-llvm %s -fopenmp-is-target-device -o - | FileCheck %s --check-prefixes=CHECK,CHECK-CPP
5 // Test that we did not include <stdbool.h> in C, and OCKL functions using bool
6 // produce an i1
8 #ifdef __cplusplus
9 typedef bool ockl_bool;
10 #define EXTERN_C extern "C"
11 #else
12 typedef _Bool ockl_bool;
13 #define EXTERN_C
14 #endif
16 #pragma omp begin declare target
18 // CHECK-LABEL: define hidden float @test_fdot2
19 // CHECK-SAME: (<2 x half> noundef [[A:%.*]], <2 x half> noundef [[B:%.*]], float noundef [[C:%.*]], i1 noundef zeroext [[S:%.*]]) #[[ATTR0:[0-9]+]] {
20 // CHECK-NEXT: entry:
21 // CHECK-NEXT: [[RETVAL:%.*]] = alloca float, align 4, addrspace(5)
22 // CHECK-NEXT: [[A_ADDR:%.*]] = alloca <2 x half>, align 4, addrspace(5)
23 // CHECK-NEXT: [[B_ADDR:%.*]] = alloca <2 x half>, align 4, addrspace(5)
24 // CHECK-NEXT: [[C_ADDR:%.*]] = alloca float, align 4, addrspace(5)
25 // CHECK-NEXT: [[S_ADDR:%.*]] = alloca i8, align 1, addrspace(5)
26 // CHECK-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
27 // CHECK-NEXT: [[A_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[A_ADDR]] to ptr
28 // CHECK-NEXT: [[B_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[B_ADDR]] to ptr
29 // CHECK-NEXT: [[C_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[C_ADDR]] to ptr
30 // CHECK-NEXT: [[S_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[S_ADDR]] to ptr
31 // CHECK-NEXT: store <2 x half> [[A]], ptr [[A_ADDR_ASCAST]], align 4
32 // CHECK-NEXT: store <2 x half> [[B]], ptr [[B_ADDR_ASCAST]], align 4
33 // CHECK-NEXT: store float [[C]], ptr [[C_ADDR_ASCAST]], align 4
34 // CHECK-NEXT: [[FROMBOOL:%.*]] = zext i1 [[S]] to i8
35 // CHECK-NEXT: store i8 [[FROMBOOL]], ptr [[S_ADDR_ASCAST]], align 1
36 // CHECK-NEXT: [[TMP0:%.*]] = load <2 x half>, ptr [[A_ADDR_ASCAST]], align 4
37 // CHECK-NEXT: [[TMP1:%.*]] = load <2 x half>, ptr [[B_ADDR_ASCAST]], align 4
38 // CHECK-NEXT: [[TMP2:%.*]] = load float, ptr [[C_ADDR_ASCAST]], align 4
39 // CHECK-NEXT: [[TMP3:%.*]] = load i8, ptr [[S_ADDR_ASCAST]], align 1
40 // CHECK-NEXT: [[TOBOOL:%.*]] = trunc i8 [[TMP3]] to i1
41 // CHECK-NEXT: [[CALL:%.*]] = call float @__ockl_fdot2(<2 x half> noundef [[TMP0]], <2 x half> noundef [[TMP1]], float noundef [[TMP2]], i1 noundef zeroext [[TOBOOL]]) #[[ATTR2:[0-9]+]]
42 // CHECK-NEXT: ret float [[CALL]]
44 EXTERN_C float test_fdot2(__2f16 a, __2f16 b, float c, ockl_bool s) {
45 return __ockl_fdot2(a, b, c, s);
49 #ifndef __cplusplus
51 enum my_bool {
52 false,
53 true
56 // CHECK-C-LABEL: define hidden i32 @use_my_bool
57 // CHECK-C-SAME: (i32 noundef [[B:%.*]]) #[[ATTR0]] {
58 // CHECK-C-NEXT: entry:
59 // CHECK-C-NEXT: [[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
60 // CHECK-C-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4, addrspace(5)
61 // CHECK-C-NEXT: [[T:%.*]] = alloca i32, align 4, addrspace(5)
62 // CHECK-C-NEXT: [[F:%.*]] = alloca i32, align 4, addrspace(5)
63 // CHECK-C-NEXT: [[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
64 // CHECK-C-NEXT: [[B_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[B_ADDR]] to ptr
65 // CHECK-C-NEXT: [[T_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[T]] to ptr
66 // CHECK-C-NEXT: [[F_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[F]] to ptr
67 // CHECK-C-NEXT: store i32 [[B]], ptr [[B_ADDR_ASCAST]], align 4
68 // CHECK-C-NEXT: store volatile i32 1, ptr [[T_ASCAST]], align 4
69 // CHECK-C-NEXT: store volatile i32 0, ptr [[F_ASCAST]], align 4
70 // CHECK-C-NEXT: [[TMP0:%.*]] = load i32, ptr [[B_ADDR_ASCAST]], align 4
71 // CHECK-C-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[TMP0]], 0
72 // CHECK-C-NEXT: [[LNOT:%.*]] = xor i1 [[TOBOOL]], true
73 // CHECK-C-NEXT: [[LNOT_EXT:%.*]] = zext i1 [[LNOT]] to i32
74 // CHECK-C-NEXT: ret i32 [[LNOT_EXT]]
76 enum my_bool use_my_bool(enum my_bool b) {
77 volatile enum my_bool t = true;
78 volatile enum my_bool f = false;
80 return !b;
83 #endif
87 #pragma omp end declare target
88 //// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
89 // CHECK-CPP: {{.*}}