Skip to content

Commit 5e908a0

Browse files
committed
Merge from 'main' to 'sycl-web' (58 commits)
CONFLICT (content): Merge conflict in clang/include/clang/Basic/BuiltinsAMDGPU.def
2 parents b974307 + 7f55d7d commit 5e908a0

File tree

258 files changed

+15189
-3391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+15189
-3391
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,5 +411,21 @@ TARGET_BUILTIN(__builtin_amdgcn_cvt_sr_fp8_f32, "ifiiIi", "nc", "fp8-insts")
411411
//===----------------------------------------------------------------------===//
412412
BUILTIN(__builtin_amdgcn_implicit_offset, "Ui*5", "nc")
413413

414+
//===----------------------------------------------------------------------===//
415+
// GFX12+ only builtins.
416+
//===----------------------------------------------------------------------===//
417+
418+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal, "vIi", "n", "gfx12-insts")
419+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_var, "vi", "n", "gfx12-insts")
420+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_wait, "vIs", "n", "gfx12-insts")
421+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_isfirst, "bIi", "n", "gfx12-insts")
422+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_signal_isfirst_var, "bi", "n", "gfx12-insts")
423+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_init, "vii", "n", "gfx12-insts")
424+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_join, "vi", "n", "gfx12-insts")
425+
TARGET_BUILTIN(__builtin_amdgcn_s_wakeup_barrier, "vi", "n", "gfx12-insts")
426+
TARGET_BUILTIN(__builtin_amdgcn_s_barrier_leave, "b", "n", "gfx12-insts")
427+
TARGET_BUILTIN(__builtin_amdgcn_s_get_barrier_state, "Uii", "n", "gfx12-insts")
428+
429+
414430
#undef BUILTIN
415431
#undef TARGET_BUILTIN

clang/lib/AST/Interp/Interp.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -350,11 +350,6 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
350350
}
351351

352352
if (!F->isConstexpr()) {
353-
// Don't emit anything if we're checking for a potential constant
354-
// expression. That will happen later when actually executing.
355-
if (S.checkingPotentialConstantExpression())
356-
return false;
357-
358353
const SourceLocation &Loc = S.Current->getLocation(OpPC);
359354
if (S.getLangOpts().CPlusPlus11) {
360355
const FunctionDecl *DiagDecl = F->getDecl();
@@ -371,13 +366,21 @@ bool CheckCallable(InterpState &S, CodePtr OpPC, const Function *F) {
371366
// FIXME: If DiagDecl is an implicitly-declared special member function
372367
// or an inheriting constructor, we should be much more explicit about why
373368
// it's not constexpr.
374-
if (CD && CD->isInheritingConstructor())
369+
if (CD && CD->isInheritingConstructor()) {
375370
S.FFDiag(Loc, diag::note_constexpr_invalid_inhctor, 1)
376371
<< CD->getInheritedConstructor().getConstructor()->getParent();
377-
else
372+
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
373+
} else {
374+
// Don't emit anything if the function isn't defined and we're checking
375+
// for a constant expression. It might be defined at the point we're
376+
// actually calling it.
377+
if (!DiagDecl->isDefined() && S.checkingPotentialConstantExpression())
378+
return false;
379+
378380
S.FFDiag(Loc, diag::note_constexpr_invalid_function, 1)
379381
<< DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
380-
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
382+
S.Note(DiagDecl->getLocation(), diag::note_declared_at);
383+
}
381384
} else {
382385
S.FFDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
383386
}

clang/lib/Headers/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
387387
clang_generate_header(-gen-arm-mve-header arm_mve.td arm_mve.h)
388388
# Generate arm_cde.h
389389
clang_generate_header(-gen-arm-cde-header arm_cde.td arm_cde.h)
390+
# Generate arm_vector_types.h
391+
clang_generate_header(-gen-arm-vector-type arm_neon.td arm_vector_types.h)
390392

391393
# Add headers to target specific lists
392394
list(APPEND arm_common_generated_files
@@ -403,6 +405,7 @@ if(ARM IN_LIST LLVM_TARGETS_TO_BUILD OR AArch64 IN_LIST LLVM_TARGETS_TO_BUILD)
403405
"${CMAKE_CURRENT_BINARY_DIR}/arm_sve.h"
404406
"${CMAKE_CURRENT_BINARY_DIR}/arm_sme_draft_spec_subject_to_change.h"
405407
"${CMAKE_CURRENT_BINARY_DIR}/arm_bf16.h"
408+
"${CMAKE_CURRENT_BINARY_DIR}/arm_vector_types.h"
406409
)
407410
endif()
408411
if(RISCV IN_LIST LLVM_TARGETS_TO_BUILD)

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15913,7 +15913,7 @@ Decl *Sema::ActOnSkippedFunctionBody(Decl *Decl) {
1591315913
}
1591415914

1591515915
Decl *Sema::ActOnFinishFunctionBody(Decl *D, Stmt *BodyArg) {
15916-
return ActOnFinishFunctionBody(D, BodyArg, false);
15916+
return ActOnFinishFunctionBody(D, BodyArg, /*IsInstantiation=*/false);
1591715917
}
1591815918

1591915919
/// RAII object that pops an ExpressionEvaluationContext when exiting a function

clang/lib/Sema/SemaType.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8447,12 +8447,25 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
84478447
// not to need a separate attribute)
84488448
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
84498449
S.Context.getTargetInfo().hasFeature("mve") ||
8450-
IsTargetCUDAAndHostARM)) {
8450+
S.Context.getTargetInfo().hasFeature("sve") ||
8451+
S.Context.getTargetInfo().hasFeature("sme") ||
8452+
IsTargetCUDAAndHostARM) &&
8453+
VecKind == VectorKind::Neon) {
8454+
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
8455+
<< Attr << "'neon', 'mve', 'sve' or 'sme'";
8456+
Attr.setInvalid();
8457+
return;
8458+
}
8459+
if (!(S.Context.getTargetInfo().hasFeature("neon") ||
8460+
S.Context.getTargetInfo().hasFeature("mve") ||
8461+
IsTargetCUDAAndHostARM) &&
8462+
VecKind == VectorKind::NeonPoly) {
84518463
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
84528464
<< Attr << "'neon' or 'mve'";
84538465
Attr.setInvalid();
84548466
return;
84558467
}
8468+
84568469
// Check the attribute arguments.
84578470
if (Attr.getNumArgs() != 1) {
84588471
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)

clang/test/AST/Interp/functions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,17 @@ namespace InvalidCall {
267267
// ref-error {{must be initialized by a constant expression}} \
268268
// ref-note {{in call to 'SS()'}}
269269

270+
271+
/// This should not emit a diagnostic.
272+
constexpr int f();
273+
constexpr int a() {
274+
return f();
275+
}
276+
constexpr int f() {
277+
return 5;
278+
}
279+
static_assert(a() == 5, "");
280+
270281
}
271282

272283
namespace CallWithArgs {
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3
2+
3+
// RUN: %clang_cc1 -DSVE_HEADER -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s
4+
// RUN: %clang_cc1 -DSVE_HEADER -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s
5+
6+
// RUN: %clang_cc1 -DNEON_HEADER -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s
7+
// RUN: %clang_cc1 -DNEON_HEADER -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s
8+
9+
// RUN: %clang_cc1 -DSVE_HEADER -DNEON_HEADER -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s
10+
// RUN: %clang_cc1 -DSVE_HEADER -DNEON_HEADER -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s
11+
12+
// RUN: %clang_cc1 -DNEON_HEADER -DSVE_HEADER2 -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s
13+
// RUN: %clang_cc1 -DNEON_HEADER -DSVE_HEADER2 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s
14+
15+
// REQUIRES: aarch64-registered-target
16+
17+
#ifdef SVE_HEADER
18+
#include <arm_sve.h>
19+
#endif
20+
21+
#ifdef NEON_HEADER
22+
#include <arm_neon.h>
23+
#endif
24+
25+
#ifdef SVE_HEADER_2
26+
#include <arm_sve.h>
27+
#endif
28+
29+
// function return types
30+
// CHECK-LABEL: define dso_local <8 x half> @test_ret_v8f16(
31+
// CHECK-SAME: <8 x half> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
32+
// CHECK-NEXT: entry:
33+
// CHECK-NEXT: ret <8 x half> [[V]]
34+
//
35+
float16x8_t test_ret_v8f16(float16x8_t v) {
36+
return v;
37+
}
38+
39+
// CHECK-LABEL: define dso_local <4 x float> @test_ret_v4f32(
40+
// CHECK-SAME: <4 x float> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
41+
// CHECK-NEXT: entry:
42+
// CHECK-NEXT: ret <4 x float> [[V]]
43+
//
44+
float32x4_t test_ret_v4f32(float32x4_t v) {
45+
return v;
46+
}
47+
48+
// CHECK-LABEL: define dso_local <2 x double> @test_ret_v2f64(
49+
// CHECK-SAME: <2 x double> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
50+
// CHECK-NEXT: entry:
51+
// CHECK-NEXT: ret <2 x double> [[V]]
52+
//
53+
float64x2_t test_ret_v2f64(float64x2_t v) {
54+
return v;
55+
}
56+
57+
// CHECK-LABEL: define dso_local <8 x bfloat> @test_ret_v8bf16(
58+
// CHECK-SAME: <8 x bfloat> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
59+
// CHECK-NEXT: entry:
60+
// CHECK-NEXT: ret <8 x bfloat> [[V]]
61+
//
62+
bfloat16x8_t test_ret_v8bf16(bfloat16x8_t v) {
63+
return v;
64+
}
65+
66+
// CHECK-LABEL: define dso_local <16 x i8> @test_ret_v16s8(
67+
// CHECK-SAME: <16 x i8> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
68+
// CHECK-NEXT: entry:
69+
// CHECK-NEXT: ret <16 x i8> [[V]]
70+
//
71+
int8x16_t test_ret_v16s8(int8x16_t v) {
72+
return v;
73+
}
74+
75+
// CHECK-LABEL: define dso_local <8 x i16> @test_ret_v8s16(
76+
// CHECK-SAME: <8 x i16> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
77+
// CHECK-NEXT: entry:
78+
// CHECK-NEXT: ret <8 x i16> [[V]]
79+
//
80+
int16x8_t test_ret_v8s16(int16x8_t v) {
81+
return v;
82+
}
83+
84+
// CHECK-LABEL: define dso_local <4 x i32> @test_ret_v32s4(
85+
// CHECK-SAME: <4 x i32> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
86+
// CHECK-NEXT: entry:
87+
// CHECK-NEXT: ret <4 x i32> [[V]]
88+
//
89+
int32x4_t test_ret_v32s4(int32x4_t v) {
90+
return v;
91+
}
92+
93+
// CHECK-LABEL: define dso_local <2 x i64> @test_ret_v64s2(
94+
// CHECK-SAME: <2 x i64> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
95+
// CHECK-NEXT: entry:
96+
// CHECK-NEXT: ret <2 x i64> [[V]]
97+
//
98+
int64x2_t test_ret_v64s2(int64x2_t v) {
99+
return v;
100+
}
101+
102+
// CHECK-LABEL: define dso_local <16 x i8> @test_ret_v16u8(
103+
// CHECK-SAME: <16 x i8> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
104+
// CHECK-NEXT: entry:
105+
// CHECK-NEXT: ret <16 x i8> [[V]]
106+
//
107+
uint8x16_t test_ret_v16u8(uint8x16_t v) {
108+
return v;
109+
}
110+
111+
// CHECK-LABEL: define dso_local <8 x i16> @test_ret_v8u16(
112+
// CHECK-SAME: <8 x i16> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
113+
// CHECK-NEXT: entry:
114+
// CHECK-NEXT: ret <8 x i16> [[V]]
115+
//
116+
uint16x8_t test_ret_v8u16(uint16x8_t v) {
117+
return v;
118+
}
119+
120+
// CHECK-LABEL: define dso_local <4 x i32> @test_ret_v32u4(
121+
// CHECK-SAME: <4 x i32> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
122+
// CHECK-NEXT: entry:
123+
// CHECK-NEXT: ret <4 x i32> [[V]]
124+
//
125+
uint32x4_t test_ret_v32u4(uint32x4_t v) {
126+
return v;
127+
}
128+
129+
// CHECK-LABEL: define dso_local <2 x i64> @test_ret_v64u2(
130+
// CHECK-SAME: <2 x i64> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
131+
// CHECK-NEXT: entry:
132+
// CHECK-NEXT: ret <2 x i64> [[V]]
133+
//
134+
uint64x2_t test_ret_v64u2(uint64x2_t v) {
135+
return v;
136+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// REQUIRES: amdgpu-registered-target
2+
3+
// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1200 -verify -S -emit-llvm -o - %s
4+
5+
kernel void builtins_amdgcn_s_barrier_signal_err(global int* in, global int* out, int barrier) {
6+
7+
__builtin_amdgcn_s_barrier_signal(barrier); // expected-error {{'__builtin_amdgcn_s_barrier_signal' must be a constant integer}}
8+
__builtin_amdgcn_s_barrier_wait(-1);
9+
*out = *in;
10+
}
11+
12+
kernel void builtins_amdgcn_s_barrier_wait_err(global int* in, global int* out, int barrier) {
13+
14+
__builtin_amdgcn_s_barrier_signal(-1);
15+
__builtin_amdgcn_s_barrier_wait(barrier); // expected-error {{'__builtin_amdgcn_s_barrier_wait' must be a constant integer}}
16+
*out = *in;
17+
}
18+
19+
kernel void builtins_amdgcn_s_barrier_signal_isfirst_err(global int* in, global int* out, int barrier) {
20+
21+
__builtin_amdgcn_s_barrier_signal_isfirst(barrier); // expected-error {{'__builtin_amdgcn_s_barrier_signal_isfirst' must be a constant integer}}
22+
__builtin_amdgcn_s_barrier_wait(-1);
23+
*out = *in;
24+
}

0 commit comments

Comments
 (0)