
\K]c           @@ s  d  d l  m Z m Z d  d l Z d  d l Z d  d l j Z d  d l j	 j
 Z d  d l m Z 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 m Z m Z m Z 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 e j) f d     YZ* d e j) f d     YZ+ d e f d     YZ, d e- f d     YZ. d e- f d     YZ/ d e" f d     YZ0 d   Z1 d   Z2 d   Z3 d S(   i    (   t   print_functiont   absolute_importN(   t   _dynfunct   config(   t   PyCallWrapperi   (   t   BaseContextt   PYOBJECT(   t   utilst   cgutilst   types(   t   cached_property(   t   callconvt   codegent	   externalst
   intrinsicst   listobjt   setobjt   dictimpl(   t   TargetOptions(   t   rtsys(   t   global_compiler_lock(   t   fastmathpasst   ClosureBodyc           B@ s   e  Z d  e j f g Z RS(   t   env(   t   __name__t
   __module__R	   t   pyobjectt   _fields(    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR      s   t   EnvBodyc           B@ s&   e  Z d  e j f d e j f g Z RS(   t   globalst   consts(   R   R   R	   R   R   (    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR      s   t
   CPUContextc           B@ s   e  Z d  Z e Z d   Z e d    Z d   Z e	 d    Z
 d   Z d   Z e d    Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z RS(   s0   
    Changes BaseContext calling convention
    c         C@ s   |  j  j |  S(   N(   t   _internal_codegent   _create_empty_module(   t   selft   name(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   create_module+   s    c         C@ s   t  j d k |  _ t j d  |  _ t j   d k rF t j	 d  n  t
 j j |   t j |   t  j r{ d d  l } n  d  S(   Ni    s
   numba.exect   armv7ls   libgcc_s.so.1i    (   R   t   MACHINE_BITSt   is32bitR   t   JITCPUCodegenR    t   platformt   machinet   llt   load_library_permanentlyR   t   c_math_functionst   installR   t
   initializet   PY3t   numba.unicode(   R"   t   numba(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   init.   s    	c         C@ s   d d l  m } m } m } m } m } m } |  j | j  |  j | j  |  j | j  |  j | j  |  j | j  |  j | j  |  j | j  d  S(   Ni   (   t   cffiimplt	   cmathimplt   mathimplt   npyimplt	   printimplt
   randomimpl(	   t    R4   R5   R6   R7   R8   R9   t   install_registryt   registry(   R"   R4   R5   R6   R7   R8   R9   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   load_additional_registriesA   s    .c         C@ s
   |  j  j S(   N(   R    t   target_data(   R"   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR>   M   s    c         K@ s(   t  j | |  } |  j d | d t  S(   NR    t   aot_mode(   R   t   AOTCPUCodegent	   subtargett   True(   R"   R#   t   aot_optionst   aot_codegen(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   with_aot_codegenQ   s    c         C@ s   |  j  S(   N(   R    (   R"   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR   V   s    c         C@ s   t  j |   S(   N(   R   t   CPUCallConv(   R"   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt	   call_convY   s    c         C@ s5   t  j | | t j d  } t |  | d | d t S(   s   
        From the given *envptr* (a pointer to a _dynfunc.Environment object),
        get a EnvBody allowing structured access to environment fields.
        t   offsetof_env_bodyt   reft   cast_ref(   R   t   pointer_addR   t
   _impl_infoR   RB   (   R"   t   buildert   envptrt   body_ptr(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   get_env_body]   s    c         C@ st   |  j  | j |  j |  j   } | j |  } |  j |  } | j |  |  j | |  } | j |  j	 | |  S(   N(
   t   declare_env_globalt   modulet   get_env_namet   fndesct   loadt   get_python_apit   emit_environment_sentryRP   t   get_env_managert   environment(   R"   RM   t   envgvt   envargt   pyapit   env_body(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyRX   f   s    c         C@ s    t  j | | t j d d | S(   s~   
        From the given *genptr* (a pointer to a _dynfunc.Generator object),
        get a pointer to its state area.
        t   offsetof_generator_statet   return_type(   R   RK   R   RL   (   R"   RM   t   genptrR_   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   get_generator_stateo   s    c         C@ s   t  j |  | | |  S(   sR   
        Build a list from the Numba *list_type* and its initial *items*.
        (   R   t
   build_list(   R"   RM   t	   list_typet   items(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyRb   x   s    c         C@ s   t  j |  | | |  S(   sP   
        Build a set from the Numba *set_type* and its initial *items*.
        (   R   t	   build_set(   R"   RM   t   set_typeRd   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyRe   ~   s    c         C@ s)   d d l  m } | j |  | | | |  S(   Ni    (   t
   dictobject(   R2   Rg   t	   build_map(   R"   RM   t	   dict_typet
   item_typesRd   Rg   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyRh      s    c         C@ sL   |  j  r t j | |  j   n  |  j r8 t j |  n  | j t j  d  S(   N(	   t   fastmathR   t   rewrite_moduleR'   R   t
   fix_divmodt   add_linking_libraryR   t   library(   R"   t   modRo   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   post_lowering   s
    		c   
   
   C@ s~   |  j  d  } |  j j | j | j  } | j | | j  } t |  | | | | d | d | }	 |	 j   | j	 |  d  S(   Nt   wrappert   call_helpert   release_gil(
   R$   RG   t   get_function_typet   restypet   argtypest   add_functiont   llvm_func_nameR   t   buildt   add_ir_module(
   R"   Ro   RT   R   Rs   Rt   t   wrapper_modulet   fntyt   wrapper_calleeRM   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   create_cpython_wrapper   s    	
c         C@ s   | j  | j  } | j  | j  } d | j f } t j | j   | j j d  d | | | | f  } | j j	 |  j
 |  |  | S(   s   
        Returns
        -------
        (cfunc, fnptr)

        - cfunc
            callable function (Can be None)
        - fnptr
            callable function address
        - env
            an execution environment (from _dynfunc)
        s   compiled wrapper for %rt   .i(   t   get_pointer_to_functionRy   t   llvm_cpython_wrapper_namet   qualnameR   t   make_functiont   lookup_modulet   splitR   t   set_envRS   (   R"   Ro   RT   R   t   baseptrt   fnptrt   doct   cfunc(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   get_executable   s    	c         C@ s.   t  j t  j | d  } |  j |  j |   S(   sI   
        Calculate the size of an array struct on the CPU target
        t   A(   R	   t   Arrayt   int32t   get_abi_sizeoft   get_value_type(   R"   t   ndimt   aryty(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   calc_array_sizeof   s    (   R   R   t   __doc__RB   t   allow_dynamic_globalsR$   R   R3   R=   t   propertyR>   RE   R   R
   RG   RP   RX   Ra   Rb   Re   Rh   Rq   t   FalseR   R   R   (    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR   $   s&   														
	t   FastMathOptionsc           B@ s&   e  Z d  Z d   Z d   Z e Z RS(   s9   
    Options for controlling fast math optimization.
    c         C@ s   d d d d d d d d h } | t  k r9 d h |  _ n | t k rT t   |  _ n t | t  r | | } | r t d	 |   n  | |  _ nf t | t  r t | j    | } | r t d	 |   n  d
   | j   D |  _ n t d   d  S(   Nt   fastt   nnant   ninft   nszt   arcpt   contractt   afnt   reassocs   Unrecognized fastmath flags: %sc         S@ s"   h  |  ] \ } } | r |  q S(    (    (   t   .0t   vt   enable(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pys	   <setcomp>   s   	 s<   Expected fastmath option(s) to be either a bool, dict or set(	   RB   t   flagsR   t   sett
   isinstancet
   ValueErrort   dictt   keysRd   (   R"   t   valuet   valid_flagst   invalid(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   __init__   s$    
c         C@ s   t  |  j  S(   N(   t   boolR   (   R"   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   __bool__   s    (   R   R   R   R   R   t   __nonzero__(    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR      s   		t   ParallelOptionsc           B@ s   e  Z d  Z d   Z RS(   s7   
    Options for controlling auto parallelization.
    c         C@ s7  t  | t  rZ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _	 n t  | t
  r't |  _ | j d t  |  _ | j d t  |  _ | j d t  |  _ | j d t  |  _ | j d t  |  _ | j d t  |  _ | j d t  |  _	 | r3t d | j     q3n t d	   d  S(
   Nt   comprehensiont	   reductiont   setitemt   numpyt   stencilt   fusiont   pranges!   Unrecognized parallel options: %ss4   Expect parallel option to be either a bool or a dict(   R   R   t   enabledR   R   R   R   R   R   R   R   RB   t   popt	   NameErrorR   R   (   R"   R   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR      s*    								(   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR      s   t   CPUTargetOptionsc           B@ sb   e  Z i e d  6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d	 6e d
 6e d 6Z RS(   t   nopythont   nogilt   forceobjt   loopliftt
   boundcheckt   debugt   _nrtt   no_rewritest   no_cpython_wrapperRk   t   error_modelt   parallel(   R   R   R   R   t   strR   t   OPTIONS(    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR     s   c         C@ s,   x% |  j  D] } t |  t |  q
 Wd S(   sD   
    Remove redundant incref/decref within on a per block basis
    N(   t   basic_blockst   remove_null_refct_callt   remove_refct_pairs(   t   funct   bb(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   remove_refct_calls  s    
c         C@ s   d S(   s0   
    Remove refct api calls to NULL pointer
    N(    (   R   (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR   %  s    c         C@ s   t  } x | r t } i  } i  } x~ |  j D]s } t | t j  r+ | j j } | d k ru | j d } | | | <q | d k r | j d } | | | <q q+ q+ WxE | j	   D]7 } | | k r | | j
   | | j
   t  } q q Wq	 Wd S(   s9   
    Remove incref decref pairs on the same variable
    t	   Py_IncRefi    t	   Py_DecRefN(   RB   R   t   instructionsR   t   lct   CallOrInvokeInstructiont   called_functionR#   t   operandsR   t   erase_from_parent(   R   t   didsomethingt   increfst   decrefst   instt   fnamet   argt   val(    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyR   5  s&    	(4   t
   __future__R    R   t   sysR)   t   llvmlite.bindingt   bindingR+   t   llvmlite.llvmpy.coret   llvmpyt   coreR   R2   R   R   t   numba.callwrapperR   t   baseR   R   R   R   R	   t   numba.utilsR
   t   numba.targetsR   R   R   R   R   R   R   t   optionsR   t   numba.runtimeR   t   numba.compiler_lockR   R:   R   t	   StructureR   R   R   t   objectR   R   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/numba/targets/cpu.pyt   <module>   s.   4# 			