Skip to content

Commit eb25675

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:738c3ede315a into amd-gfx:2fa5a20ffe88
Local branch amd-gfx 2fa5a20 Merged main:15798f4ec4df into amd-gfx:dd440633e215 Remote branch main 738c3ed [RISCV] Pre-commit test for FrameIndex handling in getMemOperandsWithOffsetWidth
2 parents 2fa5a20 + 738c3ed commit eb25675

File tree

68 files changed

+1680
-281
lines changed

Some content is hidden

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

68 files changed

+1680
-281
lines changed

clang/include/clang/Basic/arm_sve.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,6 +2101,16 @@ let TargetGuard = "sme2" in {
21012101
defm SVMAXNM : SInstMinMaxByVector<"max">;
21022102
}
21032103

2104+
let TargetGuard = "sme2" in {
2105+
def SVSCLAMP_X2 : SInst<"svclamp[_single_{d}_x2]", "22dd", "csil", MergeNone, "aarch64_sve_sclamp_single_x2", [IsStreaming], []>;
2106+
def SVUCLAMP_X2 : SInst<"svclamp[_single_{d}_x2]", "22dd", "UcUsUiUl", MergeNone, "aarch64_sve_uclamp_single_x2", [IsStreaming], []>;
2107+
def SVFCLAMP_X2 : SInst<"svclamp[_single_{d}_x2]", "22dd", "hfd", MergeNone, "aarch64_sve_fclamp_single_x2", [IsStreaming], []>;
2108+
2109+
def SVSCLAMP_X4 : SInst<"svclamp[_single_{d}_x4]", "44dd", "csil", MergeNone, "aarch64_sve_sclamp_single_x4", [IsStreaming], []>;
2110+
def SVUCLAMP_X4 : SInst<"svclamp[_single_{d}_x4]", "44dd", "UcUsUiUl", MergeNone, "aarch64_sve_uclamp_single_x4", [IsStreaming], []>;
2111+
def SVFCLAMP_X4 : SInst<"svclamp[_single_{d}_x4]", "44dd", "hfd", MergeNone, "aarch64_sve_fclamp_single_x4", [IsStreaming], []>;
2112+
}
2113+
21042114
let TargetGuard = "sme2" in {
21052115
// == ADD (vectors) ==
21062116
def SVADD_SINGLE_X2 : SInst<"svadd[_single_{d}_x2]", "22d", "cUcsUsiUilUl", MergeNone, "aarch64_sve_add_single_x2", [IsStreaming], []>;

clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_clamp.c

Lines changed: 747 additions & 0 deletions
Large diffs are not rendered by default.

libcxx/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,10 @@ function(get_sanitizer_flags OUT_VAR USE_SANITIZER)
621621
append_flags(SANITIZER_FLAGS "-fsanitize-memory-track-origins")
622622
endif()
623623
elseif (USE_SANITIZER STREQUAL "Undefined")
624-
append_flags(SANITIZER_FLAGS "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
624+
append_flags(SANITIZER_FLAGS "-fsanitize=undefined" "-fno-sanitize=vptr,function" "-fno-sanitize-recover=all")
625625
elseif (USE_SANITIZER STREQUAL "Address;Undefined" OR
626626
USE_SANITIZER STREQUAL "Undefined;Address")
627-
append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all")
627+
append_flags(SANITIZER_FLAGS "-fsanitize=address,undefined" "-fno-sanitize=vptr,function" "-fno-sanitize-recover=all")
628628
elseif (USE_SANITIZER STREQUAL "Thread")
629629
append_flags(SANITIZER_FLAGS -fsanitize=thread)
630630
elseif (USE_SANITIZER STREQUAL "DataFlow")
@@ -639,6 +639,8 @@ function(get_sanitizer_flags OUT_VAR USE_SANITIZER)
639639
endfunction()
640640

641641
get_sanitizer_flags(SANITIZER_FLAGS "${LLVM_USE_SANITIZER}")
642+
add_library(cxx-sanitizer-flags INTERFACE)
643+
target_compile_options(cxx-sanitizer-flags INTERFACE ${SANITIZER_FLAGS})
642644

643645
# Link system libraries =======================================================
644646
function(cxx_link_system_libraries target)
@@ -821,6 +823,7 @@ function(cxx_add_common_build_flags target)
821823
cxx_add_rtti_flags(${target})
822824
cxx_add_module_flags(${target})
823825
cxx_link_system_libraries(${target})
826+
target_link_libraries(${target} PRIVATE cxx-sanitizer-flags)
824827
endfunction()
825828

826829
#===============================================================================
Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#include "benchmark/benchmark.h"
22
#include "test_macros.h"
33

4+
#include <mutex>
45
#include <sstream>
56

67
TEST_NOINLINE double istream_numbers();
78

8-
double istream_numbers() {
9+
double istream_numbers(std::locale* loc) {
910
const char* a[] = {"-6 69 -71 2.4882e-02 -100 101 -2.00005 5000000 -50000000",
1011
"-25 71 7 -9.3262e+01 -100 101 -2.00005 5000000 -50000000",
1112
"-14 53 46 -6.7026e-02 -100 101 -2.00005 5000000 -50000000"};
@@ -14,17 +15,73 @@ double istream_numbers() {
1415
double f1 = 0.0, f2 = 0.0, q = 0.0;
1516
for (int i = 0; i < 3; i++) {
1617
std::istringstream s(a[i]);
18+
if (loc)
19+
s.imbue(*loc);
1720
s >> a1 >> a2 >> a3 >> f1 >> a4 >> a5 >> f2 >> a6 >> a7;
1821
q += (a1 + a2 + a3 + a4 + a5 + a6 + a7 + f1 + f2) / 1000000;
1922
}
2023
return q;
2124
}
2225

26+
struct LocaleSelector {
27+
std::locale* imbue;
28+
std::locale old;
29+
static std::mutex mutex;
30+
31+
LocaleSelector(benchmark::State& state) {
32+
std::lock_guard guard(mutex);
33+
switch (state.range(0)) {
34+
case 0: {
35+
old = std::locale::global(std::locale::classic());
36+
imbue = nullptr;
37+
break;
38+
}
39+
case 1: {
40+
old = std::locale::global(std::locale::classic());
41+
thread_local std::locale loc("en_US.UTF-8");
42+
imbue = &loc;
43+
break;
44+
}
45+
case 2: {
46+
old = std::locale::global(std::locale::classic());
47+
static std::locale loc("en_US.UTF-8");
48+
imbue = &loc;
49+
break;
50+
}
51+
case 3: {
52+
old = std::locale::global(std::locale("en_US.UTF-8"));
53+
imbue = nullptr;
54+
break;
55+
}
56+
}
57+
}
58+
59+
~LocaleSelector() {
60+
std::lock_guard guard(mutex);
61+
std::locale::global(old);
62+
}
63+
};
64+
65+
std::mutex LocaleSelector::mutex;
66+
2367
static void BM_Istream_numbers(benchmark::State& state) {
68+
LocaleSelector sel(state);
2469
double i = 0;
2570
while (state.KeepRunning())
26-
benchmark::DoNotOptimize(i += istream_numbers());
71+
benchmark::DoNotOptimize(i += istream_numbers(sel.imbue));
72+
}
73+
BENCHMARK(BM_Istream_numbers)->DenseRange(0, 3)->UseRealTime()->Threads(1)->ThreadPerCpu();
74+
75+
static void BM_Ostream_number(benchmark::State& state) {
76+
LocaleSelector sel(state);
77+
while (state.KeepRunning()) {
78+
std::ostringstream ss;
79+
if (sel.imbue)
80+
ss.imbue(*sel.imbue);
81+
ss << 0;
82+
benchmark::DoNotOptimize(ss.str().c_str());
83+
}
2784
}
85+
BENCHMARK(BM_Ostream_number)->DenseRange(0, 3)->UseRealTime()->Threads(1)->ThreadPerCpu();
2886

29-
BENCHMARK(BM_Istream_numbers)->RangeMultiplier(2)->Range(1024, 4096);
3087
BENCHMARK_MAIN();

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ set(files
850850
__utility/integer_sequence.h
851851
__utility/is_pointer_in_range.h
852852
__utility/move.h
853+
__utility/no_destroy.h
853854
__utility/pair.h
854855
__utility/piecewise_construct.h
855856
__utility/priority_tag.h

libcxx/include/__locale

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <__memory/shared_ptr.h> // __shared_count
1616
#include <__mutex/once_flag.h>
1717
#include <__type_traits/make_unsigned.h>
18+
#include <__utility/no_destroy.h>
1819
#include <cctype>
1920
#include <clocale>
2021
#include <cstdint>

libcxx/include/__utility/no_destroy.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___UTILITY_NO_DESTROY_H
10+
#define _LIBCPP___UTILITY_NO_DESTROY_H
11+
12+
#include <__config>
13+
#include <__type_traits/is_constant_evaluated.h>
14+
#include <__utility/forward.h>
15+
16+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17+
# pragma GCC system_header
18+
#endif
19+
20+
_LIBCPP_BEGIN_NAMESPACE_STD
21+
22+
struct __uninitialized_tag {};
23+
24+
// This class stores an object of type _Tp but never destroys it.
25+
//
26+
// This is akin to using __attribute__((no_destroy)), except that it is possible
27+
// to control the lifetime of the object with more flexibility by deciding e.g.
28+
// whether to initialize the object at construction or to defer to a later
29+
// initialization using __emplace.
30+
template <class _Tp>
31+
struct __no_destroy {
32+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(__uninitialized_tag) : __dummy_() {
33+
if (__libcpp_is_constant_evaluated()) {
34+
__dummy_ = char();
35+
}
36+
}
37+
_LIBCPP_HIDE_FROM_ABI ~__no_destroy() {
38+
// nothing
39+
}
40+
41+
template <class... _Args>
42+
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args)
43+
: __obj_(std::forward<_Args>(__args)...) {}
44+
45+
template <class... _Args>
46+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp& __emplace(_Args&&... __args) {
47+
new (&__obj_) _Tp(std::forward<_Args>(__args)...);
48+
return __obj_;
49+
}
50+
51+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp& __get() { return __obj_; }
52+
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp const& __get() const { return __obj_; }
53+
54+
private:
55+
union {
56+
_Tp __obj_;
57+
char __dummy_; // so we can initialize a member even with __uninitialized_tag for constexpr-friendliness
58+
};
59+
};
60+
61+
_LIBCPP_END_NAMESPACE_STD
62+
63+
#endif // _LIBCPP___UTILITY_NO_DESTROY_H

libcxx/include/module.modulemap.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,7 @@ module std_private_utility_move [system] {
20432043
export std_private_type_traits_is_nothrow_move_constructible
20442044
export std_private_type_traits_remove_reference
20452045
}
2046+
module std_private_utility_no_destroy [system] { header "__utility/no_destroy.h" }
20462047
module std_private_utility_pair [system] {
20472048
header "__utility/pair.h"
20482049
export std_private_ranges_subrange_fwd

0 commit comments

Comments
 (0)