Skip to content

Commit dc0eaac

Browse files
committed
Implementing DefaultUnsignedArgument class
Signed-off-by: Aleksander Fadeev <[email protected]>
1 parent 8a3f1b8 commit dc0eaac

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ class DefaultIntArgument<string name, int default> : IntArgument<name, 1> {
236236
int Default = default;
237237
}
238238

239+
class DefaultUnsignedArgument<string name, int default> : UnsignedArgument<name, 1> {
240+
int Default = default;
241+
}
242+
239243
// This argument is more complex, it includes the enumerator type name,
240244
// a list of strings to accept, and a list of enumerators to map them to.
241245
class EnumArgument<string name, string type, list<string> values,
@@ -2413,14 +2417,14 @@ def NoDeref : TypeAttr {
24132417
let Documentation = [NoDerefDocs];
24142418
}
24152419

2416-
//Default arguments in ReqWorkGroupSize can be used only with
2417-
//intel::reqd_work_group_size spelling.
2420+
// Default arguments in ReqWorkGroupSize can be used only with
2421+
// intel::reqd_work_group_size spelling.
24182422
def ReqdWorkGroupSize : InheritableAttr {
24192423
let Spellings = [GNU<"reqd_work_group_size">,
2420-
CXX11<"cl","reqd_work_group_size">,
2421-
CXX11<"intel","reqd_work_group_size">];
2422-
let Args = [IntArgument<"XDim">, DefaultIntArgument<"YDim", 1>,
2423-
DefaultIntArgument<"ZDim", 1>];
2424+
CXX11<"intel","reqd_work_group_size">,
2425+
CXX11<"cl","reqd_work_group_size">];
2426+
let Args = [UnsignedArgument<"XDim">, DefaultUnsignedArgument<"YDim", 1>,
2427+
DefaultUnsignedArgument<"ZDim", 1>];
24242428
let Subjects = SubjectList<[Function], ErrorDiag>;
24252429
let Documentation = [ReqdWorkGroupSizeAttrDocs];
24262430
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,9 +2922,7 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29222922
return;
29232923

29242924
uint32_t WGSize[3];
2925-
if (AL.getAttributeSpellingListIndex() == 2) {
2926-
WorkGroupAttr *Ex = D->getAttr<WorkGroupAttr>
2927-
std::string str(Ex->getSpelling());
2925+
if (AL.getNormalizedFullName() == "intel::reqd_work_group_size") {
29282926
WGSize[1] = ReqdWorkGroupSizeAttr::DefaultYDim;
29292927
WGSize[2] = ReqdWorkGroupSizeAttr::DefaultZDim;
29302928
} else if (!checkAttributeNumArgs(S, AL, 3))

clang/test/SemaSYCL/intel-reqd-work-group-size.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// expected-no-diagnostics
77
class Functor {
88
public:
9-
[[intel::reqd_work_group_size(4)]] [[intel::reqd_work_group_size(4)]] void operator()() {}
9+
[[intel::reqd_work_group_size(4)]] void operator()() {}
1010
};
1111

1212
template <typename name, typename Func>

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,9 @@ createArgument(const Record &Arg, StringRef Attr,
13041304
else if (ArgName == "DefaultIntArgument")
13051305
Ptr = std::make_unique<DefaultSimpleArgument>(
13061306
Arg, Attr, "int", Arg.getValueAsInt("Default"));
1307+
else if (ArgName == "DefaultUnsignedArgument")
1308+
Ptr = std::make_unique<DefaultSimpleArgument>(
1309+
Arg, Attr, "unsigned", Arg.getValueAsInt("Default"));
13071310
else if (ArgName == "IntArgument")
13081311
Ptr = std::make_unique<SimpleArgument>(Arg, Attr, "int");
13091312
else if (ArgName == "StringArgument")

0 commit comments

Comments
 (0)