Skip to content

Commit 502b3bf

Browse files
committed
[AMDGPU] require s-memtime-inst for __builtin_amdgcn_s_memtime
Differential Revision: https://reviews.llvm.org/D97420
1 parent 6103b6a commit 502b3bf

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ BUILTIN(__builtin_amdgcn_grid_size_z, "Ui", "nc")
4444
BUILTIN(__builtin_amdgcn_mbcnt_hi, "UiUiUi", "nc")
4545
BUILTIN(__builtin_amdgcn_mbcnt_lo, "UiUiUi", "nc")
4646

47+
TARGET_BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n", "s-memtime-inst")
48+
4749
//===----------------------------------------------------------------------===//
4850
// Instruction builtins.
4951
//===----------------------------------------------------------------------===//
@@ -105,7 +107,6 @@ BUILTIN(__builtin_amdgcn_cubeid, "ffff", "nc")
105107
BUILTIN(__builtin_amdgcn_cubesc, "ffff", "nc")
106108
BUILTIN(__builtin_amdgcn_cubetc, "ffff", "nc")
107109
BUILTIN(__builtin_amdgcn_cubema, "ffff", "nc")
108-
BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n")
109110
BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
110111
BUILTIN(__builtin_amdgcn_s_incperflevel, "vIi", "n")
111112
BUILTIN(__builtin_amdgcn_s_decperflevel, "vIi", "n")

clang/test/CodeGenOpenCL/builtins-amdgcn-ci.cl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S -emit-llvm -o - %s | FileCheck %s
66

77
typedef unsigned int uint;
8+
typedef unsigned long ulong;
89

910
// CHECK-LABEL: @test_s_dcache_inv_vol
1011
// CHECK: call void @llvm.amdgcn.s.dcache.inv.vol(
@@ -27,6 +28,13 @@ void test_gws_sema_release_all(uint id)
2728
__builtin_amdgcn_ds_gws_sema_release_all(id);
2829
}
2930

31+
// CHECK-LABEL: @test_s_memtime
32+
// CHECK: call i64 @llvm.amdgcn.s.memtime()
33+
void test_s_memtime(global ulong* out)
34+
{
35+
*out = __builtin_amdgcn_s_memtime();
36+
}
37+
3038
// CHECK-LABEL: @test_is_shared(
3139
// CHECK: [[CAST:%[0-9]+]] = bitcast i32* %{{[0-9]+}} to i8*
3240
// CHECK: call i1 @llvm.amdgcn.is.shared(i8* [[CAST]]

clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1012 -S -emit-llvm -o - %s | FileCheck %s
55

66
typedef unsigned int uint;
7+
typedef unsigned long ulong;
78

89
// CHECK-LABEL: @test_permlane16(
910
// CHECK: call i32 @llvm.amdgcn.permlane16(i32 %a, i32 %b, i32 %c, i32 %d, i1 false, i1 false)
@@ -22,3 +23,10 @@ void test_permlanex16(global uint* out, uint a, uint b, uint c, uint d) {
2223
void test_mov_dpp8(global uint* out, uint a) {
2324
*out = __builtin_amdgcn_mov_dpp8(a, 1);
2425
}
26+
27+
// CHECK-LABEL: @test_s_memtime
28+
// CHECK: call i64 @llvm.amdgcn.s.memtime()
29+
void test_s_memtime(global ulong* out)
30+
{
31+
*out = __builtin_amdgcn_s_memtime();
32+
}

clang/test/CodeGenOpenCL/builtins-amdgcn-gfx9.cl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -S -emit-llvm -o - %s | FileCheck %s
44

55
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
6+
typedef unsigned long ulong;
67

78
// CHECK-LABEL: @test_fmed3_f16
89
// CHECK: call half @llvm.amdgcn.fmed3.f16(half %a, half %b, half %c)
910
void test_fmed3_f16(global half* out, half a, half b, half c)
1011
{
1112
*out = __builtin_amdgcn_fmed3h(a, b, c);
1213
}
14+
15+
// CHECK-LABEL: @test_s_memtime
16+
// CHECK: call i64 @llvm.amdgcn.s.memtime()
17+
void test_s_memtime(global ulong* out)
18+
{
19+
*out = __builtin_amdgcn_s_memtime();
20+
}

clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,10 @@ void test_ds_fminf(local float *out, float src) {
130130
void test_ds_fmaxf(local float *out, float src) {
131131
*out = __builtin_amdgcn_ds_fmaxf(out, src, 0, 0, false);
132132
}
133+
134+
// CHECK-LABEL: @test_s_memtime
135+
// CHECK: call i64 @llvm.amdgcn.s.memtime()
136+
void test_s_memtime(global ulong* out)
137+
{
138+
*out = __builtin_amdgcn_s_memtime();
139+
}

clang/test/CodeGenOpenCL/builtins-amdgcn.cl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,6 @@ void test_wave_barrier()
396396
__builtin_amdgcn_wave_barrier();
397397
}
398398

399-
// CHECK-LABEL: @test_s_memtime
400-
// CHECK: call i64 @llvm.amdgcn.s.memtime()
401-
void test_s_memtime(global ulong* out)
402-
{
403-
*out = __builtin_amdgcn_s_memtime();
404-
}
405-
406399
// CHECK-LABEL: @test_s_sleep
407400
// CHECK: call void @llvm.amdgcn.s.sleep(i32 1)
408401
// CHECK: call void @llvm.amdgcn.s.sleep(i32 15)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// REQUIRES: amdgpu-registered-target
2+
// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx1030 -verify -S -o - %s
3+
4+
void test_gfx1030_s_memtime()
5+
{
6+
__builtin_amdgcn_s_memtime(); // expected-error {{'__builtin_amdgcn_s_memtime' needs target feature s-memtime-inst}}
7+
}

0 commit comments

Comments
 (0)