U
    Ã9%eTÜ  ã                	   @   sÈ  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ	 d dl
mZ d dlmZmZ d dlmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
l m!Z! e"ddddddddgƒZ#dd„ Z$dd„ Z%dd„ Z&G dd„ de'ƒZ(G dd„ dedZ)G dd„ de)ƒZ*G d d!„ d!e*ƒZ+G d"d#„ d#e*ƒZ,G d$d%„ d%e'ƒZ-d&d'„ Z.G d(d)„ d)e'ƒZ/G d*d+„ d+edZ0G d,d-„ d-e0ƒZ1G d.d/„ d/e1ƒZ2G d0d1„ d1e1ƒZ3d2d3„ Z4d4d5„ Z5dS )6é    N)ÚabstractmethodÚABCMeta)ÚutilsÚconfigÚcgutils)Úcreate_pass_manager_builder)Úremove_redundant_nrt_refct)Úrtsys)Úrequire_global_compiler_lock)ÚNumbaInvalidConfigWarning)Údisassemble_elf_to_cfg)ÚPassTimingsCollectionÚx86Úi386Zi486Zi586Úi686Zi786Zi886Zi986c                 C   s   |   d¡d }|tkS )Nú-r   )ÚsplitÚ_x86arch)ÚtripleÚarch© r   úQ/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/numba/core/codegen.pyÚ_is_x86   s    r   c               	   C   sn   t j d¡} | sdS d}| D ]L}| ¡ }z|ttj| ¡ ƒO }W q tk
rf   t	 
d|›t¡ Y qX q|S )zÌParse refprune flags from the `config`.

    Invalid values are ignored an warn via a `NumbaInvalidConfigWarning`
    category.

    Returns
    -------
    flags : llvmlite.binding.RefPruneSubpasses
    ú,r   zinvalid refprune flags )r   ZLLVM_REFPRUNE_FLAGSr   ÚstripÚgetattrÚllZRefPruneSubpassesÚupperÚAttributeErrorÚwarningsÚwarnr   )ÚflagsÚvalÚitemr   r   r   Ú_parse_refprune_flags    s    
ÿr$   c           	         sÆ   t jr–zdd l}W n  tk
r2   d}t|ƒ‚Y qšX ddlm‰ ddlm} ddlm} ddl	m
‰  ddlm‰ ||dœ}|| ‰‡ ‡‡‡fd	d
„}nt}tdƒ t|  dd¡ƒ ||ƒ tdƒ d S )Nr   z0Please install pygments to see highlighted dumps)Ú	highlight)ÚGasLexer)Ú	LlvmLexer)ÚTerminal256Formatter)Úby_colorscheme)ÚllvmÚasmc                    s   t ˆ| ˆƒ ˆ ˆƒ dƒƒ d S )N)Ústyle)Úprint)Úarg©r(   r)   r%   Úlexerr   r   ÚprinterH   s    

ÿzdump.<locals>.printerzP================================================================================éP   r   )r   ZHIGHLIGHT_DUMPSÚpygmentsÚImportErrorÚ
ValueErrorr%   Zpygments.lexersr&   r'   Zpygments.formattersr(   Znumba.misc.dump_styler)   r-   Úcenter)	ÚheaderÚbodyÚlangr3   ÚmsgZ	gas_lexerZ
llvm_lexerZ	lexer_mapr1   r   r/   r   Údump8   s&    
r;   c                   @   s<   e Zd ZdZdd„ Zddd	„Zddd„Zdd„ Zdd„ ZdS )Ú_CFGa  
    Wraps the CFG graph for different display method.

    Instance of the class can be stringified (``__repr__`` is defined) to get
    the graph in DOT format.  The ``.display()`` method plots the graph in
    PDF.  If in IPython notebook, the returned image can be inlined.
    c                 K   s2   || _ || _|| _| |¡}t |¡| _|| _d S ©N)ÚcresÚnameÚpy_funcÚget_functionr   Úget_function_cfgÚdotÚkwargs)Úselfr>   r?   r@   rD   Úfnr   r   r   Ú__init__[   s    
z_CFG.__init__NTFé
   c	           K         sP  ddl ‰ddl‰ddl}	ddl}
ddlm} ddlm} ddlm	} ddl
m} d}|||||||||d}|||d	‰ d
d„ }|||ƒ |ˆ |ƒ |dd„ ƒ‰dˆd< dˆd< dˆd< dˆd< dˆd< dˆd< dˆd< dˆd< dˆd< d ˆd!< d"ˆd#< | j | j¡}| j ¡ }‡fd$d%„}||ƒ‰
‡fd&d'„}|| j| j|ƒ}ˆ d(¡}ˆ d)¡}ˆ d*¡‰d+}ˆ |¡‰	ˆ d,¡}ˆ d-¡}ˆ d.¡}ˆ d/¡}ˆ d0¡}ˆ d1¡}ˆ d2¡} ˆ d3¡}!d4d5„ }"d6d7„ ‰i }#i }$ˆ jrì|
 | j¡\‰‰| |¡ d8d9¡}%ˆ |%¡jd:d;}&|	 |& d<¡¡}'d}(|'d= D ]})d>\‰‰|)d? }*|)d@ }+|)dA },|+|#|,< |*dBdC… }*|* dD¡}-g }.dB‰d9}/| |-dC ¡}0|-}1|0dk	r2|0 ¡ d }2|2 dE¡}3t|3ƒ‰dF}4g }5|jrÚˆd ˆd dGœ}6ni }6|3D ]8}7| |7¡ ¡ \}8}9|6 |9dH¡}:|5  |4 !|:|8|9¡¡ qâd9 "|5¡}/|-ddC… }1dI};|.  |; !ˆdJ ˆˆ|1d  #¡ ƒ¡¡ dK‰‡ ‡‡‡‡‡‡‡‡	‡
‡‡fdLdM„}<|1dBd… D ]X}=| |=¡r¢qŒˆ j$s²ˆ jrÎ|<|=|.ƒ}>|>dk	rÎ|>\‰‰|j%rì| &|=¡rìˆd }?n¼|j'r
| &|=¡r
ˆd }?nž|j(r(| &|=¡r(ˆd }?n€|j)rF|  &|=¡rFˆd }?nb|j*rd|! &|=¡rdˆd }?nD|j+r‚| &|=¡r‚ˆd! }?n&|j,r | &|=¡r ˆd# }?nˆdJ }?|?ˆdJ k	s¼|sŒ|"ˆ|=ƒƒD ]}@|.  ˆ !|?ˆ|@¡¡ qÈqŒ|/rþ|.  dN !|/¡¡ d9 "|.¡}A|Ar&dO|(|Af }BdP !|B¡}*nd9}*|j-|+|*dQ q,dR|'kr€|'dR D ]0}C|CdA },|C dSd¡}D|CdT |CdU |Df|$|,< qN|$ .¡ D ]L\},}C|#|CdB  }E|#|Cd  }F|CdV }G|Gdk	rÆ|EdW|G 7 }E| /|E|F¡ qˆ|r g }Hˆ .¡ D ]\}I}J|H  dX !|J|I¡¡ qè|j-dYdZ !d9 "|H¡¡dQ |dk	s4|dk	rD|j0|||d[ |jd\d;S )]z§
        "Pretty" prints the DOT graph of the CFG.
        For explanation of the parameters see the docstring for
        numba.core.dispatcher::inspect_cfg.
        r   N)Úbinding)ÚList)ÚSimpleNamespace)ÚdefaultdictF)ÚincrefÚdecrefÚreturnsÚraisesÚmeminfoÚbranchesÚllvm_intrin_callsÚfunction_calls)ÚpythonÚlineinfoc                 S   sÖ   t |tƒr$| jD ]}t| ||ƒ qn®t |tƒr„| ¡ D ]J\}}|| jkrTtd| ƒ‚t |tƒrlt| ||ƒ q6d}t|||f ƒ‚q6nNt |tƒr¾|D ](}|| jkr®td| ƒ‚q’t| |dƒ q’nd}t|t|ƒ ƒ‚dS )zß Parses the kwarg into a consistent format for use in configuring
            the Digraph rendering. _config is the configuration instance to
            update, kwarg is the kwarg on which to base the updates.
            zUnexpected key in kwarg: %sz$Unexpected value for key: %s, got:%sTz)Unhandled configuration type for kwarg %sN)	Ú
isinstanceÚboolÚ__dict__ÚsetattrÚdictÚitemsr5   ÚsetÚtype)Ú_configÚkwargÚattrÚkÚvr:   r#   r   r   r   Úparse_config€   s$    






z)_CFG.pretty_printer.<locals>.parse_configc                   S   s   dS )NÚwhiter   r   r   r   r   Ú<lambda>    ó    z%_CFG.pretty_printer.<locals>.<lambda>ZorangeÚmarkerÚyellowrU   ÚgreenZtruebrÚredZfalsebrÚcyanrM   Z	turquoiserN   Z	lightpinkÚraiseZlightseagreenrQ   ÚpurpleÚreturnZ	rosybrownrS   ÚtomatorT   c                    sb   i }ˆ   d¡}|  ¡ D ]F}| |¡}|dk	r| ¡ }|dk	rt|ƒdksLt‚|d ||d < q|S )zÑ Gets the metadata entries from the LLVM IR, these look something
            like '!123 = INFORMATION'. Returns a map of metadata key to metadata
            value, i.e. from the example {'!123': INFORMATION}z(^[!][0-9]+)(\s+=\s+.*)Né   é   r   )ÚcompileÚ
splitlinesÚmatchÚgroupsÚlenÚAssertionError)Úllvm_strÚmdZmetadata_entryÚxru   Úg)Úrer   r   Úget_metadata²   s    

z)_CFG.pretty_printer.<locals>.get_metadatac                    sj   d}t |ƒ|kr4d|› d}t |t¡ |d |… }ˆ j| |d}|jdd |jddd	t|ƒ d
 |S )NéÈ   zCFG output filename "z9" exceeds maximum supported length, it will be truncated.)ÚfilenameÚTB)ZrankdirÚnodeÚnonez%s)ÚshapeÚfontsize)rw   r   r    r   ZDigraphra   Ústr)r?   Úfnamer…   ZcmaxZwstrÚf)Úgvr   r   Úinit_digraphÄ   s    z)_CFG.pretty_printer.<locals>.init_digraphz
.*{(.*)}.*z.*<(.*)>(.*)z.*!dbg\s+(![0-9]+).*z7.*!DILocation\(line:\s+([0-9]+),\s+column:\s+([0-9]),.*z.*call void @llvm.dbg.value.*z@NRT_incref\bz@NRT_decref\bz@NRT_MemInfoz.*call.*@llvm\..*z.*call.*@.*z"store .*\!numba_exception_output.*zret i32 [^1],?.*c                 S   s   t j| dddS )Néx   z... )ÚwidthÚsubsequent_indent)ÚtextwrapÚwrap)Úsr   r   r   r   ñ   s    z!_CFG.pretty_printer.<locals>.wrapc                 S   sz   d}t | ƒ|kr0tt| ƒƒ}d | d |… |¡} t | ¡} |  dd¡} |  dd¡} |  dd¡} |  d	d
¡} |  dd¡} | S )Ni,  z{}...<hash={}>z\{z&#123;z\}z&#125;ú\z&#92;ú%z&#37;ú!z&#33;)rw   r†   ÚhashÚformatÚhtmlÚescapeÚreplace)r   ÚnÚhsr   r   r   Úcleanö   s    
z"_CFG.pretty_printer.<locals>.cleanz\l...Ú Zdot_json)r•   úutf-8Úobjects)éÿÿÿÿrŸ   Úlabelr?   Z_gvidrr   rŸ   z\lú|z<<td BGCOLOR="{}" BORDER="1" ALIGN="center" PORT="{}">{}</td>)ÚTÚFre   zF<tr><td BGCOLOR="{}" BORDER="1" ALIGN="left" COLSPAN="{}">{}</td></tr>ÚdefaultzF<tr><td BGCOLOR="{}" BORDER="0" ALIGN="left" COLSPAN="{}">{}</td></tr>c                    s*  ˆ
  | ¡}|dk	r&| ¡ }|dk	r&t|ƒdks:t|ƒ‚|d }ˆ	 |d¡}|dk	r&ˆ  |¡}|dk	r&t| ¡ ƒdks„t|ƒ‚| ¡ \}}|ˆks¢|ˆkr&ˆ jrÚd}	|	|||f }
ˆ ˆd ˆˆ|
ƒ¡}| |¡ ˆ jrt	|ƒˆd  }ˆ|d  }ˆ ˆd ˆˆ|ƒ¡}| |¡ ||fS dS )zŸ
                Search line `l` for metadata associated with python or line info
                and inject it into `new_lines` if requested.
                Nrr   r   rq   zMarker %s, Line %s, column %srh   rU   )
ru   rv   rw   rx   ÚgetrV   r•   ÚappendrU   Úint)ÚlÚ	new_linesÚmatchedr|   rh   Z
debug_dataÚldÚlineÚcolZmfmtZ	mark_lineÚlnZlidxZsource_line)Ú_interleaver›   Úcol_spanÚcsÚcur_colÚcur_lineÚfirstlinenoÚfmtÚlocation_entryrz   Úmetadata_markerÚsrc_coder   r   Úmetadata_interleavei  s8    





ÿ
ÿ
z0_CFG.pretty_printer.<locals>.metadata_interleavez<tr>{}</tr>zS<table id="%s" BORDER="1" CELLBORDER="0" CELLPADDING="0" CELLSPACING="0">%s</table>z<{}>)r    ÚedgesZtailportÚheadÚtailrq   z:%sz;<tr><td BGCOLOR="{}" BORDER="0" ALIGN="center">{}</td></tr>ÚKeyzn<<table BORDER="1" CELLBORDER="1" CELLPADDING="2" CELLSPACING="1"><tr><td BORDER="0">Key:</td></tr>{}</table>>)r€   Úviewr•   Úsvg)1Úgraphvizr}   ÚjsonÚinspectZllvmliterI   Znumba.typedrJ   ÚtypesrK   ÚcollectionsrL   r>   rA   r?   Úget_llvm_strrs   rU   Úgetsourcelinesr@   rB   r˜   ZSourceÚpipeÚloadsÚdecoder   ru   rv   rw   rR   r¥   r¦   r•   Újoinr   rV   rM   ÚsearchrN   rQ   rP   rO   rS   rT   r‚   r\   ÚedgeÚrender)KrE   r€   r¾   Úrender_formatr%   Ú
interleaveZstrip_irZshow_keyr…   rÁ   rÂ   r   rJ   rK   rL   Ú_defaultÚ
_highlightrd   rF   ry   r~   rŠ   rˆ   Z
port_matchZport_jmp_matchZlocation_exprZ	dbg_valueZ
nrt_increfZ
nrt_decrefZnrt_meminfoZll_intrin_callsZll_function_callZll_raiseZ	ll_returnr   Znode_idsZedge_idsZraw_dotZ
json_bytesZjzonZidcÚobjr    r?   ZgvidÚlinesr©   Z	port_linerª   Zsliced_linesZportsZports_tokensZtdfmtZtbl_dataÚcolorsÚtokÚtargetÚvalueÚcolorZ	fmtheaderr¹   r¨   Zupdated_lineinfoÚcolourr{   ZdatÚtabrÌ   Útpr¼   r»   ÚportZkey_tabrb   rc   r   )r¯   r›   r°   r±   r²   r³   r´   rµ   r‰   r¶   rz   r·   r}   r¸   r   Úpretty_printerc   s>   	ù


















ÿ"+









ÿÿ

 ÿ

þz_CFG.pretty_printerÚpdfc                 C   s$   | j f |||dœ| j—Ž}| d¡S )a›  
        Plot the CFG.  In IPython notebook, the return image object can be
        inlined.

        The *filename* option can be set to a specific path for the rendered
        output to write to.  If *view* option is True, the plot is opened by
        the system default application for the image format (PDF). *format* can
        be any valid format string accepted by graphviz, default is 'pdf'.
        )r€   r¾   rÎ   r   ©rÝ   rD   rÉ   )rE   r€   r•   r¾   Zrawbytr   r   r   Údisplayñ  s    

ÿÿz_CFG.displayc                 C   s   | j f | jŽ d¡S )Nr   rß   ©rE   r   r   r   Ú
_repr_svg_ÿ  s    z_CFG._repr_svg_c                 C   s   | j S r=   )rC   rá   r   r   r   Ú__repr__  s    z_CFG.__repr__)NNNTFFTrH   )NrÞ   F)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__rG   rÝ   rà   râ   rã   r   r   r   r   r<   S   s           ý
   
r<   c                   @   sÜ   e Zd ZdZdZdZdZdedœdd„Ze	dd„ ƒZ
e	d	d
„ ƒZe	dd„ ƒZe	dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd „ ƒZed!d"„ ƒZd#d$„ Zd%d&„ Zd'd(„ Zd)S )*ÚCodeLibraryzÒ
    An interface for bundling LLVM code together and compiling it.
    It is tied to a *codegen* instance (e.g. JITCPUCodegen) that will
    determine how the LLVM code is transformed and linked together.
    FÚ
CPUCodegen)Úcodegenr?   c                 C   s6   || _ || _| jj› d| j›d}t|ƒ| _g | _d S )Nú(ú))Ú_codegenÚ_nameÚ	__class__rä   r   Ú_recorded_timingsÚ_dynamic_globals)rE   rê   r?   Zptc_namer   r   r   rG     s
    
zCodeLibrary.__init__c                 C   s   |   ¡  t| jƒdkS )Nr   )Ú_ensure_finalizedrw   rñ   rá   r   r   r   Úhas_dynamic_globals  s    zCodeLibrary.has_dynamic_globalsc                 C   s   | j S r=   )rð   rá   r   r   r   Úrecorded_timings  s    zCodeLibrary.recorded_timingsc                 C   s   | j S )z9
        The codegen object owning this library.
        )rí   rá   r   r   r   rê   "  s    zCodeLibrary.codegenc                 C   s   | j S r=   )rî   rá   r   r   r   r?   )  s    zCodeLibrary.namec                 C   s   d| j t| ƒf S )Nz<Library %r at 0x%x>)r?   Úidrá   r   r   r   rã   -  s    zCodeLibrary.__repr__c                 C   s   | j rtd| f ƒ‚d S )Nz+operation impossible on finalized object %r)Ú
_finalizedÚRuntimeErrorrá   r   r   r   Ú_raise_if_finalized0  s    ÿzCodeLibrary._raise_if_finalizedc                 C   s   | j s|  ¡  d S r=   )rö   Úfinalizerá   r   r   r   rò   5  s    zCodeLibrary._ensure_finalizedc                 C   s   |   ¡  | j |¡}|S )zC
        Create an LLVM IR module for use by this library.
        )rø   rí   Ú_create_empty_module©rE   r?   Ú	ir_moduler   r   r   Úcreate_ir_module9  s    zCodeLibrary.create_ir_modulec                 C   s   dS )zk
        Add a library for linking into this library, without losing
        the original library.
        Nr   ©rE   Úlibraryr   r   r   Úadd_linking_libraryA  s    zCodeLibrary.add_linking_libraryc                 C   s   dS )zC
        Add an LLVM IR module's contents to this library.
        Nr   )rE   rü   r   r   r   Úadd_ir_moduleH  s    zCodeLibrary.add_ir_modulec                 C   s   dS )z®
        Finalize the library.  After this call, nothing can be added anymore.
        Finalization involves various stages of code optimization and
        linking.
        Nr   rá   r   r   r   rù   N  s    zCodeLibrary.finalizec                 C   s   dS )z5
        Return the function named ``name``.
        Nr   ©rE   r?   r   r   r   rA   V  s    zCodeLibrary.get_functionc                 C   s   dS )zA
        Get the human-readable form of the LLVM module.
        Nr   rá   r   r   r   rÅ   \  s    zCodeLibrary.get_llvm_strc                 C   s   dS )z2
        Get the human-readable assembly.
        Nr   rá   r   r   r   Úget_asm_strb  s    zCodeLibrary.get_asm_strc                 C   s   d| _ d | _d| _d S )NTF)Ú_object_caching_enabledÚ_compiled_objectÚ	_compiledrá   r   r   r   Úenable_object_cachingl  s    z!CodeLibrary.enable_object_cachingc                 C   s2   | j std| f ƒ‚| jd kr,td| f ƒ‚| jS )Nú object caching not enabled in %szno compiled object yet for %s)r  r5   r  r÷   rá   r   r   r   Ú_get_compiled_objectq  s
    
z CodeLibrary._get_compiled_objectc                 C   s8   | j std| f ƒ‚| jr(td| f ƒ‚|| _d| _d S )Nr  zlibrary already compiled: %sT)r  r5   r  r  Ú_disable_inspection)rE   r×   r   r   r   Ú_set_compiled_objectx  s    z CodeLibrary._set_compiled_objectN)rä   rå   ræ   rç   rö   r  r
  r†   rG   Úpropertyró   rô   rê   r?   rã   rø   rò   rý   r   r   r  rù   rA   rÅ   r  r  r	  r  r   r   r   r   rè     s@   









	rè   )Ú	metaclassc                       sæ   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd2d"d#„Zd$d%„ Zed&d'„ ƒZed(d)„ ƒZed*d+„ ƒZd,d-„ Zd.d/„ Zed0d1„ ƒZ‡  ZS )3ÚCPUCodeLibraryc                    sH   t ƒ  ||¡ g | _t t| j | j¡ƒ¡| _	t
 | j¡| j	_d | _d S r=   )ÚsuperrG   Ú_linking_librariesr   Úparse_assemblyr†   rí   rú   r?   Ú_final_moduler   Únormalize_ir_textÚ_shared_module)rE   rê   r?   ©rï   r   r   rG   ƒ  s    ÿzCPUCodeLibrary.__init__c                 C   sp   | j j|_| j  |¡P}|jD ]B}d|j›}| j |¡  | ¡  | 	|¡ | 
¡  W 5 Q R X qW 5 Q R X dS )zP
        Internal: run function-level optimizations inside *ll_module*.
        zFunction passes on N)rí   Ú_data_layoutÚdata_layoutÚ_function_pass_managerÚ	functionsr?   rð   ÚrecordÚ
initializeÚrunrù   )rE   Ú	ll_moduleZfpmÚfuncrb   r   r   r   Ú_optimize_functions‹  s    


z"CPUCodeLibrary._optimize_functionsc              	   C   sn   d}| j  |¡ | jj | j¡ W 5 Q R X tjs>t| jƒ| _d}| j  |¡ | jj	 | j¡ W 5 Q R X dS )zA
        Internal: optimize this library's final module.
        z/Module passes (cheap optimization for refprune)z!Module passes (full optimization)N)
rð   r  rí   Ú
_mpm_cheapr  r  r   ÚLLVM_REFPRUNE_PASSr   Ú	_mpm_full)rE   Z
cheap_nameZ	full_namer   r   r   Ú_optimize_final_module›  s    z%CPUCodeLibrary._optimize_final_modulec                 C   sœ   |   ¡  | jdk	r| jS | j}g }d}|jD ],}|d7 }|js,|jtjjkr,| 	|j
¡ q,|dkrptd| f ƒ‚|r’| ¡ }|D ]}d| |¡_q€|| _|S )a:  
        Internal: get a LLVM module suitable for linking multiple times
        into another library.  Exported functions are made "linkonce_odr"
        to allow for multiple definitions, inlining, and removal of
        unused exports.

        See discussion in https://github.com/numba/numba/pull/890
        Nr   rr   z7library unfit for linking: no available functions in %sZlinkonce_odr)rò   r  r  r  Úis_declarationÚlinkager   ZLinkageÚexternalr¦   r?   r÷   ÚclonerA   )rE   ÚmodZto_fixZnfuncsrF   r?   r   r   r   Ú_get_module_for_linking¬  s(    	

þz&CPUCodeLibrary._get_module_for_linkingc                 C   s   |  ¡  | j |¡ d S r=   )rò   r  r¦   rþ   r   r   r   r   Ï  s    z"CPUCodeLibrary.add_linking_libraryc                 C   sN   |   ¡  t|tjƒst‚t t|ƒ¡}t 	|¡}|j
|_
| ¡  |  |¡ d S r=   )rø   rW   ÚllvmirÚModulerx   r   r  r†   r   r  r?   ÚverifyÚadd_llvm_module)rE   rü   Úirr  r   r   r   r  Ó  s    
zCPUCodeLibrary.add_ir_modulec                 C   s(   |   |¡ tjst|ƒ}| j |¡ d S r=   )r  r   r!  r   r  Úlink_in)rE   r  r   r   r   r-  Ü  s    
zCPUCodeLibrary.add_llvm_modulec                 C   sŠ   t ƒ  | j ¡  |  ¡  tjr4td| j |  ¡ dƒ t	ƒ }| j
D ]*}||kr@| |¡ | jj| ¡ dd q@|  ¡  | j ¡  |  ¡  d S )NzFUNCTION OPTIMIZED DUMP %sr*   T)Zpreserve)r
   rí   Ú_check_llvm_bugsrø   r   ZDUMP_FUNC_OPTr;   r?   rÅ   r]   r  Úaddr  r/  r)  r#  r,  Ú_finalize_final_module)rE   Úseenrÿ   r   r   r   rù   ã  s&    

 ÿ

 ÿ
zCPUCodeLibrary.finalizec                 C   s,   | j jD ]}|j d¡r| j |j¡ qd S )Nznumba.dynamic.globals)r  Úglobal_variablesr?   Ú
startswithrñ   r¦   )rE   r‰   r   r   r   Ú_finalize_dynamic_globalsÿ  s    z(CPUCodeLibrary._finalize_dynamic_globalsc                 C   s8   | j jD ]*}|jr|j d¡rd}t| |j¡ƒ‚qd S )NZ	_ZN5numbazSymbol {} not linked properly)r  r  r$  r?   r5  rx   r•   )rE   rF   r:   r   r   r   Ú_verify_declare_only_symbols  s    z+CPUCodeLibrary._verify_declare_only_symbolsc                 C   s†   |   ¡  |  ¡  t | ¡| j_| j | j¡}|r<t | |¡ |  	¡  d| _
tjrftd| j |  ¡ dƒ tjr‚td| j |  ¡ dƒ dS )z?
        Make the underlying LLVM module ready to use.
        TzOPTIMIZED DUMP %sr*   zASSEMBLY %sr+   N)r6  r7  ÚweakrefÚproxyr  Ú_CPUCodeLibrary__libraryrí   Ú_add_modulerù   Ú_finalize_specificrö   r   ZDUMP_OPTIMIZEDr;   r?   rÅ   ZDUMP_ASSEMBLYr  )rE   Úcleanupr   r   r   r2    s    z%CPUCodeLibrary._finalize_final_modulec                 c   s"   | j }|jD ]}|js|V  qdS )zj
        Get all functions defined in the library.  The library must have
        been finalized.
        N)r  r  r$  )rE   r(  rF   r   r   r   Úget_defined_functions'  s    
z$CPUCodeLibrary.get_defined_functionsc                 C   s   | j  |¡S r=   )r  rA   r  r   r   r   rA   1  s    zCPUCodeLibrary.get_functionc                 C   s   | j rt d¡ d S )Nz@Inspection disabled for cached code. Invalid result is returned.)r
  r   r    rá   r   r   r   Ú _sentry_cache_disable_inspection4  s    z/CPUCodeLibrary._sentry_cache_disable_inspectionc                 C   s   |   ¡  t| jƒS r=   )r?  r†   r  rá   r   r   r   rÅ   9  s    zCPUCodeLibrary.get_llvm_strc                 C   s   |   ¡  t| jj | j¡ƒS r=   )r?  r†   rí   Ú_tmZemit_assemblyr  rá   r   r   r   r  =  s    zCPUCodeLibrary.get_asm_strNc                 K   s   |   ¡  t| ||f|ŽS )z=
        Get control-flow graph of the LLVM function
        )r?  r<   )rE   r?   r@   rD   r   r   r   rB   A  s    zCPUCodeLibrary.get_function_cfgc                 C   s   |   ¡ }t||ƒS )aa  
        Get the CFG of the disassembly of the ELF object at symbol mangled_name.

        Requires python package: r2pipe
        Requires radare2 binary on $PATH.
        Notebook rendering requires python package: graphviz
        Optionally requires a compiler toolchain (via pycc) to link the ELF to
        get better disassembly results.
        )r	  r   )rE   Zmangled_nameÚelfr   r   r   Úget_disasm_cfgH  s    
zCPUCodeLibrary.get_disasm_cfgc           	      C   sÊ   ddl m} ddlm} ddlm} |||ƒƒ}tdƒ | ¡ D ]~}|d dkr@t| 	¡ dd	„ d
}tdƒ |D ]L}|j
s|qptd|j
 ¡ |d |d | |d d ¡| |d d ¡f ƒ qpq@tƒ  dS )zw
        Dump the symbol table of an ELF file.
        Needs pyelftools (https://github.com/eliben/pyelftools)
        r   )ÚELFFile)Údescriptions)ÚBytesIOz	ELF file:Zsh_typeZ
SHT_SYMTABc                 S   s   | j S r=   ©r?   )Úsymr   r   r   rf   b  rg   z*CPUCodeLibrary._dump_elf.<locals>.<lambda>)Úkeyz    symbols:z/    - %r: size=%d, value=0x%x, type=%s, bind=%sÚst_sizeZst_valueZst_infor^   ÚbindN)Zelftools.elf.elffilerC  Zelftools.elfrD  ÚiorE  r-   Ziter_sectionsÚsortedZiter_symbolsr?   rÉ   Zdescribe_symbol_typeZdescribe_symbol_bind)	ÚclsÚbufrC  rD  rE  rˆ   ÚsecÚsymbolsrG  r   r   r   Ú	_dump_elfU  s*    üÿ
zCPUCodeLibrary._dump_elfc                 C   s8   z
|j }W n tk
r    Y dS X |jr4d|_||_dS )zB
        `ll_module` was compiled into object code `buf`.
        NT)r:  r   r  r  r  )rM  r  rN  rE   r   r   r   Ú_object_compiled_hookp  s    
z$CPUCodeLibrary._object_compiled_hookc                 C   sB   z
|j }W n tk
r    Y dS X |jr>|jr>|j}d|_|S dS )z>
        Return a cached object code for `ll_module`.
        N)r:  r   r  r  )rM  r  rE   rN  r   r   r   Ú_object_getbuffer_hook}  s    
z%CPUCodeLibrary._object_getbuffer_hookc                 C   s   |   ¡  | jd| j ¡ fS )zX
        Serialize this library using its bitcode as the cached representation.
        Úbitcode)rò   r?   r  Ú
as_bitcoderá   r   r   r   Úserialize_using_bitcode‹  s    z&CPUCodeLibrary.serialize_using_bitcodec                 C   s(   |   ¡  |  ¡ |  ¡  ¡ f}| jd|fS )z´
        Serialize this library using its object code as the cached
        representation.  We also include its bitcode for further inlining
        with other libraries.
        Úobject)rò   r	  r)  rU  r?   )rE   Údatar   r   r   Úserialize_using_object_code’  s
    
ÿz*CPUCodeLibrary.serialize_using_object_codec           	      C   sž   |\}}}|  |¡}t|| ƒs"t‚|dkrBt |¡|_| ¡  |S |dkrŒ|\}}| ¡  | |¡ t |¡|_	| ¡  |j
j |j	¡ |S td|f ƒ‚d S )NrT  rW  z!unsupported serialization kind %r)Úcreate_libraryrW   rx   r   Zparse_bitcoder  r2  r  r  r  rí   Ú_engineÚ_load_defined_symbolsr5   )	rM  rê   Ústater?   ÚkindrX  rE   Zobject_codeZshared_bitcoder   r   r   Ú_unserialize  s     


zCPUCodeLibrary._unserialize)N)rä   rå   ræ   rG   r  r#  r)  r   r  r-  rù   r6  r7  r2  r>  rA   r?  rÅ   r  rB   rB  ÚclassmethodrQ  rR  rS  rV  rY  r_  Ú__classcell__r   r   r  r   r    s8   #	




r  c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚAOTCodeLibraryc                 C   s   |   ¡  | jj | j¡S )z¤
        Return this library as a native object (a bytestring) -- for example
        ELF under Linux.

        This function implicitly calls .finalize().
        )rò   rí   r@  Zemit_objectr  rá   r   r   r   Úemit_native_object¶  s    z!AOTCodeLibrary.emit_native_objectc                 C   s   |   ¡  | j ¡ S )zz
        Return this library as LLVM bitcode (a bytestring).

        This function implicitly calls .finalize().
        )rò   r  rU  rá   r   r   r   Úemit_bitcodeÀ  s    zAOTCodeLibrary.emit_bitcodec                 C   s   d S r=   r   rá   r   r   r   r<  É  s    z!AOTCodeLibrary._finalize_specificN)rä   rå   ræ   rc  rd  r<  r   r   r   r   rb  ´  s   
	rb  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚJITCodeLibraryc                 C   s0   |   ¡  | jj}| |¡sdS | jj |¡S dS )aˆ  
        Generate native code for function named *name* and return a pointer
        to the start of the function (as an integer).

        This function implicitly calls .finalize().

        Returns
        -------
        pointer : int
            - zero (null) if no symbol of *name* is defined by this code
              library.
            - non-zero if the symbol is defined.
        r   N)rò   rí   r[  Úis_symbol_definedÚget_function_address)rE   r?   Úeer   r   r   Úget_pointer_to_functionÏ  s
    
z&JITCodeLibrary.get_pointer_to_functionc              	   C   s6   | j  | j¡ | j d¡ | j j ¡  W 5 Q R X d S )NzFinalize object)rí   Ú_scan_and_fix_unresolved_refsr  rð   r  r[  Úfinalize_objectrá   r   r   r   r<  ä  s    z!JITCodeLibrary._finalize_specificN)rä   rå   ræ   ri  r<  r   r   r   r   re  Í  s   re  c                   @   s4   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚRuntimeLinkerzP
    For tracking unresolved symbols generated at runtime due to recursion.
    z.numba.unresolved$c                 C   s   t  ¡ | _tƒ | _g | _d S r=   )r   Z
UniqueDictÚ_unresolvedr]   Ú_definedÚ	_resolvedrá   r   r   r   rG   ð  s    
zRuntimeLinker.__init__c                 C   st   | j }|jD ]b}|j |¡r|jt|ƒd… }| |j¡r<qtj d¡}t	 
|¡}| |t	 |¡¡ || j|< qdS )zr
        Scan and track all unresolved external symbols in the module and
        allocate memory for it.
        NZnrt_unresolved_abort)ÚPREFIXr4  r?   r5  rw   rf  r	   rÿ   ri  ÚctypesÚc_void_pÚadd_global_mappingZ	addressofrm  )rE   ÚmoduleÚengineÚprefixr‰   rG  ZabortfnÚptrr   r   r   Úscan_unresolved_symbolsõ  s    

z%RuntimeLinker.scan_unresolved_symbolsc                 C   s$   |j D ]}|js| j |j¡ qdS )z5
        Scan and track all defined symbols.
        N)r  r$  rn  r1  r?   )rE   rt  rF   r   r   r   Úscan_defined_symbols  s    
z"RuntimeLinker.scan_defined_symbolsc                    sT   ‡ fdd„ˆ j D ƒ}|D ]6}| |¡}ˆ j | }||_ˆ j ||f¡ ˆ j |= qdS )z=
        Fix unresolved symbols if they are defined.
        c                    s   g | ]}|ˆ j kr|‘qS r   )rn  )Ú.0r?   rá   r   r   Ú
<listcomp>  s     
 z)RuntimeLinker.resolve.<locals>.<listcomp>N)rm  rg  r×   ro  r¦   )rE   ru  Úpendingr?   Úfnptrrw  r   rá   r   Úresolve  s    

zRuntimeLinker.resolveN)	rä   rå   ræ   rç   rp  rG   rx  ry  r~  r   r   r   r   rl  ê  s   rl  c                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc                    s   ˆ | j f|ž|ŽS r=   )Ú_ee)rE   ÚargsrD   ©Úoldr   r   Úwrapper"  s    z_proxy.<locals>.wrapper)Ú	functoolsÚwraps)r‚  rƒ  r   r  r   Ú_proxy!  s    r†  c                   @   sh   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Ze	e
jjƒZe	e
jjƒZe	e
jjƒZe	e
jjƒZdS )Ú	JitEnginez»Wraps an ExecutionEngine to provide custom symbol tracking.
    Since the symbol tracking is incomplete  (doesn't consider
    loaded code object), we are not putting it in llvmlite.
    c                 C   s   || _ tƒ | _d S r=   )r  r]   Ú_defined_symbols)rE   rh  r   r   r   rG   -  s    
zJitEngine.__init__c                 C   s
   || j kS )z/Is the symbol defined in this session?
        )rˆ  r  r   r   r   rf  :  s    zJitEngine.is_symbol_definedc                 C   s.   |j |jfD ]}|  jdd„ |D ƒO  _qdS )z(Extract symbols from the module
        c                 S   s   h | ]}|j s|j’qS r   )r$  r?   )rz  r‰   r   r   r   Ú	<setcomp>C  s    ÿz2JitEngine._load_defined_symbols.<locals>.<setcomp>N)r  r4  rˆ  )rE   r(  Zgsetsr   r   r   r\  ?  s    zJitEngine._load_defined_symbolsc                 C   s   |   |¡ | j |¡S )zXOverride ExecutionEngine.add_module
        to keep info about defined symbols.
        )r\  r  Ú
add_module©rE   rt  r   r   r   rŠ  F  s    
zJitEngine.add_modulec                 C   s   | j  |j¡ | j ||¡S )z`Override ExecutionEngine.add_global_mapping
        to keep info about defined symbols.
        )rˆ  r1  r?   r  rs  )rE   r‰   Úaddrr   r   r   rs  M  s    zJitEngine.add_global_mappingN)rä   rå   ræ   rç   rG   rf  r\  rŠ  rs  r†  r   ZExecutionEngineÚset_object_cacherk  rg  Úget_global_value_addressr   r   r   r   r‡  (  s   
ÿr‡  c                   @   sD   e Zd ZdZedd„ ƒZedd„ ƒZedd„ ƒZdd	„ Z	d
d„ Z
dS )ÚCodegenaM  
    Base Codegen class. It is expected that subclasses set the class attribute
    ``_library_class``, indicating the CodeLibrary class for the target.

    Subclasses should also initialize:

    ``self._data_layout``: the data layout for the target.
    ``self._target_data``: the binding layer ``TargetData`` for the target.
    c                 C   s   dS )zD
        Create a new empty module suitable for the target.
        Nr   r  r   r   r   rú   j  s    zCodegen._create_empty_modulec                 C   s   dS )zu
        Add a module to the execution engine. Ownership of the module is
        transferred to the engine.
        Nr   r‹  r   r   r   r;  p  s    zCodegen._add_modulec                 C   s   | j S )zJ
        The LLVM "target data" object for this codegen instance.
        )Ú_target_datará   r   r   r   Útarget_dataw  s    zCodegen.target_datac                 K   s   | j | |f|ŽS )zb
        Create a :class:`CodeLibrary` object for use with this codegen
        instance.
        )Ú_library_class)rE   r?   rD   r   r   r   rZ  ~  s    zCodegen.create_libraryc                 C   s   | j  | |¡S r=   )r’  r_  )rE   Z
serializedr   r   r   Úunserialize_library…  s    zCodegen.unserialize_libraryN)rä   rå   ræ   rç   r   rú   r;  r  r‘  rZ  r“  r   r   r   r   r  _  s   



r  c                   @   sl   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS )ré   c                 C   sB   t ƒ  d | _t t|  |¡ƒ¡| _d| j_tƒ | _	|  
| j¡ d S )NZglobal_codegen_module)Úinitialize_llvmr  r   r  r†   rú   Ú_llvm_moduler?   rl  Ú	_rtlinkerÚ_init)rE   Úmodule_namer   r   r   rG   ‹  s    ÿzCPUCodegen.__init__c                 C   sâ   t |jƒg kstdƒ‚tj t ¡ ¡}ttj	d}|  
¡ | _|  |¡ |jf |Ž}t ||¡}tjrl| ¡  || _t|ƒ| _|j| _t| jƒ| _tj	jr¢d}d}nd}d}| j|d|dd| _|  ¡ | _| j | jj| jj¡ d S )	NzModule isn't empty)ÚoptTé   Fr   Úcheap)Úloop_vectorizeÚslp_vectorizer™  Úcost) Úlistr4  rx   r   ÚTargetZfrom_tripleÚget_process_tripler[   r   ÚOPTÚ_customize_tm_featuresÚ_tm_featuresÚ_customize_tm_optionsÚcreate_target_machineZcreate_mcjit_compilerZENABLE_PROFILINGZenable_jit_eventsr@  r‡  r[  r‘  r  r†   r  Z
is_opt_maxÚ_module_pass_managerr   r"  r  r’  rR  rS  )rE   Úllvm_modulerÖ   Z
tm_optionsÚtmru  ZloopvectÚ	opt_levelr   r   r   r—  •  s6    


ý
ÿzCPUCodegen._initc                 C   s,   t  t |¡¡}t ¡ |_| jr(| j|_|S r=   )	r*  r+  r   r  r   r¡  r   r  r  rû   r   r   r   rú   Ã  s
    
zCPUCodegen._create_empty_modulec              	   K   sª   t  ¡ }| j |¡ | dd ¡}| jf |Ž}| |¡ W 5 Q R X |d k	r”|dkr”tjdkr”| 	¡  t j
d dk r„| ¡  | ¡  n| ¡  | ¡  tjr¦| tƒ ¡ |S )Nrž  r›  r   é   )r   Zcreate_module_pass_managerr@  Úadd_analysis_passesÚpopÚ_pass_manager_builderÚpopulater   r¢  Zadd_loop_rotate_passZllvm_version_infoZadd_licm_passZadd_cfg_simplification_passZadd_instruction_combining_passZadd_jump_threading_passr!  Úadd_refprune_passr$   )rE   rD   Úpmrž  Úpmbr   r   r   r§  Ê  s    
zCPUCodegen._module_pass_managerc              	   K   sN   t  |¡}| j |¡ | jf |Ž}| |¡ W 5 Q R X tjrJ| t	ƒ ¡ |S r=   )
r   Zcreate_function_pass_managerr@  r¬  r®  r¯  r   r!  r°  r$   )rE   r¨  rD   r±  r²  r   r   r   r  é  s    
z!CPUCodegen._function_pass_managerc                 K   sD   |  dtj¡}|  dtj¡}|  dtj¡}tf |||dœ|—Ž}|S )a  
        Create a PassManagerBuilder.

        Note: a PassManagerBuilder seems good only for one use, so you
        should call this method each time you want to populate a module
        or function pass manager.  Otherwise some optimizations will be
        missed...
        r™  rœ  r  )r™  rœ  r  )r­  r   r¢  ZLOOP_VECTORIZEZSLP_VECTORIZEr   )rE   rD   rª  rœ  r  r²  r   r   r   r®  ò  s    	þýz CPUCodegen._pass_manager_builderc                 C   sZ   d}t  |¡}t|ƒ}d|ks&d|kr*dS d|krHt ¡ }td|f ƒ‚td|f ƒ‚dS )z<
        Guard against some well-known LLVM bug(s).
        zo
            define double @func()
            {
                ret double 1.23e+01
            }
            z12.3z1.23Nz1.0z°LLVM will produce incorrect floating-point code in the current locale %s.
Please read https://numba.readthedocs.io/en/stable/user/faq.html#llvm-locale-bug for more information.zUnexpected IR:
%s
)r   r  r†   ÚlocaleÚ	getlocaler÷   rx   )rE   r.  r(  Zir_outÚlocr   r   r   r0    s    	
üÿzCPUCodegen._check_llvm_bugsc                 C   s   | j j|  ¡ | jfS )zP
        Return a tuple unambiguously describing the codegen behaviour.
        )r•  r   Ú_get_host_cpu_namer¤  rá   r   r   r   Úmagic_tuple$  s    ÿzCPUCodegen.magic_tuplec                 C   s.   | j  || j¡ | j  |¡ | j  | j¡ d S r=   )r–  rx  r[  ry  r~  r‹  r   r   r   rj  +  s    z(CPUCodegen._scan_and_fix_unresolved_refsc                 C   sp   t  d¡ ¡ }| jj| }|j}z| |¡}W n* tk
rX   t j|||d}d|_	Y nX | 
| |¡| ¡ ¡S )Né   rF  r&  )r*  ZIntTypeZ
as_pointerr–  rp  rt  Z
get_globalÚKeyErrorZGlobalVariabler%  ZbitcastÚload)rE   ZbuilderZfntyr?   ZvoidptrZptrnameZllvm_modr}  r   r   r   Úinsert_unresolved_ref0  s    z CPUCodegen.insert_unresolved_refc                 C   s   t jd krt ¡ S t jS r=   )r   ZCPU_NAMEr   Zget_host_cpu_namerá   r   r   r   r¶  <  s    ÿ
þzCPUCodegen._get_host_cpu_namec                 C   s   t jd k	rt jS tƒ S r=   )r   ZCPU_FEATURESÚget_host_cpu_featuresrá   r   r   r   Ú_get_host_cpu_featuresA  s    
z!CPUCodegen._get_host_cpu_featuresN)rä   rå   ræ   rG   r—  rú   r§  r  r®  r0  r·  rj  r»  r¶  r½  r   r   r   r   ré   ‰  s   
.	ré   c                   @   s6   e Zd ZdZeZddd„Zdd„ Zdd„ Zd	d
„ Z	dS )ÚAOTCPUCodegenzp
    A codegen implementation suitable for Ahead-Of-Time compilation
    (e.g. generation of object files).
    Nc                 C   s   |pd| _ t | |¡ d S ©Nrœ   )Ú	_cpu_nameré   rG   )rE   r˜  Úcpu_namer   r   r   rG   O  s    
zAOTCPUCodegen.__init__c                 C   s<   | j }|dkr|  ¡ }||d< d|d< d|d< | j|d< d S )NÚhostÚcpuÚpicÚrelocr¤   Ú	codemodelÚfeatures)rÀ  r¶  r¤  )rE   ÚoptionsrÁ  r   r   r   r¥  T  s    z#AOTCPUCodegen._customize_tm_optionsc                 C   s   dS r¿  r   rá   r   r   r   r£  ]  s    z$AOTCPUCodegen._customize_tm_featuresc                 C   s   d S r=   r   r‹  r   r   r   r;  b  s    zAOTCPUCodegen._add_module)N)
rä   rå   ræ   rç   rb  r’  rG   r¥  r£  r;  r   r   r   r   r¾  G  s   
	r¾  c                   @   s4   e Zd ZdZeZdd„ Zdd„ Zdd„ Zdd	„ Z	d
S )ÚJITCPUCodegenzI
    A codegen implementation suitable for Just-In-Time compilation.
    c                 C   sz   |   ¡ |d< tj ¡ j}| d¡r(d}n| d¡r8d}nd}||d< d|d	< | j|d
< t tjj	¡}d|j
krvd|d< d S )NrÃ  r   ZstaticÚppcrÄ  r¤   rÅ  Z
jitdefaultrÆ  rÇ  ZjitT)r¶  r   r   Zfrom_default_tripler?   r5  r¤  r   Zpysignaturer¦  Ú
parameters)rE   rÈ  r   Zreloc_modelÚsigr   r   r   r¥  m  s    



z#JITCPUCodegen._customize_tm_optionsc                 C   s   |   ¡ S r=   )r½  rá   r   r   r   r£  ˆ  s    z$JITCPUCodegen._customize_tm_featuresc                 C   s   | j  |¡ d S r=   )r[  rŠ  r‹  r   r   r   r;  Œ  s    zJITCPUCodegen._add_modulec                 C   s2   | j  |¡}tjd  |¡}t t|ƒ¡|d< dS )zrSet the environment address.

        Update the GlobalVariable named *env_name* to the address of *env*.
        rr   r   N)r[  rŽ  rq  rr  Zfrom_addressrõ   )rE   Úenv_nameÚenvZgvaddrZenvptrr   r   r   Úset_env”  s    zJITCPUCodegen.set_envN)
rä   rå   ræ   rç   re  r’  r¥  r£  r;  rÏ  r   r   r   r   rÉ  f  s   rÉ  c                   C   s   t  ¡  t  ¡  t  ¡  dS )z Safe to use multiple times.
    N)r   r  Zinitialize_native_targetZinitialize_native_asmprinterr   r   r   r   r”  ž  s    r”  c                  C   sR   zt  ¡ } W n tk
r"   Y dS X tjsF| D ]}| d¡r.d| |< q.|  ¡ S dS )z~Get host CPU features using LLVM.

    The features may be modified due to user setting.
    See numba.config.ENABLE_AVX.
    rœ   ZavxFN)r   r¼  r÷   r   Z
ENABLE_AVXr5  Úflatten)rÇ  rb   r   r   r   r¼  ¦  s    

r¼  )6r   r„  r³  r8  rq  r–   rŽ   Zllvmlite.bindingrI   r   Zllvmlite.irr.  r*  Úabcr   r   Z
numba.corer   r   r   Znumba.core.llvm_bindingsr   Znumba.core.runtime.nrtoptr   Znumba.core.runtimer	   Znumba.core.compiler_lockr
   Znumba.core.errorsr   Znumba.misc.inspectionr   Znumba.misc.llvm_pass_timingsr   Ú	frozensetr   r   r$   r;   rW  r<   rè   r  rb  re  rl  r†  r‡  r  ré   r¾  rÉ  r”  r¼  r   r   r   r   Ú<module>   sX    ÿ   6{  577* ?8