[llvm-dev] RFC: Pass for lowering "non-linear" arithmetics of illegal types

Paweł Bylica via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 5 15:09:48 PDT 2015


Hi LLVM,

This is my idea I had some time ago, when I realized that LLVM did not
support legalization of some arithmetic instructions like mul i256. I have
implemented very simple and limited version of that in my project. Is it
something LLVM users would appreciate?

   1. The pass transforms IR and is meant to be run before CodeGen (after
   IR optimizations).
   2. The pass replaces instructions mul, udiv, urem, sdiv, srem that are
   know to be not supported by target's type legalization with a call to a
   function that implements given arithmetic operation.
   3. The pass also injects these functions to the module with a weak
   linkage.
   4. The pass requires a function generator (interface implementation) for
   mul and udivrem algorithms for integer types of sizes being powers of 2
   (i.e. i128, i256, ...). Replacements for other instructions are created
   using these 2 algorithms.
   5. A default implementation of the generator is provided.
   6. A user is able to provide its own implementation of the generator
   with algorithms better suitable for user's cases and/or for other than
   default instructions (e.g. sdiv i256, urem i199).


- Paweł
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151005/886c325e/attachment.html>


More information about the llvm-dev mailing list