
    shC                     n    S SK Jr  S SKJr   " S S\5      r " S S\5      r\" 5       r\R                  r	g)    )defaultdict)configc                   .    \ rS rSrSrSS jrS rS rSrg)	Rewrite   z8Defines the abstract base class for Numba rewrites.
    Nc                     g)z+Constructor for the Rewrite class.
        N )selfstates     p/Users/tiagomarins/Projetos/claudeai/copy_bank/venv/lib/python3.13/site-packages/numba/core/rewrites/registry.py__init__Rewrite.__init__
   s     	    c                     g)zMOverload this method to check an IR block for matching terms in the
rewrite.
Fr	   )r
   func_irblocktypemap	calltypess        r   matchRewrite.match   s     r   c                     [        S5      e)zWOverload this method to return a rewritten IR basic block when a
match has been found.
z Abstract Rewrite.apply() called!)NotImplementedErrorr
   s    r   applyRewrite.apply   s     ""DEEr   r	   )N)	__name__
__module____qualname____firstlineno____doc__r   r   r   __static_attributes__r	   r   r   r   r      s    
Fr   r   c                   >    \ rS rSrSr\" SS/5      rS rS rS r	Sr
g	)
RewriteRegistry   z+Defines a registry for Numba rewrites.
    zbefore-inferencezafter-inferencec                 ,    [        [        5      U l        g)zYConstructor for the rewrite registry.  Initializes the rewrites
member to an empty list.
N)r   listrewritesr   s    r   r   RewriteRegistry.__init__!   s     $D)r   c                 V   ^ ^ TT R                   ;  a  [        ST< 35      eUU 4S jnU$ )zN
Decorator adding a subclass of Rewrite to the registry for
the given *kind*.
zinvalid kind c                    > [        U [        5      (       d  [        SR                  U 5      5      eTR                  T   R                  U 5        U $ )Nz {0} is not a subclass of Rewrite)
issubclassr   	TypeErrorformatr'   append)rewrite_clskindr
   s    r   do_register-RewriteRegistry.register.<locals>.do_register.   sK    k733 B I I!! " "MM$&&{3r   )_kindsKeyError)r
   r0   r1   s   `` r   registerRewriteRegistry.register'   s,    
 t{{"677	 r   c                    XR                   ;   d   eUR                  R                  nUR                  5       nU R                  U    GHU  nU" U5      n[        UR                  5       5      nU(       d  M.  UR                  5       u  pUR                  UR                  XR                  UR                  5      n
U
(       a  [        R                  (       d  [        R                  (       a>  [        S5        [        SUR                  -  5        U	R!                  5         [        S5        UR#                  5       nXU'   UR%                  X45        [        R                  (       d  [        R                  (       a  UR!                  5         [        S5        U(       a  GM'  GMX     UR                  5        H  u  pXU   :w  d  M  U	R'                  5         M!     SSKJn  UR-                  UR                  5      nUR/                  5         g)z~Given a pipeline and a dictionary of basic blocks, exhaustively
attempt to apply all registered rewrites to all basic blocks.
F______________________________________________________________________zREWRITING (%s):<____________________________________________________________r   )postprocN)r3   r   blockscopyr'   r&   itemspopr   r   r   r   DEBUGDUMP_IRprintr   dumpr   r.   verify
numba.corer:   PostProcessorrun)r
   r0   r   r;   
old_blocksr/   rewrite	work_listkeyr   matches	new_blockr:   	post_procs                 r   r   RewriteRegistry.apply6   sZ    {{"""%%[[]
==.K!%(GV\\^,I)&]]_
!--umm(-9||v~~h/+2F2FFG

h 'I"+3K$$c%56||v~~!(h )	 /* !,,.JC3' ) 	(**5==9	r   )r'   N)r   r   r   r   r    	frozensetr3   r   r5   r   r!   r	   r   r   r#   r#      s'    *,=>?F*(r   r#   N)
collectionsr   rD   r   objectr   r#   rewrite_registryr5   register_rewriter	   r   r   <module>rT      s?    # Ff F,Bf BJ #$ #,, r   