VapourSynth-llvmexpr
Loading...
Searching...
No Matches
MathFunctionImpl< VectorWidth, MathOp::Atan > Struct Template Reference

#include <llvmexpr/codegen/llvm/Math.hpp>

Static Public Member Functions

static llvm::Function * generate (MathFunctionGenerator< VectorWidth > *gen)

Detailed Description

template<int VectorWidth>
struct MathFunctionImpl< VectorWidth, MathOp::Atan >

Definition at line 559 of file Math.hpp.

Member Function Documentation

◆ generate()

template<int VectorWidth>
llvm::Function * MathFunctionImpl< VectorWidth, MathOp::Atan >::generate ( MathFunctionGenerator< VectorWidth > * gen)
inlinestatic

Definition at line 560 of file Math.hpp.

560 {
561 constexpr auto OP_INFO = get_math_op_info(MathOp::Atan);
562 // https://stackoverflow.com/a/23097989
563 return gen->createFunction(
564 OP_INFO.name, OP_INFO.arity,
566 auto* var = args[0];
567 // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
568 auto* one = gen->getConstant(1.0F);
569 auto* pi_div_2 = gen->getConstant(1.5707963267948966F);
570 auto* z =
571 gen->createIntrinsicCall(llvm::Intrinsic::fabs, {var});
572 auto* z_gt_1 = gen->builder.CreateFCmpOGT(z, one);
573 auto* one_div_zz = gen->builder.CreateFDiv(one, z);
574 auto* a = gen->builder.CreateSelect(z_gt_1, one_div_zz, z);
575 auto* s = gen->builder.CreateFMul(a, a);
576 auto* q = gen->builder.CreateFMul(s, s);
577 llvm::Value* p = gen->getConstant(-2.0258553044340116e-5F);
578 llvm::Value* t = gen->getConstant(2.2302240345710764e-4F);
579 p = gen->createIntrinsicCall(
581 {p, q, gen->getConstant(-1.1640717779912220e-3F)});
582 t = gen->createIntrinsicCall(
584 {t, q, gen->getConstant(3.8559749383656407e-3F)});
585 p = gen->createIntrinsicCall(
587 {p, q, gen->getConstant(-9.1845592187222193e-3F)});
588 t = gen->createIntrinsicCall(
590 {t, q, gen->getConstant(1.6978035834594660e-2F)});
591 p = gen->createIntrinsicCall(
593 {p, q, gen->getConstant(-2.5826796814492296e-2F)});
594 t = gen->createIntrinsicCall(
596 {t, q, gen->getConstant(3.4067811082715810e-2F)});
597 p = gen->createIntrinsicCall(
599 {p, q, gen->getConstant(-4.0926382420509999e-2F)});
600 t = gen->createIntrinsicCall(
602 {t, q, gen->getConstant(4.6739496199158334e-2F)});
603 p = gen->createIntrinsicCall(
605 {p, q, gen->getConstant(-5.2392330054601366e-2F)});
606 t = gen->createIntrinsicCall(
608 {t, q, gen->getConstant(5.8773077721790683e-2F)});
609 p = gen->createIntrinsicCall(
611 {p, q, gen->getConstant(-6.6658603633512892e-2F)});
612 t = gen->createIntrinsicCall(
614 {t, q, gen->getConstant(7.6922129305867892e-2F)});
615 p = gen->createIntrinsicCall(llvm::Intrinsic::fma, {p, s, t});
616 p = gen->createIntrinsicCall(
618 {p, s, gen->getConstant(-9.0909012354005267e-2F)});
619 p = gen->createIntrinsicCall(
621 {p, s, gen->getConstant(1.1111110678749421e-1F)});
622 p = gen->createIntrinsicCall(
624 {p, s, gen->getConstant(-1.4285714271334810e-1F)});
625 p = gen->createIntrinsicCall(
627 {p, s, gen->getConstant(1.9999999999755005e-1F)});
628 p = gen->createIntrinsicCall(
630 {p, s, gen->getConstant(-3.3333333333331838e-1F)});
631 // NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
632 auto* pp_mul_ss = gen->builder.CreateFMul(p, s);
633 p = gen->createIntrinsicCall(llvm::Intrinsic::fma,
634 {pp_mul_ss, a, a});
635 auto* rr_if_gt_1 = gen->builder.CreateFSub(pi_div_2, p);
636 auto* rr = gen->builder.CreateSelect(z_gt_1, rr_if_gt_1, p);
637 return gen->createIntrinsicCall(llvm::Intrinsic::copysign,
638 {rr, var});
639 });
640 }
constexpr MathopInfo get_math_op_info(MathOp op)
Definition Math.hpp:86

References Atan, and get_math_op_info().


The documentation for this struct was generated from the following file: