Skip to content

Commit b296dfd

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 0224ec0 + f42bbcc commit b296dfd

File tree

15 files changed

+509
-81
lines changed

15 files changed

+509
-81
lines changed

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ void disableUnsupportedOptions(CompilerInvocation &CI) {
8989
CI.getLangOpts().ProfileListFiles.clear();
9090
CI.getLangOpts().XRayAlwaysInstrumentFiles.clear();
9191
CI.getLangOpts().XRayNeverInstrumentFiles.clear();
92+
if (CI.getLangOpts().SYCLIsDevice) {
93+
CI.getLangOpts().SYCLIsDevice = false;
94+
CI.getLangOpts().SYCLUnnamedLambda = false;
95+
CI.getLangOpts().DeclareSPIRVBuiltins = false;
96+
CI.getTargetOpts().Triple = CI.getTargetOpts().HostTriple;
97+
}
9298
}
9399

94100
std::unique_ptr<CompilerInvocation>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# RUN: rm -rf %t.dir/* && mkdir -p %t.dir
2+
# RUN: echo '[{"directory": "%/t.dir", "command": "clang++ -fsycl main.cpp", "file": "main.cpp"}]' > %t.dir/compile_commands.json
3+
# RUN: sed -e "s|INPUT_DIR|%/t.dir|g" %s > %t.test.1
4+
5+
# On Windows, we need the URI in didOpen to look like "uri":"file:///C:/..."
6+
# (with the extra slash in the front), so we add it here.
7+
# RUN: sed -E -e 's|"file://([A-Z]):/|"file:///\1:/|g' %t.test.1 > %t.test
8+
9+
# RUN: clangd -lit-test < %t.test | FileCheck -strict-whitespace %t.test
10+
11+
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"initializationOptions":{"compilationDatabasePath":"INPUT_DIR"}}}
12+
---
13+
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include <sycl/sycl.hpp>\nsycl::queue q{};"}}}
14+
---
15+
{"jsonrpc":"2.0","id":1,"method":"textDocument/symbolInfo","params":{
16+
"textDocument":{"uri":"test:///main.cpp"},
17+
"position":{"line":1,"character":13}
18+
}}
19+
# CHECK: "id": 1
20+
# CHECK-NEXT: "jsonrpc": "2.0",
21+
# CHECK-NEXT: "result": [
22+
# CHECK-NEXT: {
23+
# CHECK-NEXT: "containerName": "sycl::queue::",
24+
# CHECK-NEXT: "declarationRange": {
25+
# CHECK-NEXT: "range": {
26+
# CHECK-NEXT: "end": {
27+
# CHECK-NEXT: "character": 16,
28+
# CHECK-NEXT: "line": 124
29+
# CHECK-NEXT: },
30+
# CHECK-NEXT: "start": {
31+
# CHECK-NEXT: "character": 11,
32+
# CHECK-NEXT: "line": 124
33+
# CHECK-NEXT: }
34+
# CHECK-NEXT: },
35+
# CHECK-NEXT: "uri": "file://{{.*}}/include/sycl/queue.hpp"
36+
# CHECK-NEXT: },
37+
---
38+
{"jsonrpc":"2.0","id":3,"method":"shutdown"}
39+
---
40+
{"jsonrpc":"2.0","method":"exit"}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7526,9 +7526,7 @@ static void handleSYCLIntelDoublePumpAttr(Sema &S, Decl *D,
75267526

75277527
/// Handle the [[intel::fpga_memory]] attribute.
75287528
/// This is incompatible with the [[intel::fpga_register]] attribute.
7529-
static void handleSYCLIntelMemoryAttr(Sema &S, Decl *D,
7530-
const ParsedAttr &AL) {
7531-
checkForDuplicateAttribute<SYCLIntelMemoryAttr>(S, D, AL);
7529+
static void handleSYCLIntelMemoryAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
75327530
if (checkAttrMutualExclusion<SYCLIntelRegisterAttr>(S, D, AL))
75337531
return;
75347532

@@ -7549,10 +7547,20 @@ static void handleSYCLIntelMemoryAttr(Sema &S, Decl *D,
75497547
}
75507548
}
75517549

7552-
// We are adding a user memory attribute, drop any implicit default.
7553-
if (auto *MA = D->getAttr<SYCLIntelMemoryAttr>())
7554-
if (MA->isImplicit())
7555-
D->dropAttr<SYCLIntelMemoryAttr>();
7550+
if (auto *MA = D->getAttr<SYCLIntelMemoryAttr>()) {
7551+
// Check to see if there's a duplicate memory attribute with different
7552+
// values already applied to the declaration.
7553+
if (!MA->isImplicit()) {
7554+
if (MA->getKind() != Kind) {
7555+
S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << &AL;
7556+
S.Diag(MA->getLocation(), diag::note_previous_attribute);
7557+
}
7558+
// Drop the duplicate attribute.
7559+
return;
7560+
}
7561+
// We are adding a user memory attribute, drop any implicit default.
7562+
D->dropAttr<SYCLIntelMemoryAttr>();
7563+
}
75567564

75577565
D->addAttr(::new (S.Context) SYCLIntelMemoryAttr(S.Context, AL, Kind));
75587566
}

clang/test/SemaSYCL/intel-fpga-local-ast.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,46 @@ void check_ast()
265265
[[intel::merge("mrg6", "depth")]]
266266
[[intel::merge("mrg6", "depth")]] unsigned int mrg_mrg6[4];
267267

268+
// Check to see if there's a duplicate attribute with different values
269+
// already applied to the declaration. Drop the duplicate attribute.
270+
// CHECK: VarDecl{{.*}}mem_block_ram
271+
// CHECK: SYCLIntelMemoryAttr{{.*}}MLAB
272+
// CHECK-NOT: SYCLIntelMemoryAttr
273+
[[intel::fpga_memory("MLAB")]]
274+
[[intel::fpga_memory("BLOCK_RAM")]] unsigned int mem_block_ram[32];
275+
276+
// Check to see if there's a duplicate attribute with same Default values
277+
// already applied to the declaration. Drop the duplicate attribute.
278+
// CHECK: VarDecl{{.*}}mem_memory
279+
// CHECK: SYCLIntelMemoryAttr{{.*}}Default
280+
// CHECK-NOT: SYCLIntelMemoryAttr
281+
[[intel::fpga_memory]]
282+
[[intel::fpga_memory]] unsigned int mem_memory[64];
283+
284+
// Check to see if there's a duplicate attribute with same values
285+
// already applied to the declaration. Drop the duplicate attribute.
286+
// CHECK: VarDecl{{.*}}mem_memory_block
287+
// CHECK: SYCLIntelMemoryAttr{{.*}}BlockRAM
288+
// CHECK-NOT: SYCLIntelMemoryAttr
289+
[[intel::fpga_memory("BLOCK_RAM")]]
290+
[[intel::fpga_memory("BLOCK_RAM")]] unsigned int mem_memory_block[64];
291+
292+
// Check to see if there's a duplicate attribute with different values
293+
// already applied to the declaration. Drop the duplicate attribute.
294+
// CHECK: VarDecl{{.*}}mem_mlabs
295+
// CHECK: SYCLIntelMemoryAttr{{.*}}Default
296+
// CHECK-NOT: SYCLIntelMemoryAttr
297+
[[intel::fpga_memory]]
298+
[[intel::fpga_memory("MLAB")]] unsigned int mem_mlabs[64];
299+
300+
// Check to see if there's a duplicate attribute with different values
301+
// already applied to the declaration. Drop the duplicate attribute.
302+
// CHECK: VarDecl{{.*}}mem_mlabs_block_ram
303+
// CHECK: SYCLIntelMemoryAttr{{.*}}BlockRAM
304+
// CHECK-NOT: SYCLIntelMemoryAttr
305+
[[intel::fpga_memory("BLOCK_RAM")]]
306+
[[intel::fpga_memory]] unsigned int mem_mlabs_block_ram[64];
307+
268308
// FIXME: Duplicate attribute should be ignored.
269309
// Both are applied at the moment.
270310
//CHECK: VarDecl{{.*}}bb_bb

clang/test/SemaSYCL/intel-fpga-local.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,45 @@ void diagnostics()
143143
//expected-note@-2 {{conflicting attribute is here}}
144144
unsigned int mem_reg[64];
145145

146-
//expected-warning@+1{{attribute 'fpga_memory' is already applied}}
147-
[[intel::fpga_memory]] [[intel::fpga_memory]] unsigned int mem_mem[64];
146+
// Check to see if there's a duplicate attribute with same Default values
147+
// already applied to the declaration.
148+
// No diagnostic is emitted because the arguments match.
149+
[[intel::fpga_memory]]
150+
[[intel::fpga_memory]] unsigned int mem_mem[64]; // OK
148151

149152
//expected-warning@+1 {{unknown attribute 'memory' ignored}}
150153
[[intelfpga::memory]] unsigned int memory_var[64];
151154

155+
// Check to see if there's a duplicate attribute with different values
156+
// already applied to the declaration.
157+
// Diagnostic is emitted because the arguments mismatch.
158+
//expected-warning@+2{{attribute 'fpga_memory' is already applied with different arguments}}
159+
[[intel::fpga_memory("MLAB")]] // expected-note {{previous attribute is here}}
160+
[[intel::fpga_memory("BLOCK_RAM")]] unsigned int mem_block_ram[32];
161+
162+
// Check to see if there's a duplicate attribute with same values
163+
// already applied to the declaration.
164+
// No diagnostic is emitted because the arguments match.
165+
[[intel::fpga_memory("MLAB")]]
166+
[[intel::fpga_memory("MLAB")]] unsigned int mem_mlab[32]; // OK
167+
168+
[[intel::fpga_memory("BLOCK_RAM")]]
169+
[[intel::fpga_memory("BLOCK_RAM")]] unsigned int mem_block[32]; // OK
170+
171+
// Check to see if there's a duplicate attribute with different values
172+
// already applied to the declaration.
173+
// Diagnostic is emitted because the arguments mismatch.
174+
//expected-warning@+2{{attribute 'fpga_memory' is already applied with different arguments}}
175+
[[intel::fpga_memory]] // expected-note {{previous attribute is here}}
176+
[[intel::fpga_memory("MLAB")]] unsigned int mem_mlabs[64];
177+
178+
// Check to see if there's a duplicate attribute with different values
179+
// already applied to the declaration.
180+
// Diagnostic is emitted because the arguments mismatch.
181+
//expected-warning@+2{{attribute 'fpga_memory' is already applied with different arguments}}
182+
[[intel::fpga_memory("BLOCK_RAM")]] // expected-note {{previous attribute is here}}
183+
[[intel::fpga_memory]] unsigned int mem_mlabs_block_ram[64];
184+
152185
// **bankwidth
153186
//expected-warning@+1 {{unknown attribute 'bankwidth' ignored}}
154187
[[intelfpga::bankwidth(4)]] unsigned int bankwidth_var[32];

llvm-spirv/test/FPFastMathModeNotNaNFast.spvasm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
OpName %r3 "r3"
1414
OpName %r4 "r4"
1515
OpName %r5 "r5"
16+
OpName %r6 "r6"
1617
OpDecorate %dec FPFastMathMode NotNaN|Fast
1718
%dec = OpDecorationGroup
18-
OpGroupDecorate %dec %r1 %r2 %r3 %r4 %r5
19+
OpGroupDecorate %dec %r1 %r2 %r3 %r4 %r5 %r6
1920
%void = OpTypeVoid
2021
%float = OpTypeFloat 32
2122
%5 = OpTypeFunction %void %float %float
@@ -28,6 +29,7 @@
2829
%r3 = OpFMul %float %a %b
2930
%r4 = OpFDiv %float %a %b
3031
%r5 = OpFRem %float %a %b
32+
%r6 = OpFNegate %float %a
3133
OpReturn
3234
OpFunctionEnd
3335

@@ -36,3 +38,4 @@
3638
; CHECK: %r3 = fmul fast float %a, %b
3739
; CHECK: %r4 = fdiv fast float %a, %b
3840
; CHECK: %r5 = frem fast float %a, %b
41+
; CHECK: %r6 = fneg fast float %a

llvm-spirv/test/OpFNegate.spvasm

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)