U
    Ã9%e»  ã                   @   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   úV/var/www/html/Darija-Ai-API/env/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   