U
    ð¾|e„Ø  ã                	   @   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i486Úi586Úi686Zi786Zi886Zi986c                 C   s   |   d¡d }|tkS )Nú-r   )ÚsplitÚ_x86arch)ÚtripleÚarch© r   úO/var/www/website-v5/atlas_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   ÚLLVM_REFPRUNE_FLAGSr   ÚstripÚgetattrÚllÚ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   ÚHIGHLIGHT_DUMPSÚpygmentsÚImportErrorÚ
ValueErrorr(   Úpygments.lexersr)   r*   Úpygments.formattersr+   Únumba.misc.dump_styler,   r0   Úcenter)	ÚheaderÚbodyÚlangr7   ÚmsgZ	gas_lexerZ
llvm_lexerZ	lexer_mapr4   r   r2   r   Údump8   s&    
rB   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)ÚselfrE   rF   rG   rK   Ú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Úitemsr9   ÚsetÚtype)Ú_configÚkwargÚattrÚkÚvrA   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Úyellowr\   ÚgreenÚtruebrÚredÚfalsebrÚcyanrT   Z	turquoiserU   Z	lightpinkÚraiseZlightseagreenrX   ZpurpleÚreturnZ	rosybrownrZ   Ztomator[   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Úxr|   Ú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)r~   r"   r#   r   ÚDigraphrh   Ústr)rF   ÚfnamerŒ   Ú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;)r~   rŽ   ÚhashÚformatÚhtmlÚescapeÚreplace)r™   ÚnZhsr   r   r   Úcleanö   s    
z"_CFG.pretty_printer.<locals>.cleanz\l...Ú Zdot_json)rž   úutf-8Úobjects)éÿÿÿÿr§   ÚlabelrF   Z_gvidry   r§   z\lú|z<<td BGCOLOR="{}" BORDER="1" ALIGN="center" PORT="{}">{}</td>)ÚTÚFrl   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.
                Nry   r   rx   zMarker %s, Line %s, column %sro   r\   )
r|   r}   r~   r   Úgetr]   rž   Úappendr\   Úint)ÚlÚ	new_linesÚmatchedrƒ   ro   Z
debug_dataÚldÚlineÚcolZmfmtZ	mark_lineÚlnZlidxZsource_line)Ú_interleaver£   Úcol_spanÚcsÚcur_colÚcur_lineÚfirstlinenoÚfmtÚlocation_entryr�   Ú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Útailrx   z:%sz;<tr><td BGCOLOR="{}" BORDER="0" ALIGN="center">{}</td></tr>ZKeyzn<<table BORDER="1" CELLBORDER="1" CELLPADDING="2" CELLSPACING="1"><tr><td BORDER="0">Key:</td></tr>{}</table>>)r‡   Úviewrž   Úsvg)1Úgraphvizr„   ÚjsonÚinspectÚllvmliterP   Únumba.typedrQ   ÚtypesrR   ÚcollectionsrS   rE   rH   rF   Úget_llvm_strrz   r\   ÚgetsourcelinesrG   rI   r¡   ÚSourceÚpipeÚloadsÚdecoder   r|   r}   r~   rY   r­   r®   rž   Újoinr   r]   rT   ÚsearchrU   rX   rW   rV   rZ   r[   r‰   rc   ÚedgeÚrender)KrL   r‡   rÅ   Úrender_formatr(   Ú
interleaveZstrip_irZshow_keyrŒ   rÈ   rÉ   r   rQ   rR   rS   Ú_defaultZ
_highlightrk   rM   r€   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¨   rF   ZgvidÚlinesr±   Z	port_liner²   Zsliced_linesZportsZports_tokensZtdfmtZtbl_dataÚcolorsÚtokÚtargetÚvalueÚcolorZ	fmtheaderrÁ   r°   Zupdated_lineinfoZcolourr‚   ÚdatÚtabrÖ   ÚtprÄ   rÃ   ÚportZkey_tabri   rj   r   )r·   r£   r¸   r¹   rº   r»   r¼   r½   r’   r¾   r�   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æ   rK   rÓ   )rL   r‡   rž   rÅ   Zrawbytr   r   r   Údisplayñ  s    

ÿÿz_CFG.displayc                 C   s   | j f | jŽ d¡S )Nr¥   rè   ©rL   r   r   r   Ú
_repr_svg_ÿ  s    z_CFG._repr_svg_c                 C   s   | j S rD   )rJ   rê   r   r   r   Ú__repr__  s    z_CFG.__repr__)NNNTFFTrO   )Nrç   F)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__rN   ræ   ré   rë   rì   r   r   r   r   rC   S   s           ý
   
rC   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)ÚcodegenrF   c                 C   s6   || _ || _| jj› d| j›d�}t|ƒ| _g | _d S )Nú(ú))Ú_codegenÚ_nameÚ	__class__rí   r   Ú_recorded_timingsÚ_dynamic_globals)rL   ró   rF   Zptc_namer   r   r   rN     s
    
zCodeLibrary.__init__c                 C   s   |   ¡  t| jƒdkS )Nr   )Ú_ensure_finalizedr~   rú   rê   r   r   r   Úhas_dynamic_globals  s    zCodeLibrary.has_dynamic_globalsc                 C   s   | j S rD   )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 rD   )r÷   rê   r   r   r   rF   )  s    zCodeLibrary.namec                 C   s   d| j t| ƒf S )Nz<Library %r at 0x%x>)rF   Ú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 rD   )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©rL   rF   Ú	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   ©rL   Ú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   )rL   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   ©rL   rF   r   r   r   rH   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  r9   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  r9   r  r  Ú_disable_inspection)rL   rà   r   r   r   Ú_set_compiled_objectx  s    z CodeLibrary._set_compiled_objectN)rí   rî   rï   rð   rÿ   r  r  rŽ   rN   Úpropertyrü   rý   ró   rF   rì   r  rû   r  r   r	  r
  r  rH   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 rD   )ÚsuperrN   Ú_linking_librariesr   Úparse_assemblyrŽ   rö   r  rF   Ú_final_moduler   Únormalize_ir_textÚ_shared_module)rL   ró   rF   ©rø   r   r   rN   ƒ  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Ú	functionsrF   rù   ÚrecordÚ
initializeÚrunr  )rL   Ú	ll_moduleZfpmÚfuncri   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)rL   Z
cheap_nameÚ	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   ry   z7library unfit for linking: no available functions in %sÚlinkonce_odr)rû   r  r  r"  Úis_declarationÚlinkager   ÚLinkageÚexternalr®   rF   r   ÚclonerH   )rL   ÚmodZto_fixZnfuncsrM   rF   r   r   r   Ú_get_module_for_linking¬  s(    	

þz&CPUCodeLibrary._get_module_for_linkingc                 C   s   |  ¡  | j |¡ d S rD   )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 rD   )r  r^   ÚllvmirÚModuler   r   r  rŽ   r   r  rF   ÚverifyÚadd_llvm_module)rL   r  Úirr&  r   r   r   r
  Ó  s    
zCPUCodeLibrary.add_ir_modulec                 C   s(   |   |¡ tjst|ƒ}| j |¡ d S rD   )r(  r   r*  r   r  Úlink_in)rL   r&  r   r   r   r9  Ü  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)Úpreserve)r
   rö   Ú_check_llvm_bugsr  r   ÚDUMP_FUNC_OPTrB   rF   rÎ   rd   r  Úaddr  r;  r5  r-  r8  Ú_finalize_final_module)rL   Ú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_variablesrF   Ú
startswithrú   r®   )rL   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/  rF   rC  r   rž   )rL   rM   rA   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)rD  rE  ÚweakrefÚproxyr  Ú_CPUCodeLibrary__libraryrö   Ú_add_moduler  Ú_finalize_specificrÿ   r   ÚDUMP_OPTIMIZEDrB   rF   rÎ   ÚDUMP_ASSEMBLYr  )rL   Úcleanupr   r   r   r@    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/  )rL   r4  rM   r   r   r   Úget_defined_functions'  s    
z$CPUCodeLibrary.get_defined_functionsc                 C   s   | j  |¡S rD   )r  rH   r  r   r   r   rH   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 rD   )rO  rŽ   r  rê   r   r   r   rÎ   9  s    zCPUCodeLibrary.get_llvm_strc                 C   s   |   ¡  t| jj | j¡ƒS rD   )rO  rŽ   rö   Ú_tmÚ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
        )rO  rC   )rL   rF   rG   rK   r   r   r   rI   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   )rL   Úmangled_nameZ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 rD   ©rF   )Úsymr   r   r   rm   b  rn   z*CPUCodeLibrary._dump_elf.<locals>.<lambda>)Úkeyz    symbols:z/    - %r: size=%d, value=0x%x, type=%s, bind=%sÚst_sizeZst_valueZst_infore   ÚbindN)Zelftools.elf.elffilerT  Zelftools.elfrU  ÚiorV  r0   Ziter_sectionsÚsortedZiter_symbolsrF   rÓ   Zdescribe_symbol_typeZdescribe_symbol_bind)	ÚclsÚbufrT  rU  rV  r‘   ÚsecÚsymbolsrX  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)rH  r!   r  r  r  )r^  r&  r_  rL   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)rH  r!   r  r  )r^  r&  rL   r_  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û   rF   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  r5  rf  rF   )rL   Ú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 )Nre  rh  z!unsupported serialization kind %r)Úcreate_libraryr^   r   r   Úparse_bitcoder  r@  r  r  r  rö   Ú_engineÚ_load_defined_symbolsr9   )	r^  ró   ÚstaterF   Úkindri  rL   Zobject_codeZshared_bitcoder   r   r   Ú_unserialize�  s     


zCPUCodeLibrary._unserialize)N)rí   rî   rï   rN   r(  r-  r5  r	  r
  r9  r  rD  rE  r@  rN  rH   rO  rÎ   r  rI   rS  Úclassmethodrb  rc  rd  rg  rj  rq  Ú__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ö   rP  Ú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  rf  rê   r   r   r   Úemit_bitcodeÀ  s    zAOTCodeLibrary.emit_bitcodec                 C   s   d S rD   r   rê   r   r   r   rJ  É  s    z!AOTCodeLibrary._finalize_specificN)rí   rî   rï   rv  rw  rJ  r   r   r   r   rt  ´  s   
	rt  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ö   rm  Úis_symbol_definedÚget_function_address)rL   rF   Ú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#  rm  Úfinalize_objectrê   r   r   r   rJ  ä  s    z!JITCodeLibrary._finalize_specificN)rí   rî   rï   r|  rJ  r   r   r   r   rx  Í  s   rx  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 rD   )r   Ú
UniqueDictÚ_unresolvedrd   Ú_definedÚ	_resolvedrê   r   r   r   rN   ð  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)ÚPREFIXrB  rF   rC  r~   ry  r	   r  r|  ÚctypesÚc_void_pÚadd_global_mappingÚ	addressofr�  )rL   ÚmoduleÚengineÚprefixr’   rX  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/  r‚  r?  rF   )rL   r‰  rM   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   )r‚  )Ú.0rF   rê   r   r   Ú
<listcomp>  s     
 z)RuntimeLinker.resolve.<locals>.<listcomp>N)r�  rz  rà   rƒ  r®   )rL   rŠ  ÚpendingrF   ÚfnptrrŒ  r   rê   r   Úresolve  s    

zRuntimeLinker.resolveN)	rí   rî   rï   rð   r„  rN   r�  rŽ  r“  r   r   r   r   r  ê  s   r  c                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc                    s   ˆ | j f|ž|ŽS rD   )Ú_ee)rL   ÚargsrK   ©Ú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 rD   )r”  rd   Ú_defined_symbols)rL   r{  r   r   r   rN   -  s    
zJitEngine.__init__c                 C   s
   || j kS )z/Is the symbol defined in this session?
        )r�  r  r   r   r   ry  :  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/  rF   )r�  r’   r   r   r   Ú	<setcomp>C  s    ÿz2JitEngine._load_defined_symbols.<locals>.<setcomp>N)r"  rB  r�  )rL   r4  Zgsetsr   r   r   rn  ?  s    zJitEngine._load_defined_symbolsc                 C   s   |   |¡ | j |¡S )zXOverride ExecutionEngine.add_module
        to keep info about defined symbols.
        )rn  r”  Ú
add_module©rL   r‰  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�  r?  rF   r”  r‡  )rL   r’   Úaddrr   r   r   r‡  M  s    zJitEngine.add_global_mappingN)rí   rî   rï   rð   rN   ry  rn  rŸ  r‡  r›  r   ÚExecutionEngineÚset_object_cacher~  rz  Ú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   rI  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)rL   rF   rK   r   r   r   rk  ~  s    zCodegen.create_libraryc                 C   s   | j  | |¡S rD   )r¨  rq  )rL   Ú
serializedr   r   r   Úunserialize_library…  s    zCodegen.unserialize_libraryN)rí   rî   rï   rð   r   r  rI  r  r§  rk  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_modulerF   r  Ú	_rtlinkerÚ_init)rL   Úmodule_namer   r   r   rN   ‹  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ƒ| _| jddddd�| _|  ¡ | _| j | jj| jj¡ d S )NzModule isn't empty)ÚoptFr   Úcheap)Úloop_vectorizeÚslp_vectorizer°  Úcost)ÚlistrB  r   r   ÚTargetÚfrom_tripleÚget_process_triplerb   r   ÚOPTÚ_customize_tm_featuresÚ_tm_featuresÚ_customize_tm_optionsÚcreate_target_machineÚcreate_mcjit_compilerÚENABLE_PROFILINGÚenable_jit_eventsrP  rœ  rm  r§  r¦  rŽ   r  Ú_module_pass_managerr)  r+  r£  r¨  rc  rd  )rL   Úllvm_modulerß   Z
tm_optionsÚtmrŠ  r   r   r   r®  •  s,    


ý
ÿzCPUCodegen._initc                 C   s,   t  t |¡¡}t ¡ |_| jr(| j|_|S rD   )	r6  r7  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   Úcreate_module_pass_managerrP  Úadd_analysis_passesÚpopÚ_pass_manager_builderÚpopulater   r¹  Úadd_loop_rotate_passÚllvm_version_infoÚadd_licm_passÚadd_cfg_simplification_passÚadd_instruction_combining_passÚadd_jump_threading_passr*  Úadd_refprune_passr'   )rL   rK   Ú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 rD   )
r   Úcreate_function_pass_managerrP  rÆ  rÈ  rÉ  r   r*  rÐ  r'   )rL   rÂ  rK   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¹  ÚLOOP_VECTORIZEÚSLP_VECTORIZEr   )rL   rK   Ú	opt_levelr²  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   r   )rL   r:  r4  Zir_outÚlocr   r   r   r=  ò  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 rD   )r­  r�  rm  rŽ  r“  r   r   r   r   r}    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é   rW  r2  )r6  ÚIntTypeÚ
as_pointerr­  r„  r‰  Ú
get_globalÚKeyErrorÚGlobalVariabler0  ÚbitcastÚload)rL   ÚbuilderÚfntyrF   ÚvoidptrZptrnameÚllvm_modr’  r   r   r   Úinsert_unresolved_ref  s    z CPUCodegen.insert_unresolved_refc                 C   s   t jd krt ¡ S t jS rD   )r   ÚCPU_NAMEr   Ú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 rD   )r   ÚCPU_FEATURESÚget_host_cpu_featuresrê   r   r   r   Ú_get_host_cpu_features-  s    
z!CPUCodegen._get_host_cpu_featuresN)rí   rî   rï   rN   r®  r  rÁ  r!  rÈ  r=  rÛ  r}  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ò   rN   )rL   r¯  Úcpu_namer   r   r   rN   ;  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»  )rL   Úoptionsrñ  r   r   r   r¼  @  s    z#AOTCPUCodegen._customize_tm_optionsc                 C   s   dS rï  r   rê   r   r   r   rº  I  s    z$AOTCPUCodegen._customize_tm_featuresc                 C   s   d S rD   r   r   r   r   r   rI  N  s    zAOTCPUCodegen._add_module)N)
rí   rî   rï   rð   rt  r¨  rN   r¼  rº  rI  r   r   r   r   rî  3  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   ÚstaticÚppcrô  r¬   rõ  Ú
jitdefaultrö  r÷  ÚjitT)rÚ  r   r¶  Úfrom_default_triplerF   rC  r»  r   Úpysignaturer½  Ú
parameters)rL   rø  r   Zreloc_modelÚsigr   r   r   r¼  Y  s    



z#JITCPUCodegen._customize_tm_optionsc                 C   s   |   ¡ S rD   )rí  rê   r   r   r   rº  t  s    z$JITCPUCodegen._customize_tm_featuresc                 C   s   | j  |¡ d S rD   )rm  rŸ  r   r   r   r   rI  x  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*.
        ry   r   N)rm  r¤  r…  r†  Úfrom_addressrþ   )rL   Úenv_nameÚenvZgvaddrÚenvptrr   r   r   Úset_env€  s    zJITCPUCodegen.set_envN)
rí   rî   rï   rð   rx  r¨  r¼  rº  rI  r  r   r   r   r   rù  R  s   rù  c                   C   s   t  ¡  t  ¡  t  ¡  dS )z Safe to use multiple times.
    N)r   r$  Úinitialize_native_targetÚ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¤   ÚavxFN)r   rì  r   r   Ú
ENABLE_AVXrC  Úflatten)r÷  ri   r   r   r   rì  ’  s    

rì  )6r"   r™  r×  rF  r…  rŸ   r—   Úllvmlite.bindingrP   r   Úllvmlite.irr:  r6  Úabcr   r   Ú
numba.corer   r   r   Znumba.core.llvm_bindingsr   Znumba.core.runtime.nrtoptr   Únumba.core.runtimer	   Únumba.core.compiler_lockr
   Únumba.core.errorsr   Znumba.misc.inspectionr   Znumba.misc.llvm_pass_timingsr   Ú	frozensetr   r   r'   rB   rh  rC   rñ   r  rt  rx  r  r›  rœ  r¥  rò   rî  rù  r«  rì  r   r   r   r   Ú<module>   sX    ÿ   6{  577* +8