@@ -3006,12 +3006,14 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &AL) {
3006
3006
return true ;
3007
3007
};
3008
3008
3009
- // / Returns the usigned constant integer value represented by
3010
- // / given expression.
3009
+ // Returns the unsigned constant integer value represented by
3010
+ // given expression.
3011
3011
auto getExprValue = [](const Expr *E, ASTContext &Ctx) {
3012
3012
return E->getIntegerConstantExpr (Ctx)->getZExtValue ();
3013
3013
};
3014
3014
3015
+ ASTContext &Ctx = S.getASTContext ();
3016
+
3015
3017
if (AL.getKind () == ParsedAttr::AT_SYCLIntelMaxGlobalWorkDim) {
3016
3018
ArrayRef<const Expr *> Dims;
3017
3019
Attr *B = nullptr ;
@@ -3020,51 +3022,45 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &AL) {
3020
3022
else if (const auto *B = D->getAttr <ReqdWorkGroupSizeAttr>())
3021
3023
Dims = B->dimensions ();
3022
3024
if (B) {
3023
- Result &= checkZeroDim (B, getExprValue (Dims[ 0 ], S. getASTContext ()),
3024
- getExprValue (Dims[1 ], S. getASTContext () ),
3025
- getExprValue (Dims[2 ], S. getASTContext () ));
3025
+ Result &=
3026
+ checkZeroDim (B, getExprValue (Dims[0 ], Ctx ),
3027
+ getExprValue (Dims[ 1 ], Ctx), getExprValue (Dims[2 ], Ctx ));
3026
3028
}
3027
3029
return Result;
3028
3030
}
3029
3031
3030
3032
if (AL.getKind () == ParsedAttr::AT_SYCLIntelMaxWorkGroupSize)
3031
3033
S.CheckDeprecatedSYCLAttributeSpelling (AL);
3032
3034
3033
- // For a SYCLDevice, WorkGroupAttr arguments are reversed.
3034
- // "XDim" gets the third argument to the attribute and
3035
- // "ZDim" gets the first argument of the attribute.
3036
3035
if (const auto *A = D->getAttr <SYCLIntelMaxGlobalWorkDimAttr>()) {
3037
- int64_t AttrValue =
3038
- A->getValue ()->getIntegerConstantExpr (S.Context )->getSExtValue ();
3039
- if (AttrValue == 0 ) {
3040
- Result &=
3041
- checkZeroDim (A, getExprValue (AL.getArgAsExpr (0 ), S.getASTContext ()),
3042
- getExprValue (AL.getArgAsExpr (1 ), S.getASTContext ()),
3043
- getExprValue (AL.getArgAsExpr (2 ), S.getASTContext ()),
3044
- /* ReverseAttrs=*/ true );
3036
+ if ((A->getValue ()->getIntegerConstantExpr (Ctx)->getSExtValue ()) == 0 ) {
3037
+ Result &= checkZeroDim (A, getExprValue (AL.getArgAsExpr (0 ), Ctx),
3038
+ getExprValue (AL.getArgAsExpr (1 ), Ctx),
3039
+ getExprValue (AL.getArgAsExpr (2 ), Ctx),
3040
+ /* ReverseAttrs=*/ true );
3045
3041
}
3046
3042
}
3047
3043
3048
3044
if (const auto *A = D->getAttr <SYCLIntelMaxWorkGroupSizeAttr>()) {
3049
- if (!((getExprValue (AL.getArgAsExpr (0 ), S. getASTContext () ) <=
3050
- getExprValue (A->getXDim (), S. getASTContext () )) &&
3051
- (getExprValue (AL.getArgAsExpr (1 ), S. getASTContext () ) <=
3052
- getExprValue (A->getYDim (), S. getASTContext () )) &&
3053
- (getExprValue (AL.getArgAsExpr (2 ), S. getASTContext () ) <=
3054
- getExprValue (A->getZDim (), S. getASTContext () )))) {
3045
+ if (!((getExprValue (AL.getArgAsExpr (0 ), Ctx ) <=
3046
+ getExprValue (A->getXDim (), Ctx )) &&
3047
+ (getExprValue (AL.getArgAsExpr (1 ), Ctx ) <=
3048
+ getExprValue (A->getYDim (), Ctx )) &&
3049
+ (getExprValue (AL.getArgAsExpr (2 ), Ctx ) <=
3050
+ getExprValue (A->getZDim (), Ctx )))) {
3055
3051
S.Diag (AL.getLoc (), diag::err_conflicting_sycl_function_attributes)
3056
3052
<< AL << A->getSpelling ();
3057
3053
Result &= false ;
3058
3054
}
3059
3055
}
3060
3056
3061
3057
if (const auto *A = D->getAttr <ReqdWorkGroupSizeAttr>()) {
3062
- if (!((getExprValue (AL.getArgAsExpr (0 ), S. getASTContext () ) >=
3063
- getExprValue (A->getXDim (), S. getASTContext () )) &&
3064
- (getExprValue (AL.getArgAsExpr (1 ), S. getASTContext () ) >=
3065
- getExprValue (A->getYDim (), S. getASTContext () )) &&
3066
- (getExprValue (AL.getArgAsExpr (2 ), S. getASTContext () ) >=
3067
- getExprValue (A->getZDim (), S. getASTContext () )))) {
3058
+ if (!((getExprValue (AL.getArgAsExpr (0 ), Ctx ) >=
3059
+ getExprValue (A->getXDim (), Ctx )) &&
3060
+ (getExprValue (AL.getArgAsExpr (1 ), Ctx ) >=
3061
+ getExprValue (A->getYDim (), Ctx )) &&
3062
+ (getExprValue (AL.getArgAsExpr (2 ), Ctx ) >=
3063
+ getExprValue (A->getZDim (), Ctx )))) {
3068
3064
S.Diag (AL.getLoc (), diag::err_conflicting_sycl_function_attributes)
3069
3065
<< AL << A->getSpelling ();
3070
3066
Result &= false ;
0 commit comments