Skip to content

Commit 0a00ecf

Browse files
authored
merge main into amd-staging (llvm#1962)
2 parents 1e0492c + b2a9db6 commit 0a00ecf

File tree

37 files changed

+340
-166
lines changed

37 files changed

+340
-166
lines changed

clang/include/clang/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,7 @@ class Parser : public CodeCompletionHandler {
32533253

32543254
void ParseTypeQualifierListOpt(
32553255
DeclSpec &DS, unsigned AttrReqs = AR_AllAttributesParsed,
3256-
bool AtomicAllowed = true, bool IdentifierRequired = false,
3256+
bool AtomicOrPtrauthAllowed = true, bool IdentifierRequired = false,
32573257
std::optional<llvm::function_ref<void()>> CodeCompletionHandler =
32583258
std::nullopt);
32593259
void ParseDirectDeclarator(Declarator &D);

clang/include/clang/Sema/Overload.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ class Sema;
362362

363363
/// Whether the source expression was originally a single element
364364
/// braced-init-list. Such a conversion is not a perfect match,
365-
/// as we prefer a std::list_initializer constructor over an exact match
365+
/// as we prefer a std::initializer_list constructor over an exact match
366366
/// constructor.
367367
LLVM_PREFERRED_TYPE(bool)
368368
unsigned FromBracedInitList : 1;
@@ -420,7 +420,7 @@ class Sema;
420420
if (!isIdentityConversion())
421421
return false;
422422

423-
// We might prefer a std::initializer constructor,
423+
// We might prefer a std::initializer_list constructor,
424424
// so this sequence cannot be perfect
425425
if (FromBracedInitList)
426426
return false;

clang/lib/Headers/hlsl/hlsl_intrinsic_helpers.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ template <typename T> constexpr T faceforward_impl(T N, T I, T Ng) {
134134
#endif
135135
}
136136

137+
template <typename T> constexpr T ldexp_impl(T X, T Exp) {
138+
return exp2(Exp) * X;
139+
}
140+
137141
} // namespace __detail
138142
} // namespace hlsl
139143

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,48 @@ fmod(__detail::HLSL_FIXED_VECTOR<float, N> X,
303303
return __detail::fmod_vec_impl(X, Y);
304304
}
305305

306+
//===----------------------------------------------------------------------===//
307+
// ldexp builtins
308+
//===----------------------------------------------------------------------===//
309+
310+
/// \fn T ldexp(T X, T Exp)
311+
/// \brief Returns the result of multiplying the specified value by two raised
312+
/// to the power of the specified exponent.
313+
/// \param X [in] The specified value.
314+
/// \param Exp [in] The specified exponent.
315+
///
316+
/// This function uses the following formula: X * 2^Exp
317+
318+
template <typename T>
319+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
320+
const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
321+
__detail::is_same<half, T>::value,
322+
T> ldexp(T X, T Exp) {
323+
return __detail::ldexp_impl(X, Exp);
324+
}
325+
326+
template <typename T>
327+
const inline __detail::enable_if_t<
328+
__detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>
329+
ldexp(T X, T Exp) {
330+
return __detail::ldexp_impl(X, Exp);
331+
}
332+
333+
template <int N>
334+
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
335+
const inline __detail::HLSL_FIXED_VECTOR<half, N> ldexp(
336+
__detail::HLSL_FIXED_VECTOR<half, N> X,
337+
__detail::HLSL_FIXED_VECTOR<half, N> Exp) {
338+
return __detail::ldexp_impl(X, Exp);
339+
}
340+
341+
template <int N>
342+
const inline __detail::HLSL_FIXED_VECTOR<float, N>
343+
ldexp(__detail::HLSL_FIXED_VECTOR<float, N> X,
344+
__detail::HLSL_FIXED_VECTOR<float, N> Exp) {
345+
return __detail::ldexp_impl(X, Exp);
346+
}
347+
306348
//===----------------------------------------------------------------------===//
307349
// length builtins
308350
//===----------------------------------------------------------------------===//

clang/lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6511,7 +6511,7 @@ bool Parser::isConstructorDeclarator(bool IsUnqualified, bool DeductionGuide,
65116511
/// Note: vendor can be GNU, MS, etc and can be explicitly controlled via
65126512
/// AttrRequirements bitmask values.
65136513
void Parser::ParseTypeQualifierListOpt(
6514-
DeclSpec &DS, unsigned AttrReqs, bool AtomicAllowed,
6514+
DeclSpec &DS, unsigned AttrReqs, bool AtomicOrPtrauthAllowed,
65156515
bool IdentifierRequired,
65166516
std::optional<llvm::function_ref<void()>> CodeCompletionHandler) {
65176517
if ((AttrReqs & AR_CXX11AttributesParsed) &&
@@ -6551,7 +6551,7 @@ void Parser::ParseTypeQualifierListOpt(
65516551
getLangOpts());
65526552
break;
65536553
case tok::kw__Atomic:
6554-
if (!AtomicAllowed)
6554+
if (!AtomicOrPtrauthAllowed)
65556555
goto DoneWithTypeQuals;
65566556
diagnoseUseOfC11Keyword(Tok);
65576557
isInvalid = DS.SetTypeQual(DeclSpec::TQ_atomic, Loc, PrevSpec, DiagID,
@@ -6584,6 +6584,8 @@ void Parser::ParseTypeQualifierListOpt(
65846584

65856585
// __ptrauth qualifier.
65866586
case tok::kw___ptrauth:
6587+
if (!AtomicOrPtrauthAllowed)
6588+
goto DoneWithTypeQuals;
65876589
ParsePtrauthQualifier(DS.getAttributes());
65886590
EndLoc = PrevTokLocation;
65896591
continue;
@@ -6860,7 +6862,8 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
68606862
((D.getContext() != DeclaratorContext::CXXNew)
68616863
? AR_GNUAttributesParsed
68626864
: AR_GNUAttributesParsedAndRejected);
6863-
ParseTypeQualifierListOpt(DS, Reqs, true, !D.mayOmitIdentifier());
6865+
ParseTypeQualifierListOpt(DS, Reqs, /*AtomicOrPtrauthAllowed=*/true,
6866+
!D.mayOmitIdentifier());
68646867
D.ExtendWithDeclSpec(DS);
68656868

68666869
// Recursively parse the declarator.
@@ -7725,7 +7728,7 @@ void Parser::ParseFunctionDeclarator(Declarator &D,
77257728
// Parse cv-qualifier-seq[opt].
77267729
ParseTypeQualifierListOpt(
77277730
DS, AR_NoAttributesParsed,
7728-
/*AtomicAllowed*/ false,
7731+
/*AtomicOrPtrauthAllowed=*/false,
77297732
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
77307733
Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D);
77317734
}));

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2802,7 +2802,7 @@ void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
28022802
// GNU-style and C++11 attributes are not allowed here, but they will be
28032803
// handled by the caller. Diagnose everything else.
28042804
ParseTypeQualifierListOpt(
2805-
DS, AR_NoAttributesParsed, false,
2805+
DS, AR_NoAttributesParsed, /*AtomicOrPtrauthAllowed=*/false,
28062806
/*IdentifierRequired=*/false, llvm::function_ref<void()>([&]() {
28072807
Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
28082808
}));
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil-pc-shadermodel6.3-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -o - | FileCheck %s
2+
3+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) half @_ZN4hlsl8__detail10ldexp_implIDhEET_S2_S2_
4+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn half @llvm.exp2.f16(half %{{.*}})
5+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn half %elt.exp2, %{{.*}}
6+
// CHECK: ret half %mul
7+
half test_ldexp_half(half X, half Exp) { return ldexp(X, Exp); }
8+
9+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <2 x half> @_ZN4hlsl8__detail10ldexp_implIDv2_DhEET_S3_S3_
10+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <2 x half> @llvm.exp2.v2f16(<2 x half> %{{.*}})
11+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <2 x half> %elt.exp2, %{{.*}}
12+
// CHECK: ret <2 x half> %mul
13+
half2 test_ldexp_half2(half2 X, half2 Exp) { return ldexp(X, Exp); }
14+
15+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <3 x half> @_ZN4hlsl8__detail10ldexp_implIDv3_DhEET_S3_S3_
16+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <3 x half> @llvm.exp2.v3f16(<3 x half> %{{.*}})
17+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <3 x half> %elt.exp2, %{{.*}}
18+
// CHECK: ret <3 x half> %mul
19+
half3 test_ldexp_half3(half3 X, half3 Exp) { return ldexp(X, Exp); }
20+
21+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <4 x half> @_ZN4hlsl8__detail10ldexp_implIDv4_DhEET_S3_S3_
22+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <4 x half> @llvm.exp2.v4f16(<4 x half> %{{.*}})
23+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <4 x half> %elt.exp2, %{{.*}}
24+
// CHECK: ret <4 x half> %mul
25+
half4 test_ldexp_half4(half4 X, half4 Exp) { return ldexp(X, Exp); }
26+
27+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) float @_ZN4hlsl8__detail10ldexp_implIfEET_S2_S2_
28+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn float @llvm.exp2.f32(float %{{.*}})
29+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn float %elt.exp2, %{{.*}}
30+
// CHECK: ret float %mul
31+
float test_ldexp_float(float X, float Exp) { return ldexp(X, Exp); }
32+
33+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <2 x float> @_ZN4hlsl8__detail10ldexp_implIDv2_fEET_S3_S3_
34+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.exp2.v2f32(<2 x float> %{{.*}})
35+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <2 x float> %elt.exp2, %{{.*}}
36+
// CHECK: ret <2 x float> %mul
37+
float2 test_ldexp_float2(float2 X, float2 Exp) { return ldexp(X, Exp); }
38+
39+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <3 x float> @_ZN4hlsl8__detail10ldexp_implIDv3_fEET_S3_S3_
40+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.exp2.v3f32(<3 x float> %{{.*}})
41+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <3 x float> %elt.exp2, %{{.*}}
42+
// CHECK: ret <3 x float> %mul
43+
float3 test_ldexp_float3(float3 X, float3 Exp) { return ldexp(X, Exp); }
44+
45+
// CHECK-LABEL: define linkonce_odr noundef nofpclass(nan inf) <4 x float> @_ZN4hlsl8__detail10ldexp_implIDv4_fEET_S3_S3_
46+
// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.exp2.v4f32(<4 x float> %{{.*}})
47+
// CHECK: %mul = fmul reassoc nnan ninf nsz arcp afn <4 x float> %elt.exp2, %{{.*}}
48+
// CHECK: ret <4 x float> %mul
49+
float4 test_ldexp_float4(float4 X, float4 Exp) { return ldexp(X, Exp); }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -triple arm64-apple-ios -x c -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter
2+
// RUN: %clang_cc1 -triple arm64-apple-ios -x c++ -fsyntax-only -verify -fptrauth-intrinsics %s -fexperimental-new-constant-interpreter
3+
4+
struct Foo {
5+
void (*f)(int) __ptrauth(1,1,1);
6+
// expected-error@-1 {{expected ';' at end of declaration list}}
7+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify
2+
3+
float test_double_inputs(double p0, double p1) {
4+
return ldexp(p0, p1);
5+
// expected-error@-1 {{no matching function for call to 'ldexp'}}
6+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
7+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
8+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
9+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
10+
}
11+
12+
float test_int_inputs(int p0, int p1, int p2) {
13+
return ldexp(p0, p1);
14+
// expected-error@-1 {{no matching function for call to 'ldexp'}}
15+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
16+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
17+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
18+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored}}
19+
}
20+
21+
float1 test_vec1_inputs(float1 p0, float1 p1) {
22+
return ldexp(p0, p1);
23+
// expected-error@-1 {{no matching function for call to 'ldexp'}}
24+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
25+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 1>>'}}
26+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
27+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 1]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
28+
}
29+
30+
typedef float float5 __attribute__((ext_vector_type(5)));
31+
32+
float5 test_vec5_inputs(float5 p0, float5 p1) {
33+
return ldexp(p0, p1);
34+
// expected-error@-1 {{no matching function for call to 'ldexp'}}
35+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
36+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with T = float5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, vector<float, 5>>'}}
37+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, half>'}}
38+
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate template ignored: substitution failure [with N = 5]: no type named 'Type' in 'hlsl::__detail::enable_if<false, float>'}}
39+
}

libcxx/include/__vector/vector.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,28 @@ class vector {
8989
//
9090
// Types
9191
//
92-
typedef vector __self;
93-
typedef _Tp value_type;
94-
typedef _Allocator allocator_type;
95-
typedef allocator_traits<allocator_type> __alloc_traits;
96-
typedef value_type& reference;
97-
typedef const value_type& const_reference;
98-
typedef typename __alloc_traits::size_type size_type;
99-
typedef typename __alloc_traits::difference_type difference_type;
100-
typedef typename __alloc_traits::pointer pointer;
101-
typedef typename __alloc_traits::const_pointer const_pointer;
92+
using __self _LIBCPP_NODEBUG = vector;
93+
using value_type = _Tp;
94+
using allocator_type = _Allocator;
95+
using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
96+
using reference = value_type&;
97+
using const_reference = const value_type&;
98+
using size_type = typename __alloc_traits::size_type;
99+
using difference_type = typename __alloc_traits::difference_type;
100+
using pointer = typename __alloc_traits::pointer;
101+
using const_pointer = typename __alloc_traits::const_pointer;
102102
#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
103103
// Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
104104
// pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
105105
// considered contiguous.
106-
typedef __bounded_iter<__wrap_iter<pointer> > iterator;
107-
typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;
106+
using iterator = __bounded_iter<__wrap_iter<pointer> >;
107+
using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >;
108108
#else
109-
typedef __wrap_iter<pointer> iterator;
110-
typedef __wrap_iter<const_pointer> const_iterator;
109+
using iterator = __wrap_iter<pointer>;
110+
using const_iterator = __wrap_iter<const_pointer>;
111111
#endif
112-
typedef std::reverse_iterator<iterator> reverse_iterator;
113-
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
112+
using reverse_iterator = std::reverse_iterator<iterator>;
113+
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
114114

115115
// A vector containers the following members which may be trivially relocatable:
116116
// - pointer: may be trivially relocatable, so it's checked

0 commit comments

Comments
 (0)