@@ -3451,29 +3451,27 @@ static void handleWorkGroupSizeHint(Sema &S, Decl *D, const ParsedAttr &AL) {
3451
3451
}
3452
3452
3453
3453
// Handles max_work_group_size attribute.
3454
- // Returns a AttrArgResult value; EqualToOne means all argument values are
3455
- // equal to one, NotEqualToOne means at least one argument value is not
3456
- // equal to one, and Unknown means that at least one of the argument values
3457
- // could not be determined.
3458
- enum class AttrArgResult { Unknown, EqualToOne, NotEqualToOne };
3459
- static AttrArgResult AreAllAttrArgsOne (const Expr *E, const Expr *E1 ,
3460
- const Expr *E2 , const Expr *E3 ) {
3454
+ // If the declaration has a SYCLIntelMaxWorkGroupSizeAttr,
3455
+ // check to see if the attribute holds equal values (1, 1, 1).
3456
+ // Returns true if the attribute values are equal to one.
3457
+ static bool InvalidWorkGroupSizeAttrs (const Expr *E, const Expr *E1 ,
3458
+ const Expr *E2 , const Expr *E3 ) {
3461
3459
// If any of the operand is still value dependent, we can't test anything.
3462
3460
const auto *CE = dyn_cast<ConstantExpr>(E);
3463
3461
const auto *CE1 = dyn_cast<ConstantExpr>(E1 );
3464
3462
const auto *CE2 = dyn_cast<ConstantExpr>(E2 );
3465
3463
const auto *CE3 = dyn_cast<ConstantExpr>(E3 );
3466
3464
3467
3465
if (!CE || !CE1 || !CE2 || !CE3)
3468
- return AttrArgResult::Unknown ;
3466
+ return false ;
3469
3467
3470
3468
// Otherwise, check if the attribute values are equal to one.
3471
3469
if (CE->getResultAsAPSInt () == 0 &&
3472
3470
(CE1->getResultAsAPSInt () != 1 || CE2->getResultAsAPSInt () != 1 ||
3473
3471
CE3->getResultAsAPSInt () != 1 )) {
3474
- return AttrArgResult::NotEqualToOne ;
3472
+ return true ;
3475
3473
}
3476
- return AttrArgResult::EqualToOne ;
3474
+ return false ;
3477
3475
}
3478
3476
3479
3477
void Sema::AddSYCLIntelMaxWorkGroupSizeAttr (Decl *D,
@@ -3520,8 +3518,7 @@ void Sema::AddSYCLIntelMaxWorkGroupSizeAttr(Decl *D,
3520
3518
// the attribute holds equal values to (1, 1, 1) in case the value of
3521
3519
// SYCLIntelMaxGlobalWorkDimAttr equals to 0.
3522
3520
if (const auto *DeclAttr = D->getAttr <SYCLIntelMaxGlobalWorkDimAttr>()) {
3523
- if (AreAllAttrArgsOne (DeclAttr->getValue (), XDim, YDim, ZDim) ==
3524
- AttrArgResult::NotEqualToOne) {
3521
+ if (InvalidWorkGroupSizeAttrs (DeclAttr->getValue (), XDim, YDim, ZDim)) {
3525
3522
Diag (CI.getLoc (), diag::err_sycl_x_y_z_arguments_must_be_one)
3526
3523
<< CI << DeclAttr;
3527
3524
return ;
@@ -3582,8 +3579,8 @@ SYCLIntelMaxWorkGroupSizeAttr *Sema::MergeSYCLIntelMaxWorkGroupSizeAttr(
3582
3579
// (1, 1, 1) in case the value of SYCLIntelMaxGlobalWorkDimAttr
3583
3580
// equals to 0.
3584
3581
if (const auto *DeclAttr = D->getAttr <SYCLIntelMaxGlobalWorkDimAttr>()) {
3585
- if (AreAllAttrArgsOne (DeclAttr->getValue (), A.getXDim (), A. getYDim (),
3586
- A.getZDim ()) == AttrArgResult::NotEqualToOne ) {
3582
+ if (InvalidWorkGroupSizeAttrs (DeclAttr->getValue (), A.getXDim (),
3583
+ A. getYDim (), A.getZDim ())) {
3587
3584
Diag (A.getLoc (), diag::err_sycl_x_y_z_arguments_must_be_one)
3588
3585
<< &A << DeclAttr;
3589
3586
return nullptr ;
0 commit comments