<div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Message: 5<br>
Date: Sun, 14 Jul 2019 10:40:27 +0200<br>
From: Gonzalo BG via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
To: <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
Subject: [llvm-dev] How to lower LLVM vector math intrinsics to symbol<br>
calls ?<br>
Message-ID:<br>
<<a href="mailto:CAPMgRLQ6gRpkRxv_ocwc_RWuyF_tkgkes4af2HfAzRrH91juyQ@mail.gmail.com" target="_blank">CAPMgRLQ6gRpkRxv_ocwc_RWuyF_tkgkes4af2HfAzRrH91juyQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
>From a language frontend that generates LLVM-IR containing vector math<br>
intrinsics, how can I tell LLVM to lower those to specific symbols ?<br>...<br>
I kind of assumed that there must be a way for frontends too hook in<br>
symbols to which to lower the intrinsics, but it appears that all symbol<br>
lowering is hardcoded in LowerIntrinsic. For example, if instead of<br>
emitting `_memcpy` for `llvm.memcpy` I wanted that intrinsic to call a<br>
symbol `_foo` instead, is that possible ?<br>
<br>
What would be the simplest way to achieve this ? Could I insert my own<br>
`LowerIntrinsic` pass that runs before the LLVM one, doing the lowering<br>
that I want?<br></blockquote><div><br></div><div>I wrote a (trivial) pass that walked basic blocks looking for various function calls and rewrote them to symbols that were provided by a vector version of libm. Essentially a string switch and some type checks. In my case I ran it after vectorisation but there's a fair degree of control over when passes are run. Immediately after the front end sounds like it would suit you. Failing that, you can always look for whatever LowerIntrinsic rewrote them to.</div></div></div>