U
    ?h                     @   sH   d dl mZ d dlmZmZ G dd deZG dd deZdd Zd	S )
    )ir)VisitorCallVisitorc                   @   s4   e Zd ZdZeddddddgZdd	 Zd
d ZdS )FastFloatBinOpVisitorzb
    A pass to add fastmath flag to float-binop instruction if they don't have
    any flags.
    ZfaddZfsubZfmulZfdivZfremZfcmpc                 C   s
   || _ d S Nflagsselfr    r   I/var/www/html/venv/lib/python3.8/site-packages/numba/core/fastmathpass.py__init__   s    zFastFloatBinOpVisitor.__init__c                 C   s.   |j | jkr*|js*| jD ]}|j| qd S r   )opnamefloat_binopsr   appendr
   instrflagr   r   r   visit_Instruction   s    
z'FastFloatBinOpVisitor.visit_InstructionN)__name__
__module____qualname____doc__	frozensetr   r   r   r   r   r   r   r      s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )FastFloatCallVisitorzD
    A pass to change all float function calls to use fastmath.
    c                 C   s
   || _ d S r   r   r	   r   r   r   r      s    zFastFloatCallVisitor.__init__c                 C   s2   |j t t fkr.| jD ]}|j| qd S r   )typer   Z	FloatTypeZ
DoubleTyper   Zfastmathaddr   r   r   r   
visit_Call   s    
zFastFloatCallVisitor.visit_CallN)r   r   r   r   r   r   r   r   r   r   r      s   r   c                 C   s&   |j }t||  t||  dS )zC
    Rewrite the given LLVM module to use fastmath everywhere.
    N)r   r   visitr   )modoptionsr   r   r   r   rewrite_module%   s    r!   N)Zllvmliter   Zllvmlite.ir.transformsr   r   r   r   r!   r   r   r   r   <module>   s   