§
    ƒÛgm  ã                   óÂ   — d dl mZmZ d dlmZmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZmZmZ d dlmZmZmZ d dlmZ d dlmZ  G d	„ d
e¦  «        Z G d„ de¦  «        ZdS )é    )ÚCompilerÚDefaultPassBuilder)ÚFunctionPassÚAnalysisPassÚregister_pass)ÚInlineInlinables)ÚIRLegalization)ÚjitÚgenerated_jitÚobjmodeÚnjitÚcfunc)ÚtypesÚpostprocÚerrors)Ú
FunctionIR)ÚTestCasec                   ó6   ‡ — e Zd Zˆ fd„Zd„ Zd„ Zd„ Zd„ Zˆ xZS )ÚTestCustomPipelinec                 ó�   •‡— t          t          | ¦  «                             ¦   «           G ˆfd„dt          ¦  «        Š‰| _        d S )Nc                   ó2   •‡ — e Zd Zg Zˆˆ fd„Zˆˆ fd„Zˆ xZS )ú0TestCustomPipeline.setUp.<locals>.CustomPipelinec                 ó~   •— | j                              |¦  «         t          ‰| ¦  «                             |¦  «        S ©N)Úcustom_pipeline_cacheÚappendÚsuperÚcompile_extra)ÚselfÚfuncÚCustomPipelineÚ	__class__s     €€úO/granary/edev/quantum/lib/python3.11/site-packages/numba/tests/test_pipeline.pyr   z>TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_extra   s8   ø€ àÔ*×1Ò1°$Ñ7Ô7Ð7Ý˜^¨TÑ2Ô2×@Ò@ÀÑFÔFÐFó    c                 óv   •— | j                              |¦  «          t          ‰| ¦  «        j        |g|¢R i |¤ŽS r   )r   r   r   Ú
compile_ir)r   Úfunc_irÚargsÚkwargsr!   r"   s       €€r#   r&   z;TestCustomPipeline.setUp.<locals>.CustomPipeline.compile_ir   sX   ø€ àÔ*×1Ò1°'Ñ:Ô:Ð:Ø=•u˜^¨TÑ2Ô2Ô=Øð.Ø"ð.ð .ð .Ø&,ð.ð .ð .r$   )Ú__name__Ú
__module__Ú__qualname__r   r   r&   Ú__classcell__)r"   r!   s   @€r#   r!   r      sh   øø€ € € € € Ø$&Ð!ðGð Gð Gð Gð Gð Gð
.ð .ð .ð .ð .ð .ð .ð .ð .ð .r$   r!   )r   r   ÚsetUpr   Úpipeline_class)r   r!   r"   s    @€r#   r.   zTestCustomPipeline.setUp   se   øø€ ÝÕ  $Ñ'Ô'×-Ò-Ñ/Ô/Ð/ð	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.�Xñ 	.ô 	.ð 	.ð -ˆÔÐÐr$   c                 ó  — |                       | j        j        g ¦  «         t          | j        ¬¦  «        d„ ¦   «         }|                       |d¦  «        d¦  «         |                       | j        j        |j        g¦  «         d S )N©r/   c                 ó   — | S r   © ©Úxs    r#   Úfooz8TestCustomPipeline.test_jit_custom_pipeline.<locals>.foo$   ó   € àˆHr$   é   )ÚassertListEqualr/   r   r
   ÚassertEqualÚpy_func©r   r6   s     r#   Útest_jit_custom_pipelinez+TestCustomPipeline.test_jit_custom_pipeline!   s—   € Ø×Ò˜TÔ0ÔFÈÑKÔKÐKå	˜DÔ/Ð	0Ñ	0Ô	0ð	ð 	ñ 
1Ô	0ð	ð 	×Ò˜˜˜Q™œ Ñ#Ô#Ð#Ø×Ò˜TÔ0ÔFØ!œk˜]ñ	,ô 	,ð 	,ð 	,ð 	,r$   c                 óF  — |                       | j        j        g ¦  «         t          t	          j        t          j        ¦  «        | j        ¬¦  «        d„ ¦   «         }|                       |d¦  «        d¦  «         |                       | j        j        |j        g¦  «         d S )Nr1   c                 ó   — | S r   r3   r4   s    r#   r6   z:TestCustomPipeline.test_cfunc_custom_pipeline.<locals>.foo/   r7   r$   r8   )r9   r/   r   r   r   Úint64r:   Ú__wrapped__r<   s     r#   Útest_cfunc_custom_pipelinez-TestCustomPipeline.test_cfunc_custom_pipeline,   s§   € Ø×Ò˜TÔ0ÔFÈÑKÔKÐKå	�uŒ{�5œ;Ñ'Ô'¸Ô8KÐ	LÑ	LÔ	Lð	ð 	ñ 
MÔ	Lð	ð 	×Ò˜˜˜Q™œ Ñ#Ô#Ð#Ø×Ò˜TÔ0ÔFØ!œoÐ.ñ	0ô 	0ð 	0ð 	0ð 	0r$   c                 ó  ‡— |                       | j        j        g ¦  «         d„ Št          | j        ¬¦  «        ˆfd„¦   «         }|                       |d¦  «        d¦  «         |                       | j        j        ‰g¦  «         d S )Nc                 ó   — | S r   r3   r4   s    r#   ÚinnerzDTestCustomPipeline.test_generated_jit_custom_pipeline.<locals>.inner:   s   € ØˆHr$   r1   c                 ó@   •— t          | t          j        ¦  «        r‰S d S r   )Ú
isinstancer   ÚInteger)r5   rE   s    €r#   r6   zBTestCustomPipeline.test_generated_jit_custom_pipeline.<locals>.foo=   s&   ø€ å˜!�Uœ]Ñ+Ô+ð Ø�ðð r$   é   )r9   r/   r   r   r:   )r   r6   rE   s     @r#   Ú"test_generated_jit_custom_pipelinez5TestCustomPipeline.test_generated_jit_custom_pipeline7   s±   ø€ Ø×Ò˜TÔ0ÔFÈÑKÔKÐKð	ð 	ð 	õ 
 dÔ&9Ð	:Ñ	:Ô	:ð	ð 	ð 	ð 	ñ 
;Ô	:ð	ð 	×Ò˜˜˜Q™œ Ñ#Ô#Ð#Ø×Ò˜TÔ0ÔFØ#˜Wñ	&ô 	&ð 	&ð 	&ð 	&r$   c                 óØ  — |                       | j        j        g ¦  «         t          | j        ¬¦  «        d„ ¦   «         }d}|                       ||¦  «        |dz   ¦  «         |                      t          | j        j        ¦  «        d¦  «         | j        j        d         }|                      ||j        ¦  «         | j        j        d         }|                      |t          ¦  «         d S )Nr1   c                 óz   — t          d¬¦  «        5  | t          d¦  «        z  } d d d ¦  «         n# 1 swxY w Y   | S )NÚintpr4   é   )r   Úintr4   s    r#   r6   z<TestCustomPipeline.test_objmode_custom_pipeline.<locals>.fooI   s|   € å˜6Ð"Ñ"Ô"ð ð Ø•S˜‘X”X‘�ðð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð àˆHs   ‘0°4·4é{   rN   é   r   )
r9   r/   r   r
   r:   ÚlenÚassertIsr;   ÚassertIsInstancer   )r   r6   ÚargÚfirstÚseconds        r#   Útest_objmode_custom_pipelinez/TestCustomPipeline.test_objmode_custom_pipelineF   så   € Ø×Ò˜TÔ0ÔFÈÑKÔKÐKå	˜DÔ/Ð	0Ñ	0Ô	0ð	ð 	ñ 
1Ô	0ð	ð
 ˆØ×Ò˜˜˜S™œ 3¨¡7Ñ+Ô+Ð+à×Ò�˜TÔ0ÔFÑGÔGÈÑKÔKÐKàÔ#Ô9¸!Ô<ˆØ�Š�e˜Sœ[Ñ)Ô)Ð)àÔ$Ô:¸1Ô=ˆØ×Ò˜f¥jÑ1Ô1Ð1Ð1Ð1r$   )	r*   r+   r,   r.   r=   rB   rJ   rX   r-   )r"   s   @r#   r   r      st   ø€ € € € € ð-ð -ð -ð -ð -ð(	,ð 	,ð 	,ð	0ð 	0ð 	0ð&ð &ð &ð2ð 2ð 2ð 2ð 2ð 2ð 2r$   r   c                   ó"   — e Zd Zdd„Zd„ Zd„ ZdS )ÚTestPassManagerFunctionalityNc                 óâ   ‡‡‡— |                       ‰du¦  «         |                       ‰du¦  «         t          dd¬¦  «         G ˆfd„d‰¦  «        ¦   «         Š G ˆˆfd„dt          ¦  «        }|S )zŒ
        Creates a new compiler pipeline with the _InjectDelsPass injected after
        the pass supplied in kwarg 'inject_after'.
        NF)Úmutates_CFGÚanalysis_onlyc                   ó@   •— e Zd ZdZd e” ¦  «        z  Zˆ fd„Zd„ ZdS )úLTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPasszD
            This pass injects ir.Del nodes into the IR
            zinject_dels_%sc                 ó2   •— ‰                      | ¦  «         d S r   )Ú__init__)r   Úbases    €r#   ra   zUTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPass.__init__l   s   ø€ Ø—’˜dÑ#Ô#Ð#Ð#Ð#r$   c                 ód   — t          j        |j        ¦  «        }|                     d¬¦  «         dS )NT)Ú	emit_dels)r   ÚPostProcessorr'   Úrun)r   ÚstateÚpps      r#   Úrun_passzUTestPassManagerFunctionality._create_pipeline_w_del.<locals>._InjectDelsPass.run_passo   s-   € ÝÔ+¨E¬MÑ:Ô:�Ø—’ �Ñ&Ô&Ð&Ø�tr$   N)r*   r+   r,   Ú__doc__ÚstrÚ_namera   ri   )rb   s   €r#   Ú_InjectDelsPassr_   e   s[   ø€ € € € € ðð ð % s s¨4¡y¤yÑ0ˆEð$ð $ð $ð $ð $ðð ð ð ð r$   rm   c                   ó   •— e Zd Zˆ ˆfd„ZdS )úITestPassManagerFunctionality._create_pipeline_w_del.<locals>.TestCompilerc                 ó�   •— t          j        | j        ¦  «        }|                     ‰‰¦  «         |                     ¦   «          |gS r   )r   Údefine_nopython_pipelinerg   Úadd_pass_afterÚfinalize)r   Úpmrm   Úinject_afters     €€r#   Údefine_pipelineszZTestPassManagerFunctionality._create_pipeline_w_del.<locals>.TestCompiler.define_pipelinesv   s?   ø€ Ý'Ô@ÀÄÑLÔL�Ø×!Ò! /°<Ñ@Ô@Ð@Ø—’‘”�Ø�t�r$   N)r*   r+   r,   rv   )rm   ru   s   €€r#   ÚTestCompilerro   t   s3   ø€ € € € € ðð ð ð ð ð ð ð r$   rw   )Ú
assertTruer   r   )r   rb   ru   rw   rm   s    `` @r#   Ú_create_pipeline_w_delz3TestPassManagerFunctionality._create_pipeline_w_del]   sÂ   øøø€ ð
 	�Š˜¨DÐ0Ñ1Ô1Ð1Ø�Š˜ DÐ(Ñ)Ô)Ð)å	 5¸Ð	>Ñ	>Ô	>ð	ð 	ð 	ð 	ð 	ð 	ð 	˜dñ 	ô 	ñ 
?Ô	>ð	ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	�8ñ 	ô 	ð 	ð Ðr$   c                 ó|  — |                       t          t          ¦  «        }t          |¬¦  «        d„ ¦   «         }|                      t
          j        ¦  «        5 } |d¦  «         d d d ¦  «         n# 1 swxY w Y   t          |j        ¦  «        }|  	                    d|¦  «         |  	                    d|¦  «         d S )Nr1   c                 ó   — | dz   S ©NrN   r3   r4   s    r#   r6   zYTestPassManagerFunctionality.test_compiler_error_on_ir_del_from_functionpass.<locals>.foo‚   ó   € à�q‘5ˆLr$   é
   zIllegal IR, del found at:zdel x)
ry   r   r   r   ÚassertRaisesr   ÚCompilerErrorrk   Ú	exceptionÚassertIn)r   Únew_compilerr6   ÚraisesÚerrstrs        r#   Ú/test_compiler_error_on_ir_del_from_functionpasszLTestPassManagerFunctionality.test_compiler_error_on_ir_del_from_functionpass~   sþ   € Ø×2Ò2µ<Ý3CñEô Eˆõ 
˜\Ð	*Ñ	*Ô	*ð	ð 	ñ 
+Ô	*ð	ð ×Ò�vÔ3Ñ4Ô4ð 	¸ØˆC�‰GŒGˆGð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ �VÔ%Ñ&Ô&ˆà�ŠÐ1°6Ñ:Ô:Ð:Ø�Š�g˜vÑ&Ô&Ð&Ð&Ð&s   ÁA1Á1A5Á8A5c                 óÜ   — |                       t          t          ¦  «        }t          |¬¦  «        d„ ¦   «         }|                       |d¦  «        |                     d¦  «        ¦  «         d S )Nr1   c                 ó   — | dz   S r|   r3   r4   s    r#   r6   z]TestPassManagerFunctionality.test_no_compiler_error_on_ir_del_after_legalization.<locals>.fooš   r}   r$   r~   )ry   r   r	   r   rx   r;   )r   rƒ   r6   s      r#   Ú3test_no_compiler_error_on_ir_del_after_legalizationzPTestPassManagerFunctionality.test_no_compiler_error_on_ir_del_after_legalizationŽ   su   € ð ×2Ò2µ<Ý3AñCô Cˆõ 
˜\Ð	*Ñ	*Ô	*ð	ð 	ñ 
+Ô	*ð	ð 	�Š˜˜˜B™œ §¢¨R¡¤Ñ1Ô1Ð1Ð1Ð1r$   )NN)r*   r+   r,   ry   r†   r‰   r3   r$   r#   rZ   rZ   [   sG   € € € € € ðð ð ð ðB'ð 'ð 'ð 2ð 2ð 2ð 2ð 2r$   rZ   N)Únumba.core.compilerr   r   Únumba.core.compiler_machineryr   r   r   Únumba.core.untyped_passesr   Únumba.core.typed_passesr	   Únumbar
   r   r   r   r   Ú
numba.corer   r   r   Únumba.core.irr   Únumba.tests.supportr   r   rZ   r3   r$   r#   ú<module>r’      sP  ðØ <Ð <Ð <Ð <Ð <Ð <Ð <Ð <ð:ð :ð :ð :ð :ð :ð :ð :ð :ð :à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø $Ð $Ð $Ð $Ð $Ð $Ø (Ð (Ð (Ð (Ð (Ð (ðL2ð L2ð L2ð L2ð L2˜ñ L2ô L2ð L2ð^C2ð C2ð C2ð C2ð C2 8ñ C2ô C2ð C2ð C2ð C2r$   