Me and Aaron talked about this over IRC. The plan for now is to make this produce an "attribute ignored" warning, since full support isn't there yet.
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Aaron Ballman Sent: 04 September 2013 13:27 To: Joey Gouly Cc: llvm cfe Subject: Re: r177035 - Add support for the 'endian' attribute for OpenCL. Ping? On Sun, Sep 1, 2013 at 1:51 PM, Aaron Ballman <[email protected]> wrote: > I realize this is kind of ancient history, but I'm confused -- this > doesn't attach the attribute to anything in handleEndianAttr. It does > some semantic checking, but makes no Attr object, and doesn't attach > anything to the decl. What's more, it seems to have no semantic > changes elsewhere either (no modifications to codegen, etc). > > Am I missing something that makes this functionality complete? If > not, is anyone actively working on it? > > ~Aaron > > On Thu, Mar 14, 2013 at 5:54 AM, Joey Gouly <[email protected]> wrote: >> Author: joey >> Date: Thu Mar 14 04:54:43 2013 >> New Revision: 177035 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=177035&view=rev >> Log: >> Add support for the 'endian' attribute for OpenCL. >> >> Added: >> cfe/trunk/test/SemaOpenCL/endian-attr.cl >> Modified: >> cfe/trunk/include/clang/Basic/Attr.td >> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> cfe/trunk/lib/Sema/SemaDeclAttr.cpp >> >> Modified: cfe/trunk/include/clang/Basic/Attr.td >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=177035&r1=177034&r2=177035&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Basic/Attr.td (original) >> +++ cfe/trunk/include/clang/Basic/Attr.td Thu Mar 14 04:54:43 2013 >> @@ -632,6 +632,11 @@ def ReqdWorkGroupSize : InheritableAttr >> UnsignedArgument<"ZDim">]; >> } >> >> +def Endian : InheritableAttr { >> + let Spellings = [GNU<"endian">]; >> + let Args = [IdentifierArgument<"platform">]; >> +} >> + >> def WorkGroupSizeHint : InheritableAttr { >> let Spellings = [GNU<"work_group_size_hint">]; >> let Args = [UnsignedArgument<"XDim">, >> >> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=177035&r1=177034&r2=177035&view=diff >> ============================================================================== >> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) >> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar 14 04:54:43 >> 2013 >> @@ -2150,6 +2150,8 @@ def warn_attribute_protected_visibility >> Warning<"target does not support 'protected' visibility; using >> 'default'">, >> InGroup<DiagGroup<"unsupported-visibility">>; >> def err_mismatched_visibility: Error<"visibility does not match previous >> declaration">; >> +def warn_attribute_unknown_endian : Warning<"unknown endian '%0'">, >> + InGroup<IgnoredAttributes>; >> def note_previous_attribute : Note<"previous attribute is here">; >> def err_unknown_machine_mode : Error<"unknown machine mode %0">; >> def err_unsupported_machine_mode : Error<"unsupported machine mode %0">; >> >> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=177035&r1=177034&r2=177035&view=diff >> ============================================================================== >> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) >> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Mar 14 04:54:43 2013 >> @@ -2799,6 +2799,15 @@ static void handleVecTypeHint(Sema &S, D >> ParmType, Attr.getLoc())); >> } >> >> +static void handleEndianAttr(Sema &S, Decl *D, const AttributeList &Attr) { >> + if (!dyn_cast<VarDecl>(D)) >> + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << "endian" >> + << 9; >> + StringRef EndianType = Attr.getParameterName()->getName(); >> + if (EndianType != "host" && EndianType != "device") >> + S.Diag(Attr.getLoc(), diag::warn_attribute_unknown_endian) << >> EndianType; >> +} >> + >> SectionAttr *Sema::mergeSectionAttr(Decl *D, SourceRange Range, >> StringRef Name, >> unsigned AttrSpellingListIndex) { >> @@ -4783,6 +4792,10 @@ static void ProcessInheritableDeclAttr(S >> case AttributeList::AT_VecTypeHint: >> handleVecTypeHint(S, D, Attr); break; >> >> + case AttributeList::AT_Endian: >> + handleEndianAttr(S, D, Attr); >> + break; >> + >> case AttributeList::AT_InitPriority: >> handleInitPriorityAttr(S, D, Attr); break; >> >> >> Added: cfe/trunk/test/SemaOpenCL/endian-attr.cl >> URL: >> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/endian-attr.cl?rev=177035&view=auto >> ============================================================================== >> --- cfe/trunk/test/SemaOpenCL/endian-attr.cl (added) >> +++ cfe/trunk/test/SemaOpenCL/endian-attr.cl Thu Mar 14 04:54:43 2013 >> @@ -0,0 +1,9 @@ >> +// RUN: %clang_cc1 -verify %s >> + >> +constant long a __attribute__((endian(host))) = 100; >> + >> +constant long b __attribute__((endian(device))) = 100; >> + >> +constant long c __attribute__((endian(none))) = 100; // expected-warning >> {{unknown endian 'none'}} >> + >> +void func() __attribute__((endian(host))); // expected-warning {{endian >> attribute only applies to variables}} >> >> >> _______________________________________________ >> cfe-commits mailing list >> [email protected] >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
