|
26 | 26 | unarys += [("floor", "floorf", math.floor)] |
27 | 27 | unarys += [("fabs", "fabsf", math.fabs)] |
28 | 28 | unarys += [("exp", "expf", math.exp)] |
| 29 | +if sys.version_info >= (3, 11): |
| 30 | + unarys += [("exp2", "exp2f", math.exp2)] |
29 | 31 | unarys += [("expm1", "expm1f", math.expm1)] |
30 | 32 | unarys += [("erf", "erff", math.erf)] |
31 | 33 | unarys += [("erfc", "erfcf", math.erfc)] |
@@ -332,33 +334,6 @@ def tanhf_impl_fastmath(): |
332 | 334 | impl_unary_int(math.tanh, uint64, libdevice.tanh) |
333 | 335 |
|
334 | 336 |
|
335 | | -if sys.version_info >= (3, 11): |
336 | | - def impl_exp2(ty, libfunc): |
337 | | - def lower_exp2_impl(context, builder, sig, args): |
338 | | - def exp2_impl_inline_asm(): |
339 | | - fnty = ir.FunctionType(ir.FloatType(), [ir.FloatType()]) |
340 | | - if context.fastmath: |
341 | | - asm = ir.InlineAsm(fnty, "ex2.approx.ftz.f32 $0, $1;", "=f,f") |
342 | | - else: |
343 | | - asm = ir.InlineAsm(fnty, "ex2.approx.f32 $0, $1;", "=f,f") |
344 | | - return builder.call(asm, args) |
345 | | - |
346 | | - if ty == float32: |
347 | | - return exp2_impl_inline_asm() |
348 | | - else: |
349 | | - exp2_sig = typing.signature(ty, ty) |
350 | | - libfunc_impl = context.get_function(libfunc, exp2_sig) |
351 | | - return libfunc_impl(builder, args) |
352 | | - |
353 | | - lower(math.exp2, ty)(lower_exp2_impl) |
354 | | - |
355 | | - impl_exp2(types.float32, libdevice.exp2f) |
356 | | - impl_exp2(types.float64, libdevice.exp2) |
357 | | - |
358 | | - impl_unary_int(math.exp2, int64, libdevice.exp2) |
359 | | - impl_unary_int(math.exp2, uint64, libdevice.exp2) |
360 | | - |
361 | | - |
362 | 337 | # Complex power implementations - translations of _Py_c_pow from CPython |
363 | 338 | # https://github.com/python/cpython/blob/a755410e054e1e2390de5830befc08fe80706c66/Objects/complexobject.c#L123-L151 |
364 | 339 | # |
|
0 commit comments