From e70190c0c62bc40c0a066390202dfe6488037df6 Mon Sep 17 00:00:00 2001 From: Soumi Manna Date: Tue, 21 Dec 2021 19:19:48 -0800 Subject: [PATCH 1/2] [SYCL][FPGA][NFC] Update [[intel::doublepump]] and [[intel::singlepump]] atributes This patch returns the attribute itself instead of handleSimpleAttribute<> function and adds a separate handler function instead of common templated function to align with the community attributes for the two FPGA memory attributes below: 1. [[intel::doublepump] 2. [[intel::singlepump]] Signed-off-by: Soumi Manna --- clang/lib/Sema/SemaDeclAttr.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index c271bcf1b2dd1..ab79a23170501 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6513,17 +6513,32 @@ static void handleSYCLIntelNoGlobalWorkOffsetAttr(Sema &S, Decl *D, S.AddSYCLIntelNoGlobalWorkOffsetAttr(D, A, E); } -/// Handle the [[intel::doublepump]] and [[intel::singlepump]] -/// attributes. -template -static void handleIntelFPGAPumpAttr(Sema &S, Decl *D, const ParsedAttr &A) { - checkForDuplicateAttribute(S, D, A); +/// Handle the [[intel::singlepump]] attribute. +static void handleSYCLIntelFPGASinglePumpAttr(Sema &S, Decl *D, + const ParsedAttr &AL) { + checkForDuplicateAttribute(S, D, AL); + + // If the declaration does not have an [[intel::fpga_memory]] + // attribute, this creates one as an implicit attribute. + if (!D->hasAttr()) + D->addAttr(IntelFPGAMemoryAttr::CreateImplicit( + S.Context, IntelFPGAMemoryAttr::Default)); + D->addAttr(::new (S.Context) IntelFPGASinglePumpAttr(S.Context, AL)); +} + +/// Handle the [[intel::doublepump]] attribute. +static void handleSYCLIntelFPGADoublePumpAttr(Sema &S, Decl *D, + const ParsedAttr &AL) { + checkForDuplicateAttribute(S, D, AL); + + // If the declaration does not have an [[intel::fpga_memory]] + // attribute, this creates one as an implicit attribute. if (!D->hasAttr()) D->addAttr(IntelFPGAMemoryAttr::CreateImplicit( S.Context, IntelFPGAMemoryAttr::Default)); - handleSimpleAttribute(S, D, A); + D->addAttr(::new (S.Context) IntelFPGADoublePumpAttr(S.Context, AL)); } /// Handle the [[intel::fpga_memory]] attribute. @@ -10428,10 +10443,10 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, // Intel FPGA specific attributes case ParsedAttr::AT_IntelFPGADoublePump: - handleIntelFPGAPumpAttr(S, D, AL); + handleSYCLIntelFPGADoublePumpAttr(S, D, AL); break; case ParsedAttr::AT_IntelFPGASinglePump: - handleIntelFPGAPumpAttr(S, D, AL); + handleSYCLIntelFPGASinglePumpAttr(S, D, AL); break; case ParsedAttr::AT_IntelFPGAMemory: handleIntelFPGAMemoryAttr(S, D, AL); From 25ac7c8f5b3eebc15a2967a8382f4b2196eed59d Mon Sep 17 00:00:00 2001 From: Soumi Manna Date: Tue, 21 Dec 2021 19:37:05 -0800 Subject: [PATCH 2/2] Fix Clang format errors Signed-off-by: Soumi Manna --- clang/lib/Sema/SemaDeclAttr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index ab79a23170501..a3731fdf24939 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6515,7 +6515,7 @@ static void handleSYCLIntelNoGlobalWorkOffsetAttr(Sema &S, Decl *D, /// Handle the [[intel::singlepump]] attribute. static void handleSYCLIntelFPGASinglePumpAttr(Sema &S, Decl *D, - const ParsedAttr &AL) { + const ParsedAttr &AL) { checkForDuplicateAttribute(S, D, AL); // If the declaration does not have an [[intel::fpga_memory]]