
    shs                       S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SK	JrJ
r
JrJrJrJrJr  S SKJr  S SKJrJrJr  S SKJrJrJrJr  S SKrS qS r " S S	5      r\" 5       rCS
 r S r!S r"S r#S r$S r%S r&S r'S r(S r)S r*S r+S r,S r-S r.S r/0 r0S r1S r2S r30 r4S r50 r6S r7S r8S  r9S! r:  SkS" jr;SkS# jr<0 r=S$ r>/ r?S% r@\?R                  \@5        S& rB/ rCS' rDS( rE0 rF0 rGS) rH  SlS* jrIS+ rJS, rKS- rLS. rM0 rNS/ rO0 rP SmS0 jrQS1 rRSmS2 jrSSmS3 jrT0 rUSnS4 jrV0 rWSmS5 jrXS6 rYS7 rZS8 r[/ S9Qr\S: r]0 r^SmS; jr_S< r`S= raS> rbS? rc " S@ SA\d5      reSB rfSC rgSD rhSmSE jri0 rjS\h4SF jrkSG rlSH rm  SoSI jrnSJ roSK rpSL rqSM rrSN rsSO rtSP ruSQ rvSR rwSS rxST rySU rzSV r{SW r|SX r}SY r~SZ rS[ rS\ rS] rS^ rS_ rS` rSa rSpSb jrSc rSd rSe rSf rSg rSh rSi rSj rg)q    N)
_Intrinsic)typestypingiranalysispostprocrewritesconfig)	signature)compute_live_mapcompute_use_defscompute_cfg_from_blocks)TypingErrorUnsupportedErrorNumbaPendingDeprecationWarningCompilerErrorc                 B    U S-   [        [        5      -   n[        S-   qU$ )N.   )str_unique_var_count)prefixvars     g/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/ir_utils.pymk_unique_varr      s&    
3,./
/C)A-J    c                   *    \ rS rSrSS jrS rS rSrg)	_MaxLabel#   c                     Xl         g N_value)selfvalues     r   __init___MaxLabel.__init__$   s    r   c                 D    U =R                   S-  sl         U R                   $ )Nr   r"   )r$   s    r   next_MaxLabel.next'   s    q{{r   c                 8    [        XR                  5      U l        g r!   )maxr#   )r$   newvals     r   update_MaxLabel.update+   s    &++.r   r"   N)r   )__name__
__module____qualname____firstlineno__r&   r)   r.   __static_attributes__ r   r   r   r   #   s    /r   r   c                 @    Sn U [        U5      -   nX1;  a  U$ US-  nM  )z_Get a new var name with a given prefix and
make sure it is unused in the given variable table.
r   r   )r   )r   	var_tablecurr   s       r   get_unused_var_namer9   3   s3     C
s3xJq	 r   c                  *    [         R                  5       $ r!   )_the_max_labelr)   r5   r   r   
next_labelr<   ?   s      r   c	                    / n	Sn
[         R                  n[        U[        5      (       Ga$  [	        U5      S:X  a  US   n[        XAXgU	5      nGO[	        U5      n
[        R                  " U[        S5      U5      nU(       a:  [         R                  R                  [         R                  U
5      XR                  '   U Vs/ s H  n[        XXgU	5      PM     nn[        R                  R                  X5      n[        R                  " XU5      nU	R                  U5        Un[         R                  R                  [         R                  U
5      n[!        US5      (       a  UR#                  U UUUUUUUUUU	5      $ [        R                  " U[        S5      U5      nU(       a0  [         R$                  R'                  [(        5      UUR                  '   [        R*                  " S[(        U5      n[        R                  " UUU5      n[        R                  R-                  USU5      n[        R                  " U[        S5      U5      nU(       a&  [/        [(        R0                  5      UUR                  '   [        R                  " UUU5      n[3        U5      n[        R                  " U[        S	5      U5      nU(       a,  [         R4                  R7                  U5      UUR                  '   [        U[         R8                  [         R:                  45      (       a@  UR<                  S
:w  a0  [        R>                  " UU5      n[        R                  " UUU5      nOAUS:X  a  Sn[        R                  R-                  UUU5      n[        R                  " UUU5      n[        R                  RA                  UUU/SU5      nU(       ai  UUR                     RC                  X[         R4                  R7                  U5      /0 5      nURD                  S:X  a  URG                  SS9OUUl$        UUU'   URD                  S:X  Gap  URG                  SS9n[        R                  " U[        S5      U5      nU(       a  URG                  SS9UUR                  '   [        R                  " UUU5      n [        R                  R-                  USU5      n![        R                  " U[        S5      U5      n"U(       a&  [/        [(        RJ                  5      UU"R                  '   [        R                  " U!U"U5      n#[        R                  RA                  U"U/SU5      n$U(       a$  UU"R                     RC                  U U/0 5      UU$'   [        R                  " U$X75      n%U	RM                  UUUU U#U%/5        U	$ [        R                  " UX75      n&U	RM                  UUUU&/5        U	$ s  snf )zgenerate an array allocation with np.empty() and return list of nodes.
size_var can be an int variable or tuple of int variables.
lhs_typ is the type of the array being allocated.
r   r   z
$tuple_var__allocate__	$np_g_varnpemptyz$empty_attr_attrz$np_typ_var boolbool_r5   FClayoutz$empty_c_varasfortranarrayz$asfortran_array_attr)'r   intp
isinstancetuplelenconvert_size_to_varr   Varr   
containersUniTuplenameExprbuild_tupleAssignappendhasattrr>   miscModulenumpyGlobalgetattrget_np_ufunc_typrA   r   	functionsNumberClass
NPDatetimeNPTimedeltaunitConstcallget_call_typerH   copy_return_typerI   extend)'	typingctxtypemap	calltypeslhssize_vardtypescopeloclhs_typoutndimssize_typ	tuple_vars	new_sizes
tuple_calltuple_assigng_np_varg_npg_np_assignempty_attr_callattr_varattr_assign	dtype_strtyp_vartypename_consttyp_var_assignnp_typ_getattr
alloc_callcacempty_c_typempty_c_varempty_c_assignasfortranarray_attr_callafa_attr_varafa_attr_assignasfortranarray_callasfortranarray_assignalloc_assigns'                                          r   mk_allocr   C   s    CEzzH(E""x=A{H*8e#NH MEumL&A3GI*/*:*:*C*CJJ+'' #+,"*Q -QSI"*  ,,,Y<J99ZC@LJJ|$ H''00UCHw''##
 	
 vve];7=H!&!2!25!999T5#&D))D(C0Kggooh=Ovve]+=>DH!1%++!>))OXs;KE
IffUM-8#>G % ; ;E B 	55++U->->?@@

bXXi5NYY~wDNfI9cB>7C@h7(;REJhmm$22%//"="=e"DErK  '~~4 $LLL4!( 	 !$	*~~ll#l.ffUM.$A3G(/C(@GK$$%:{C@ $&77??8=Ms#S vve]3J%KSQ)9%:N:N)OGL%%&))$<lCP ggll<+CP-4\5F5F-G-U-UK="..I)* !#		*=s H

Knn#%:< 	= J yyS6

KnlKLJw,s   ?W c                 v   [        U [        5      (       a  [        R                  " U[	        S5      U5      nU(       a  [
        R                  XR                  '   [        R                  " [        R                  " X5      XS5      nUR                  U5        U$ [        U [        R                  5      (       d   eU $ )Nz$alloc_size)rK   intr   rO   r   r   rJ   rR   rU   rc   rV   )rm   rj   ro   rp   nodesnew_sizesize_assigns          r   rN   rN      s    (C  66%}!=sC%*ZZGMM"ii 7G[!h''''Or   c                     [         R                  R                  R                   H  u  pX:X  d  M  Us  $    [         R                  R
                  R                   H  u  pX:X  d  M  Us  $    [        SU S5      e)z7get type of the incoming function from builtin registryztype for func z
 not found)r   npydeclregistryglobals	templatesbuiltin_registryRuntimeErrorfunckvs      r   r]   r]      sd    ..))119H 2 ""33;;9H < '|
<<r   c                    [         R                  " U[        S5      U5      n[        [        5      XR
                  '   [         R                  " S[        U5      n[         R                  " XU5      n	[        XX#XV5      u  p[         R                  R                  X{SU5      nXR
                     R                  [        R                  " 5       [        R                  /[!        U5      -  0 5      XL'   [         R                  " U[        S5      U5      n[        R"                  R%                  [        R                  5      XR
                  '   [         R                  " XU5      n[         R                  R'                  X5      n[(        R*                  (       a)  [-        [        R.                  [        R0                  5      nO([-        [        R2                  [        R4                  5      nUXO'   [         R                  " U[        S5      U5      n[        R"                  R7                  [        R                  5      U UR
                  '   [         R                  " UUU5      n[         R                  " U[        S5      U5      n[        R"                  R7                  [        R                  5      U UR
                  '   [         R                  " UUU5      n[         R8                  " SU5      n[         R:                  " XV5      nXUUUU/-   Ul        U$ )zhmake a block that initializes loop range and iteration variables.
target label in jump needs to be set.
z$range_g_varranger5   z$range_c_varz	$iter_var$phi)r   rO   r   get_global_func_typr   rR   r[   rU   _mk_range_argsrS   rd   re   r   Contextr   rJ   rM   	iterators	RangeTypegetiterr
   USE_LEGACY_TYPE_SYSTEMr   range_iter64_typerange_state64_typerange_iter_typerange_state_typeRangeIteratorTypeJumpBlockbody)rj   startstopsteprk   ro   rp   g_range_varg_rangeg_range_assign	arg_nodesargs
range_callrange_call_varrange_call_assign	iter_callcalltype_sigiter_variter_call_assignphi_var
phi_assignjump_headerrange_blocks                          r   mk_range_blockr      s$   
 &&n =sCK 3E :Gii,GYYwS9N$WTLOIkS9J#$4$45CC5::,T2B8I VVE=#@#FN#(??#<#<UZZ#HG 		*cB4I$$ !8!8%:R:RS !6!68N8NO'Ivve];7=H"__>>uzzJGHMMyyHc:ffUM&137G!OO==ejjIGGLL8Wc2J''"c"K((5&K 4E$4j+$O OKr   c                    / n[        U[        R                  5      (       a  UnO[        U[        5      (       d   e[        R                  " U[	        S5      U5      nU (       a  [
        R                  XR                  '   [        R                  " [        R                  " X%5      Xu5      nUR                  U5        US:X  a
  US:X  a  Xg/4$ [        U[        R                  5      (       a  Un	O[        U[        5      (       d   e[        R                  " U[	        S5      U5      n	U (       a  [
        R                  X	R                  '   [        R                  " [        R                  " X5      X5      n
UR                  U
5        US:X  a  XiU/4$ [        U[        R                  5      (       a  UnO[        U[        5      (       d   e[        R                  " U[	        S5      U5      nU (       a  [
        R                  XR                  '   [        R                  " [        R                  " X55      X5      nUR                  U5        XiX{/4$ )Nz$range_stopr   r   z$range_startz$range_step)rK   r   rO   r   r   r   rJ   rR   rU   rc   rV   )rj   r   r   r   ro   rp   r   
g_stop_varstop_assigng_start_varstart_assign
g_step_varstep_assigns                r   r   r      s   E$
$$$$$VVE=#?E
',zzGOO$ii 3ZE[!zdail""%  %%%%%ffUM.$A3G(-

G$$%yy%!5{H\"qyJ///$
$$$$$VVE=#?E
',zzGOO$ii 3ZE[!
777r   c                     [         R                  R                  R                   H  u  pX:X  d  M  Us  $    [	        SR                  U 5      5      e)z2get type variable for func() from builtin registryzfunc type not found {})r   r   r   r   r   formatr   s      r   r   r     sC    ""33;;9H < /66t<
==r   c                 (   [         R                  " U[        S5      U5      n[        R                  R                  [        R                  [        R                  5      XR                  '   [         R                  R                  X5      n[        R                  (       a  [        R                  nO[        R                  n[        [        R                  R                  [        R                  [        R                  5      U5      X&'   [         R                   " XeU5      n[         R                  " U[        S5      U5      n	[        R                  X	R                  '   [         R                  R#                  XT5      n
[         R                   " XU5      n[         R                  " U[        S5      U5      n[        R                  XR                  '   [         R                  R%                  XT5      n[         R                   " XU5      n[         R                  " U[        S5      U5      n[        R                  XR                  '   [         R                   " XU5      n[         R&                  " USSU5      n[         R(                  " X45      nXUUU/Ul        U$ )zimake a block that is a loop header updating iteration variables.
target labels in branch need to be set.
z$iternext_varz$pair_first_varz$pair_second_varr   r   )r   rO   r   r   rP   PairrJ   booleanrR   rS   iternextr
   r   r   r   r   rU   
pair_firstpair_secondBranchr   r   )rj   r   rk   ro   rp   iternext_variternext_callr   iternext_assignpair_first_varpair_first_callpair_first_assignpair_second_varpair_second_callpair_second_assign	phi_b_varphi_b_assignbranchheader_blocks                      r   mk_loop_headerr   $  s   
 66%!?EL!&!1!1!6!6

EMM"#GGG$$W2M$$11//(JJMM	 		 I
 iiSAOVVE=1B#CSIN#(::G gg((;O		/3GffUM2D$EsKO$)MMG  !ww**<=#3cJumF3S9I#jjGNN99^<LYYB4F88E'L(+\6CLr   c                     0 nU  H@  nUR                  SS5      R                  SS5      R                  SS5      nX1;  d   eX1U'   MB     U$ )zPreturns a dictionary for conversion of variable names to legal
parameter names.
___$r   )replace)varnamesvar_mapr   new_names       r   legalize_namesr   M  sW     G;;sD)11#s;CCCM&&&  Nr   c                 (    S n0 n[        XU5        U$ )z<create a mapping from variable names to their ir.Var objectsc                 "    XU R                   '   U $ r!   rR   )r   namevars     r   get_name_var_visit.get_name_var_table.<locals>.get_name_var_visit[  s    
r   )
visit_vars)blocksr   r   s      r   get_name_var_tabler   Y  s     Gv73Nr   c                 n    0 nUR                  5        H  u  p4X4:w  d  M  XBU'   M     S n[        XU5        g)zCreplace variables (ir.Var to ir.Var) from dictionary (name -> name)c                     [        U [        R                  5      (       d   eU R                  U;   aJ  [        R                  " U R                  XR                     U R
                  5      n U R                  U;   a  MJ  U $ r!   )rK   r   rO   rR   ro   rp   )r   namedicts     r   replace_name'replace_var_names.<locals>.replace_namek  sY    #rvv&&&&hh("&&HXX$6@C hh("
r   N)itemsr   )r   r   new_namedictlrr   s         r   replace_var_namesr  c  s9     L 6O !
 v\2r   c                    [        U [        R                  5      (       d   eU R                  UR	                  5       ;   a  XR                     R                  U R                  :w  d   eXR                     n[        R                  " UR
                  UR                  UR                  5      n U R                  UR	                  5       ;   a  M  U $ r!   )rK   r   rO   rR   keysro   rp   )r   vardictnew_vars      r   replace_var_callbackr  s  s    c266""""
((glln
$xx %%121((#ffW]]GLL'++> ((glln
$ Jr   c                     0 nUR                  5        H  u  p4X4R                  :w  d  M  XBU'   M     [        U [        U5        g)zEreplace variables (ir.Var to ir.Var) from dictionary (name -> ir.Var)N)r   rR   r   r  )r   r  new_vardictr   r   s        r   replace_varsr	  |  s:     K;N   v+[9r   c                 &    [        U [        U5        g r!   )visit_vars_stmtr  )stmtr  s     r   replace_vars_stmtr    s    D.8r   c                 $    [        U [        U5      $ r!   )visit_vars_innerr  )noder  s     r   replace_vars_innerr    s    D"6@@r   c                 p    U R                  5        H"  nUR                   H  n[        XAU5        M     M$     g)zOgo over statements of block bodies and replace variable names with
dictionary.
N)valuesr   r  )r   callbackcbdatablockr  s        r   r   r     s1     JJDDF3  ! r   c                    [         R                  5        H   u  p4[        X5      (       d  M  U" XU5          g    [        U [        R                  5      (       a7  [        U R                  X5      U l        [        U R                  X5      U l        g [        U [        R                  5      (       a  [        U R                  X5      U l	        g [        U [        R                  5      (       a  [        U R                  X5      U l        g [        U [        R                  5      (       a  [        U R                  X5      U l        g [        U [        R                  5      (       a  [        U R                  X5      U l        g [        U [        R                  5      (       a  [        U R                  X5      U l        g [        U [        R                   5      (       aJ  [        R"                  " S U R                  U R$                  5      n[        XQU5      nUR                  U l        g [        U [        R&                  5      (       a7  [        U R                  X5      U l        [        U R(                  X5      U l        g [        U [        R*                  5      (       aR  [        U R                  X5      U l        [        U R(                  X5      U l        [        U R                  X5      U l        g [        U [        R,                  5      (       a7  [        U R                  X5      U l        [        U R.                  X5      U l        g [        U [        R0                  5      (       aR  [        U R                  X5      U l        [        U R2                  X5      U l        [        U R                  X5      U l        g [        U [        R4                  5      (       aR  [        U R                  X5      U l        [        U R.                  X5      U l        [        U R                  X5      U l        g [        U [        R6                  5      (       a-  U R8                   Vs/ s H  n[        XaU5      PM     snU l        g  g s  snf r!   )visit_vars_extensionsr   rK   r   rU   r  targetr%   ArgrR   ReturnRaise	exceptionr   condr   DelrO   rp   DelAttrattrSetAttrDelItemindexStaticSetItem	index_varSetItemPrintr   )r  r  r  tfr   xs          r   r  r    s=   %++-ddf% . $		""&t{{HE%djj(C
P O 
D"&&	!	!$TYYA	L K 
D"))	$	$%djj(C
H G 
D"((	#	#)$..(KD C 
D"))	$	$$TYYA	@ ? 
D"''	"	"&t{{HE< ; 
D"&&	!	! ffT4::txx0sf5XX
0 / 
D"**	%	%&t{{HE$TYYA	* ) 
D"**	%	%&t{{HE$TYYA	%djj(C
" ! 
D"**	%	%&t{{HE%djj(C
  
D"**	+	+&t{{HE)$..(K%djj(C
  
D"**	%	%&t{{HE%djj(C
%djj(C
  
D"((	#	#DHIINIq%a6:IN	  	
	 Os   Q,c           
         [        U [        R                  5      (       a  U" X5      $ [        U [        5      (       a  U  Vs/ s H  n[	        X1U5      PM     sn$ [        U [
        5      (       a&  [        U  Vs/ s H  n[	        X1U5      PM     sn5      $ [        U [        R                  5      (       aI  U R                  R                  5        H)  n[	        U R                  U   X5      U R                  U'   M+     U $ [        U [        R                  5      (       a  [	        U R                  X5      U l
        U $ s  snf s  snf r!   )rK   r   rO   listr  rL   rS   _kwsr  Yieldr%   )r  r  r  nargs        r   r  r    s    $%%	D$		?CDt! f5tDD	D%	 	 TJT&qF;TJKK	D"''	"	" 99>>#C-diinhODIIcN $ K 
D"((	#	#%djj(C
K EJs   D98D>c                    0 nU R                  5        GHE  u  p4SnUR                  (       aY  UR                  S   nUR                   H:  n[        R                  5        H  u  px[        Xg5      (       d  M  U" Xa5      n	M!     M<     [        U[        R
                  5      (       a;  [        R
                  " UR                  U-   UR                  5      UR                  S'   [        U[        R                  5      (       aT  [        R                  " UR                  UR                  U-   UR                  U-   UR                  5      UR                  S'   XBX1-   '   GMH     U$ )z>add an offset to all block labels and jump/branch targets
    Nr   )r   r   add_offset_to_labels_extensionsrK   r   r   r  rp   r   r  truebrfalsebr)
r   offset
new_blocksr   bterminstTr*  f_maxs
             r   add_offset_to_labelsr=    s    J6666":D;AACDA!$** !$ D  dBGG$$v!5txx@AFF2JdBII&&499dkkF.B#'<<&#8$((DAFF2J!"1:  r   c                 8   SnU R                  5        H  u  p#S nUR                  (       ab  UR                  S   nUR                   HC  n[        R                  5        H(  u  pg[        XV5      (       d  M  U" U5      nX:  d  M&  UnM*     ME     X!:  d  M  UnM     U$ )Nr   r   )r   r   find_max_label_extensionsrK   )	r   	max_labelr   r8  r9  r:  r;  r*  r<  s	            r   find_max_labelrA     s    I6666":D5;;=DA!$** !$ ,(-I	 >  =I  r   c                    [        U [        U 5      S-   5      n 0 n[        U 5      n[        5       nSnU H  nXCU'   US-  nM     U H  nX   nSnUR                  (       a  UR                  S   n[        U[        R                  5      (       a:  [        R                  " X8R                     UR                  5      UR                  S'   [        U[        R                  5      (       aR  [        R                  " UR                  X8R                     X8R                     UR                  5      UR                  S'   XqX6   '   M     U$ )zFmakes the labels in range(0, len(blocks)), useful to compare CFGs
    r   r   Nr   )r=  rA  find_topo_orderdictr   rK   r   r   r  rp   r   r  r4  r5  )	r   r7  
topo_orderl_mapidxr+  t_noder8  r9  s	            r   flatten_labelsrI    s    "&.*@1*DEFJ (JFE
Caq  N6666":DdBGG$${{!3TXX>AFF2JdBII&&499eKK.@#(#6BAFF2J$%5=!  r   c                     U R                  5        HP  n/ nUR                   H5  n[        U[        R                  5      (       a  M$  UR                  U5        M7     X!l        MR     g)zremove ir.Del nodesN)r  r   rK   r   r  rV   r   r  new_bodyr  s       r   remove_delsrM  .  sN    JJDdBFF++%  
 ! r   c                    U R                  5        Hy  n/ nUR                   H^  n[        U[        R                  5      (       a+  [        UR
                  [        R                  5      (       a  MM  UR                  U5        M`     X!l        M{     g)zremove ir.Arg nodesN)r  r   rK   r   rU   r%   r  rV   rK  s       r   remove_argsrO  9  se    JJD$		**z$**bff/M/MOOD!  
 ! r   c                    Sn[        U R                  U R                  XX#5      (       a+  Sn[        U R                  U R                  XX#5      (       a  M+  U(       a'  [        R                  " U 5      nUR                  5         gg)zJPerforms dead code elimination and leaves the IR in a valid state on
exit
FTN)remove_deadr   	arg_namesr   PostProcessorrun)func_irrj   	alias_maparg_aliasesdo_post_proc	post_procs         r   dead_code_eliminationrZ  E  ss    
 Lw~~w'8'8' / / w~~w'8'8' / / **73	 r   c                 d   [        U 5      n[        U 5      n[        X`UR                  UR                  5      n[        U 5      u  pUb  Uc  [        XUU5      u  pE[        R                  S:  a\  [        SU5        [        SU5        [        SU5        [        SU5        [        SUR                  5        [        SUR                  5        [        UR                  5       5      nSnU R                  5        H  u  pUR                  R                  5        Vs1 s H  oR                  iM     nn[        R                  S	:  a  [        S
UU5        UR!                  U5       H2  u  nn[        R                  S	:  a  [        SUUU   5        UUU   -  nM4     U[#        UUXXKX#5      -  nM     U$ s  snf )zdead code elimination using liveness and CFG info.
Returns True if something has been removed, or False if nothing is removed.
r   zargs:z
alias map:zarg_aliases:z	live_map:zusemap:zdefmap:F   zremove_dead processing blockzsucc live_map)r   r   r   usemapdefmapget_call_tablefind_potential_aliasesr
   DEBUG_ARRAY_OPTprintsetr  r   
terminator	list_varsrR   
successorsremove_dead_block)r   r   rU  rj   rV  rW  cfgusedefslive_map
call_tabler   	alias_setremovedlabelr  r   livesout_blk_datas                      r   rQ  rQ  T  s    "&
)Cv&GW^^W^^LH"6*MJK/!7g8?"A	"gtlI&nk*k8$i(i(INN$%IG!&!1!1!;!;!=>!=A!=>!!Q&0%?!nnU3NGU%%*ow0ABXg&&E 4 	$UE:%.7M 	M ' N ?s   F-c           
         SnU R                   /n	[        U R                  SS 5       GHv  n
[        R                  S:  a  [        SU
5        [        5       nX-  nU H
  nXU   -  nM     X-  U-  n[        U
5      [        ;   aC  [        [        U
5         nU" XXXFU5      n
U
c#  [        R                  S:  a  [        S5        SnM  [        U
[        R                  5      (       a  U
R                  nU
R                  nUR                  U;  a5  [        UX5      (       a$  [        R                  S:  a  [        S5        SnGM  [        U[        R                   5      (       a>  UR                  UR                  :X  a$  [        R                  S:  a  [        S5        SnGMx  [        U
[        R"                  5      (       a4  U
R                  U;  a$  [        R                  S:  a  [        S5        SnGM  [        U
[        R$                  5      (       a>  U
R                  R                  nUU;  a"  [        R                  S:  a  [        S5        GM(  [        U
5      [&        R(                  ;   a2  [&        R(                  [        U
5         nU" U
5      u  nnUU-  nUU-  nOXR+                  5        Vs1 s H  oR                  iM     sn-  n[        U
[        R                  5      (       a  [        U
R                  [        R,                  5      (       a_  U
R                  R+                  5        Vs1 s H  oR                  iM     nnWR                  U;  a  UR/                  UR                  5        OUR/                  WR                  5        U	R1                  U
5        GMy     U	R3                  5         Xl        U$ s  snf s  snf )zremove dead code using liveness info.
Mutable arguments (e.g. arrays) that are not definitely assigned are live
after return of function.
FNr   r\  rg  zStatement was removed.T)rd  reversedr   r
   ra  rb  rc  typeremove_dead_extensionsrK   r   rU   r  r%   rR   has_no_side_effectrO   r  r'  r   ir_extension_usedefsre  rS   removerV   reverse)r  ro  rk  rW  rV  rl  rU  rj   rm  rL  r  alias_livesinit_alias_livesr   lives_n_aliasesr*  rl   rhsrR   def_funcusesdefsrhs_varss                          r   rg  rg    s    G   !HCR)!!Q&%t,e ,!AQ<'K "-; ://&tDz2AT/	D|))Q.23 dBII&&++C**Cxxu$);*6 *6))Q.23#rvv&&388sxx+?))Q.23 dBFF##zz&))Q.23dBJJ'';;##D?*))Q.23:66644T$Z@H!$JD$TMETMEnn&67&6ff&677E$		**djj"''2204

0D0D0FG0F10FHGxxx/SXX.LL*I *J JN 8  Hs   1N;/O c                 P    [        U5      S:X  a  USS  S[        /:X  a  US   S;  $ g)N   r   randomr   >   seedshuffleF)rM   rZ   )r}  ro  	call_lists      r   remove_dead_random_callr    s3    
9~y}50AA|#666r   c                 ^   SSK JnJn  SSKJn  [        U [        R                  5      (       Gag  U R                  S:X  GaV  U R                  R                  nXb;  d  X&   / :X  a  gX&   nUS[        /:X  d  U[        /:X  d  US[        /:X  dx  US[        /:X  dl  US	[        /:X  d`  XsR                  /:X  dP  Xu/:X  dJ  US
[        /:X  d>  US[        /:X  d2  XtR                  /:X  d"  US[         /:X  d  U["        /:X  d  U[$        /:X  a  g[        US   [&        5      (       a'  US   R(                  S:X  d  US   R(                  S:X  a  gSSKJn  SSKJn	  [        US   U5      (       a  US   R2                  n
X:X  a  g[4         H  nU" XU5      (       d  M    g   g[        U [        R                  5      (       a)  U R                  S:X  a  U R6                  R                  U;  $ [        U [        R8                  5      (       a  g[        U [        R                  5      (       a  U R                  S:X  a  gg)zTReturns True if this expression has no side effects that
would prevent re-ordering.
r   )array_analysisparfor)prangerd   FrA   stencillogrn   r  pndindexceilTempty_inferredunsafe_empty_inferred)CPUDispatcher)dot_3_mv_check_argsinplace_binopr   )numba.parforsr  r  numba.misc.specialr  rK   r   rS   opr   rR   rZ   slicenumba
wrap_indexinternal_prangemathr,   r   r   _namenumba.core.registryr  numba.np.linalgr  py_funcremove_call_handlersrl   r/  )r}  ro  rk  r  r  r  	func_namer  r  r  r  r*  s               r   rv  rv    s    5)#rwwCFFf$4HHMM	&**?2*E)	'5))% )U++%''5))3344!(E***e,,0011&$'##1z22|!!%55|!!%<<57ilM22l**G-%AY'' & #rwwCFFo$=ww||5((#rxx  #rwwCFFl$:r   c                    [        U [        R                  5      (       a  U R                  S:X  a  U R                  R
                  nX2;  d  X#   / :X  a  gX#   nU[        /:X  d:  US[        /:X  d.  US[        /:X  d"  US[        /:X  d  U[        /:X  d  U[        /:X  a  g[         H  nU" XU5      (       d  M    g   gU R                  S:X  d  U R                  S:X  a  g[        U [        R                  5      (       a  gg)	zReturns True if every time this expression is evaluated it
returns the same result.  This is not the case for things
like calls to numpy.random.
rd   Fr  rA   r  Tr   r   )rK   r   rS   r  r   rR   r  rZ   r  r,   r   is_pure_extensionsr/  )r}  ro  rk  r  r  r*  s         r   is_purer    s    
 #rww66VI*j.Cr.I"-IeW$eU^+gu--fd^+cU"cU"'S++ ( VVy CFFj$8#rxx  r   c                     U S:X  a  US;   a  gg)NrZ   )rA   TFr5   )module_namer  s     r   is_const_callr  -  s    g	!r   c                 F    X;  a  U $ [        [        X   5      5      nUS   $ )Nr   )sortedr-  )r   rV  	v_aliasess      r   get_canonical_aliasr  7  s(    tIL)*IQ<r   c           
        ^ Uc  0 nUc  [        U4S jU 5       5      n[        UR                  5      Ul        / SQnU R	                  5        GHM  nUR
                   GH8  n[        U5      [        ;   a  [        [        U5         n	U	" XTX4U5        [        U[        R                  5      (       d  MU  UR                  n
UR                  R                  n[        UT5      (       a  M  [        U
[        R                  5      (       a%  XR                  :w  a  [!        XR                  XE5        [        U
[        R"                  5      (       a@  U
R$                  S:X  d  U
R$                  S;   a   [!        XR                  R                  XE5        [        U
[        R"                  5      (       a0  U
R$                  S:X  a   [!        XR&                  R                  XE5        [        U
[        R"                  5      (       a@  U
R$                  S:X  a0  U
R(                  S;   a   [!        XR                  R                  XE5        [        U
[        R"                  5      (       aZ  U
R$                  S:X  aJ  U
R(                  S;  a:  U
R                  R                  U;   a   [!        XR                  R                  XE5        [        U
[        R"                  5      (       d  GMv  U
R$                  S	:X  d  GM  [+        [,        X:T5      nUc  GM  Uu  pU[.        ;   a  [.        U   nU" XR0                  XE5        US
:X  a(  X;   a#  [!        XR0                  S   R                  XE5        [        U[        R                  5      (       d  GM  X;   d  GM"  [!        XR                  XE5        GM;     GMP     [2        R4                  " U5      nU H3  nUU    H  nUU==   UU   -  ss'   M     UU    H  nUU   UU'   M     M5     XE4$ )zCfind all array aliases and argument aliases to avoid remove as deadc              3   N   >#    U  H  n[        UT5      (       a  M  Uv   M     g 7fr!   )is_immutable_type).0arj   s     r   	<genexpr>)find_potential_aliases.<locals>.<genexpr>D  s     OT1B1g1N!!Ts   %	%)ravel	transposereshapecastgetitemstatic_getitemr  r\   )r;  ctypesflat)shaperd   rZ   r   )rc  build_definitionsr   _definitionsr  r   rt  alias_analysis_extensionsrK   r   rU   r%   r  rR   r  rO   
_add_aliasrS   r  rl   r!  guardfind_callnamealias_func_extensionsr   rf   deepcopy)r   r   rj   rU  rV  rW  np_alias_funcsblinstrr*  exprrl   fdeffnamefmod
alias_funcold_alias_mapr   ws     `                r   r`  r`  >  s    	OTOO -W^^<G6NmmoWWEE{77-d5k:%wKH%++{{ll''$S'22dBFF++YYsIIyFtRWW--477f3DGG<<sJJOOYLdBGG,,O1KsHHMM9JtRWW--$''Y2F II)@@sJJOOYLtRWW--$''Y2F IIY6 JJOO{:sJJOOYLdBGG,,F1B wGD
 | "&KE44%:4%@
"3		9Jw5+B"3		!(9(99R!$//E4K"3		9JW  ^ MM),Mq!AaLIaL(L "q!A$Q<IaL "  !!r   c                     X;   a  UR                  U 5        g X;  a  [        5       X!'   X;  a  [        5       X '   X!   R                  U 5        X    R                  U5        g r!   )addrc  )rl   r}  rV  rW  s       r   r  r    s\    
   UIN UIN33
r   c                     Ub  X;  a  gX   n[        U[        R                  [        R                  R                  [        R
                  R                  45      (       a  gU[        R                  :X  a  gg)NFT)rK   r   Numberscalars_NPDatetimeBaser   r   string)r   rj   typs      r   r  r    s^    #,
,C#emm&C&C113 4 4
ELLr   c                 *   [        U 5      nUR                  5       n[        XU5      nUu  pVpxn	Sn
[        R                  " U	5      nX:w  a  U R                  5        Hn  nX:X  a  M
  UR                  U5       VVs/ s H  u  pUPM	     nnnXS      R                  5       X'   U H  nX==   U	U   -  ss'   M     X\   X   X|   -
  -  X'   Mp     Un
[        R                  " U	5      nX:w  a  M  [        R                  S:  a  [        SU	5        X4$ s  snnf )zcompute copy propagation information for each block using fixed-point
iteration on data flow equations:
in_b = intersect(predec(B))
out_b = gen_b | (in_b - kill_b)
Nr   r   zcopy propagate out_copies:)
r   entry_pointinit_copy_propagate_datarf   r  r  predecessorsr
   ra  rb  )r   rj   rh  entryc_data
gen_copies
all_copieskill_copies	in_copies
out_copies	old_point	new_pointrn  i_dpredecsps                    r   copy_propagater    s#    "&
)COOE &fW=FCI@Z[ZIj)I

 [[]E~&)&6&6u&=>&=UQq&=G>)!*5::<I JqM1   ",!2$-$4{7I$I"KJ # 	MM*-	 
  "*J7   ?s   9Dc                    [        X5      u  p4[        5       nUR                  5        H  u  pgXSU   -  nM     0 nUR                  5        H  u  p[        5       X'   U Hi  u  pXU	   ;   d  XU	   ;   a  X   R                  X45        U
 VVs1 s H  u  pUiM	     nnnWW4U
;  d  MI  X;   d  X;   d  MU  X   R                  X45        Mk     M     U R	                  5        Vs0 s H  ofUR                  5       _M     nn[        5       X'   0 nU R	                  5        H  n	X9   X   X   -
  -  X'   M     X1   X'   X5XU4$ s  snnf s  snf )zHget initial condition of copy propagation data flow for each block.
    )get_block_copiesrc  r   r  r  rf   )r   r  rj   r  
extra_killr  r   rv   r  rn  gen_setrl   r}  assignedr  r  s                   r   r  r    sY   
 .f>JJ  "m#
 #K$**, U"HC''3U2C+C"&&z2 -44GGH4c
')CO"&&z2 # - 06{{}=}!JOO%%}I=uIJ'. ) 0;3E EG
  #)JKJGG 5 >s   D<
 Ec                 *   0 n0 nU R                  5        GHx  u  pE0 n[        5       X4'   UR                   GH6  n[        R                  5        H  u  p[	        Xx5      (       d  M  U	" Xq5      u  pU
 H	  u  pXU'   M     0 nUR                  5        H0  u  nnX;  a
  UU;  a  UX'   UU;   d  M  X4   R                  U5        M2     UnX4==   U-  ss'   M     [	        U[        R                  5      (       d  M  UR                  R                  n[	        UR                  [        R                  5      (       a,  UR                  R                  nX   X   :X  a  X:w  a  XU'   GM,  [	        UR                  [        R                  5      (       a  UR                  R                  S:X  a  UR                  R                  R                  nUU   n[	        U[        R                   5      (       dp  U[        R"                  :X  d\  X4   R                  U5        0 nUR                  5        H1  u  nnUU:w  a
  UU:w  a  UX'   UU:X  d  M  X4   R                  U5        M3     UnX4   R                  U5        GM9     [        UR                  5       5      nUX$'   GM{     X#4$ )z2get copies generated and killed by each block
    r  )r   rc  r   copy_propagate_extensionsrK   r  r   rU   r  rR   r%   rO   rS   r  rl   r   r  r  )r   rj   block_copiesr  rn  r  assign_dictr  r;  r*  r  kill_setrl   r}  new_assign_dictr   r   in1_varin1_typ	block_cpss                       r   r  r    sA    LJE
JJD1779d&&()$(8%G$++.C( %, ')O + 1 1 31,(1B12O.=&-11!4	 !4
 #2K%1% : $		**kk&&djj"&&11**//C |w|3
+.C( djj gg' '+/::==O+K"jjnn11G%g.G&w==&%,,6")--g6*,$/$5$5$7DAq G|W56 2 G| * 1 5 5a 8	 %8
 '6!%%c*Y Z ))+,	'e 'f ##r   c           
         Uc  / nU R                  5        GHM  u  pgX    VV	s0 s H
  u  pXU	   _M     n
nn	UR                   GH  n[        U5      [        ;   a  [        [        U5         nU" XUX4U5        OF[	        U[
        R                  5      (       a  [        UR                  U
5      Ul        O[        X5        [        XU5        [        R                  5        H  u  p[	        X5      (       d  M  U" X5      u  pU H  u  nnUU;   d  M  UU   U
U'   M     U
R                  5       R                  5        H-  u  pX;   d  U	R                  U;   d  M  U
R                  U5        M/     M     [	        U[
        R                  5      (       a  [	        UR                  [
        R                  5      (       a  UR                   R                  nUR                  R                  nUU:w  a  UU   UU   :X  a  UU;   a	  UU   U
U'   OU
R                  US5        / nU
R                  5        H)  u  nnUR                  U:X  d  M  UR#                  U5        M+     U H  nU
R                  US5        M     [	        U[
        R                  5      (       d  GMN  [	        UR                  [
        R                  5      (       a  GMz  UR                   R                  nU
R                  US5        / nU
R                  5        H)  u  nnUR                  U:X  d  M  UR#                  U5        M+     U H  nU
R                  US5        M     GM     UR%                  U
R                  5       5        GMP     U$ s  sn	nf )zEapply copy propagation to IR: replace variables when copies availableN)r   r   rt  apply_copy_propagate_extensionsrK   r   rU   r  r%   r  fix_setitem_typer  rf   rR   poprO   r  rV   rh   )r   r  name_var_tablerj   rk   save_copiesrn  r  r   r   var_dictr  r*  r;  r  r  rl   r}  lhs_killr   r   s                        r   apply_copy_propagater  +  s    5>5EF5ETQAa((5EFJJDDz<<3DJ?$.5 D")),,/

HE
!$1TI61779d&&()$(8%G$+S.0,:3,?HSM %, !) 5 5 7=AFFh,>$LLO !8 : $		**z$**bff/M/Mkk&&jjoo#: s|ws|3~8M(6s(; S$/!H ( 0166S=$OOA. !1 & Q- &4++0:4::rvv0N0Nkk&&S$'$NN,DAqvv} * - "ALLD) "a d 	8>>+,k 'n m Gs   M*c                 "   [        U [        R                  [        R                  45      (       d  gXR                  R
                     nX    R                  S   n[        U[        R                  R                  5      (       a)  [        U[        R                  R                  5      (       d  gUR                  S:X  aS  UR                  S:w  aC  UR                  UR                  S9nUX    R                  S   X    R                  S   4X    l        g)zCopy propagation can replace setitem target variable, which can be array
with 'A' layout. The replaced variable can be 'C' or 'F', so we update
setitem call type reflect this (from matrix power test)
Nr   ArG   r   r\  )rK   r   r'  r%  r  rR   r   r   npytypesArrayrH   rf   )r  rj   rk   t_typs_typ	new_s_typs         r   r  r  m  s    
 dRZZ)9)9:;;KK$$%EO  #ENN  " ")3NN  *" *" 	||su||s2JJellJ3	O  #O  # %	 r   c                    [         R                  S:  av  U R                  nUS:X  a  UOUU l        U R                  R                  n[        SU< SU< 3R                  SS5      5        U R                  5         [        S5        X0l        gg)ziDebug print function IR, with an optional blocks argument
that may differ from the IR's original blocks.
r   NzIR z: P   -z(----------------------------------------)r
   ra  r   func_idfunc_qualnamerb  centerdump)rU  titler   	ir_blocksrR   s        r   dprint_func_irr    sm     "NN	&,n&,,eT*222s;<h" #r   c                    Uc  [        U 5      n/ n[        5       n[        5       nUR                  5       /n[        U5      S:  Ga  US   nXd;  a  Xc;  a  UR	                  U5        UR
                  U   nX   R                  S   n[        U[        R                  5      (       a  UR                  UR                  /nU H.  n	Xi4UR                  ;  d  M  X;  d  M  UR                  U	5        M0     OMUR                  5       nXd;  a"  UR                  U5        UR	                  U5        Xc;   a  UR                  U5        [        U5      S:  a  GM  UR!                  5         U$ )zfind topological order of blocks such that true branches are visited
first (e.g. for_break test in test_dataflow). This is written as an iterative
implementation of post order traversal to avoid recursion limit issues.
r   r   )r   rc  r  rM   r  _succsr   rK   r   r   r4  r5  _back_edgesrV   r  rx  ry  )
r   rh  
post_orderseenvisitedstackr  succs	last_instdests
             r   rC  rC    s1   
 {%f-J5DeG__E
e*q.Ry4#3HHTNJJt$E))"-I)RYY//"))9+<+<=<s6'T*  99;D"!!$'D!| D!3 e*q.6 r   c                 2   Uc  0 nUc  0 nU(       a  [        U 5      nO[        U R                  5       5      n[        U5       GH  n[        X   R                  5       GH  n[        U[        R                  5      (       GaS  UR                  R                  nUR                  n[        U[        R                  5      (       a(  UR                  S:X  a  / XR                  R                  '   [        U[        R                  5      (       a  UR                  S:X  ax  Xq;   a5  X   R                  UR                  5        XrUR                  R                  '   Xr;   a9  X'   n	X   R                  UR                  5        XUR                  R                  '   [        U[        R                   5      (       aH  Xq;   a  X   R                  UR                  5        Xr;   a!  X'   n	X   R                  UR                  5        [        U[        R"                  5      (       aH  Xq;   a  X   R                  UR                  5        Xr;   a!  X'   n	X   R                  UR                  5        [        U[        R$                  5      (       aV  Xq;   a+  X   R                  UR                  5        XrUR                  '   Xr;   a!  X'   n	X   R                  UR                  5        [&        R)                  5        H   u  p[        Xj5      (       d  M  U" XaU5        M"     GM     GM     X4$ )zAreturns a dictionary of call variables and their references.
    rd   r\   )rC  r-  r  rs  r   rK   r   rU   r  rR   r%   rS   r  r   rV   r!  r[   FreeVarrO   call_table_extensionsr   )r   rk  reverse_call_tabletopological_orderingorderrn  r:  rl   r}  call_varr;  r*  s               r   r_  r_    sY   
 
!'V[[]#%V]//0D$		**kk&&jjc277++&0@02Jxx}}-c277++)0C("..sxx8=@399>>:0#5#:",33CHH==E399>>:c299--("..syy90#5#:",33CII>c2::..("..syy90#5#:",33CII>c266**("..sxx87:38840#5#:",33CHH=-335d&&d(:; 6C 1 !J ))r   c                 n   Uc  0 nU R                  5        GH  nUR                   GH  n[        U[        R                  5      (       a  UR
                  R                  nUR                  n[        U[        R                  5      (       a  UR                  S:X  a  UR                  X'   [        U[        R                  5      (       a-  [        UR                  [        5      (       a  UR                  X'   [        R                  5        H  u  pg[        X65      (       d  M  U" X15        M!     GM     GM     U$ )z>returns a dictionary of tuple variables and their values.
    rT   )r  r   rK   r   rU   r  rR   r%   rS   r  r   rc   rL   tuple_table_extensions)r   tuple_tabler  r:  rl   r}  r;  r*  s           r   get_tuple_tabler'    s     JJD$		**kk&&jjc277++-0G'*yyK$c288,,CIIu1M1M'*yyK$.446d&&d( 7  ! r   c                     [        5       n[        U [        R                  [        R                  [        R
                  45      (       a%  UR                  U R                  R                  5        U$ r!   )	rc  rK   r   rU   r'  r%  r  r  rR   )r  writess     r   get_stmt_writesr*    sF    UF$BJJ0@0@ABB

4;;##$Mr   c                 t   [        U 5      nSnU R                  5        H5  u  p4[        UR                  S   [        R
                  5      (       d  M3  UnM7     US:w  a"  UR                  U5        UR                  U5        0 n[        USS9nU H  nUR                  5       XW'   M     U R                  5        H  nUR                  n[        U[        R                  5      (       a:  [        R                  " XXR                     UR                  5      UR                  S'   [        U[        R                  5      (       d  M  [        R                  " UR                   XXR"                     XXR$                     UR                  5      UR                  S'   M     0 n	U R                  5        H  u  pXZ   nXIU'   M     U	$ )z~rename labels of function body blocks according to topological sort.
The set of labels of these blocks will remain unchanged.
r   T)ry  )rC  r   rK   r   r   r  rx  rV   r  r  r  rd  r   r  rp   r   r  r4  r5  )r   rE  return_labelr   r8  	label_map
all_labelsrn  r9  r7  r   	new_labels               r   rename_labelsr0    s^    !(J LaffRj")),,L  r,','I
D1J%>>+	  ]]_|| dBGG$$;;!7BAFF2JdBII&&499#,[[#9#,\\#:#'88-AFF2J  JL	 !9  r   c                   ^  [        T 5      nU 4S jn[        [        UT R                  5       5      5      n[	        5       nU H  nT U   R
                  S   nUR                  U5      nSnU H]  u  pT U	   n[        UR
                  S   [        R                  5      (       a%  [        R                  " U5      UR
                  S'   M[  SnM_     U(       d  M  UR                  U5        M     U H  nT U	 M     [        T 5        [        T 5      $ )z@transform chains of blocks that have no loop into a single blockc                    > TU    n[        UR                  5      S:H  =(       a'    [        UR                  S   [        R                  5      $ Nr   r   )rM   r   rK   r   r   )rn  r  r   s     r   find_single_branch(simplify_CFG.<locals>.find_single_branchO  s7    u5::!#L
5::a="))(LLr   r   Tr   F)r   r-  filterr  rc  r   r  rK   r   r   rf   r  merge_adjacent_blocksr0  )r   rh  r4  single_branch_blocksmarked_for_delrn  r:  r  delete_blockr  qr  s   `           r   simplify_CFGr<  K  s     "&
)CM  '96;;= IJUN%e}!!!$''."FQ1IE%**R."''22!%4

2$ # <u% &  5M  &!  r   )minr,   sumprodmeanr   stdcumsumcumprodargmaxargminargsortnonzeror  c           	         U R                   n0 n[        U5      nU GH*  nXG   n/ n	UR                   GH	  n
[        U
[        R
                  5      (       Ga  [        U
R                  [        R                  5      (       Ga  U
R                  R                  nU
R                  nUR                  S:X  Gaz  UR                  [        ;   Gae  [        XR                  R                     [        R                  R                  5      (       Ga%  U
R                  nUR                  nXU'   UR                   nUR"                  n[        R$                  " U['        S5      U5      n[        R(                  R+                  [,        5      UUR                  '   [        R.                  " S[,        U5      n[        R
                  " UUU5      nUUl        U	R1                  U5        U/U R2                  UR                  '   [5        [,        UR                  5      n[7        U5      nUR9                  U5        UX'   UR                  S:X  a  UR:                  R                  U;   a  X\R:                  R                     nUR9                  U5      nUR<                  S [?        UR<                  5       nUR@                   VVs0 s H  u  nnUUUR                     _M     nnnXR:                  R                     RC                  X1UR                     /[E        U5      -   U5      X,'   U/UR<                  -   Ul        U	R1                  U
5        GM     Xl        GM-     g s  snnf )Nr\   r?   r@   rd   )#r   rC  r   rK   r   rU   r%   rS   r  rR   r  r!  arr_mathr   r  r  ro   rp   rO   r   rX   rY   rZ   r[   rV   r  r\   r]   r  r   r   rM   kwsre   r-  )rU  rj   rk   ri   r   saved_arr_argrE  rn  r  rL  r  rl   r}  arrro   rp   rz   r{   r|   r   func_typold_sigargtypsrR   r   kwtypss                             r   canonicalize_array_mathrQ  l  s    ^^FM (JJJD$		**z$**bgg/N/Nkk&&jjFFi'CHH,@&#IINN3U^^5I5IK K**C))C),#&IIE''C!vve];-GMH-2ZZ->->u-EGHMM*99T5#6D"$))D(C"@K (CIOOK0;?&G((7"5#((3D/5HKK$#+GL66V#(F'6C'mmC0G &ll>CM:GCF77K7adGAFFO37FK%,XX]]%;%I%I!CHH$5#6g#F&PIN #usxx/CHOOD!O P 
W X  Ls   1M
c                    Uc
  [        5       nU R                  5        GH;  nUR                   GH&  n[        U[        R
                  5      (       a;  UR                  UR                  R                  UR                  R                  45        [        U[        R                  5      (       a;  UR                  UR                  R                  UR                  R                  45        [        U[        R                  5      (       Ga  UR                  R                  nUR                  n[        U[        R                  5      (       aK  UR                  S:X  a;  UR                  UR                  R                  UR                  R                  45        [        U[        R                  5      (       al  UR                  S:X  a\  UR                  nUb  [!        U5      (       a  UR                  R                  nUR                  UR                  R                  U45        ["        R%                  5        H  u  px[        X75      (       d  M  U" X15        M!     GM)     GM>     U$ )z8returns a set of arrays accessed and their indices.
    r  r  )rc  r  r   rK   r   r'  r  r  rR   r$  r%  r&  rU   r%   rS   r  is_slice_indexarray_accesses_extensionsr   )	r   accessesr  r:  rl   r}  r$  r;  r*  s	            r   get_array_accessesrV    s    5JJD$

++dkk..

@A$ 0 011dkk..0C0CDE$		**kk&&jjc277++)0CLL#))..#))..!ABc277++:J0JIIE}u(=(= # 2 2LL#))..%!891779d&&d% :!  !( Or   c                     [        U [        5      (       a  g[        U [        5      (       a   U  H  n[        U[        5      (       d  M    g   g)z0see if index is a slice index or has slice in itTF)rK   r  rL   )r$  r  s     r   rS  rS    s>    %%A!U##  r   c                 @   [        U 5      n[        5       n[        U R                  5       5       H  nX2;   a  M
  X   n[        UR	                  U5      5      n [        U5      S:w  a  M:  US   S   nXb;   a  MI  [        UR                  U5      5      n[        UR	                  U5      5      n[        U5      S:w  d  US   S   U:w  a  M  X   nUR                  R                  5         U=R                  UR                  -  sl        X	 UR                  U5        UnM     g r3  )
r   rc  r-  r  rf  rM   r  r   r  r  )	r   rh  rm  rn  r  r  r<   preds
next_blocks	            r   r7  r7    s    
!&
)CeGfkkm$S^^E*+5zQq!J$))*56E
34E5zQ%(1+"6+J JJNNJJ*//)J"KK
#E+  %r   c                 z   U(       d  0 $ 0 n0 nU H  u  pVUR                  S5      (       a  M  UR                  R                  S5      (       d  M?  UR                  U;  d  MQ  [        SR                  U5      5      nXsUR                  '   XTU'   UR	                  UR                  5      nXU'   M     [        X5        U$ )zK
restores variable names of user variables after applying copy propagation
r   z${})
startswithrR   r   r   r  r  )	r   r  rj   rename_dictvar_rename_mapr  r8  r   r  s	            r   restore_copy_var_namesr_    s     	KN S!!aff&7&7&<&<45FF+4M$U\\!_5H"*'(8$++aff%C #H  f*r   c                    [        U R                  U5      u  pE[        U R                  5      n[        U R                  UUUU5      n[	        U R                  Xq5      nSU;  a  0 US'   US   R                  U5        [        R                  S:  a  [        U S5        [        U R                  U R                  X5        [        U R                  5      U l        [        R                  S:  a  [        U S5        g g )Nr^  r   zafter copy propzafter simplify)r  r   r   r  r_  r.   r
   ra  r  rQ  rR  r<  )	rU  rj   rk   metadatain_cpsr   r  r  r^  s	            r   simplifyrc    s    w~~w7IF'7N&K ,GNNKQNx')+H%&%%n5"w 12 1 17D!'..1GN"w 01 #r   c                       \ rS rSrSrg)GuardExceptioni  r5   N)r0   r1   r2   r3   r4   r5   r   r   re  re    s    r   re  c                     U (       d  [         eg)z7
Raise GuardException if the given condition is False.
Nre  )r  s    r   requirerh  !  s      r   c                 4     U " U0 UD6$ ! [          a     gf = f)z
Run a function with given set of arguments, and guard against
any GuardException raised by the function by returning None,
or the expected return results if no such exception was raised.
Nrg  )r   r   kwargss      r   r  r  (  s)    T$V$$ s   
 
c                 R     U R                   " U40 UD6$ ! [         a    [        ef = f)za
Same as func_ir.get_definition(name), but raise GuardException if
exception KeyError is caught.
)get_definitionKeyErrorre  )rU  rR   rj  s      r   rl  rl  3  s2    
%%d5f55 s    &c                    Uc  [         R                  " [        5      nU R                  5        H  nUR                   H  n[        U[        R                  5      (       aM  UR                  R                  nUR                  U/ 5      nU/ :X  a  XQU'   UR                  UR                  5        [        U5      [        ;   d  M  [        [        U5         nU" X15        M     M     U$ )zBuild the definitions table of the given blocks by scanning
through all blocks and instructions, useful when the definitions
table is out-of-sync.
Will return a new definition table if one is not passed.
)collectionsdefaultdictr-  r  r   rK   r   rU   r  rR   getrV   r%   rt  build_defs_extensions)r   definitionsr  r:  rR   
definitionr*  s          r   r  r  =  s     !--d3JJD$		**{{''(__T26
#(2%!!$**-Dz22)$t*5$$  ! r   c                 V   [        [        U[        R                  5      =(       a    UR                  S:H  5        UR
                  nU" X5      n/ nSn [        U[        R                  [        R                  45      (       Ga  / SQnSn	U H6  n
[        UR                  U
5      (       d  M   [        UR                  U
5      n	  O   U	(       a  [        U	[        5      (       d  [        eUR                  U	5        UR                  n[        U[        5      (       a  UR                  n[        US5      (       a  UR                   nUSLnU=(       a    US:H  =(       d    UR#                  S5      nU(       a0  [        [$        U	5      (       a  U[        [$        U	5      :X  a  US/-  nO[        [$        R&                  U	5      (       a&  U[        [$        R&                  U	5      :X  a  USS/-  nONU(       a  UR                  U5        O5UR(                  R*                  nUS:X  a  S	nUS
:w  a  UR                  U5        O[        U[        R                  5      (       a  UR                  S:X  a{  UR                  nUR                  UR,                  5        U(       aD  UR.                  U;   a4  X'R.                     n[        U[0        R2                  5      (       d  US   U4$ U" X5      nO%Ub  SR5                  [7        U5      5      U4$ [        eGM  US   SR5                  [7        USS 5      5      4$ )af  Try to find a call expression's function and module names and return
them as strings for unbounded calls. If the call is a bounded call, return
the self object instead of module name. Raise GuardException if failed.

Providing typemap can make the call matching more accurate in corner cases
such as bounded call on an object which is inside another object.
rd   N)rR   r  r0   r1   rZ   znumpy.r  builtin_function_or_methodbuiltinmoduler\   r   r   r   )rh  rK   r   rS   r  r   r[   r  rW   r%   r\   r   re  rV   r   _defnr1   r\  rZ   r  	__class__r0   r!  rR   r   rY   joinrs  )rU  r  rj   definition_findercallee
callee_defattrsobjr  r%   keydef_valmod_namemod_not_nonenumpy_toplevel
class_namer  s                    r   r  r  V  s    JtRWW%;$''V*;<YYF"73JE
C
j299bjj"9:: 1DE:++S11#J$4$4c:E  
5# 6 6$$LL &&G ':..!--w--"--  (t3". #E#+w#6 $D&.&9&9(&C  #wue'<'<#wue'<<gY&EellE22#wu||U'CCh00E!LL*$..77
!==!*J)LL,
BGG,,)1K""CLL)388w.hh'!#u||44 8S=(*78J xx0#55  { | 8SXXhuQRy1222r   c                    [        [        U[        R                  5      5        [	        X5      n[        [        U[        R
                  5      5        / SQn[        UR                  U;   5        UR                  UR                  4$ )zCheck if a variable is constructed via build_tuple or
build_list or build_set, and return the sequence and the
operator, or raise GuardException otherwise.
Note: only build_tuple is immutable, so use with care.
)rT   
build_list	build_set)rh  rK   r   rO   rl  rS   r  r   )rU  r   var_def	build_opss       r   find_build_sequencer    s]     JsBFF#$W*GJw():IGJJ)#$=='**$$r   c                     [        [        U[        R                  5      5        [	        X5      n[        [        U[        R
                  [        R                  [        R                  45      5        UR                  $ )znCheck if a variable is defined as constant, and return
the constant value, or raise GuardException otherwise.
)	rh  rK   r   rO   rl  rc   r[   r  r%   )rU  r   r  s      r   
find_constr    sM     JsBFF#$W*GJw299bjj ABC==r   c                    SSK Jn  [        U S5      (       a  U R                  nO8[        U S5      (       a  U R                  nO[        SR                  U 5      5      e[        X5      n	[        U	R                  5        [        U	R                  [        R                  5       5      U	l	        [        U	R                  R                  5       5      n
[        R                  U
5        [!        U	R                  5      n0 nUR#                  5        H  u  p[%        U5      X'   M     ['        U	R                  U5        U(       a~  UR)                  X#XS5      u  nnnnU Vs/ s H  nUR+                  S5      (       d  M  UPM     nnU H  nUR-                  U5        M     UR                  U5        UR                  U5        U	$ s  snf )z
Compile a function or a make_function node to Numba IR.

Rename variables and
labels to avoid conflict if inlined somewhere else. Perform type inference
if typingctx and other typing inputs are available and update typemap and
calltypes.
r   )typed_passescode__code__zfunction type not recognized {}Narg.)
numba.corer  rW   r  r  NotImplementedErrorr   get_ir_of_coderM  r   r=  r;   r)   r,   r  r.   r   r   r   r  type_inference_stager\  r  )mk_funcglblsri   	targetctxarg_typsrj   rk   r  r  f_irr@  r7   new_var_dictrR   r   	f_typemapf_return_typef_calltypesr   vnamerR  r  s                         r   compile_to_numba_irr    sj    (w||	*	%	%!"C"J"J7"STT%&D 't{{N4G4G4IJDKDKK$$&'I)$ #4;;/IL__&	*40 'dkk<0 3?3T3Tdd4<0	=+q )2N	uU5E5Ef5MU		NAMM! y!%K Os   F<6F<c           
          U R                   R                  SS5      R                  SS5      nSU SU SU SU SU 3
n0 n[        XdU5        US	   " 5       nXl        U R                   Ul        U$ )
a  
Creates a function from a code object. Args:
* fcode - the code object
* func_env - string for the freevar placeholders
* func_arg - string for the function args (e.g. "a, b, c, d=None")
* func_clo - string for the closure args
* glbls - the function globals
<r   >zdef closure():
z
	def (z):
		return (z
)
	return closure)co_namer   execr  r0   )	fcodefunc_envfunc_argfunc_clor  sanitized_co_name	func_textrp   r*  s	            r   _create_function_from_code_objr    s     --c37??SI#H: .+,AhZ 8  (z *./1I C3IAJAJHr   c                   ^ [        UR                  5      nSR                  [        U5       Vs/ s H  nSU-  PM
     sn5      nSR                  [        U5       Vs/ s H  nSU-  PM
     sn5      nSR                  [        UR                  5       Vs/ s H  nSU-  PM
     sn5      n[        XXeU 5      nSSKJm  TR                  U5      n " U4S jS	[        5      n	U	" U5      R                  n
[        R                  R                  S
U
5        0 nSSKnUR                  R                   R#                  XR                  R$                  R'                  S5      U5      nUR)                  5         SSKJn  SSKJn  U" 5       nU" 5       nUR3                  U
5        UR3                  U
5        [4        R6                  " U5      nUR)                  S5        U$ s  snf s  snf s  snf )z?
Compile a code object to get its IR, ir.Del nodes are emitted

z	c_%d = None,c_%dzx_%dr   compilerc                   "   > \ rS rSrU 4S jrSrg)%get_ir_of_code.<locals>.DummyPipelinei  c                   > TR                  5       U l        S U R                  l        S U R                  l        S U R                  l        XR                  l        S U R                  l        S U R                  l        S U R                  l        g r!   )		StateDictstateri   r  r   rU  rj   return_typerk   )r$   r  r  s     r   r&   .get_ir_of_code.<locals>.DummyPipeline.__init__  sd    !++-DJ#'DJJ #'DJJ "DJJO!%JJ!%DJJ%)DJJ"#'DJJ r   )r  N)r0   r1   r2   r3   r&   r4   r  s   r   DummyPipeliner    s    	( 	(r   r  zbefore-inferenceNF)ReconstructSSA)PreLowerStripPhisT)rM   co_freevarsr{  r   co_argcountr  r  r  run_frontendobjectr  r	   rewrite_registryapplynumba.core.inline_closurecallcoreinline_closurecallInlineClosureCallPasscpuParallelOptionsrT  numba.core.untyped_passesr  numba.core.typed_passesr  run_passr   rS  )r  r  nfreer  r  r  r  r*  r   r  r  swappedr  inline_passr  r  reconstruct_ssaphistriprY  r  s                      @r   r  r    s    !!"EyyuU|D|!/A-|DEHxxU5\:\!\:;HxxU53D3D-EF-E!-EFGH&u',	.A $			q	!B	( 	( "##E##$6>G(**//EE
JJNN**517<KOO 99$&O "HU#e&&r*IMM$Ic E:Fs   GGG!c                 "   U R                    H  n[        U[        R                  5      (       d  M$  [        UR                  [        R
                  5      (       d  MO  UR                  R                  nU[        U5      :  d   eX   Ul        M     g)z$
Replace ir.Arg(...) with variables
N)r   rK   r   rU   r%   r  r$  rM   )r  r   r  rG  s       r   replace_arg_nodesr  6  sd     

dBII&&:djj"&&+I+I**""CT?#?DJ	 
 r   c                    U R                  5        GHh  nUR                  (       d  M  UR                  n[        U[        R
                  5      (       d  MD  UR                  R                  5         UR                  R                  5       n[        U[        R                  5      (       aC  [        UR                  [        R                  5      (       a  UR                  R                  S:X  d   S5       eUR                  R                  [        R                  " UR                  R                  XR                  5      5        UR                  R                  [        R                  " X$R                  5      5        GMk     g)zF
Return return statement by assigning directly to target, and a jump.
r  zinvalid return castN)r  r   rd  rK   r   r  r  rU   r%   rS   r  rV   rp   r   )r   r  r,  r  r  	cast_stmts         r   replace_returnsr  B  s     zzdBII&&JJNN

(Iy"))44y88OO&&&0I3HI 1 JJbii	(=(=vxxPQJJbgglHH=> !r   c                    US   R                   nUS   R                  n[        R                  " U[	        S5      U5      n	[
        R                  R                  [        5      XYR                  '   [        R                  " S[        U5      n
[        R                  " XU5      n[        R                  R                  XU5      n[        R                  " U[	        S5      U5      n[        U5      nXUR                  '   [        R                  " XU5      n[        R                  R                  XSU5      nU Vs/ s H  nUUR                     PM     nnUR!                  UU0 5      nUUU'   [        R                  " UX(5      nXU/$ s  snf )Nr   r?   r@   z$np_attr_attrr5   )ro   rp   r   rO   r   r   rX   rY   rZ   rR   r[   rU   rS   r\   r]   rd   re   )func_as_strr   rl   r   ri   rj   rk   ro   rp   rz   r{   r|   np_attr_callr~   func_var_typr   np_callr+  	arg_typesrM  	np_assigns                        r   gen_np_callr  U  s3   GMME
q'++C vve];7=H"ZZ..u5GMM99T5#&D))DC0K77??8#>Lvve]?;SAH#D)L)HMM))LC8Kggll82s3G*./$Q$I/)))YCH!Ig		'3,Ii00	 0s   8Fc                 Z    [        U S5        UR                   H  n[        SU5        M     g )N:z    )rb  r   )rn  r  r  s      r   
dump_blockr  l  s$    	%

fd r   c                 L    U R                  5        H  u  p[        X5        M     g r!   )r   r  )r   rn  r  s      r   dump_blocksr  q  s    5  'r   c                     [        U [        R                  5      =(       a#    [        U SS5      =(       a    U R                  S;   $ )z3true if expr is unary or binary operator or getitemr  F)unarybinopr  r  r  )rK   r   rS   r\   r  )r  s    r   is_operator_or_getitemr  u  s;    tRWW% \dE*\[[]r   c                 <    [        U 5      =(       d    [        U 5      $ )z8stmt is getitem assignment or setitem (and static cases))
is_getitem
is_setitemr  s    r   is_get_setitemr  {  s    d/z$//r   c                     [        U [        R                  5      =(       aD    [        U R                  [        R                  5      =(       a    U R                  R
                  S;   $ )z6true if stmt is a getitem or static_getitem assignmentr  )rK   r   rU   r%   rS   r  r  s    r   r  r    sC    tRYY' ?4::rww/?

!>>@r   c                 V    [        U [        R                  [        R                  45      $ )z/true if stmt is a SetItem or StaticSetItem node)rK   r   r'  r%  r  s    r   r  r    s    dRZZ)9)9:;;r   c                 >   [        U 5      (       aF  U R                  R                  S:X  a  U R                  R                  $ U R                  R                  $ [        U 5      (       a7  [        U [        R                  5      (       a  U R                  $ U R                  $ g)z?get index variable for getitem/setitem nodes (and static cases)r  N)	r  r%   r  r$  r&  r  rK   r   r'  r  s    r   index_var_of_get_setitemr    sp    $::==I%::###::'''$dBJJ''::>>!r   c                 H   [        U 5      (       a<  U R                  R                  S:X  a  XR                  l        g XR                  l        g [        U 5      (       a-  [        U [        R                  5      (       a  Xl        g Xl        g [        SR                  U 5      5      e)Nr  z0getitem or setitem node expected but received {})r  r%   r  r$  r&  r  rK   r   r'  
ValueErrorr   )r  	new_indexs     r   set_index_var_of_get_setitemr    su    $::==I%(JJ#,JJ 	D		dBJJ''"J&NKRR  	r   c                    [        U [        5      (       d  gU R                  n[        U5      S:w  d  US   [        :w  a  g[        U S5      (       d  g[        U SS5      n[        U[        5      (       d  g[        S U 5       5      $ )z check if c is a namedtuple classFr   r   _make_fieldsNc              3   B   #    U  H  n[        U[        5      v   M     g 7fr!   )rK   r   )r  r*  s     r   r  &is_namedtuple_class.<locals>.<genexpr>  s     26az!S!!6s   )rK   rt  	__bases__rM   rL   rW   r\   all)cbasesfieldss      r   is_namedtuple_classr    ss    aKKE
5zQ%(e+1gQ	4(Ffe$$26222r   c           	         U R                   nU R                  n[        R                  " XS9nUR	                  US9nU R                  [        R                  " XUS95        U V	s/ s H  oR                  U	5      PM     n
n	[        R                  R                  XSUS9nUR	                  US9nU R                  [        R                  " XUS95        [        U5       HZ  u  pUR                  U5      n[        R                  R                  XSUS9nU R                  [        R                  " UUUS95        M\     U R                  [        R                  " X&S95        U $ s  sn	f )	zFill *newblock* to call *callee* with arguments listed in *inputs*.
The returned values are unwrapped into variables in *outputs*.
The block would then jump to *label_next*.
r%   rp   rp   r  r%   rp   r5   )r   r   rJ  rp   N)r%   r$  r&  rp   r  rp   )ro   rp   r   rc   	make_temprV   rU   	get_exactrS   rd   	enumerater  r   )newblockr}  
label_nextinputsoutputsro   rp   fnfnvarrR   r   callexprcallresr  rr   r  r  s                    r   fill_block_with_callr    s   
 NNE
,,C		(BOOO$EOOBIIU#>?.45fdOOD!fD5ww||rs|CHoo#o&GOOBIIW#FGG$%''((w37S ) B		wCHI	 % OOBGG:78O 6s   $E c           
         U R                   nU R                  n[        U5       VVs/ s H  u  pV[        R                  " XeUS9PM     nnn[        X5       H>  u  p[        R                  " X8US9n
U R                  [        R                  " XUS95        M@     U R                  [        R                  " X$S95        U $ s  snnf )z
Fill a new block *block* that unwraps arguments using names in *inputs* and
then jumps to *label_next*.

Expected to use with *fill_block_with_call()*
)rR   r$  rp   )ro   rR   rp   r  r  )
ro   rp   r
  r   r  ziprO   rV   rU   r   )r  r  r  ro   rp   r  r   r   anameavaltmps              r   fill_callee_prologuer    s     KKE
))C "&)+) FF,) 	 +6(ff5#6RYYc3?@ ) 
LL
45L+s   !B=c                 b   U R                   nU R                  nU Vs/ s H  oBR                  US9PM     nn[        R                  R                  XSS9nUR                  US9nU R                  [        R                  " XvUS95        U R                  [        R                  " XsS95        U $ s  snf )z
Fill a new block *block* to prepare the return values.
This block is the last block of the function.

Expected to use with *fill_block_with_call()*
r   )r   rp   r  r  r  )
ro   rp   r	  r   rS   rT   r  rV   rU   r  )r  r  ro   rp   rR   valstupexprtups           r   fill_callee_epiloguer    s     KKE
))C3:;74OOO&7D;gg!!!6G
//c/
"C	LL##>?	LL./L <s   B,c                 z   [        X5      n[        U[        R                  [        R                  45      (       a  UR
                  $ [        U[        R                  5      (       a=  UR                  S:X  a-  [        XR
                  5      n [        X2R                  5      nU$ [        e! [         a    [        ef = f)z`Check if a variable is a global value, and return the value,
or raise GuardException otherwise.
r\   )rl  rK   r   r[   r  r%   rS   r  find_outer_valuer\   r!  AttributeErrorre  )rU  r   dfnprev_valvals        r   r   r     s     
&C#		2::.//yy#rwwCFFi$7#GYY7	!(HH-CJ   	!  	!s   B) )B:c                 n
   / nU R                    Ho  nX1;   d  M
  [        X   [        R                  R                  5      (       d  M7  X   R
                  S:  d  MK  SR                  U5      n[        X@R                  5      e   U R                  R                  5        GHA  nUR                  [        R                  5       GH  n[        UR                  [        R                  5      (       a  UR                  R                   S:X  ao  UR                  n[#        USS5      nUb%  [#        USS5      b  Sn	Sn
OUR$                  n	S	U	-  n
OS
n	Sn
SU	< SU
< S3n[        XFR                  R                  5      e[        UR                  [        R&                  [        R(                  45      (       a  UR                  n[#        USS5      nUc  GM  Sn[        U[*        R,                  5      (       a#  U[.        R0                  [.        R2                  1;   nU(       d  [#        USS5      S:H  nU(       a  UR5                  UR                  5        [        UR                  [        R                  5      (       Gaa  UR                  R                   S:X  GaF  UR                  R6                  S:X  Ga+  UR                  R                  R8                  n[        X   [        R:                  5      (       a  GM/  U R=                  U5      n[?        [@        X5      nU(       as  US   S:X  aj  [#        [B        US   5      n[B        RD                  " U[B        RF                  5      (       d*  [B        RD                  " U[B        RH                  5      (       a  GM  URK                  S5      (       a  SOSR                  U5      n[M        SR                  U5      UR                  S9e[        UR                  [        R&                  5      (       a  XRN                  R8                     nSn[#        USS5      (       d/  [        U[        RP                  [        RR                  45      (       a-  [M        XOUR                  R8                  U4-  UR                  S9e[        UR                  [        RT                  5      (       d  GM  U RV                  (       a  GM  Sn[        XFR                  S9e   GMD     [Y        U5      S:  a@  SnSR[                  U Vs/ s H  nUR]                  5       PM     sn5      n[        UU-  5      egs  snf ) a  
Helper function to walk IR and raise if it finds op codes
that are unsupported. Could be extended to cover IR sequences
as well as op codes. Intended use is to call it as a pipeline
stage just prior to lowering to prevent LoweringErrors for known
unsupported features.
i  a'  Tuple '{}' length must be smaller than 1000.
Large tuples lead to the generation of a prohibitively large LLVM IR which causes excessive memory pressure and large compile times.
As an alternative, the use of a 'list' is recommended in place of a 'tuple' as lists do not suffer from this problem.make_functionr  Nr  z$<creating a function from a closure>rB   z(%s) z<could not ascertain use case>zUNumba encountered the use of a language feature it does not support in this context: z (op code: make_function not supported). If the feature is explicitly supported it is likely that the result of the expression z'is being used in an unsupported manner.r%   Fr  gdb_internalr\   viewr   rZ   r   r   z'{}' zZ'view' can only be called on NumPy dtypes, try wrapping the variable {}with 'np.<dtype>()'r  zThe use of a %s type, assigned to variable '%s' in globals, is not supported as globals are considered compile-time constants and there is no known way to compile a %s type as a constant.	reflectedz0The use of generator expressions is unsupported.av  Calling either numba.gdb() or numba.gdb_init() more than once in a function is unsupported (strange things happen!), use numba.gdb_breakpoint() to create additional breakpoints instead.

Relevant documentation is available here:
https://numba.readthedocs.io/en/stable/user/troubleshoot.html#using-numba-s-direct-gdb-bindings-in-nopython-mode

Conflicting calls found at:
 %sr  )/rR  rK   r   rP   rQ   countr   r   rp   r   r  
find_instsr   rU   r%   rS   r  r\   r  r[   r  pytypesFunctionTyper  gdbgdb_initrV   r!  rR   r  rl  r  r  rZ   
issubdtypeintegerfloatingr\  r   r  DictTypeListTyper/  is_generatorrM   r{  	strformat)rU  rj   	gdb_callsarg_namemsgblkr  r$  r  user  foundr   dfcntyvardescrr+  bufs                      r   raise_on_unsupported_featurerB    s    I %%g')9)9)B)BCC""T)R
 SYRXYaRb  #344 & ~~$$&NN299-D$**bgg..::==O3**C #35D' #3	48D"HC#%D"&,,C#*S=D>! !$(C +3

?? $**ryy"**&=>>jjc7D1; c7#7#788EIIu~~#>>E#C"5GE$$TXX. $**bgg..::==I-$**//V2K****//C!',<<  //4B}g:Bbew.$UBqE2!,,R?? % 0 0U^^ D D$%(^^C%8%8rgnnS>QH%Jx(dhh8 8 $**bii00[[--.: BU33rENNENN#CDD%c",E&E488TT $**bhh//8L8L8LH&s99e . 'l 9~2 ii	:	1	:;sSy))  ;s   T2c           	         UR                  5        H  u  p#UR                  (       d  M  UR                  S5      (       d  M0  U R                  nUR	                  S5      S   nU R
                  R                  n[        U[        R                  5      (       a  SOSnSnSU< SU< S	U< S
U< 3n	[        R                  " [        XS95        M     g )Nr  r   r   r-  rc  zrhttps://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-typeszR
Encountered the use of a type that is scheduled for deprecation: type 'reflected z' found for argument 'z' of function 'z'.

For more information visit r  )r   r)  r\  rp   splitr  r  rK   r   Listwarningswarnr   )
rU  rj   rR   r?  rp   r1  r  tynameurlr9  s
             r   warn_deprecatedrJ    s    MMO<<<v&&kkjjoa(55#-b%**#=#=5$ !'UC9 <SJK! $r   c                    ^ ^^ / mU UU4S jmT" U5      nUb,  UR                   nT H  n[        X4S5      nU(       a  M    g   U$ g)aK  
This returns the python function that is being getattr'd from a module in
some IR, it resolves import chains/submodules recursively. Should it not be
possible to find the python function being called None will be returned.

func_ir - the FunctionIR object
node - the IR node from which to start resolving (should be a `getattr`).
c                 |  > [        U SS5      S:X  a@  TR                  SU R                  5         TR                  U R                  5      n T" U 5      $ [        U [        R                  [        R                  45      (       a+  [        U R                  [        R                  5      (       a  U $ g ! [
         a     g f = f)Nr  Fr\   r   )r\   insertr!  rl  r%   rm  rK   r   r[   r  r,  
ModuleType)modrU  getattr_chainresolve_mods    r   rQ  -resolve_func_from_module.<locals>.resolve_mod  s    3e$	1  CHH-,,SYY7 s##bii455#))W%7%788
  s   B. .
B;:B;NF)r%   r\   )rU  r  rO  defnr+  rP  rQ  s   `    @@r   resolve_func_from_modulerT    sQ     M d
C
yyA4E*D4 
 Kr   c                     U R                   R                  5        HV  nUR                  [        R                  5       Vs/ s H  o"PM     nnU(       d  M:  SUS   -  n[        XCS   R                  S9e   gs  snf )z0
Enforce there being no ir.Del nodes in the IR.
zIllegal IR, del found at: %sr   r  N)r   r  r+  r   r  r   rp   )rU  r:  r+  delsr9  s        r   enforce_no_delsrW    sg     ~~$$&>>"&&121a124047:Ca55	 '2s   A6c                     U R                   R                  5        HF  nUR                  SS9 Vs/ s H  o"PM     nnU(       d  M*  SUS   -  n[        XCS   R                  S9e   gs  snf )z5
Enforce there being no ir.Expr.phi nodes in the IR.
phi)r  zIllegal IR, phi found at: %sr   r  N)r   r  
find_exprsr   rp   )rU  r:  r+  phisr9  s        r   enforce_no_phisr\    se     ~~$$&>>U>343a344047:Ca55	 '4s   A&c                 x    [        U R                  5        Vs1 s H  oR                  iM     sn5      S:H  $ s  snf )zGCheck the given mapping of ir.Block for containing a single scope.
    r   )rM   r  ro   )r   r:  s     r   legalize_single_scoper^    s.     V]]_5_c		_56!;;5s   7c                     [        U 5        [        U 5        [        R                  " U 5      nUR	                  SUR
                  S9  g)z,
This checks that the IR presented is legal
T)extend_lifetimesN)r\  rW  r   rS  rT  dbg_extend_lifetimes)rU  flagsrY  s      r   check_and_legalize_irrc    s:     GG&&w/IMM$)C)CMDr   c           	         U R                   n[        UR                  5      n/ nUR                   Hg  n UR                  U5      n[        U[        R                  5      (       a  UR                  UR                  5        MQ  SU-  n[        XpR                  S9e   SR                  [        U5       VVs/ s H  u  pSX4-  PM     snn5      n	SR                  [        U5       Vs/ s H  nSU-  PM
     sn5      n
[        UR                   5      nSnUR"                  nUR                  U R$                  5      nUb  [        U[&        5      (       a6  U Vs/ s H  oQR                  U5      R                  PM     nn['        U5      nO@UR(                   Vs/ s H  nUR                  U5      R                  PM      nn['        U5      n[        U5      nX-
  nSR                  [        U5       Vs/ s H
  nS	X   -  PM     sn5      nU(       aC  [        U5       Vs/ s H  nXU-      < S
WU   < 3PM     nnUS-  nUSR                  U5      -  nUR*                  R,                  R.                  n[1        X)UU
U5      $ ! [         a    SU-  n[        XpR                  S9ef = fs  snnf s  snf s  snf s  snf s  snf s  snf )z
Converts a code object from a `make_function.code` attr in the IR into a
python function, caller_ir is the FunctionIR of the caller and is used for
the resolution of freevars.
z\Cannot capture a constant value for variable '%s' as there are multiple definitions present.r  zbCannot capture the non-constant value associated with variable '%s' in a function that may escape.r  z
	c_%d = %sr  r  r   z%sz = z, )r  rM   r  rl  rm  r   rp   rK   r   rc   rV   r%   r{  r
  r   r-  co_varnamesr  defaultsrL   r   r  r   __globals__r  )code_obj	caller_irr  r  freevarsr+  freevar_defr9  r  r  r  re  n_kwargs	n_allargskwarg_defaultsdkwarg_defaults_tupnargsr  kw_constr  s                        r   convert_code_obj_to_functionrs    s    MME!!"E H	5#2215K
 k288,,OOK--.BDEFCc||44   yyYx=PQ=PTQ-1&0=PQRHxxU5\:\!\:;Hu(()K H!!I--h.?.?@N!ne,,<JKNq))!,22NAK!&q )..0.Q ))!,22.  0!&q)* Exx%,G,Q0,GHH"8_., "-Y!79KA9NO, 	 .DDIIh'' ""..E *%8X*/1 1_  	579:;Cc||44	5 R: L0 H.s/   I?4J%
&J+$J0%J5/J:J??#J"c                    0 nU R                  5        H=  nUR                  nUR                   H  nUR                  5        H  nXAU'   M	     M      M?     U R                  5        Hj  nUR                  nUR	                  5        HG  u  pTUR
                  UR                  ;  d  M!  UR                  R                  UR
                  U5        MI     Ml     g)aM  Fixes the mapping of ir.Block to ensure all referenced ir.Var are
defined in every scope used by the function. Such that looking up a variable
from any scope in this function will not fail.

Note: This is a workaround. Ideally, all the blocks should refer to the
same ir.Scope, but that property is not maintained by all the passes.
N)r  ro   r   re  r   rR   	localvarsdefine)r   used_varr:  ro   r:  r   s         r   fixup_var_define_in_scoperx  .	  s     H}}		HHD~~' $ (   }}		!)ICxxu.&&sxx5	 * r   c                    U R                   nX!L a  U $ UR                  R                  R                  5        HE  nUR                  UR                  ;  d  M  UR                  R                  UR                  U5        MG     Xl         U $ )z5Transfer the ir.Block to use the given ir.Scope.
    )ro   ru  _conr  rR   rv  )r  ro   	old_scoper   s       r   transfer_scoper|  H	  sk     I""''..0885??*OO""388S1 1 KLr   c                 6    [        U [        R                  5      $ r!   )rK   r   	EnterWithr  s    r   is_setup_withr  X	  s    dBLL))r   c                 6    [        U [        R                  5      $ r!   )rK   r   
Terminatorr  s    r   is_terminatorr  \	  s    dBMM**r   c                 6    [        U [        R                  5      $ r!   )rK   r   r  r  s    r   is_raiser  `	  s    dBHH%%r   c                 6    [        U [        R                  5      $ r!   )rK   r   r  r  s    r   	is_returnr  d	  s    dBII&&r   c                 6    [        U [        R                  5      $ r!   )rK   r   PopBlockr  s    r   is_pop_blockr  h	  s    dBKK((r   )NNN)NNr!   )NNT)NNNNN)rb  znumba.core.compiler.Flags)rZ   r  r   r,  ro  rF  r  numba.core.extendingr   r  r   r   r   r   r	   r
   numba.core.typing.templatesr   numba.core.analysisr   r   r   numba.core.errorsr   r   r   r   rf   r   r   r   r;   r9   r<   r   rN   r]   r   r   r   r   r   r   r  r  r	  r  r  r  r   r  r  r3  r=  r?  rA  rI  rM  rO  rZ  rQ  ru  rg  r  r  rV   rv  r  r  r  r  r  r  r`  r  r  r  r  r  r  r  r  r  r  rC  r  r_  r%  r'  r*  r0  r<  rI  rQ  rT  rV  rS  r7  r_  rc  	Exceptionre  rh  r  rl  r  rr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   rB  rJ  rT  rW  r\  r^  rc  rs  rx  r|  r  r  r  r  r  r5   r   r   <module>r     s         + N N N 15 5. .  	/ 	/ 	!pf	=%P$8N>&R	3 :9A  0f( #% ,  ":	 <@&*#P  Tn  
   3 4.`  8    FJGKD"L
"!J HJ  8$z #%  &*@D2#+`  4*r  *)X!8 
2l  8B220	Y 		.  )- K3Z% CG?C,\.6p	?&1.
!]0
@<  3$6(&&x*vL*!H66<EA1H64 *+&')r   