From ed1608cf639b407a0e1d048fcee9bab0e5bf181e Mon Sep 17 00:00:00 2001 From: Viktoria Maksimova Date: Tue, 31 Mar 2020 16:00:36 +0300 Subject: [PATCH] [SYCL] Move template function definition to .h file It is done in order to avoid possible linkage problems. Signed-off-by: Viktoria Maksimova --- clang/include/clang/Sema/Sema.h | 44 +++++++++++++++++++++++++++++++++ clang/lib/Sema/SemaStmtAttr.cpp | 43 -------------------------------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 29c9b840407cd..188a2e88804b3 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -12557,6 +12557,50 @@ void Sema::AddOneConstantPowerTwoValueAttr(Decl *D, D->addAttr(::new (Context) AttrType(Context, CI, E)); } +template +FPGALoopAttrT *Sema::BuildSYCLIntelFPGALoopAttr(const AttributeCommonInfo &A, + Expr *E) { + if (!E && !(A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce)) + return nullptr; + + if (E && !E->isInstantiationDependent()) { + llvm::APSInt ArgVal(32); + + if (!E->isIntegerConstantExpr(ArgVal, getASTContext())) { + Diag(E->getExprLoc(), diag::err_attribute_argument_type) + << A.getAttrName() << AANT_ArgumentIntegerConstant + << E->getSourceRange(); + return nullptr; + } + + int Val = ArgVal.getSExtValue(); + + if (A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGAII || + A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce) { + if (Val <= 0) { + Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer) + << A.getAttrName() << /* positive */ 0; + return nullptr; + } + } else if (A.getParsedKind() == + ParsedAttr::AT_SYCLIntelFPGAMaxConcurrency || + A.getParsedKind() == + ParsedAttr::AT_SYCLIntelFPGAMaxInterleaving || + A.getParsedKind() == + ParsedAttr::AT_SYCLIntelFPGASpeculatedIterations) { + if (Val < 0) { + Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer) + << A.getAttrName() << /* non-negative */ 1; + return nullptr; + } + } else { + llvm_unreachable("unknown sycl fpga loop attr"); + } + } + + return new (Context) FPGALoopAttrT(Context, A, E); +} + /// RAII object that enters a new expression evaluation context. class EnterExpressionEvaluationContext { Sema &Actions; diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 941dcdcc3d441..825f365579253 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -192,49 +192,6 @@ Sema::BuildSYCLIntelFPGAIVDepAttr(const AttributeCommonInfo &CI, Expr *Expr1, SYCLIntelFPGAIVDepAttr(Context, CI, SafeLenExpr, ArrayExpr, SafelenValue); } -template -FPGALoopAttrT *Sema::BuildSYCLIntelFPGALoopAttr(const AttributeCommonInfo &A, - Expr *E) { - if (!E && !(A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce)) - return nullptr; - - if (E && !E->isInstantiationDependent()) { - llvm::APSInt ArgVal(32); - - if (!E->isIntegerConstantExpr(ArgVal, getASTContext())) { - Diag(E->getExprLoc(), diag::err_attribute_argument_type) - << A.getAttrName() << AANT_ArgumentIntegerConstant - << E->getSourceRange(); - return nullptr; - } - - int Val = ArgVal.getSExtValue(); - - if (A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGAII || - A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce) { - if (Val <= 0) { - Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer) - << A.getAttrName() << /* positive */ 0; - return nullptr; - } - } else if (A.getParsedKind() == - ParsedAttr::AT_SYCLIntelFPGAMaxConcurrency || - A.getParsedKind() == - ParsedAttr::AT_SYCLIntelFPGAMaxInterleaving || - A.getParsedKind() == - ParsedAttr::AT_SYCLIntelFPGASpeculatedIterations) { - if (Val < 0) { - Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer) - << A.getAttrName() << /* non-negative */ 1; - return nullptr; - } - } else { - llvm_unreachable("unknown sycl fpga loop attr"); - } - } - - return new (Context) FPGALoopAttrT(Context, A, E); -} // Filters out any attributes from the list that are either not the specified // type, or whose function isDependent returns true. template