Skip to content

Commit bfb344e

Browse files
committed
Merge remote-tracking branch 'intel/sycl' into weak_obj
2 parents fc589db + 8311d79 commit bfb344e

40 files changed

+1067
-259
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9550,7 +9550,9 @@ void SPIRVTranslator::ConstructJob(Compilation &C, const JobAction &JA,
95509550
",+SPV_INTEL_bfloat16_conversion"
95519551
",+SPV_INTEL_joint_matrix"
95529552
",+SPV_INTEL_hw_thread_queries"
9553-
",+SPV_KHR_uniform_group_instructions";
9553+
",+SPV_KHR_uniform_group_instructions"
9554+
",+SPV_INTEL_masked_gather_scatter"
9555+
",+SPV_INTEL_tensor_float32_conversion";
95549556
TranslatorArgs.push_back(TCArgs.MakeArgString(ExtArg));
95559557
}
95569558
for (auto I : Inputs) {

clang/test/CodeGenSYCL/remove-restriction-builtin-printf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int main() {
1010
q.submit([&](handler &h) {
1111
// CHECK: define {{.*}}spir_kernel {{.*}}
1212
h.single_task<class kernelA>([=]() {
13-
// CHECK: printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 24)
13+
// CHECK: call {{.*}}printf(ptr noundef nonnull dereferenceable(1) @{{.*}}, i32 noundef 24)
1414
__builtin_printf("hello, %d\n", 24);
1515
});
1616
});

clang/test/Driver/sycl-spirv-ext.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
// CHECK-DEFAULT-SAME:,+SPV_INTEL_bfloat16_conversion
4949
// CHECK-DEFAULT-SAME:,+SPV_INTEL_joint_matrix
5050
// CHECK-DEFAULT-SAME:,+SPV_INTEL_hw_thread_queries
51-
// CHECK-DEFAULT-SAME:,+SPV_KHR_uniform_group_instructions"
51+
// CHECK-DEFAULT-SAME:,+SPV_KHR_uniform_group_instructions
52+
// CHECK-DEFAULT-SAME:,+SPV_INTEL_masked_gather_scatter
53+
// CHECK-DEFAULT-SAME:,+SPV_INTEL_tensor_float32_conversion"
5254
// CHECK-FPGA-HW: llvm-spirv{{.*}}"-spirv-ext=-all
5355
// CHECK-FPGA-HW-SAME:,+SPV_EXT_shader_atomic_float_add
5456
// CHECK-FPGA-HW-SAME:,+SPV_EXT_shader_atomic_float_min_max

libdevice/imf_half.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,12 @@ static uint16_t __iml_integral2half_u(Ty u, __iml_rounding_mode rounding_mode) {
367367
break;
368368
}
369369
}
370-
}
371-
372-
if (h_mant == 0x400) {
373-
h_exp++;
374-
h_mant = 0;
375-
if (h_exp > 15)
376-
is_overflow = true;
370+
if (h_mant == 0x400) {
371+
h_exp++;
372+
h_mant = 0;
373+
if (h_exp > 15)
374+
is_overflow = true;
375+
}
377376
}
378377

379378
if (is_overflow) {
@@ -437,13 +436,12 @@ static uint16_t __iml_integral2half_s(Ty i, __iml_rounding_mode rounding_mode) {
437436
break;
438437
}
439438
}
440-
}
441-
442-
if (h_mant == 0x400) {
443-
h_exp++;
444-
h_mant = 0;
445-
if (h_exp > 15)
446-
is_overflow = true;
439+
if (h_mant == 0x400) {
440+
h_exp++;
441+
h_mant = 0;
442+
if (h_exp > 15)
443+
is_overflow = true;
444+
}
447445
}
448446

449447
if (is_overflow) {

llvm/include/llvm/Support/Base64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ template <class InputBytes> std::string encodeBase64(InputBytes const &Bytes) {
5757
return Buffer;
5858
}
5959

60+
llvm::Error decodeBase64(llvm::StringRef Input, std::vector<char> &Output);
61+
6062
// General-purpose Base64 encoder/decoder.
6163
// TODO update WinCOFFObjectWriter.cpp to use this library.
6264
class Base64 {

llvm/lib/Support/Base64.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,93 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#define INVALID_BASE64_BYTE 64
910
#include "llvm/Support/Base64.h"
1011

1112
#include <memory>
1213

14+
static char decodeBase64Byte(uint8_t Ch) {
15+
constexpr char Inv = INVALID_BASE64_BYTE;
16+
static const char DecodeTable[] = {
17+
Inv, Inv, Inv, Inv, Inv, Inv, Inv, Inv, // ........
18+
Inv, Inv, Inv, Inv, Inv, Inv, Inv, Inv, // ........
19+
Inv, Inv, Inv, Inv, Inv, Inv, Inv, Inv, // ........
20+
Inv, Inv, Inv, Inv, Inv, Inv, Inv, Inv, // ........
21+
Inv, Inv, Inv, Inv, Inv, Inv, Inv, Inv, // ........
22+
Inv, Inv, Inv, 62, Inv, Inv, Inv, 63, // ...+.../
23+
52, 53, 54, 55, 56, 57, 58, 59, // 01234567
24+
60, 61, Inv, Inv, Inv, 0, Inv, Inv, // 89...=..
25+
Inv, 0, 1, 2, 3, 4, 5, 6, // .ABCDEFG
26+
7, 8, 9, 10, 11, 12, 13, 14, // HIJKLMNO
27+
15, 16, 17, 18, 19, 20, 21, 22, // PQRSTUVW
28+
23, 24, 25, Inv, Inv, Inv, Inv, Inv, // XYZ.....
29+
Inv, 26, 27, 28, 29, 30, 31, 32, // .abcdefg
30+
33, 34, 35, 36, 37, 38, 39, 40, // hijklmno
31+
41, 42, 43, 44, 45, 46, 47, 48, // pqrstuvw
32+
49, 50, 51 // xyz.....
33+
};
34+
if (Ch >= sizeof(DecodeTable))
35+
return Inv;
36+
return DecodeTable[Ch];
37+
}
38+
39+
llvm::Error llvm::decodeBase64(llvm::StringRef Input,
40+
std::vector<char> &Output) {
41+
constexpr char Base64InvalidByte = INVALID_BASE64_BYTE;
42+
// Invalid table value with short name to fit in the table init below. The
43+
// invalid value is 64 since valid base64 values are 0 - 63.
44+
Output.clear();
45+
const uint64_t InputLength = Input.size();
46+
if (InputLength == 0)
47+
return Error::success();
48+
// Make sure we have a valid input string length which must be a multiple
49+
// of 4.
50+
if ((InputLength % 4) != 0)
51+
return createStringError(std::errc::illegal_byte_sequence,
52+
"Base64 encoded strings must be a multiple of 4 "
53+
"bytes in length");
54+
const uint64_t FirstValidEqualIdx = InputLength - 2;
55+
char Hex64Bytes[4];
56+
for (uint64_t Idx = 0; Idx < InputLength; Idx += 4) {
57+
for (uint64_t ByteOffset = 0; ByteOffset < 4; ++ByteOffset) {
58+
const uint64_t ByteIdx = Idx + ByteOffset;
59+
const char Byte = Input[ByteIdx];
60+
const char DecodedByte = decodeBase64Byte(Byte);
61+
bool Illegal = DecodedByte == Base64InvalidByte;
62+
if (!Illegal && Byte == '=') {
63+
if (ByteIdx < FirstValidEqualIdx) {
64+
// We have an '=' in the middle of the string which is invalid, only
65+
// the last two characters can be '=' characters.
66+
Illegal = true;
67+
} else if (ByteIdx == FirstValidEqualIdx && Input[ByteIdx + 1] != '=') {
68+
// We have an equal second to last from the end and the last character
69+
// is not also an equal, so the '=' character is invalid
70+
Illegal = true;
71+
}
72+
}
73+
if (Illegal)
74+
return createStringError(
75+
std::errc::illegal_byte_sequence,
76+
"Invalid Base64 character %#2.2x at index %" PRIu64, Byte, ByteIdx);
77+
Hex64Bytes[ByteOffset] = DecodedByte;
78+
}
79+
// Now we have 6 bits of 3 bytes in value in each of the Hex64Bytes bytes.
80+
// Extract the right bytes into the Output buffer.
81+
Output.push_back((Hex64Bytes[0] << 2) + ((Hex64Bytes[1] >> 4) & 0x03));
82+
Output.push_back((Hex64Bytes[1] << 4) + ((Hex64Bytes[2] >> 2) & 0x0f));
83+
Output.push_back((Hex64Bytes[2] << 6) + (Hex64Bytes[3] & 0x3f));
84+
}
85+
// If we had valid trailing '=' characters strip the right number of bytes
86+
// from the end of the output buffer. We already know that the Input length
87+
// it a multiple of 4 and is not zero, so direct character access is safe.
88+
if (Input.back() == '=') {
89+
Output.pop_back();
90+
if (Input[InputLength - 2] == '=')
91+
Output.pop_back();
92+
}
93+
return Error::success();
94+
}
95+
1396
using namespace llvm;
1497

1598
namespace {

llvm/test/tools/sycl-post-link/device-code-split/per-aspect-split-2.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
; RUN: FileCheck %s -input-file=%t.table --check-prefix CHECK-TABLE
66
;
77
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefix CHECK-M0-SYMS \
8-
; RUN: --implicit-check-not kernel0 --implicit-check-not kernel1 \
8+
; RUN: --implicit-check-not kernel3 --implicit-check-not kernel1 \
99
; RUN: --implicit-check-not kernel2
1010
;
1111
; RUN: FileCheck %s -input-file=%t_1.sym --check-prefix CHECK-M1-SYMS \
12-
; RUN: --implicit-check-not kernel3 --implicit-check-not kernel1 \
12+
; RUN: --implicit-check-not kernel0 --implicit-check-not kernel1 \
1313
; RUN: --implicit-check-not kernel2
1414
;
1515
; RUN: FileCheck %s -input-file=%t_2.sym --check-prefix CHECK-M2-SYMS \
@@ -21,9 +21,9 @@
2121
; CHECK-TABLE-NEXT: _2.sym
2222
; CHECK-TABLE-EMPTY:
2323

24-
; CHECK-M0-SYMS: kernel3
24+
; CHECK-M0-SYMS: kernel0
2525

26-
; CHECK-M1-SYMS: kernel0
26+
; CHECK-M1-SYMS: kernel3
2727

2828
; CHECK-M2-SYMS: kernel1
2929
; CHECK-M2-SYMS: kernel2

llvm/test/tools/sycl-post-link/device-code-split/per-aspect-split-3.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; RUN: --implicit-check-not kernel0 --implicit-check-not foo \
1515
; RUN: --implicit-check-not bar
1616
;
17-
; RUN: FileCheck %s -input-file=%t_2.ll --check-prefix CHECK-M2-IR \
17+
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefix CHECK-M1-IR \
1818
; RUN: --implicit-check-not kernel0 --implicit-check-not bar
1919

2020
; We expect to see 3 modules generated:
@@ -49,14 +49,14 @@
4949
; should also present in a separate device image, because it is an entry point
5050
; with unique set of used aspects.
5151
;
52-
; CHECK-M1-SYMS: foo
52+
; CHECK-M1-SYMS: kernel1
5353
;
54-
; CHECK-M2-SYMS: kernel1
54+
; CHECK-M2-SYMS: foo
5555
;
5656
; @kernel1 uses @foo and therefore @foo should be present in the same module as
5757
; @kernel1 as well
58-
; CHECK-M2-IR-DAG: define spir_func void @foo
59-
; CHECK-M2-IR-DAG: define spir_kernel void @kernel1
58+
; CHECK-M1-IR-DAG: define spir_func void @foo
59+
; CHECK-M1-IR-DAG: define spir_kernel void @kernel1
6060

6161

6262
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"

llvm/test/tools/sycl-post-link/sycl-esimd-large-grf.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99

1010
; RUN: sycl-post-link -split=source -symbols -split-esimd -lower-esimd -S %s -o %t.table
1111
; RUN: FileCheck %s -input-file=%t.table
12-
; RUN: FileCheck %s -input-file=%t_esimd_large_grf_0.ll --check-prefixes CHECK-ESIMD-LargeGRF-IR
13-
; RUN: FileCheck %s -input-file=%t_esimd_large_grf_0.prop --check-prefixes CHECK-ESIMD-LargeGRF-PROP
12+
; RUN: FileCheck %s -input-file=%t_esimd_large_grf_1.ll --check-prefixes CHECK-ESIMD-LargeGRF-IR
13+
; RUN: FileCheck %s -input-file=%t_esimd_large_grf_1.prop --check-prefixes CHECK-ESIMD-LargeGRF-PROP
1414
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYCL-SYM
1515
; RUN: FileCheck %s -input-file=%t_esimd_0.sym --check-prefixes CHECK-ESIMD-SYM
16-
; RUN: FileCheck %s -input-file=%t_esimd_large_grf_0.sym --check-prefixes CHECK-ESIMD-LargeGRF-SYM
16+
; RUN: FileCheck %s -input-file=%t_esimd_large_grf_1.sym --check-prefixes CHECK-ESIMD-LargeGRF-SYM
1717

1818
; CHECK: [Code|Properties|Symbols]
19-
; CHECK: {{.*}}esimd_large_grf_0.ll|{{.*}}esimd_large_grf_0.prop|{{.*}}esimd_large_grf_0.sym
2019
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop|{{.*}}_0.sym
2120
; CHECK: {{.*}}esimd_0.ll|{{.*}}esimd_0.prop|{{.*}}esimd_0.sym
21+
; CHECK: {{.*}}esimd_large_grf_1.ll|{{.*}}esimd_large_grf_1.prop|{{.*}}esimd_large_grf_1.sym
2222

2323
; CHECK-ESIMD-LargeGRF-PROP: isEsimdImage=1|1
2424
; CHECK-ESIMD-LargeGRF-PROP: isLargeGRF=1|1

llvm/test/tools/sycl-post-link/sycl-large-grf.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
; RUN: sycl-post-link -split=source -symbols -split-esimd -lower-esimd -S %s -o %t.table
1111
; RUN: FileCheck %s -input-file=%t.table
12-
; RUN: FileCheck %s -input-file=%t_large_grf_0.ll --check-prefixes CHECK-LARGE-GRF-IR
13-
; RUN: FileCheck %s -input-file=%t_large_grf_0.prop --check-prefixes CHECK-LARGE-GRF-PROP
12+
; RUN: FileCheck %s -input-file=%t_large_grf_1.ll --check-prefixes CHECK-LARGE-GRF-IR
13+
; RUN: FileCheck %s -input-file=%t_large_grf_1.prop --check-prefixes CHECK-LARGE-GRF-PROP
1414
; RUN: FileCheck %s -input-file=%t_0.sym --check-prefixes CHECK-SYCL-SYM
15-
; RUN: FileCheck %s -input-file=%t_large_grf_0.sym --check-prefixes CHECK-LARGE-GRF-SYM
15+
; RUN: FileCheck %s -input-file=%t_large_grf_1.sym --check-prefixes CHECK-LARGE-GRF-SYM
1616

1717
; CHECK: [Code|Properties|Symbols]
18-
; CHECK: {{.*}}_large_grf_0.ll|{{.*}}_large_grf_0.prop|{{.*}}_large_grf_0.sym
1918
; CHECK: {{.*}}_0.ll|{{.*}}_0.prop|{{.*}}_0.sym
19+
; CHECK: {{.*}}_large_grf_1.ll|{{.*}}_large_grf_1.prop|{{.*}}_large_grf_1.sym
2020

2121
; CHECK-LARGE-GRF-PROP: isLargeGRF=1|1
2222

0 commit comments

Comments
 (0)