Skip to content

Commit a7e903a

Browse files
authored
[SYCL][FPGA] Add implicit memory attribute with [[intel::max_replicates()]] (#3409)
If the declaration does not have an [[intel::fpga_memory]] attribute, we create one as an implicit attribute. During refactoring work with [[intel::max_replicates()]] attribute, we somehow dropped the implicit memory attribute. This patch fixes the problem. Signed-off-by: soumi.manna <[email protected]>
1 parent a249316 commit a7e903a

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5992,12 +5992,19 @@ void Sema::AddIntelFPGAMaxReplicatesAttr(Decl *D, const AttributeCommonInfo &CI,
59925992
return;
59935993
}
59945994
}
5995-
// [[intel::fpga_register]] and [[intel::max_replicates()]]
5996-
// attributes are incompatible.
5997-
if (checkAttrMutualExclusion<IntelFPGARegisterAttr>(*this, D, CI))
5998-
return;
59995995
}
60005996

5997+
// [[intel::fpga_register]] and [[intel::max_replicates()]]
5998+
// attributes are incompatible.
5999+
if (checkAttrMutualExclusion<IntelFPGARegisterAttr>(*this, D, CI))
6000+
return;
6001+
6002+
// If the declaration does not have an [[intel::fpga_memory]]
6003+
// attribute, this creates one as an implicit attribute.
6004+
if (!D->hasAttr<IntelFPGAMemoryAttr>())
6005+
D->addAttr(IntelFPGAMemoryAttr::CreateImplicit(
6006+
Context, IntelFPGAMemoryAttr::Default));
6007+
60016008
D->addAttr(::new (Context) IntelFPGAMaxReplicatesAttr(Context, CI, E));
60026009
}
60036010

clang/test/SemaSYCL/intel-fpga-global-const.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// Test that checks global constant variable (which allows the redeclaration) since
44
// IntelFPGAConstVar is one of the subjects listed for [[intel::max_replicates()]] attribute.
55

6-
// Checking of duplicate argument values.
6+
// Check duplicate argument values with implicit memory attribute.
77
//CHECK: VarDecl{{.*}}var_max_replicates
8+
//CHECK: IntelFPGAMemoryAttr{{.*}}Implicit
89
//CHECK: IntelFPGAMaxReplicatesAttr
910
//CHECK-NEXT: ConstantExpr
1011
//CHECK-NEXT: value:{{.*}}12

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ void check_ast()
109109
[[intel::doublepump]]
110110
[[intel::fpga_memory("MLAB")]] unsigned int doublepump_mlab[64];
111111

112+
// Add implicit memory attribute.
112113
//CHECK: VarDecl{{.*}}max_replicates
114+
//CHECK: IntelFPGAMemoryAttr{{.*}}Implicit
113115
//CHECK: IntelFPGAMaxReplicatesAttr
114116
//CHECK: ConstantExpr
115117
//CHECK-NEXT: value:{{.*}}2
@@ -146,8 +148,9 @@ void check_ast()
146148
[[intel::force_pow2_depth(1)]] int var_force_p2d;
147149
[[intel::force_pow2_depth(1)]] const int const_force_p2d[64] = {0, 1};
148150

149-
// Checking of duplicate argument values.
151+
// Check duplicate argument values with implicit memory attribute.
150152
//CHECK: VarDecl{{.*}}var_max_replicates
153+
//CHECK: IntelFPGAMemoryAttr{{.*}}Implicit
151154
//CHECK: IntelFPGAMaxReplicatesAttr
152155
//CHECK-NEXT: ConstantExpr
153156
//CHECK-NEXT: value:{{.*}}12
@@ -336,7 +339,9 @@ void diagnostics()
336339
unsigned int bankwidth_reg[64];
337340

338341
// **max_replicates
342+
// Add implicit memory attribute.
339343
//CHECK: VarDecl{{.*}}max_replicates
344+
//CHECK: IntelFPGAMemoryAttr{{.*}}Implicit
340345
//CHECK: IntelFPGAMaxReplicatesAttr
341346
//CHECK: ConstantExpr
342347
//CHECK-NEXT: value:{{.*}}2
@@ -813,7 +818,9 @@ void check_template_parameters() {
813818
//CHECK-NEXT: IntegerLiteral{{.*}}8{{$}}
814819
[[intel::bank_bits(A, 3), intel::bankwidth(C)]] unsigned int bank_bits_width;
815820

821+
// Add implicit memory attribute.
816822
//CHECK: VarDecl{{.*}}max_replicates
823+
//CHECK: IntelFPGAMemoryAttr{{.*}}Implicit
817824
//CHECK: IntelFPGAMaxReplicatesAttr
818825
//CHECK: ConstantExpr
819826
//CHECK-NEXT: value:{{.*}}2

0 commit comments

Comments
 (0)