Skip to content

Commit 925a587

Browse files
authored
[SYCL][NFC] Move template function definition to .h file (#1433)
It is done in order to avoid possible linkage problems. Signed-off-by: Viktoria Maksimova <[email protected]>
1 parent f43883b commit 925a587

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12557,6 +12557,50 @@ void Sema::AddOneConstantPowerTwoValueAttr(Decl *D,
1255712557
D->addAttr(::new (Context) AttrType(Context, CI, E));
1255812558
}
1255912559

12560+
template <typename FPGALoopAttrT>
12561+
FPGALoopAttrT *Sema::BuildSYCLIntelFPGALoopAttr(const AttributeCommonInfo &A,
12562+
Expr *E) {
12563+
if (!E && !(A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce))
12564+
return nullptr;
12565+
12566+
if (E && !E->isInstantiationDependent()) {
12567+
llvm::APSInt ArgVal(32);
12568+
12569+
if (!E->isIntegerConstantExpr(ArgVal, getASTContext())) {
12570+
Diag(E->getExprLoc(), diag::err_attribute_argument_type)
12571+
<< A.getAttrName() << AANT_ArgumentIntegerConstant
12572+
<< E->getSourceRange();
12573+
return nullptr;
12574+
}
12575+
12576+
int Val = ArgVal.getSExtValue();
12577+
12578+
if (A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGAII ||
12579+
A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce) {
12580+
if (Val <= 0) {
12581+
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
12582+
<< A.getAttrName() << /* positive */ 0;
12583+
return nullptr;
12584+
}
12585+
} else if (A.getParsedKind() ==
12586+
ParsedAttr::AT_SYCLIntelFPGAMaxConcurrency ||
12587+
A.getParsedKind() ==
12588+
ParsedAttr::AT_SYCLIntelFPGAMaxInterleaving ||
12589+
A.getParsedKind() ==
12590+
ParsedAttr::AT_SYCLIntelFPGASpeculatedIterations) {
12591+
if (Val < 0) {
12592+
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
12593+
<< A.getAttrName() << /* non-negative */ 1;
12594+
return nullptr;
12595+
}
12596+
} else {
12597+
llvm_unreachable("unknown sycl fpga loop attr");
12598+
}
12599+
}
12600+
12601+
return new (Context) FPGALoopAttrT(Context, A, E);
12602+
}
12603+
1256012604
/// RAII object that enters a new expression evaluation context.
1256112605
class EnterExpressionEvaluationContext {
1256212606
Sema &Actions;

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -192,49 +192,6 @@ Sema::BuildSYCLIntelFPGAIVDepAttr(const AttributeCommonInfo &CI, Expr *Expr1,
192192
SYCLIntelFPGAIVDepAttr(Context, CI, SafeLenExpr, ArrayExpr, SafelenValue);
193193
}
194194

195-
template <typename FPGALoopAttrT>
196-
FPGALoopAttrT *Sema::BuildSYCLIntelFPGALoopAttr(const AttributeCommonInfo &A,
197-
Expr *E) {
198-
if (!E && !(A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce))
199-
return nullptr;
200-
201-
if (E && !E->isInstantiationDependent()) {
202-
llvm::APSInt ArgVal(32);
203-
204-
if (!E->isIntegerConstantExpr(ArgVal, getASTContext())) {
205-
Diag(E->getExprLoc(), diag::err_attribute_argument_type)
206-
<< A.getAttrName() << AANT_ArgumentIntegerConstant
207-
<< E->getSourceRange();
208-
return nullptr;
209-
}
210-
211-
int Val = ArgVal.getSExtValue();
212-
213-
if (A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGAII ||
214-
A.getParsedKind() == ParsedAttr::AT_SYCLIntelFPGALoopCoalesce) {
215-
if (Val <= 0) {
216-
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
217-
<< A.getAttrName() << /* positive */ 0;
218-
return nullptr;
219-
}
220-
} else if (A.getParsedKind() ==
221-
ParsedAttr::AT_SYCLIntelFPGAMaxConcurrency ||
222-
A.getParsedKind() ==
223-
ParsedAttr::AT_SYCLIntelFPGAMaxInterleaving ||
224-
A.getParsedKind() ==
225-
ParsedAttr::AT_SYCLIntelFPGASpeculatedIterations) {
226-
if (Val < 0) {
227-
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
228-
<< A.getAttrName() << /* non-negative */ 1;
229-
return nullptr;
230-
}
231-
} else {
232-
llvm_unreachable("unknown sycl fpga loop attr");
233-
}
234-
}
235-
236-
return new (Context) FPGALoopAttrT(Context, A, E);
237-
}
238195
// Filters out any attributes from the list that are either not the specified
239196
// type, or whose function isDependent returns true.
240197
template <typename T>

0 commit comments

Comments
 (0)