1 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_70 \
2 // RUN: -fcuda-is-device -target-feature +ptx60 \
3 // RUN: -S -emit-llvm -o - -x cuda %s \
4 // RUN: | FileCheck -check-prefix=CHECK %s
5 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_80 \
6 // RUN: -fcuda-is-device -target-feature +ptx65 \
7 // RUN: -S -emit-llvm -o - -x cuda %s \
8 // RUN: | FileCheck -check-prefix=CHECK %s
9 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_80 \
10 // RUN: -fcuda-is-device -target-feature +ptx70 \
11 // RUN: -S -emit-llvm -o - -x cuda %s \
12 // RUN: | FileCheck -check-prefix=CHECK %s
13 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_70 \
14 // RUN: -fcuda-is-device -S -o /dev/null -x cuda -verify %s
16 #define __device__ __attribute__((device))
17 #define __global__ __attribute__((global))
18 #define __shared__ __attribute__((shared))
19 #define __constant__ __attribute__((constant))
21 typedef unsigned long long uint64_t;
23 // We have to keep all builtins that depend on particular target feature in the
24 // same function, because the codegen will stop after the very first function
25 // that encounters an error, so -verify will not be able to find errors in
26 // subsequent functions.
28 // CHECK-LABEL: nvvm_sync
29 __device__ void nvvm_sync(unsigned mask, int i, float f, int a, int b,
30 bool pred, uint64_t i64) {
32 // CHECK: call void @llvm.nvvm.bar.warp.sync(i32
33 // expected-error@+1 {{'__nvvm_bar_warp_sync' needs target feature ptx60}}
34 __nvvm_bar_warp_sync(mask);
35 // CHECK: call void @llvm.nvvm.barrier.sync(i32
36 // expected-error@+1 {{'__nvvm_barrier_sync' needs target feature ptx60}}
37 __nvvm_barrier_sync(mask);
38 // CHECK: call void @llvm.nvvm.barrier.sync.cnt(i32
39 // expected-error@+1 {{'__nvvm_barrier_sync_cnt' needs target feature ptx60}}
40 __nvvm_barrier_sync_cnt(mask, i);
45 // CHECK: call i32 @llvm.nvvm.shfl.sync.down.i32(i32 {{%[0-9]+}}, i32
46 // expected-error@+1 {{'__nvvm_shfl_sync_down_i32' needs target feature ptx60}}
47 __nvvm_shfl_sync_down_i32(mask, i, a, b);
48 // CHECK: call contract float @llvm.nvvm.shfl.sync.down.f32(i32 {{%[0-9]+}}, float
49 // expected-error@+1 {{'__nvvm_shfl_sync_down_f32' needs target feature ptx60}}
50 __nvvm_shfl_sync_down_f32(mask, f, a, b);
51 // CHECK: call i32 @llvm.nvvm.shfl.sync.up.i32(i32 {{%[0-9]+}}, i32
52 // expected-error@+1 {{'__nvvm_shfl_sync_up_i32' needs target feature ptx60}}
53 __nvvm_shfl_sync_up_i32(mask, i, a, b);
54 // CHECK: call contract float @llvm.nvvm.shfl.sync.up.f32(i32 {{%[0-9]+}}, float
55 // expected-error@+1 {{'__nvvm_shfl_sync_up_f32' needs target feature ptx60}}
56 __nvvm_shfl_sync_up_f32(mask, f, a, b);
57 // CHECK: call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 {{%[0-9]+}}, i32
58 // expected-error@+1 {{'__nvvm_shfl_sync_bfly_i32' needs target feature ptx60}}
59 __nvvm_shfl_sync_bfly_i32(mask, i, a, b);
60 // CHECK: call contract float @llvm.nvvm.shfl.sync.bfly.f32(i32 {{%[0-9]+}}, float
61 // expected-error@+1 {{'__nvvm_shfl_sync_bfly_f32' needs target feature ptx60}}
62 __nvvm_shfl_sync_bfly_f32(mask, f, a, b);
63 // CHECK: call i32 @llvm.nvvm.shfl.sync.idx.i32(i32 {{%[0-9]+}}, i32
64 // expected-error@+1 {{'__nvvm_shfl_sync_idx_i32' needs target feature ptx60}}
65 __nvvm_shfl_sync_idx_i32(mask, i, a, b);
66 // CHECK: call contract float @llvm.nvvm.shfl.sync.idx.f32(i32 {{%[0-9]+}}, float
67 // expected-error@+1 {{'__nvvm_shfl_sync_idx_f32' needs target feature ptx60}}
68 __nvvm_shfl_sync_idx_f32(mask, f, a, b);
74 // CHECK: call i1 @llvm.nvvm.vote.all.sync(i32
75 // expected-error@+1 {{'__nvvm_vote_all_sync' needs target feature ptx60}}
76 __nvvm_vote_all_sync(mask, pred);
77 // CHECK: call i1 @llvm.nvvm.vote.any.sync(i32
78 // expected-error@+1 {{'__nvvm_vote_any_sync' needs target feature ptx60}}
79 __nvvm_vote_any_sync(mask, pred);
80 // CHECK: call i1 @llvm.nvvm.vote.uni.sync(i32
81 // expected-error@+1 {{'__nvvm_vote_uni_sync' needs target feature ptx60}}
82 __nvvm_vote_uni_sync(mask, pred);
83 // CHECK: call i32 @llvm.nvvm.vote.ballot.sync(i32
84 // expected-error@+1 {{'__nvvm_vote_ballot_sync' needs target feature ptx60}}
85 __nvvm_vote_ballot_sync(mask, pred);
88 // MATCH.{ALL,ANY}.SYNC
91 // CHECK: call i32 @llvm.nvvm.match.any.sync.i32(i32
92 // expected-error-re@+1 {{'__nvvm_match_any_sync_i32' needs target feature (sm_70{{.*}}),(ptx60{{.*}})}}
93 __nvvm_match_any_sync_i32(mask, i);
94 // CHECK: call i32 @llvm.nvvm.match.any.sync.i64(i32
95 // expected-error-re@+1 {{'__nvvm_match_any_sync_i64' needs target feature (sm_70{{.*}}),(ptx60{{.*}})}}
96 __nvvm_match_any_sync_i64(mask, i64);
97 // CHECK: call { i32, i1 } @llvm.nvvm.match.all.sync.i32p(i32
98 // expected-error-re@+1 {{'__nvvm_match_all_sync_i32p' needs target feature (sm_70{{.*}}),(ptx60{{.*}})}}
99 __nvvm_match_all_sync_i32p(mask, i, &i);
100 // CHECK: call { i32, i1 } @llvm.nvvm.match.all.sync.i64p(i32
101 // expected-error-re@+1 {{'__nvvm_match_all_sync_i64p' needs target feature (sm_70{{.*}}),(ptx60{{.*}})}}
102 __nvvm_match_all_sync_i64p(mask, i64, &i);