<div dir="ltr"><div>Thanks for the tip. For some reason it didn't work. I'm sure I'm missing something very simple. Do you mind helping out? Here is what I have so far:<br></div><div><br></div><div>I'm getting a following error when I run a simple test:</div><div>cannot compile this builtin function yet<br></div><div><br></div><div>Here is the test code:</div><div><div>typedef int v4si __attribute__ ((vector_size (16)));</div><div><br></div><div>int foo (int a, int b, int c, int d) {</div><div>  v4si vec = {a, b, c, d};</div><div>  return esencia_hadd(vec);</div><div>}</div></div><div><br></div><div>My intrinsic is defined in <full path to llvm>/include/llvm/IR/IntrinsicsEsencia.td</div><div><br></div><div><div>let TargetPrefix = "esencia" in</div><div><span class="" style="white-space:pre">        </span>def int_esencia_hadd : Intrinsic<[llvm_i32_ty],</div><div><span class="" style="white-space:pre">         </span>                               [llvm_v4i32_ty],</div><div><span class="" style="white-space:pre">             </span>                               [IntrNoMem]>;</div></div><div><br></div><div><br></div><div>My builtin is defined in <full path to clang>/include/clang/Basic/BuiltinsEsencia.def</div><div><div>BUILTIN(esencia_hadd, "iV4Si", "nc")</div></div><div><br></div><div>I've also added code to <full path to clang/lib/Basic/Targerts.cpp </div><div><br></div><div><div>const Builtin::Info EsenciaTargetInfo::BuiltinInfo[] = {</div><div>#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS, 0, ALL_LANGUAGES },</div><div>#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) { #ID, TYPE, ATTRS, HEADER,\</div><div>                                              ALL_LANGUAGES },</div><div>#include "clang/Basic/BuiltinsEsencia.def"</div><div>};</div></div><div><br></div><div><br></div><div>as well as to <full path to clang>/include/clang/Basic/TargetBuiltins.h </div><div><br></div><div><div>  /// \brief Esencia builtins</div><div>  namespace Esencia {</div><div>    enum {</div><div>        LastTIBuiltin = clang::Builtin::FirstTSBuiltin-1,</div><div>#define BUILTIN(ID, TYPE, ATTRS) BI##ID,</div><div>#include "clang/Basic/BuiltinsEsencia.def"</div><div>        LastTSBuiltin</div><div>    };</div><div>  }</div></div><div><br></div><div>What am I missing?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 6:09 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">GCCBuiltin just gives it a name for clang to lookup. Generally they match up with builtins that gcc also implements, but that's not a requirement.<div><br></div><div>If you add a builtin with the same name to the builtin file in clang's include/clang/Basic/Builtins*.def then they will find each other.</div><div><br></div><div>You can also just add a builtin to clang's builtin file and catch it in clang's lib/CodeGen/CGBuiltins.cpp and implement whatever IR you want including calling an intrinsic.</div><div><br></div><div>Hope this helps.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, May 24, 2016 at 5:04 PM, Rail Shafigulin via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">I've created an intrinsic from my target, but I can't figure out how I can run it from a C code. Most of the targets have a GCCBuiltin and it looks like it is the way to execute an intrinsic from C code. However in my case there is no actual GCC built in.<div><br></div><div>Any help on this is really appreciated.<span><font color="#888888"><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div>Rail Shafigulin<br></div>Software Engineer <br>Esencia Technologies<br></div></div></div></div>
</font></span></div></div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>~Craig</div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Rail Shafigulin<br></div>Software Engineer <br>Esencia Technologies<br></div></div></div></div>
</div>