<s> """<STR_LIT>""" <EOL> import sys <EOL> from llvmlite import ir <EOL> import llvmlite . binding as ll <EOL> from numba import utils <EOL> from numba import _helperlib , _npymath_exports <EOL> from . import intrinsics <EOL> def _add_missing_symbol ( symbol , addr ) : <EOL> """<STR_LIT>""" <EOL> if not ll . address_of_symbol ( symbol ) : <EOL> ll . add_symbol ( symbol , addr ) <EOL> def _get_msvcrt_symbol ( symbol ) : <EOL> """<STR_LIT>""" <EOL> from ctypes import cdll , cast , c_void_p <EOL> f = getattr ( cdll . msvcrt , symbol ) <EOL> return cast ( f , c_void_p ) . value <EOL> def compile_multi3 ( context ) : <EOL> """<STR_LIT>""" <EOL> codegen = context . codegen ( ) <EOL> library = codegen . create_library ( "<STR_LIT>" ) <EOL> ir_mod = library . create_ir_module ( "<STR_LIT>" ) <EOL> i64 = ir . IntType ( <NUM_LIT:64> ) <EOL> i128 = ir . IntType ( <NUM_LIT> ) <EOL> lower_mask = ir . Constant ( i64 , <NUM_LIT> ) <EOL> _32 = ir . Constant ( i64 , <NUM_LIT:32> ) <EOL> _64 = ir . Constant ( i128 , <NUM_LIT:64> ) <EOL> fn_type = ir . FunctionType ( i128 , [ i128 , i128 ] ) <EOL> fn = ir . Function ( ir_mod , fn_type , name = "<STR_LIT>" ) <EOL> a , b = fn . args <EOL> bb = fn . append_basic_block ( ) <EOL> builder = ir . IRBuilder ( bb ) <EOL> al = builder . trunc ( a , i64 ) <EOL> bl = builder . trunc ( b , i64 ) <EOL> ah = builder . trunc ( builder . ashr ( a , _64 ) , i64 ) <EOL> bh = builder . trunc ( builder . ashr ( b , _64 ) , i64 ) <EOL> rl = builder . mul ( builder . and_ ( al , lower_mask ) , builder . and_ ( bl , lower_mask ) ) <EOL> t = builder . lshr ( rl , _32 ) <EOL> rl = builder . and_ ( rl , lower_mask ) <EOL> t = builder . add ( t , builder . mul ( builder . lshr ( al , _32 ) , <EOL> builder . and_ ( bl , lower_mask ) ) ) <EOL> rl = builder . add ( rl , builder . shl ( t , _32 ) ) <EOL> rh = builder . lshr ( t , _32 ) <EOL> t = builder . lshr ( rl , _32 ) <EOL> rl = builder . and_ ( rl , lower_mask ) <EOL> t = builder . add ( t , builder . mul ( builder . lshr ( bl , _32 ) , <EOL> builder . and_ ( al , lower_mask ) ) ) <EOL> rl = builder . add ( rl , builder . shl ( t , _32 ) ) <EOL> rh = builder . add ( rh , builder . lshr ( t , _32 ) ) <EOL> rh = builder . add ( rh , builder . mul ( builder . lshr ( al , _32 ) , <EOL> builder . lshr ( bl , _32 ) ) ) <EOL> rh = builder . add ( rh , builder . mul ( bh , al ) ) <EOL> rh = builder . add ( rh , builder . mul ( bl , ah ) ) <EOL> r = builder . zext ( rl , i128 ) <EOL> r = builder . add ( r , builder . shl ( builder . zext ( rh , i128 ) , _64 ) ) <EOL> builder . ret ( r ) <EOL> library . add_ir_module ( ir_mod ) <EOL> library . finalize ( ) <EOL> return library <EOL> class _Installer ( object ) : <EOL> _installed = False <EOL> def install ( self , context ) : <EOL> """<STR_LIT>""" <EOL> if not self . _installed : <EOL> self . _do_install ( context ) <EOL> self . _installed = True <EOL> class _ExternalMathFunctions ( _Installer ) : <EOL> """<STR_LIT>""" <EOL> def _do_install ( self , context ) : <EOL> is32bit = utils . MACHINE_BITS == <NUM_LIT:32> <EOL> c_helpers = _helperlib . c_helpers <EOL> for name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> ll . add_symbol ( "<STR_LIT>" % name , c_helpers [ name ] ) <EOL> if sys . platform . startswith ( '<STR_LIT:win32>' ) and is32bit : <EOL> ftol = _get_msvcrt_symbol ( "<STR_LIT>" ) <EOL> _add_missing_symbol ( "<STR_LIT>" , ftol ) <EOL> elif sys . platform . startswith ( '<STR_LIT>' ) and is32bit : <EOL> _add_missing_symbol ( "<STR_LIT>" , c_helpers [ "<STR_LIT>" ] ) <EOL> _add_missing_symbol ( "<STR_LIT>" , c_helpers [ "<STR_LIT>" ] ) <EOL> if is32bit : <EOL> self . _multi3_lib = compile_multi3 ( context ) <EOL> ptr = self . _multi3_lib . get_pointer_to_function ( "<STR_LIT>" ) <EOL> assert ptr <EOL> _add_missing_symbol ( "<STR_LIT>" , ptr ) <EOL> for fname in intrinsics . INTR_MATH : <EOL> ll . add_symbol ( fname , c_helpers [ fname ] ) <EOL> class _ExternalNumpyFunctions ( _Installer ) : <EOL> """<STR_LIT>""" <EOL> def _do_install ( self , context ) : <EOL> for sym in _npymath_exports . symbols : <EOL> ll . add_symbol ( * sym ) <EOL> c_math_functions = _ExternalMathFunctions ( ) <EOL> c_numpy_functions = _ExternalNumpyFunctions ( ) </s>
