Skip to content

Commit 25b814e

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (9 commits)
CONFLICT (content): Merge conflict in llvm/test/CodeGen/NVPTX/tex-read-cuda.ll
2 parents c01e69a + 35693da commit 25b814e

File tree

75 files changed

+3052
-1772
lines changed

Some content is hidden

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

75 files changed

+3052
-1772
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7957,13 +7957,14 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
79577957
}
79587958

79597959
// HIP code in device-only non-RDC mode will bundle the output if it invoked
7960-
// the linker.
7960+
// the linker or if the user explicitly requested it.
79617961
bool ShouldBundleHIP =
7962-
HIPNoRDC && offloadDeviceOnly() &&
79637962
Args.hasFlag(options::OPT_gpu_bundle_output,
7964-
options::OPT_no_gpu_bundle_output, true) &&
7965-
!llvm::any_of(OffloadActions,
7966-
[](Action *A) { return A->getType() != types::TY_Image; });
7963+
options::OPT_no_gpu_bundle_output, false) ||
7964+
(HIPNoRDC && offloadDeviceOnly() &&
7965+
llvm::none_of(OffloadActions, [](Action *A) {
7966+
return A->getType() != types::TY_Image;
7967+
}));
79677968

79687969
// All kinds exit now in device-only mode except for non-RDC mode HIP.
79697970
if (offloadDeviceOnly() && !ShouldBundleHIP)

clang/test/CodeGenCUDA/bf16.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ __device__ __bf16 external_func( __bf16 in);
3535
// CHECK: .param .align 2 .b8 _Z9test_callDF16b_param_0[2]
3636
__device__ __bf16 test_call( __bf16 in) {
3737
// CHECK: ld.param.b16 %[[R:rs[0-9]+]], [_Z9test_callDF16b_param_0];
38-
// CHECK: st.param.b16 [param0], %[[R]];
3938
// CHECK: .param .align 2 .b8 retval0[2];
39+
// CHECK: st.param.b16 [param0], %[[R]];
4040
// CHECK: call.uni (retval0), _Z13external_funcDF16b, (param0);
4141
// CHECK: ld.param.b16 %[[RET:rs[0-9]+]], [retval0];
4242
return external_func(in);

clang/test/Driver/hip-binding.hip

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
// MULTI-D-ONLY-NEXT: # "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]"], output: "[[GFX90a:.+]]"
6262
// MULTI-D-ONLY-NEXT: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX90a]]"], output: "[[GFX90a_OUT:.+]]"
6363
//
64-
// RUN: not %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-bindings -nogpulib -nogpuinc \
64+
// RUN: not %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-bindings -nogpulib -nogpuinc -emit-llvm \
6565
// RUN: --no-gpu-bundle-output --offload-arch=gfx90a --offload-arch=gfx908 --offload-device-only -c -o %t %s 2>&1 \
6666
// RUN: | FileCheck -check-prefix=MULTI-D-ONLY-NO-BUNDLE-O %s
6767
// MULTI-D-ONLY-NO-BUNDLE-O: error: cannot specify -o when generating multiple output files
@@ -75,6 +75,13 @@
7575
// MULTI-D-ONLY-O-NEXT: "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX90A_OBJ]]"], output: "[[GFX90A:.+]]"
7676
// MULTI-D-ONLY-O-NEXT: "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX908]]", "[[GFX90A]]"], output: "a.out"
7777

78+
// RUN: %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-bindings -nogpulib -nogpuinc -emit-llvm \
79+
// RUN: --gpu-bundle-output --offload-arch=gfx90a --offload-arch=gfx908 --offload-device-only -c -o a.out %s 2>&1 \
80+
// RUN: | FileCheck -check-prefix=MULTI-D-ONLY-BC %s
81+
// MULTI-D-ONLY-BC: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[GFX908_BC:.+]]"
82+
// MULTI-D-ONLY-BC-NEXT: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]"], output: "[[GFX90A_BC:.+]]"
83+
// MULTI-D-ONLY-BC-NEXT: "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX908_BC]]", "[[GFX90A_BC]]"], output: "a.out"
84+
7885
//
7986
// Check to ensure that we can use '-fsyntax-only' for HIP output with the new
8087
// driver.

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,9 @@ if(LLVM_LIBC_FULL_BUILD)
12671267
libc.src.wchar.mbsinit
12681268
libc.src.wchar.mbrtowc
12691269
libc.src.wchar.mbtowc
1270+
libc.src.wchar.mbstowcs
1271+
libc.src.wchar.mbsrtowcs
1272+
libc.src.wchar.mbsnrtowcs
12701273
libc.src.wchar.wcrtomb
12711274
libc.src.wchar.wctomb
12721275
libc.src.wchar.wcstombs

libc/include/wchar.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,33 @@ functions:
5353
- type: wchar_t *__restrict
5454
- type: const char *__restrict
5555
- type: size_t
56+
- name: mbsnrtowcs
57+
standards:
58+
- stdc
59+
return_type: size_t
60+
arguments:
61+
- type: wchar_t *__restrict
62+
- type: const char **__restrict
63+
- type: size_t
64+
- type: size_t
65+
- type: mbstate_t *__restrict
66+
- name: mbsrtowcs
67+
standards:
68+
- stdc
69+
return_type: size_t
70+
arguments:
71+
- type: wchar_t *__restrict
72+
- type: const char **__restrict
73+
- type: size_t
74+
- type: mbstate_t *__restrict
75+
- name: mbstowcs
76+
standards:
77+
- stdc
78+
return_type: size_t
79+
arguments:
80+
- type: wchar_t *__restrict
81+
- type: const char *__restrict
82+
- type: size_t
5683
- name: mbsinit
5784
standards:
5885
- stdc

libc/src/__support/wchar/CMakeLists.txt

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,31 @@ add_object_library(
6060
SRCS
6161
mbrtowc.cpp
6262
DEPENDS
63-
libc.hdr.errno_macros
64-
libc.hdr.types.wchar_t
65-
libc.hdr.types.size_t
66-
libc.src.__support.common
67-
libc.src.__support.error_or
68-
libc.src.__support.macros.config
69-
.character_converter
70-
.mbstate
63+
libc.hdr.errno_macros
64+
libc.hdr.types.wchar_t
65+
libc.hdr.types.size_t
66+
libc.src.__support.common
67+
libc.src.__support.error_or
68+
libc.src.__support.macros.config
69+
.character_converter
70+
.mbstate
71+
)
72+
73+
add_header_library(
74+
mbsnrtowcs
75+
HDRS
76+
mbsnrtowcs.h
77+
DEPENDS
78+
libc.hdr.errno_macros
79+
libc.hdr.types.wchar_t
80+
libc.hdr.types.size_t
81+
libc.src.__support.common
82+
libc.src.__support.error_or
83+
libc.src.__support.macros.config
84+
libc.src.__support.macros.null_check
85+
.character_converter
86+
.mbstate
87+
.string_converter
7188
)
7289

7390
add_header_library(
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//===-- Implementation for mbsnrtowcs function ------------------*- C++ -*-===//
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 LLVM_LIBC_SRC___SUPPORT_WCHAR_MBSNRTOWCS_H
10+
#define LLVM_LIBC_SRC___SUPPORT_WCHAR_MBSNRTOWCS_H
11+
12+
#include "hdr/errno_macros.h"
13+
#include "hdr/types/size_t.h"
14+
#include "hdr/types/wchar_t.h"
15+
#include "src/__support/common.h"
16+
#include "src/__support/error_or.h"
17+
#include "src/__support/macros/config.h"
18+
#include "src/__support/macros/null_check.h"
19+
#include "src/__support/wchar/character_converter.h"
20+
#include "src/__support/wchar/mbstate.h"
21+
#include "src/__support/wchar/string_converter.h"
22+
23+
namespace LIBC_NAMESPACE_DECL {
24+
namespace internal {
25+
26+
LIBC_INLINE static ErrorOr<size_t> mbsnrtowcs(wchar_t *__restrict dst,
27+
const char **__restrict src,
28+
size_t nmc, size_t len,
29+
mbstate *__restrict ps) {
30+
LIBC_CRASH_ON_NULLPTR(src);
31+
// Checking if mbstate is valid
32+
CharacterConverter char_conv(ps);
33+
if (!char_conv.isValidState())
34+
return Error(EINVAL);
35+
36+
StringConverter<char8_t> str_conv(reinterpret_cast<const char8_t *>(*src), ps,
37+
len, nmc);
38+
size_t dst_idx = 0;
39+
ErrorOr<char32_t> converted = str_conv.popUTF32();
40+
while (converted.has_value()) {
41+
if (dst != nullptr)
42+
dst[dst_idx] = converted.value();
43+
// null terminator should not be counted in return value
44+
if (converted.value() == L'\0') {
45+
if (dst != nullptr)
46+
*src = nullptr;
47+
return dst_idx;
48+
}
49+
dst_idx++;
50+
converted = str_conv.popUTF32();
51+
}
52+
53+
if (converted.error() == -1) { // if we hit conversion limit
54+
if (dst != nullptr)
55+
*src += str_conv.getSourceIndex();
56+
return dst_idx;
57+
}
58+
59+
return Error(converted.error());
60+
}
61+
62+
} // namespace internal
63+
64+
} // namespace LIBC_NAMESPACE_DECL
65+
66+
#endif // LLVM_LIBC_SRC___SUPPORT_WCHAR_MBSNRTOWCS_H

libc/src/wchar/CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,54 @@ add_entrypoint_object(
184184
libc.src.__support.wchar.mbstate
185185
)
186186

187+
add_entrypoint_object(
188+
mbstowcs
189+
SRCS
190+
mbstowcs.cpp
191+
HDRS
192+
mbstowcs.h
193+
DEPENDS
194+
libc.hdr.types.size_t
195+
libc.hdr.types.wchar_t
196+
libc.src.__support.common
197+
libc.src.__support.macros.config
198+
libc.src.__support.libc_errno
199+
libc.src.__support.wchar.mbstate
200+
libc.src.__support.wchar.mbsnrtowcs
201+
)
202+
203+
add_entrypoint_object(
204+
mbsrtowcs
205+
SRCS
206+
mbsrtowcs.cpp
207+
HDRS
208+
mbsrtowcs.h
209+
DEPENDS
210+
libc.hdr.types.size_t
211+
libc.hdr.types.wchar_t
212+
libc.src.__support.common
213+
libc.src.__support.macros.config
214+
libc.src.__support.libc_errno
215+
libc.src.__support.wchar.mbstate
216+
libc.src.__support.wchar.mbsnrtowcs
217+
)
218+
219+
add_entrypoint_object(
220+
mbsnrtowcs
221+
SRCS
222+
mbsnrtowcs.cpp
223+
HDRS
224+
mbsnrtowcs.h
225+
DEPENDS
226+
libc.hdr.types.size_t
227+
libc.hdr.types.wchar_t
228+
libc.src.__support.common
229+
libc.src.__support.macros.config
230+
libc.src.__support.libc_errno
231+
libc.src.__support.wchar.mbstate
232+
libc.src.__support.wchar.mbsnrtowcs
233+
)
234+
187235
add_entrypoint_object(
188236
wcstombs
189237
SRCS

libc/src/wchar/mbsnrtowcs.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===-- Implementation of mbsnrtowcs --------------------------------------===//
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+
#include "src/wchar/mbsnrtowcs.h"
10+
11+
#include "hdr/types/size_t.h"
12+
#include "hdr/types/wchar_t.h"
13+
#include "src/__support/common.h"
14+
#include "src/__support/libc_errno.h"
15+
#include "src/__support/macros/config.h"
16+
#include "src/__support/wchar/mbsnrtowcs.h"
17+
#include "src/__support/wchar/mbstate.h"
18+
19+
namespace LIBC_NAMESPACE_DECL {
20+
21+
LLVM_LIBC_FUNCTION(size_t, mbsnrtowcs,
22+
(wchar_t *__restrict dst, const char **__restrict src,
23+
size_t nmc, size_t len, mbstate_t *__restrict ps)) {
24+
static internal::mbstate internal_mbstate;
25+
// If destination is null, ignore len
26+
len = dst == nullptr ? SIZE_MAX : len;
27+
auto ret = internal::mbsnrtowcs(
28+
dst, src, nmc, len,
29+
ps == nullptr ? &internal_mbstate
30+
: reinterpret_cast<internal::mbstate *>(ps));
31+
if (!ret.has_value()) {
32+
// Encoding failure
33+
libc_errno = ret.error();
34+
return -1;
35+
}
36+
return ret.value();
37+
}
38+
39+
} // namespace LIBC_NAMESPACE_DECL

libc/src/wchar/mbsnrtowcs.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===-- Implementation header for mbsnrtowcs ------------------------------===//
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 LLVM_LIBC_SRC_WCHAR_MBSNRTOWCS_H
10+
#define LLVM_LIBC_SRC_WCHAR_MBSNRTOWCS_H
11+
12+
#include "hdr/types/mbstate_t.h"
13+
#include "hdr/types/size_t.h"
14+
#include "hdr/types/wchar_t.h"
15+
#include "src/__support/macros/config.h"
16+
17+
namespace LIBC_NAMESPACE_DECL {
18+
19+
size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
20+
size_t nmc, size_t len, mbstate_t *__restrict ps);
21+
22+
} // namespace LIBC_NAMESPACE_DECL
23+
24+
#endif // LLVM_LIBC_SRC_WCHAR_MBSNRTOWCS_H

0 commit comments

Comments
 (0)