<div dir="ltr">Hi LLVM,<div><br></div><div>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?</div><div><ol><li>The pass transforms IR and is meant to be run before CodeGen (after IR optimizations).</li><li>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.</li><li>The pass also injects these functions to the module with a weak linkage.</li><li>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.</li><li>A default implementation of the generator is provided.</li><li>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).</li></ol><div><br></div></div><div>- PaweÅ‚</div></div>