Date: Sun, 14 Jul 2019 10:40:27 +0200
From: Gonzalo BG via llvm-dev <firstname.lastname@example.org>
Subject: [llvm-dev] How to lower LLVM vector math intrinsics to symbol
Content-Type: text/plain; charset=“utf-8”
From a language frontend that generates LLVM-IR containing vector math
intrinsics, how can I tell LLVM to lower those to specific symbols ?
I kind of assumed that there must be a way for frontends too hook in
symbols to which to lower the intrinsics, but it appears that all symbol
lowering is hardcoded in LowerIntrinsic. For example, if instead of
llvm.memcpyI wanted that intrinsic to call a
_fooinstead, is that possible ?
What would be the simplest way to achieve this ? Could I insert my own
LowerIntrinsicpass that runs before the LLVM one, doing the lowering
that I want?
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.