<div dir="ltr">Yes. Exactly. <div>So, I add my definition for custom attribute in '<span style="font-size:12.8px">include/clang/Basic/Attr.td', something like below.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">def MyHint : Attr {</span></div><div><span style="font-size:12.8px">  let Spellings = ~</span></div><div><span style="font-size:12.8px">  let Args = ~</span></div><div><span style="font-size:12.8px">  let AdditionalMembers = [{</span></div><div><span style="font-size:12.8px">      void printPrettyPragma( ~ ) </span></div><div><span style="font-size:12.8px">  }];</span></div><div><span style="font-size:12.8px">  let Documentation = [Undocumented];</span></div><div><span style="font-size:12.8px">}</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">This is basically similar with "def LoopHint : Attr", which is attribute of loop unroll.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">But somehow it seems it doesn't work properly. It can not emit 'MyHintAttr' class as well as its elements like 'MyHintAttr::Spelling', 'MyHintAttr::CreateImplicit(~)'. </span></div><div><span style="font-size:12.8px">My guess is there should be more things to do other than adding definition on Attr.td, so I'm trying to follow how those of LoopHIntAttr are emitted.</span></div><div><span style="font-size:12.8px">Is there any reference, or advice where to look at? Instruction on clang is somewhat simpler than my need. </span></div><div><span style="font-size:12.8px">It's my first time to hack this large program, so I'm stalling for hours at same status...</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks, in advance!</span></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 25, 2016 at 7:22 PM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> Yes. I checked that file, but I wasn't sure whether that is right one to look at.<br>
<br>
</span>It seems promising. I imagine you'd want something like the LoopHint attr.<br>
<span class=""><br>
> What is *.td extension btw?<br>
<br>
</span>The llvm project uses that extension to identify TableGen inputs<br>
(<a href="http://llvm.org/docs/TableGen/" rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>TableGen/</a>).<br>
<span class="HOEnZb"><font color="#888888"><br>
vedant<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> On Oct 25, 2016, at 4:12 PM, Sunghyun Park <<a href="mailto:sunggg@umich.edu">sunggg@umich.edu</a>> wrote:<br>
><br>
> Yes. I checked that file, but I wasn't sure whether that is right one to look at.<br>
> What is *.td extension btw? When I google it, it says this is for Windows Debug Simulator.<br>
> Why clang use this extension, which is limited to Windows environment?<br>
><br>
> On Tue, Oct 25, 2016 at 7:00 PM, Vedant Kumar <<a href="mailto:vsk@apple.com">vsk@apple.com</a>> wrote:<br>
> That file is generated by the clang-tblgen tool:<br>
><br>
>   COMMAND = cd /Users/vk/Desktop/llvm/DA-<wbr>NoModules/tools/clang/include/<wbr>clang/Sema && /Users/vk/Desktop/llvm/DA-<wbr>NoModules/bin/clang-tblgen -gen-clang-attr-parsed-attr-<wbr>list -I /Users/vk/Desktop/llvm/tools/<wbr>clang/include/clang/Sema/../..<wbr>/ -I /Users/vk/Desktop/llvm/tools/<wbr>clang/include/clang/Sema -I /Users/vk/Desktop/llvm/lib/<wbr>Target -I /Users/vk/Desktop/llvm/include /Users/vk/Desktop/llvm/tools/<wbr>clang/include/clang/Sema/../<wbr>Basic/Attr.td -o /Users/vk/Desktop/llvm/DA-<wbr>NoModules/tools/clang/include/<wbr>clang/Sema/AttrParsedAttrList.<wbr>inc.tmp<br>
><br>
> Try looking include/clang/Basic/Attr.td?<br>
><br>
> best,<br>
> vedant<br>
><br>
> > On Oct 25, 2016, at 2:54 PM, Sunghyun Park via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> ><br>
> > Hi, all.<br>
> > I want to give programmer ability to tell LLVM that certain region of code is expected to get specialized optimization.<br>
> > So, I'm trying to make custom pragma to mark certain region of code and pass this information to LLVM, in the similar way that '#pragma clang loop unroll_count(N)' works.<br>
> ><br>
> > By tracking the framework of loop unroll pragma, I found out it works in the way below.<br>
> > (1) Detect pragma at lexer, parser.<br>
> > (2) Create AttributeList and push it into AST.<br>
> > (3) Once AST is built, consume AST and generate LLVM IR at CodeGeneration<br>
> > (4) If attribute for loop unroll is found, put tag on LLVM IR with Meta data which indicates whether to unroll loop.<br>
> ><br>
> > Now I can detect my own pragma and figured it out how to create and tag custom metadata.<br>
> > The problem is that creating custom AttributeList is somewhat hard to follow.<br>
> ><br>
> > As far as I know, the attribute for loop unroll pragma gets serviced at ProcessSmtAttrbute Function @ tools/clang/lib/Sema/<wbr>SemaStmtAttr.cpp.<br>
> > It contains switch statement like below.<br>
> ><br>
> > ProcessSmtAttrbute @ tools/clang/lib/Sema/<wbr>SemaStmtAttr.cpp<br>
> > // A : AttributeList - passed by argument<br>
> > switch( A.getKind() ) {<br>
> >   case AttributeList::<wbr>UnknownAttribute:<br>
> >     ~<br>
> >   case AttributeList::AT_FallThrough:<br>
> >     return ~<br>
> >   case AttributeList::AT_LoopHint:<br>
> >     return handleLoopHintAttr( ~ )<br>
> >   case AttributeList::AT_<wbr>OpenCLUnrollHint:<br>
> >   ~<br>
> >   ...<br>
> > }<br>
> ><br>
> > As I want to define new attribute, I've tried to find where the definitions for AT_LoopHint, AT_FallThrough are done. This is what I found.<br>
> ><br>
> > class AttributeList @ tools/clang/include/clang/<wbr>Sema/AttributeList.h<br>
> ><br>
> > enum Kind{<br>
> >    #define PARSED ATTR(NAME) AT_##NAME,<br>
> >    #include "clang/Sema/<wbr>AttrParsedAttrList.inc"<br>
> >    #undef PARSED_ATTR<br>
> >    IgnoredAttribute,<br>
> >    UnkownAttribute<br>
> > };<br>
> ><br>
> > It looks like those are defined at this enum, but there's no such file, "clang/Sema/<wbr>AttrParsedAttrList.inc".<br>
> ><br>
> > Anyone knows how those definitions are defined and how the kind of attributes are decided?<br>
> > Thank you for your valuable time!<br>
> ><br>
> > --<br>
> > Best, Sung<br>
> > ______________________________<wbr>_________________<br>
> > LLVM Developers mailing list<br>
> > <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Best, Sung<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Best, Sung<br></div></div></div></div>
</div>